Search in sources :

Example 1 with DetailTransition

use of com.blankj.androidutilcode.transition.DetailTransition in project AndroidUtilCode by Blankj.

the class Demo0Fragment method addSharedElement.

private Fragment addSharedElement(Fragment fragment) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fragment.setSharedElementEnterTransition(new DetailTransition());
        fragment.setEnterTransition(new Fade());
        fragment.setSharedElementReturnTransition(new DetailTransition());
    }
    return fragment;
}
Also used : DetailTransition(com.blankj.androidutilcode.transition.DetailTransition) Fade(android.transition.Fade)

Example 2 with DetailTransition

use of com.blankj.androidutilcode.transition.DetailTransition in project AndroidUtilCode by Blankj.

the class Demo3Fragment method onClick.

@Override
public void onClick(View view) {
    tvAboutFragment.setText("");
    switch(view.getId()) {
        case R.id.btn_show_about_fragment:
            tvAboutFragment.setText("lastAdd: " + FragmentUtils.getLastAddFragment(getFragmentManager()).getClass().getSimpleName() + "\nlastAddInStack: " + (FragmentUtils.getLastAddFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getLastAddFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null") + "\ntopShow: " + FragmentUtils.getTopShowFragment(getFragmentManager()).getClass().getSimpleName() + "\ntopShowInStack: " + (FragmentUtils.getTopShowFragmentInStack(getFragmentManager()) != null ? FragmentUtils.getTopShowFragmentInStack(getFragmentManager()).getClass().getSimpleName() : "null") + "\n---all of fragments---\n" + FragmentUtils.getAllFragments(getFragmentManager()).toString() + "\n----------------------\n\n" + "---stack top---\n" + FragmentUtils.getAllFragmentsInStack(getFragmentManager()).toString() + "\n---stack bottom---\n\n");
            break;
        case R.id.btn_add_hide:
            FragmentUtils.addFragment(getFragmentManager(), Demo1Fragment.newInstance(), R.id.fragment_container, true, true);
            break;
        case R.id.btn_add_show:
            FragmentUtils.addFragment(getFragmentManager(), Demo1Fragment.newInstance(), R.id.fragment_container, false, true);
            break;
        case R.id.btn_add_child:
            FragmentUtils.addFragment(getChildFragmentManager(), Demo2Fragment.newInstance(), R.id.child_fragment_container, false, true);
            break;
        case R.id.btn_pop_to_root:
            FragmentUtils.popToFragment(getFragmentManager(), Demo1Fragment.class, true);
            break;
        case R.id.btn_pop_add:
            FragmentUtils.popAddFragment(getFragmentManager(), Demo2Fragment.newInstance(), R.id.fragment_container, true, new FragmentUtils.SharedElement(this.btnShowAboutFragment, "btnShowAboutFragment"));
            break;
        case R.id.btn_hide_show:
            Fragment fragment1 = FragmentUtils.findFragment(getFragmentManager(), Demo1Fragment.class);
            if (fragment1 != null) {
                FragmentUtils.hideShowFragment(this, fragment1);
            } else {
                ToastUtils.showLongToast("please add demo1 first!");
            }
            break;
        case R.id.btn_replace:
            Demo0Fragment demo0Fragment = Demo0Fragment.newInstance();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                demo0Fragment.setSharedElementEnterTransition(new DetailTransition());
                setExitTransition(new Fade());
                demo0Fragment.setEnterTransition(new Fade());
                demo0Fragment.setSharedElementReturnTransition(new DetailTransition());
            }
            ((FragmentActivity) getActivity()).rootFragment = FragmentUtils.replaceFragment(this, demo0Fragment, false, new FragmentUtils.SharedElement(ivSharedElement, getString(R.string.fragment_transition)));
            break;
    }
}
Also used : FragmentUtils(com.blankj.utilcode.util.FragmentUtils) DetailTransition(com.blankj.androidutilcode.transition.DetailTransition) Fragment(android.support.v4.app.Fragment) Fade(android.transition.Fade)

Aggregations

Fade (android.transition.Fade)2 DetailTransition (com.blankj.androidutilcode.transition.DetailTransition)2 Fragment (android.support.v4.app.Fragment)1 FragmentUtils (com.blankj.utilcode.util.FragmentUtils)1