Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve annotation & implement shared element transition #40

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

namkazt
Copy link

@namkazt namkazt commented Jul 24, 2018

1, add option closeIfEmpty to annotation @puppet
in some case that using Rigger.addFragment() ( fragment not added in stack ) and show ( without re-init fragment )
when press back button it will close current activity that maybe unwanted action. So set @Puppet(containerViewId = R.id.fragment_container, closeIfEmpty = false) will solve that problem.

require:

public boolean onInterruptBackPressed() {
    return true;
}

in Activity to interrupted back press.

test: implementation 'com.github.namkazt:FragmentRigger:3d8e43637c'

2, implement shared element transaction
Note2: shared element transaction only work with replace for now ( show and hide will add next PR if this go thought )
How to make it work :
1, create shared elements

new SharedElement[]{
        SharedElement.create(mContentView.findViewById(R.id.shared_container)),
        SharedElement.create(mContentView.findViewById(R.id.profile_image)),
};

2, pass it thought replaceFragment method ( new replace method act like startFragment but call replace and addSharedElement)

Rigger.getRigger(this).replaceFragment(fragment, R.id.fragment_container, sharedElements);

Note: on each fragment will need

@Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            setSharedElementEnterTransition(TransitionInflater.from(getContext()).inflateTransition(R.transition.basic_move));
            setSharedElementReturnTransition(TransitionInflater.from(mContext).inflateTransition(android.R.transition.explode));
        }
    }

@namkazt namkazt changed the title add option closeIfEmpty to annotation @Puppet Improvements Jul 24, 2018
@namkazt namkazt changed the title Improvements [WIP] Improvements Jul 24, 2018
*
* @return The default value is true.
*/
boolean closeIfEmpty() default true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you tried bondContainerView = true or stickyStack = true ?

Copy link
Author

@namkazt namkazt Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i was but it just not work on my case.
Example: i have main screen with 5 fragments (5 nav menu items) and i using addFragment to add it and this method do not add to stack. so when i create new fragment with startFragment and after finish i close it. it will check onBackPress because my stack = 0 so it close activity

i meant the case when you have like 5 fragments on Map ( will not change on app life cycle ) but 0 on stack and you want to keep it when you add and remove other fragment from stack without trigger close() if stack size = 0

Copy link
Author

@namkazt namkazt Jul 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JustKiddingBaby check show demo you will see it close application when you press back button that is something maybe user want to avoid

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namkazt OK, i got it , thanks for the PR , i will review in weekend and merge it as soon .

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@namkazt please change the target branch to dev

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okey. will fix conflict when have free time.

- add Shared Element object
- fix replace functions
@namkazt namkazt changed the title [WIP] Improvements Improvements annotation & implement shared element transition Jul 27, 2018
@namkazt namkazt changed the title Improvements annotation & implement shared element transition Improve annotation & implement shared element transition Jul 27, 2018
@namkazt namkazt changed the base branch from master to dev August 5, 2018 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants