jack-bradshaw / SlidingIntroScreen

An Android library designed to simplify the creation of introduction screens.
https://bintray.com/matthewtamlin/maven/SlidingIntroScreen/view
Apache License 2.0
181 stars 36 forks source link

generateFinalButton transition #10

Closed neutt22 closed 7 years ago

neutt22 commented 7 years ago

I'm having an issue where the overridePendingTransition doesn't work. Here's my current work:

@Override
public IntroButton.Behaviour generateFinalButtonBehaviour() {
    final Intent mainActivity = new Intent(this, MainActivity.class);

     IntroButton.Behaviour behaviour = new IntroButton.ProgressToNextActivity(mainActivity, null);
     overridePendingTransition(R.anim.slide_from_bottom, R.anim.slide_from_bottom);

    return behaviour;
}

Thanks!

jack-bradshaw commented 7 years ago

I think you're using overridePendingTransition() incorrectly. Call it in onCreate of MainActivity.java.

neutt22 commented 7 years ago

Let me give it a try in couple hours.

EDIT: Nope, no animation on onCreate

neutt22 commented 7 years ago

Going to the IntroActivity has no problem because I start the activity from MainActivity. The problem is going back to MainActivity from IntroActivity using the generateFinalButtonBehaviour Hope that made it clear for you. Thanks!

jack-bradshaw commented 7 years ago

So let me see if I've got this right. You launch MainActivity first, then you launch IntroActivity, then when the intro is done you go back to the MainActivity?

I think perhaps instead of using the ProgressToNextActivity behaviour, implement the interface and create a new behaviour which calls finish() in the IntroActivity. That way you can end the IntroActivity, and I assume that's where you should call overridePendingTransition().

Not really too sure about this TBH, but I don't think it's an issue with the library because currently all the next activity behaviour does is call startActivity(Intent) when the button is clicked.

neutt22 commented 7 years ago

You got it right, I launch MainActivity first, then it launches IntroActivity, when Finish button is clicked, it goes back to MainActivity.

I guess implementing a new ProgressToNextActivity might be a good idea. I'll let you know on this thread. Thanks!

neutt22 commented 7 years ago

Issue solved by subclassing ProgressToNextActivity and overriding run method. Thanks!

jack-bradshaw commented 7 years ago

Great, glad it worked!