openaphid / android-flip

A component for flip animation on Android, which is similar to the effect in Flipboard iPhone/Android
http://openaphid.github.com/
2.84k stars 1.25k forks source link

Flip Animation on setSelection #31

Closed junghie closed 11 years ago

junghie commented 11 years ago

Good Day,

Thanks for these awesome library find it very useful on my new project. just want to ask on how can we implement the flip animation on setSelection method FlipViewController,java? or is there another way to jump between pages with flip animation?

openaphid commented 11 years ago

I'm afraid it's not supported

ren44 commented 11 years ago

add this code in FlipCards.java

public void nextPage(){
    forward = true;
    setState(STATE_AUTO_ROTATE);
    controller.showFlipAnimation();
    controller.getSurfaceView().requestRender();
}

and call this method in FlipViewcontroller.java

Good~ Luck~!

ManojMM026 commented 11 years ago

@pekoe snippet you wrote above is not working!... can you give me FlipCards.java with this code?

sallu1001 commented 11 years ago

@pekoe , even I am getting the same, can u please share full code of the file.

ren44 commented 11 years ago

@sallu1001

Sorry. I can not disclose the code. I is not the owner.

It will be exactly how.

  1. FlipCards.java

Add the following code anywhere.

// add code public void nextPage(){ forward = true; setState(STATE_AUTO_ROTATE); controller.showFlipAnimation(); controller.getSurfaceView().requestRender(); }

  1. FlipViewController.java

Add the following code anywhere.

// add code public void autoFlip(){ cards.nextPage(); }

Now the method is called, can be used.

ex. in your main activity (used FlipView)

... FlipViewController flipView = new FlipViewController(this, this); ...

// call autoFlip

flipView.autoFlip();

The code for the auto-flip, but when used in conjunction with the setSelection.

Good Luck~!!

greathemin commented 11 years ago

Dear pekoe: thank you very much!

greathemin

From: pekoe Date: 2013-05-21 10:39 To: openaphid/android-flip Subject: Re: [android-flip] Flip Animation on setSelection (#31) The code for the auto-flip, but when used in conjunction with the setSelection. Good Luck~!! — Reply to this email directly or view it on GitHub.

sallu1001 commented 11 years ago

@pekoe , thanks for the clarification above, but I am facing one more problem it is showing me an error when it reaches to the last page, I want the animation to be circular but currently it is not like that.

ren44 commented 11 years ago

@sallu1001

FlipViewController.java

You can see total pages count (adapterDataCount) and current page index (adapterIndex).

Therefore, please modify the code.

// modify code public void autoFlip(){ if(adapterIndex + 1 < adapterDataCount){ cards.nextPage(); } }

ManojMM026 commented 11 years ago

Hi @pekoe Thanks for your precious time and help !. I need one more thing how can I slow down speed of flipping pages.

sallu1001 commented 11 years ago

Hey its working, thank you @pekoe... Just want to know one more thing, its about the timing of flip animation, can i change it accordingly ???

ren44 commented 11 years ago

@ManojMM026 @sallu1001

You probably will need to change the delta variable.

FlipCards.java

    switch (state) {
        case STATE_INIT:
        case STATE_TOUCH:
            break;
        case STATE_AUTO_ROTATE: {
            animatedFrame++;
            float delta = (forward ? ACCELERATION : -ACCELERATION) * animatedFrame % 180;

            float oldAngle = accumulatedAngle;

            accumulatedAngle += delta;

ex. float delta = (forward ? ACCELERATION : -ACCELERATION) animatedFrame % 180;
float delta = (forward ? ACCELERATION : -ACCELERATION)
animatedFrame / 2 % 180;

Sorry. =)

You just have to change the setting value.


Change setting ACCELERATION value.

private static final float ACCELERATION = 0.65f;
private static final float MOVEMENT_RATE = 1.5f;
private static final int MAX_TIP_ANGLE = 1;
private static final int MAX_TOUCH_MOVE_ANGLE = 15;
private static final float MIN_MOVEMENT = 4f;

private static final int STATE_INIT = 0;
private static final int STATE_TOUCH = 1;
private static final int STATE_AUTO_ROTATE = 2;

ex. private static final float ACCELERATION = 0.65f;

private static final float ACCELERATION = 0.35f;

sallu1001 commented 11 years ago

@pekoe , done that and thanks a lot for the help, one last thing its working very fine upto the last page but when i am setting the first page afetr the last one then its not animating that one, i am giving my code below if you can sort this out,

                             if(i>=9)
             {
                 i=0;    
                 flipView.setSelection(i);
                 flipView.autoFlip();

             }
             else{

                 flipView.autoFlip();
             }

             i++;
sallu1001 commented 11 years ago

@pekoe , hey thanks for your precious guidance.

zizih commented 11 years ago

Can I ask a question about how to flip page automatically?

On 23 May 2013 14:35, sallu1001 notifications@github.com wrote:

@pekoe https://github.com/pekoe , hey thanks for your precious guidance.

— Reply to this email directly or view it on GitHubhttps://github.com/openaphid/android-flip/issues/31#issuecomment-18326005 .

sallu1001 commented 11 years ago

@zizih , follow above comments to get that.

ren44 commented 11 years ago

@sallu1001 , Because it is a possible way have to modify the interior of the source. In the method slightly different, you can process in a way that insert another page during the page, and then use twice a page turning is usually, to use that page under certain conditions. Sorry.

ren44 commented 11 years ago

@zizih , Under certain conditions, call autoFlip(). For example, every 30 seconds, or background music when the end.

zizih commented 11 years ago

Splash Screen Question: When I call notifyDataSetChanged() of adapter in FlipViewController.ViewFlipListener.onViewFlipped(){ }, it shows splash screen,How can I fixed it? Or are there any other way to changed item view about adapter when flip to him?

zizih commented 11 years ago

@pekoe Can I ask another question about Splash Screen: When I call notifyDataSetChanged() of adapter in FlipViewController.ViewFlipListener.onViewFlipped(){ }, it shows splash screen,How can I fixed it? Or are there any other way to changed item view about adapter when flip to him?

MohitVerma commented 11 years ago

Like nextPage(), can we have function like previousPage()?

tanis2000 commented 11 years ago

This does work if you want to move forward. But what if you need to flip backwards? Has anyone accomplished that?

gaurangtalati commented 8 years ago

@pekoe have you tried the back flip.. i have put forward as false .. keeping all the things same.. Still getting no result..

luccastanan commented 8 years ago

Someone got the back flip?

gaurangtalati commented 8 years ago

For Back Flip.. use this guys..

controller.showFlipAnimation(); forward = false; swapCards(); frontCards.resetWithIndex(backCards.getIndex() - 1); controller.flippedToView(getPageIndexFromAngle(accumulatedAngle-1), false); setState(STATE_AUTO_ROTATE); controller.getSurfaceView().requestRender();

working perfectly for me

gaurangtalati commented 8 years ago

My data was coming from database.. so i just have to manage the flips.. I will try this things.. and as soon as i get anything.. will give you an update..

Regards

Gaurang Talati Software Developer Credencys Solutions Inc. _13th Floor, Landmark Building, PrahladNagar, _Ahmedabad, 380051

Mobile: +91- 7383933533

On Thu, Feb 4, 2016 at 9:16 PM, luccastanan notifications@github.com wrote:

Your code is fine, but in addition takes 2 seconds to work it skip a page, such as going from page 3 to 1, have any of that to change?

— Reply to this email directly or view it on GitHub https://github.com/openaphid/android-flip/issues/31#issuecomment-179908687 .