List of usage examples for android.transition AutoTransition AutoTransition
public AutoTransition()
From source file:com.example.tripi.transitionanimation.BasicTransitionFragment.java
@Override public void onCheckedChanged(RadioGroup group, int checkedId) { switch (checkedId) { case R.id.select_scene_1: { // BEGIN_INCLUDE(transition_simple) // You can start an automatic transition with TransitionManager.go(). mTransitionManagerForScene1.transitionTo(mScene1); // TransitionManager.go(mScene1); // END_INCLUDE(transition_simple) break;//from w w w .j a v a 2 s .co m } case R.id.select_scene_2: { mTransitionManagerForScene2.transitionTo(mScene2); // TransitionManager.go(mScene2); break; } case R.id.select_scene_3: { // BEGIN_INCLUDE(transition_custom) // You can also start a transition with a custom TransitionManager. mTransitionManagerForScene3.transitionTo(mScene3); // END_INCLUDE(transition_custom) break; } case R.id.select_scene_4: { // BEGIN_INCLUDE(transition_dynamic) // Alternatively, transition can be invoked dynamically without a Scene. // For this, we first call TransitionManager.beginDelayedTransition(). // TransitionManager.beginDelayedTransition(mSceneRoot); TransitionManager.beginDelayedTransition(mSceneRoot, new AutoTransition().setDuration(2000)); // Then, we can just change view properties as usual. View square = mSceneRoot.findViewById(R.id.transition_square); ViewGroup.LayoutParams params = square.getLayoutParams(); int newSize = getResources().getDimensionPixelSize(R.dimen.square_size_expanded); params.width = newSize; params.height = newSize; square.setLayoutParams(params); // END_INCLUDE(transition_dynamic) break; } } }
From source file:com.kai.uGuide.ui.fragment.AdapterTransitionFragment.java
/** * Toggle the UI between ListView and GridView. *///from w w w. ja va2 s.c o m public void toggle() { // We use mCover as the overlay on which we carry out the transition. mCover.setVisibility(View.VISIBLE); // This FrameLayout holds all the visible views in the current list or grid. We use this as // the starting Scene of the Transition later. FrameLayout before = copyVisibleViews(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); mCover.addView(before, params); // Swap the actual list. swapAbsListView(); // We also swap the icon for the toggle button. ActivityCompat.invalidateOptionsMenu(getActivity()); // It is now ready to start the transition. mAbsListView.post(new Runnable() { @Override public void run() { // BEGIN_INCLUDE(transition_with_listener) Scene scene = new Scene(mCover, copyVisibleViews()); Transition transition = new AutoTransition(); transition.addListener(AdapterTransitionFragment.this); TransitionManager.go(scene, transition); // END_INCLUDE(transition_with_listener) } }); }
From source file:com.example.kent_zheng.sdk_adaptertransition.AdapterTransitionFragment.java
/** * Toggle the UI between ListView and GridView. *//*from www . ja v a2 s .c om*/ private void toggle() { // We use mCover as the overlay on which we carry out the transition. mCover.setVisibility(View.VISIBLE); // This FrameLayout holds all the visible views in the current list or grid. We use this as // the starting Scene of the Transition later. FrameLayout before = copyVisibleViews(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); mCover.addView(before, params); // Swap the actual list. swapAbsListView(); // We also swap the icon for the toggle button. ActivityCompat.invalidateOptionsMenu(getActivity()); // It is now ready to start the transition. mAbsListView.post(new Runnable() { @Override public void run() { Scene scene = new Scene(mCover, copyVisibleViews()); Transition transition = new AutoTransition(); transition.addListener(AdapterTransitionFragment.this); TransitionManager.go(scene, transition); } }); }
From source file:com.example.android.adaptertransition.AdapterTransitionFragment.java
/** * Toggle the UI between ListView and GridView. *//*from w w w. j av a2 s .c o m*/ private void toggle() { // We use mCover as the overlay on which we carry out the transition. mCover.setVisibility(View.VISIBLE); // This FrameLayout holds all the visible views in the current list or grid. We use this as // the starting Scene of the Transition later. FrameLayout before = copyVisibleViews(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); mCover.addView(before, params); // Swap the actual list. swapAbsListView(); // We also swap the icon for the toggle button. ActivityCompat.invalidateOptionsMenu(getActivity()); // It is now ready to start the transition. mAbsListView.post(new Runnable() { @Override public void run() { // BEGIN_INCLUDE(transition_with_listener) Scene scene = new Scene(mCover, copyVisibleViews()); Transition transition = new AutoTransition(); transition.addListener(AdapterTransitionFragment.this); TransitionManager.go(scene, transition); // END_INCLUDE(transition_with_listener) } }); }
From source file:com.betterAlarm.deskclock.timer.TimerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.timer_fragment, container, false); mContentView = (ViewGroup) view;/*from www .j a v a2 s.co m*/ mTimerView = view.findViewById(R.id.timer_view); mSetupView = (TimerSetupView) view.findViewById(R.id.timer_setup); mViewPager = (VerticalViewPager) view.findViewById(R.id.vertical_view_pager); mPageIndicators[0] = (ImageView) view.findViewById(R.id.page_indicator0); mPageIndicators[1] = (ImageView) view.findViewById(R.id.page_indicator1); mPageIndicators[2] = (ImageView) view.findViewById(R.id.page_indicator2); mPageIndicators[3] = (ImageView) view.findViewById(R.id.page_indicator3); mCancel = (ImageButton) view.findViewById(R.id.timer_cancel); mCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mAdapter.getCount() != 0) { final AnimatorListenerAdapter adapter = new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mSetupView.reset(); // Make sure the setup is cleared for next time mSetupView.setScaleX(1.0f); // Reset the scale for setup view goToPagerView(); } }; createRotateAnimator(adapter, false).start(); } } }); mDeleteTransition = new AutoTransition(); mDeleteTransition.setDuration(ANIMATION_TIME_MILLIS / 2); mDeleteTransition.setInterpolator(new AccelerateDecelerateInterpolator()); return view; }
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 w w w . ja v a2 s . com 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; }
From source file:com.desno365.mods.DesnoUtils.java
public static void expandTextView(ViewGroup container, TextView tv) { // animation/*from w w w . j a va 2 s. c om*/ if (Build.VERSION.SDK_INT >= 19) { TransitionManager.beginDelayedTransition(container, new AutoTransition() .setDuration(SharedConstants.CHANGELOG_TEXT_ANIMATION_DURATION_PER_LINE * tv.getLineCount())); } // expand the TextView with setMaxLines tv.setMaxLines(Integer.MAX_VALUE); }
From source file:com.desno365.mods.DesnoUtils.java
public static void collapseTextView(ViewGroup container, final TextView tv, int collapsedHeight) { if (Build.VERSION.SDK_INT >= 19) { int lines = tv.getLineCount(); // animation TransitionManager.beginDelayedTransition(container, new AutoTransition() .setDuration(SharedConstants.CHANGELOG_TEXT_ANIMATION_DURATION_PER_LINE * lines)); // collapse the view by setting the collapsed height DesnoUtils.setViewHeight(tv, collapsedHeight); // restore initial state of the TextView when the animation finishes Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override/*from w w w . j av a 2 s . c om*/ public void run() { DesnoUtils.setViewHeight(tv, ViewGroup.LayoutParams.WRAP_CONTENT); tv.setMaxLines(SharedConstants.CHANGELOG_TEXT_MAX_LINES); } }, SharedConstants.CHANGELOG_TEXT_ANIMATION_DURATION_PER_LINE * lines + 100); } else { // no animation without the new APIs :/ tv.setMaxLines(SharedConstants.CHANGELOG_TEXT_MAX_LINES); } }