UdhayaBalaji / androidannotations

Automatically exported from code.google.com/p/androidannotations
0 stars 0 forks source link

Override Transitions #132

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I thought it could be cool to have an activity annotation for overriding 
pending transitions like this : 

@Transitions(R.anim.transition_in, R.anim.transition_out)

Generated code:
overridePendingTransition(R.anim.transition_in, R.anim.transition_out);

This would override all pending transitions for the activity but it could also 
be useful on Views.

What do you think ?

Original issue reported on code.google.com by mathieu.debrito on 21 Nov 2011 at 4:00

GoogleCodeExporter commented 8 years ago
http://developer.android.com/reference/android/app/Activity.html#overridePending
Transition(int, int)

Call immediately after one of the flavors of startActivity(Intent) or finish() 
to specify an explicit transition animation to perform next.

This method is to be used on a per need basis. You can call many times in an 
activity life. Where / when would you want to call it ?

Original comment by py.ricau on 21 Nov 2011 at 6:00

GoogleCodeExporter commented 8 years ago
Well, I would like to call it anytime the activity invoke a new one or is 
called back.
For now, we have to do this trick ( overridePendingTransition ) each time we 
create a new intent ... 

This code is a repetition and should be specified only once in the activity.
But I agree this feature is not a priority :D

Original comment by mathieu.debrito on 21 Nov 2011 at 8:46

GoogleCodeExporter commented 8 years ago
Ok. And what's the idea behing that change ? Why would you want to do that on 
each call to startActivity ?

Original comment by py.ricau on 21 Nov 2011 at 9:06

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
As I said, that would be better to this only 1 time on the activity : 

@EActivity()
@Transitions(R.anim.transition_in, R.anim.transition_out)

instead of calling this :
overridePendingTransition(R.anim.transition_in, R.anim.transition_out);
each time we open a new intent or get back to the activity.

In some of my activities, I have to duplicate this line up to 10 to 20 times... 
And sometimes, I forget to apply the animations -_-" So the main idea is to 
specify these animations only 1 time, like an activity attribute

Original comment by mathieu.debrito on 21 Nov 2011 at 10:43

GoogleCodeExporter commented 8 years ago
Ok, so you would want something like that :

    @Override
    public void startActivity(Intent intent) {
        super.startActivity(intent);
        overridePendingTransition(animIn, animOut);
    }

And this would be for all the startActivity* methods.

Do you usually put the exact same transition in finish(), with the same order 
(animIn / animOut) ? I would think it would be in the reverse order, because 
you are coming back.

What about pressing back in an activity ? Can you also change the animation 
when returning back ?

Original comment by py.ricau on 22 Nov 2011 at 9:58

GoogleCodeExporter commented 8 years ago
Actually, I'm not sure if what I'm asking is possible or not... it's not only 
on the startActivity because the overridePendingTransition is available only 1 
time ( for the next activity show / hide ). when the user press back, we must 
override the transition, when there is an activity result. 

Actually, it could also be easier to override the finish() method and add the 
overridePendingTransition() there.

I'm not sure...

Original comment by mathieu.debrito on 22 Nov 2011 at 1:32

GoogleCodeExporter commented 8 years ago
I think you should try to implement this in an "Abstract" activity. Once it 
works the way you want in your abstract activity, copy it here and we'll see if 
we can do that in AA.

Original comment by py.ricau on 24 Nov 2011 at 7:31

GoogleCodeExporter commented 8 years ago

Original comment by py.ricau on 24 Nov 2011 at 7:31

GoogleCodeExporter commented 8 years ago
Since this issue hasn't moved much, I'll close it for now. If you come up with 
a better view of what you want and how to implement it, please post a new issue 
on https://github.com/excilys/androidannotations/issues (maybe a with link to 
this issue)

Original comment by py.ricau on 6 Jan 2012 at 3:58