Example usage for android.transition TransitionSet ORDERING_SEQUENTIAL

List of usage examples for android.transition TransitionSet ORDERING_SEQUENTIAL

Introduction

In this page you can find the example usage for android.transition TransitionSet ORDERING_SEQUENTIAL.

Prototype

int ORDERING_SEQUENTIAL

To view the source code for android.transition TransitionSet ORDERING_SEQUENTIAL.

Click Source Link

Document

A flag used to indicate that the child transitions of this set should play in sequence; when one child transition ends, the next child transition begins.

Usage

From source file:com.android.deskclock.AlarmClockFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    // Inflate the layout for this fragment
    final View v = inflater.inflate(R.layout.alarm_clock, container, false);

    long expandedId = INVALID_ID;
    long[] repeatCheckedIds = null;
    long[] selectedAlarms = null;
    Bundle previousDayMap = null;/*from  ww w  . ja va  2s. c om*/
    if (savedState != null) {
        expandedId = savedState.getLong(KEY_EXPANDED_ID);
        repeatCheckedIds = savedState.getLongArray(KEY_REPEAT_CHECKED_IDS);
        mRingtoneTitleCache = savedState.getBundle(KEY_RINGTONE_TITLE_CACHE);
        mDeletedAlarm = savedState.getParcelable(KEY_DELETED_ALARM);
        mUndoShowing = savedState.getBoolean(KEY_UNDO_SHOWING);
        selectedAlarms = savedState.getLongArray(KEY_SELECTED_ALARMS);
        previousDayMap = savedState.getBundle(KEY_PREVIOUS_DAY_MAP);
        mSelectedAlarm = savedState.getParcelable(KEY_SELECTED_ALARM);
    }

    mExpandInterpolator = new DecelerateInterpolator(EXPAND_DECELERATION);
    mCollapseInterpolator = new DecelerateInterpolator(COLLAPSE_DECELERATION);

    if (USE_TRANSITION_FRAMEWORK) {
        mAddRemoveTransition = new AutoTransition();
        mAddRemoveTransition.setDuration(ANIMATION_DURATION);

        /// M: Scrap the views in ListView and request layout again, then alarm item will be
        /// attached correctly. This is to avoid the case when some items are not correctly
        ///  attached after animation end  @{
        mAddRemoveTransition.addListener(new Transition.TransitionListenerAdapter() {
            @Override
            public void onTransitionEnd(Transition transition) {
                mAlarmsList.clearScrapViewsIfNeeded();
            }
        });
        /// @}

        mRepeatTransition = new AutoTransition();
        mRepeatTransition.setDuration(ANIMATION_DURATION / 2);
        mRepeatTransition.setInterpolator(new AccelerateDecelerateInterpolator());

        mEmptyViewTransition = new TransitionSet().setOrdering(TransitionSet.ORDERING_SEQUENTIAL)
                .addTransition(new Fade(Fade.OUT)).addTransition(new Fade(Fade.IN))
                .setDuration(ANIMATION_DURATION);
    }

    boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    View menuButton = v.findViewById(R.id.menu_button);
    if (menuButton != null) {
        if (isLandscape) {
            menuButton.setVisibility(View.GONE);
        } else {
            menuButton.setVisibility(View.VISIBLE);
            setupFakeOverflowMenuButton(menuButton);
        }
    }

    mEmptyView = v.findViewById(R.id.alarms_empty_view);

    mMainLayout = (FrameLayout) v.findViewById(R.id.main);
    mAlarmsList = (ListView) v.findViewById(R.id.alarms_list);

    mUndoBar = (ActionableToastBar) v.findViewById(R.id.undo_bar);
    mUndoFrame = v.findViewById(R.id.undo_frame);
    mUndoFrame.setOnTouchListener(this);

    mFooterView = v.findViewById(R.id.alarms_footer_view);
    mFooterView.setOnTouchListener(this);

    mAdapter = new AlarmItemAdapter(getActivity(), expandedId, repeatCheckedIds, selectedAlarms, previousDayMap,
            mAlarmsList);
    mAdapter.registerDataSetObserver(new DataSetObserver() {

        private int prevAdapterCount = -1;

        @Override
        public void onChanged() {

            final int count = mAdapter.getCount();
            if (mDeletedAlarm != null && prevAdapterCount > count) {
                showUndoBar();
            }

            if (USE_TRANSITION_FRAMEWORK && ((count == 0 && prevAdapterCount > 0) || /* should fade  in */
            (count > 0 && prevAdapterCount == 0) /* should fade out */)) {
                TransitionManager.beginDelayedTransition(mMainLayout, mEmptyViewTransition);
            }
            mEmptyView.setVisibility(count == 0 ? View.VISIBLE : View.GONE);

            // Cache this adapter's count for when the adapter changes.
            prevAdapterCount = count;
            super.onChanged();
        }
    });

    if (mRingtoneTitleCache == null) {
        mRingtoneTitleCache = new Bundle();
    }

    mAlarmsList.setAdapter(mAdapter);
    mAlarmsList.setVerticalScrollBarEnabled(true);
    mAlarmsList.setOnCreateContextMenuListener(this);

    if (mUndoShowing) {
        showUndoBar();
    }
    return v;
}