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:com.breadwallet.tools.animation.BRAnimator.java

public static void animateDecoderFragment() {

    try {// w  ww . ja va2s.com
        MainActivity app = MainActivity.app;
        if (app == null)
            return;

        // Here, thisActivity is the current activity
        if (ContextCompat.checkSelfPermission(app,
                Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            // Should we show an explanation?
            if (ActivityCompat.shouldShowRequestPermissionRationale(app, Manifest.permission.CAMERA)) {
                ((BreadWalletApp) app.getApplication()).showCustomToast(app,
                        app.getString(R.string.allow_camera_access), MainActivity.screenParametersPoint.y / 2,
                        Toast.LENGTH_LONG, 0);
            } else {
                // No explanation needed, we can request the permission.
                ActivityCompat.requestPermissions(app, new String[] { Manifest.permission.CAMERA },
                        BRConstants.CAMERA_REQUEST_ID);
            }
        } else {
            if (BRAnimator.level > 0)
                BRAnimator.pressMenuButton(app);
            decoderFragmentOn = true;
            app.activityButtonsEnable(false);
            CustomPagerAdapter.adapter.showFragments(false, app);
            //Disabled inspection: <Expected resource type anim>
            FragmentTransaction fragmentTransaction = app.getFragmentManager().beginTransaction();
            fragmentTransaction.setCustomAnimations(R.animator.from_bottom, R.animator.to_top);
            FragmentDecoder fragmentDecoder = new FragmentDecoder();
            fragmentTransaction.replace(R.id.main_layout, fragmentDecoder, FragmentDecoder.class.getName());
            int temp = fragmentTransaction.commit();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.learnit.LearnIt.activities.MainActivity.java

public void onArticleSelected(int position) {
    // Create a new listOfFragments
    MySmartFragment fragment;//from   w w w .j  av a  2s . c om
    switch (position) {
    case ADD_WORDS_FRAGMENT:
        fragment = new AddWordFragment();
        fragment.identifier = ADD_WORDS_FRAGMENT;
        Log.d(LOG_TAG, "Created AddWordFragment with tag " + fragment.identifier);
        break;
    case DICTIONARY_FRAGMENT:
        fragment = new DictFragment();
        fragment.identifier = DICTIONARY_FRAGMENT;
        Log.d(LOG_TAG, "Created Dictionary Fragment with tag " + fragment.identifier);
        break;
    case LEARN_WORDS_FRAGMENT:
        fragment = new LearnCasualFragment();
        fragment.identifier = LEARN_WORDS_FRAGMENT;
        Log.d(LOG_TAG, "Created LearnFragment with tag " + fragment.identifier);
        break;
    default:
        fragment = null;
    }
    // Update the layout
    FragmentManager fm = getFragmentManager();

    if (fm.findFragmentByTag("android:switcher:" + 0 + ":" + position) == null) {
        FragmentTransaction ft = fm.beginTransaction();
        ft.setCustomAnimations(android.R.animator.fade_in, android.R.animator.fade_out);
        ft.replace(R.id.view_group_id, fragment, "android:switcher:" + 0 + ":" + position);
        Log.d(LOG_TAG, "current fragment id = " + fragment.getId() + " and tag = " + fragment.getTag()
                + ((Object) fragment).getClass().getName());
        ft.commit();
    }
    _currentItemShown = position;
    Log.d(LOG_TAG, "onArticleSelected current item set to " + _currentItemShown);
}

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

/**
 * Animate the transition on wipe wallet fragment
 *///from   www .  ja  va2s.c om

public static void pressWipeWallet(final MainActivity context, final Fragment to) {
    try {
        if (!wipeWalletOpen) {
            wipeWalletOpen = true;
            FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction();
            fragmentTransaction.replace(R.id.main_layout, to, to.getClass().getName());
            fragmentTransaction.commit();
            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 = to.getView();
                    if (view != null)
                        view.startAnimation(trans);
                }
            }, 1);

        } else {
            wipeWalletOpen = false;
            FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction();
            fragmentTransaction.setCustomAnimations(R.animator.from_top, R.animator.to_bottom);
            fragmentTransaction.replace(R.id.main_layout, new FragmentSettings(),
                    FragmentSettings.class.getName());
            fragmentTransaction.commit();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:xyz.sahildave.widget.SearchViewLayout.java

private void showContentFragment() {
    final FragmentTransaction transaction = mFragmentManager.beginTransaction();
    transaction.setCustomAnimations(R.animator.fade_in, R.animator.fade_out);
    transaction.replace(R.id.search_expanded_content, mExpandedContentFragment);
    mExpandedContentFragment.setHasOptionsMenu(false);
    transaction.commit();/*from  w  w w. j  a  va  2  s.  c  o m*/
}

From source file:cw.kop.autobackground.MainActivity.java

private void selectItem(int position, boolean slideAnimate) {

    if (position == currentPosition || position < 0) {
        return;//  w  ww  .  j  a v  a  2 s  .  c  om
    }

    currentPosition = position;

    setTitle(fragmentList[position]);
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();

    if (slideAnimate) {
        fragmentTransaction.setCustomAnimations(R.animator.slide_from_left, R.animator.slide_to_right);
    }

    switch (position) {

    case 0:
        fragmentTransaction.replace(R.id.content_frame, sourceListFragment, "source_fragment").commit();
        break;
    case 1:
        fragmentTransaction.replace(R.id.content_frame, new WallpaperSettingsFragment()).commit();
        break;
    case 2:
        fragmentTransaction.replace(R.id.content_frame, new DownloadSettingsFragment()).commit();
        break;
    case 3:
        fragmentTransaction.replace(R.id.content_frame, new AccountSettingsFragment()).commit();
        break;
    case 4:
        fragmentTransaction.replace(R.id.content_frame, new EffectsSettingsFragment()).commit();
        break;
    case 5:
        fragmentTransaction.replace(R.id.content_frame, new NotificationSettingsFragment()).commit();
        break;
    case 6:
        fragmentTransaction.replace(R.id.content_frame, new WearSettingsFragment()).commit();
        break;
    case 7:
        fragmentTransaction.replace(R.id.content_frame, new AppSettingsFragment()).commit();
        break;
    case 8:
        fragmentTransaction.replace(R.id.content_frame, new ImageHistoryFragment()).commit();
        break;
    case 9:
        fragmentTransaction.replace(R.id.content_frame, new AboutFragment()).commit();
        break;
    default:

    }
}

From source file:com.ysy.classpower_utils.search_view.OwnSearchViewLayout.java

private void showContentFragment() {
    final FragmentTransaction transaction = mFragmentManager.beginTransaction();
    transaction.setCustomAnimations(xyz.sahildave.widget.R.animator.fade_in,
            xyz.sahildave.widget.R.animator.fade_out);
    transaction.replace(xyz.sahildave.widget.R.id.search_expanded_content, mExpandedContentFragment);
    mExpandedContentFragment.setHasOptionsMenu(false);
    transaction.commit();/*  ww w  . j a v a2 s.c om*/
}

From source file:com.github.chenxiaolong.dualbootpatcher.MainActivity.java

private void hideFragments(boolean animate) {
    FragmentManager fm = getFragmentManager();

    Fragment prevRoms = fm.findFragmentByTag(SwitcherListFragment.TAG);
    Fragment prevPatchFile = fm.findFragmentByTag(PatchFileFragment.TAG);
    Fragment prevFreeSpace = fm.findFragmentByTag(FreeSpaceFragment.TAG);
    Fragment prevAbout = fm.findFragmentByTag(AboutFragment.TAG);

    FragmentTransaction ft = fm.beginTransaction();

    if (animate) {
        ft.setCustomAnimations(0, R.animator.fragment_out);
    }//www .  j  a v a 2 s .c o m

    if (prevRoms != null) {
        ft.hide(prevRoms);
    }
    if (prevPatchFile != null) {
        ft.hide(prevPatchFile);
    }
    if (prevFreeSpace != null) {
        ft.hide(prevFreeSpace);
    }
    if (prevAbout != null) {
        ft.hide(prevAbout);
    }

    ft.commit();
    fm.executePendingTransactions();
}

From source file:com.github.chenxiaolong.dualbootpatcher.MainActivity.java

private void showFragment() {
    FragmentManager fm = getFragmentManager();

    Fragment prevRoms = fm.findFragmentByTag(SwitcherListFragment.TAG);
    Fragment prevPatchFile = fm.findFragmentByTag(PatchFileFragment.TAG);
    Fragment prevFreeSpace = fm.findFragmentByTag(FreeSpaceFragment.TAG);
    Fragment prevAbout = fm.findFragmentByTag(AboutFragment.TAG);

    FragmentTransaction ft = fm.beginTransaction();
    ft.setCustomAnimations(R.animator.fragment_in, 0);

    switch (mFragment) {
    case FRAGMENT_ROMS:
        mTitle = R.string.title_roms;/*  w ww.j  a v  a2s  .co m*/
        updateTitle();

        if (prevRoms == null) {
            Fragment f = SwitcherListFragment.newInstance();
            ft.add(R.id.content_frame, f, SwitcherListFragment.TAG);
        } else {
            ft.show(prevRoms);
        }

        break;

    case FRAGMENT_PATCH_FILE:
        mTitle = R.string.title_patch_zip;
        updateTitle();

        if (prevPatchFile == null) {
            Fragment f = PatchFileFragment.newInstance();
            ft.add(R.id.content_frame, f, PatchFileFragment.TAG);
        } else {
            ft.show(prevPatchFile);
        }

        break;

    case FRAGMENT_FREE_SPACE:
        mTitle = R.string.title_free_space;
        updateTitle();

        if (prevFreeSpace == null) {
            Fragment f = FreeSpaceFragment.newInstance();
            ft.add(R.id.content_frame, f, FreeSpaceFragment.TAG);
        } else {
            ft.show(prevFreeSpace);
        }

        break;

    case FRAGMENT_ABOUT:
        mTitle = BuildConfig.APP_NAME_RESOURCE;
        updateTitle();

        if (prevAbout == null) {
            Fragment f = AboutFragment.newInstance();
            ft.add(R.id.content_frame, f, AboutFragment.TAG);
        } else {
            ft.show(prevAbout);
        }

        break;

    default:
        throw new IllegalStateException("Invalid fragment ID");
    }

    ft.commit();
}

From source file:com.jlabs.peepaid.searchviewlay.SearchViewLayout.java

private void showContentFragment() {
    if (mFragmentManager != null) {
        final android.app.FragmentTransaction transaction = mFragmentManager.beginTransaction();
        transaction.setCustomAnimations(R.animator.fade_in_object_animator,
                R.animator.fade_out_object_animator);
        transaction.replace(R.id.search_expanded_content, mExpandedContentFragment);
        transaction.commit();/*w ww .  j a  va 2  s. com*/
    } else if (mSupportFragmentManager != null) {
        final android.support.v4.app.FragmentTransaction transaction = mSupportFragmentManager
                .beginTransaction();
        transaction.setCustomAnimations(R.anim.fade_in_anim_set, R.anim.fade_out_anim_set);
        transaction.replace(R.id.search_expanded_content, mExpandedContentSupportFragment);
        transaction.commit();
    }
}

From source file:dev.dworks.apps.anexplorer.fragment.DirectoryFragment.java

private static void show(FragmentManager fm, int type, RootInfo root, DocumentInfo doc, String query,
        int anim) {
    final Bundle args = new Bundle();
    args.putInt(EXTRA_TYPE, type);//from  ww  w. j  a v  a  2s.  com
    args.putParcelable(EXTRA_ROOT, root);
    args.putParcelable(EXTRA_DOC, doc);
    args.putString(EXTRA_QUERY, query);

    final FragmentTransaction ft = fm.beginTransaction();
    switch (anim) {
    case ANIM_SIDE:
        args.putBoolean(EXTRA_IGNORE_STATE, true);
        break;
    case ANIM_DOWN:
        args.putBoolean(EXTRA_IGNORE_STATE, true);
        ft.setCustomAnimations(R.animator.dir_down, R.animator.dir_frozen);
        break;
    case ANIM_UP:
        ft.setCustomAnimations(R.animator.dir_frozen, R.animator.dir_up);
        break;
    }

    final DirectoryFragment fragment = new DirectoryFragment();
    fragment.setArguments(args);

    ft.replace(R.id.container_directory, fragment);
    ft.commitAllowingStateLoss();
}