johncarl81 / transfuse

:syringe: Transfuse - A Dependency Injection and Integration framework for Google Android
http://androidtransfuse.org/
Apache License 2.0
220 stars 28 forks source link

Completing functionality around Intent/Fragment factories #191

Closed johncarl81 closed 8 years ago

johncarl81 commented 9 years ago

190 #88

This includes both fragment and intent factory extensions.

Also includes the ability to chain context calls onto the start() method to leverage some "animation awesomeness":

new ActivtyFactory()
    .setValue("value")
    .start(context)
    .overridePendingTransition(R.anim.slide_left, R.anim.slide_right);
dbachelder commented 9 years ago

This looks great.. but Context doesn't have overridePendingTransition.. I think you could do something like

new ActivtyFactory()
    .setValue("value")
 .overridePendingTransition(R.anim.slide_left, R.anim.slide_right)
    .start(context);

where start() does a check to see if the context is an Activity and if so, apply the transitions.

johncarl81 commented 9 years ago

Ok, I changed the api to allow for sub-Contexts to be chained. If you inject the Activity then you can use the overridePendingTransition as a chained call. Here's the new api:

public abstract class ComponentFactory {
    //...
    public <T extends Context> T start(T context) {
        context.startActivity(build(context));
        return context;
    }
}
dbachelder commented 8 years ago

really liking this change. we just need a method for startActivityForResult()

johncarl81 commented 8 years ago

^ How's that?

dbachelder commented 8 years ago

Close! need to be able to pass request code and optional Bundle (right now passing flags which doesn't make sense in this context.)

Probably should add start() signature that takes Bundle also

johncarl81 commented 8 years ago

Oh, duh.. done!

dbachelder commented 8 years ago

Awesome! Trying it out now.

We don't need the variants of these methods that take Bundle right now.. but we probably will when we start doing scene transitions and the like

dbachelder commented 8 years ago

Doh... I'm just going to build the Intent for this one.. forgot that in fragment land you need to call Fragment.startActivityForResult(Intent, int) to get delivery of activity result to fragment... so we would need a new method that takes Fragment to facilitate the fluid API

johncarl81 commented 8 years ago

I'll look at that one in depth in a bit.. you could still build the intent using the CompeontFactory and use it in the Fragment.startActivityForResult(..) call.

dbachelder commented 8 years ago

Yes, that's what we did. works great.

johncarl81 commented 8 years ago

:+1: Merge at will if you're happy with this functionality then.