Example usage for android.app FragmentTransaction setCustomAnimations

List of usage examples for android.app FragmentTransaction setCustomAnimations

Introduction

In this page you can find the example usage for android.app FragmentTransaction setCustomAnimations.

Prototype

public abstract FragmentTransaction setCustomAnimations(@AnimatorRes int enter, @AnimatorRes int exit);

Source Link

Document

Set specific animation resources to run for the fragments that are entering and exiting in this transaction.

Usage

From source file:org.eyeseetea.malariacare.DashboardActivity.java

@NonNull
private FragmentTransaction getFragmentTransaction() {
    FragmentTransaction ft = getFragmentManager().beginTransaction();
    if (isMoveToLeft) {
        isMoveToLeft = false;/*w  ww.j a  v a2  s  .  c o  m*/
        ft.setCustomAnimations(R.animator.anim_slide_in_right, R.animator.anim_slide_out_right);
    } else {
        ft.setCustomAnimations(R.animator.anim_slide_in_left, R.animator.anim_slide_out_left);
    }
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
    return ft;
}

From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java

/**
 * Hide panel from view./*  www  .j a  v  a  2  s .  co m*/
 */
public void hidePanel(SplitPanel p) {
    Log.d(LOG, "ReaderActivity.hidePanel");

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
    fragmentTransaction.hide(p);
    fragmentTransaction.commit();
}

From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java

/**
 * Reappear panel after it has been hidden.
 *///from  ww w. ja v  a  2s .c  om
public void showPanel(SplitPanel p) {
    Log.d(LOG, "ReaderActivity.showPanel");

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
    fragmentTransaction.show(p);
    fragmentTransaction.commit();
}

From source file:com.breadwallet.tools.animation.BRAnimator.java

/**
 * Animate the transition on burgerButton/MenuButton pressed
 *//*from  w w w . j av a  2  s .  c om*/
public static void pressMenuButton(final MainActivity context) {
    try {
        if (context == null)
            return;
        ((BreadWalletApp) context.getApplication()).cancelToast();
        final FragmentManager fragmentManager = context.getFragmentManager();
        if (level == 0) {
            if (PLATFORM_ON)
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        HTTPServer.startServer();
                    }
                }).start();
            level++;
            CustomPagerAdapter.adapter.showFragments(false, context);
            context.setBurgerButtonImage(BRConstants.CLOSE);
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            FragmentSettingsAll to = (FragmentSettingsAll) fragmentManager
                    .findFragmentByTag(FragmentSettingsAll.class.getName());
            if (to == null)
                to = new FragmentSettingsAll();
            fragmentTransaction.add(R.id.main_layout, to, FragmentSettingsAll.class.getName());
            fragmentTransaction.commit();
            final FragmentSettingsAll finalTo = to;
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    TranslateAnimation trans = new TranslateAnimation(0, 0, 1920, 0);
                    trans.setDuration(500);
                    trans.setInterpolator(new DecelerateOvershootInterpolator(3f, 0.5f));
                    View view = finalTo.getView();
                    if (view != null)
                        view.startAnimation(trans);
                }
            }, 1);

            InputMethodManager keyboard = (InputMethodManager) context
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            if (keyboard != null)
                keyboard.hideSoftInputFromWindow(
                        CustomPagerAdapter.adapter.mainFragment.addressEditText.getWindowToken(), 0);
        } else if (level == 1) {
            if (PLATFORM_ON)
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        HTTPServer.stopServer();
                    }
                }).start();

            level--;
            context.setBurgerButtonImage(BRConstants.BURGER);
            FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
            fragmentTransaction.setCustomAnimations(R.animator.from_top, R.animator.to_bottom);
            FragmentSettingsAll fragmentSettingsAll = (FragmentSettingsAll) fragmentManager
                    .findFragmentByTag(FragmentSettingsAll.class.getName());
            fragmentTransaction.remove(fragmentSettingsAll);
            fragmentTransaction.commit();
            CustomPagerAdapter.adapter.showFragments(true, context);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.android.dialer.DialtactsActivity.java

/**
 * Shows the search fragment//from w  w w  . ja  va 2s .c o  m
 */
private void enterSearchUi(boolean smartDialSearch, String query, boolean animate) {
    if (mStateSaved || getFragmentManager().isDestroyed()) {
        // Weird race condition where fragment is doing work after the activity is destroyed
        // due to talkback being on (b/10209937). Just return since we can't do any
        // constructive here.
        return;
    }

    if (DEBUG) {
        Log.d(TAG, "Entering search UI - smart dial " + smartDialSearch);
    }

    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    if (mInDialpadSearch && mSmartDialSearchFragment != null) {
        transaction.remove(mSmartDialSearchFragment);
    } else if (mInRegularSearch && mRegularSearchFragment != null) {
        transaction.remove(mRegularSearchFragment);
    }

    final String tag;
    if (smartDialSearch) {
        tag = TAG_SMARTDIAL_SEARCH_FRAGMENT;
    } else {
        tag = TAG_REGULAR_SEARCH_FRAGMENT;
    }
    mInDialpadSearch = smartDialSearch;
    mInRegularSearch = !smartDialSearch;

    mFloatingActionButtonController.scaleOut();

    SearchFragment fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag);
    if (animate) {
        transaction.setCustomAnimations(android.R.animator.fade_in, 0);
    } else {
        transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
    }
    if (fragment == null) {
        if (smartDialSearch) {
            fragment = new SmartDialSearchFragment();
        } else {
            fragment = ObjectFactory.newRegularSearchFragment();
            fragment.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    // Show the FAB when the user touches the lists fragment and the soft
                    // keyboard is hidden.
                    hideDialpadFragment(true, false);
                    showFabInSearchUi();
                    return false;
                }
            });
        }
        transaction.add(R.id.dialtacts_frame, fragment, tag);
    } else {
        transaction.show(fragment);
    }
    // DialtactsActivity will provide the options menu
    fragment.setHasOptionsMenu(false);
    fragment.setShowEmptyListForNullQuery(true);
    if (!smartDialSearch) {
        fragment.setQueryString(query, false /* delaySelection */);
    }
    transaction.commit();

    if (animate) {
        mListsFragment.getView().animate().alpha(0).withLayer();
    }
    mListsFragment.setUserVisibleHint(false);

    if (smartDialSearch) {
        Logger.logScreenView(ScreenEvent.SMART_DIAL_SEARCH, this);
    } else {
        Logger.logScreenView(ScreenEvent.REGULAR_SEARCH, this);
    }
}

From source file:com.android.dialer.DialtactsFragment.java

/**
 * Shows the search fragment//from w w  w  . ja  va  2 s.co  m
 */
private void enterSearchUi(boolean smartDialSearch, String query, boolean animate) {
    if (mStateSaved || getChildFragmentManager().isDestroyed()) {
        // Weird race condition where fragment is doing work after the activity is destroyed
        // due to talkback being on (b/10209937). Just return since we can't do any
        // constructive here.
        return;
    }
    mDialpadFragment.showSearchView();

    if (DEBUG) {
        Log.d(TAG, "Entering search UI - smart dial " + smartDialSearch);
    }

    final FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
    if (mInDialpadSearch && mSmartDialSearchFragment != null) {
        transaction.remove(mSmartDialSearchFragment);
    } else if (mInRegularSearch && mRegularSearchFragment != null) {
        transaction.remove(mRegularSearchFragment);
    }

    final String tag;
    if (smartDialSearch) {
        tag = TAG_SMARTDIAL_SEARCH_FRAGMENT;
    } else {
        tag = TAG_REGULAR_SEARCH_FRAGMENT;
    }
    mInDialpadSearch = smartDialSearch;
    mInRegularSearch = !smartDialSearch;

    mFloatingActionButtonController.scaleOut();

    SearchFragment fragment = (SearchFragment) getChildFragmentManager().findFragmentByTag(tag);
    if (animate) {
        transaction.setCustomAnimations(android.R.animator.fade_in, 0);
    } else {
        transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
    }
    if (fragment == null) {

        Log.e(TAG, " --- enterSearchUi --- null");
        if (smartDialSearch) {
            fragment = new SmartDialSearchFragment();
            transaction.add(R.id.dialtacts_frame, fragment, tag);
        } else {
            fragment = new RegularSearchFragment();
            fragment.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    // Show the FAB when the user touches the lists fragment and the soft
                    // keyboard is hidden.
                    showFabInSearchUi();
                    return false;
                }
            });
        }

    } else {
        transaction.show(fragment);

    }
    // DialtactsFragment will provide the options menu
    fragment.setHasOptionsMenu(false);
    fragment.setShowEmptyListForNullQuery(true);
    fragment.setQueryString(query, false /* delaySelection */);
    transaction.commitAllowingStateLoss();
    //        transaction.commit();

    //        if (animate) {
    //            mListsFragment.getView().animate().alpha(0).withLayer();
    //        }
    //        mListsFragment.setUserVisibleHint(false);
}