Example usage for android.transition TransitionManager beginDelayedTransition

List of usage examples for android.transition TransitionManager beginDelayedTransition

Introduction

In this page you can find the example usage for android.transition TransitionManager beginDelayedTransition.

Prototype

public static void beginDelayedTransition(final ViewGroup sceneRoot) 

Source Link

Document

Convenience method to animate, using the default transition, to a new scene defined by all changes within the given scene root between calling this method and the next rendering frame.

Usage

From source file:com.wizardsofm.deskclock.stopwatch.StopwatchFragment.java

/**
 * Show or hide the list of laps./* w ww.  jav a 2  s  . com*/
 */
private void showOrHideLaps(boolean clearLaps) {
    final ViewGroup sceneRoot = (ViewGroup) getView();
    if (sceneRoot == null) {
        return;
    }

    TransitionManager.beginDelayedTransition(sceneRoot);

    if (clearLaps) {
        mLapsAdapter.clearLaps();
    }

    final boolean lapsVisible = mLapsAdapter.getItemCount() > 0;
    mLapsList.setVisibility(lapsVisible ? VISIBLE : GONE);

    if (Utils.isPortrait(getActivity())) {
        // When the lap list is visible, it includes the bottom padding. When it is absent the
        // appropriate bottom padding must be applied to the container.
        final Resources res = getResources();
        final int bottom = lapsVisible ? 0
                : res.getDimensionPixelSize(com.wizardsofm.deskclock.R.dimen.fab_height);
        final int top = sceneRoot.getPaddingTop();
        final int left = sceneRoot.getPaddingLeft();
        final int right = sceneRoot.getPaddingRight();
        sceneRoot.setPadding(left, top, right, bottom);
    }
}

From source file:com.achep.base.ui.activities.SettingsActivity.java

/**
 * Switch to a specific Fragment with taking care of validation, Title and BackStack
 *///from www .ja  v a2 s  . c o m
private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate, boolean addToBackStack,
        int titleResId, CharSequence title, boolean withTransition) {
    if (validate && !isValidFragment(fragmentName)) {
        String message = "Invalid fragment for this activity: " + fragmentName;
        throw new IllegalArgumentException(message);
    }

    Fragment f = Fragment.instantiate(this, fragmentName, args);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(android.R.id.content, f);

    if (withTransition && Device.hasKitKatApi())
        TransitionManager.beginDelayedTransition(mContent);
    if (addToBackStack)
        transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS);
    if (titleResId > 0) {
        transaction.setBreadCrumbTitle(titleResId);
    } else if (title != null) {
        transaction.setBreadCrumbTitle(title);
    }

    transaction.commitAllowingStateLoss();
    getFragmentManager().executePendingTransactions();
    return f;
}

From source file:com.bullmobi.base.ui.activities.SettingsActivity.java

/**
 * Switch to a specific Fragment with taking care of validation, Title and BackStack
 *///  w w  w  . j ava 2  s.  c  o  m
private Fragment switchToFragment(String fragmentName, Bundle args, boolean validate, boolean addToBackStack,
        int titleResId, CharSequence title, boolean withTransition) {
    if (validate && !isValidFragment(fragmentName)) {
        String message = "Invalid fragment for this activity: " + fragmentName;
        throw new IllegalArgumentException(message);
    }

    Fragment f = Fragment.instantiate(this, fragmentName, args);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.main_content, f);

    if (withTransition && Device.hasKitKatApi())
        TransitionManager.beginDelayedTransition(mContent);
    if (addToBackStack)
        transaction.addToBackStack(SettingsActivity.BACK_STACK_PREFS);
    if (titleResId > 0) {
        transaction.setBreadCrumbTitle(titleResId);
    } else if (title != null) {
        transaction.setBreadCrumbTitle(title);
    }

    transaction.commitAllowingStateLoss();
    getFragmentManager().executePendingTransactions();
    return f;
}