List of usage examples for android.transition TransitionSet TransitionSet
public TransitionSet()
From source file:com.example.android.unsplash.DetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_detail); postponeEnterTransition();//from w ww . jav a 2s .co m TransitionSet transitions = new TransitionSet(); Slide slide = new Slide(Gravity.BOTTOM); slide.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)); transitions.addTransition(slide); transitions.addTransition(new Fade()); getWindow().setEnterTransition(transitions); Intent intent = getIntent(); sharedElementCallback = new DetailSharedElementEnterCallback(intent); setEnterSharedElementCallback(sharedElementCallback); try { initialItem = Integer.parseInt(intent.getData().getLastPathSegment()); } catch (NumberFormatException e) { initialItem = 0; } PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() { @Override public void success(ArrayList<Photo> photos) { setUpViewPager(photos); findViewById(android.R.id.empty).setVisibility(View.GONE); } @Override public void error() { finishAfterTransition(); } }); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setNavigationOnClickListener(navigationOnClickListener); super.onCreate(savedInstanceState); }
From source file:com.kogitune.activitytransition.ActivityTransition.java
public ExitActivityTransition start(Bundle savedInstanceState) { if (interpolator == null) { interpolator = new DecelerateInterpolator(); }//ww w . j a v a2 s.co m final Bundle bundle = fromIntent.getExtras(); if (Build.VERSION.SDK_INT >= 21) { final TransitionData transitionData = new TransitionData(toView.getContext(), bundle); if (transitionData.imageFilePath != null) { TransitionAnimation.setImageToView(toView, transitionData.imageFilePath); } ViewCompat.setTransitionName(toView, toViewName); final Window window = ((Activity) context).getWindow(); TransitionSet set = new TransitionSet(); set.addTransition(new ChangeBounds()); set.addTransition(new ChangeImageTransform()); set.setInterpolator(interpolator); window.setSharedElementEnterTransition(set); window.setSharedElementReturnTransition(set); return new ExitActivityTransition(null); } final Context context = toView.getContext(); final MoveData moveData = TransitionAnimation.startAnimation(context, toView, bundle, savedInstanceState, duration, interpolator); return new ExitActivityTransition(moveData); }
From source file:net.huannguyen.conductorexample.transition.DetailPushTransChangeHandler.java
@NonNull @Override//w w w. j ava2 s . c o m protected Transition getTransition(@NonNull ViewGroup container, @Nullable View from, @Nullable View to, boolean isPush) { if (to == null || !(to instanceof CountryDetailView)) { throw new IllegalArgumentException("The to view must be a CountryDetailView"); } final CountryDetailView detailView = (CountryDetailView) to; detailView.flagView.setTransitionName(flagViewTransitionName); ChangeTransform changeTransform = new ChangeTransform(); // Shared elements (the flag view in this case) are drawn in the window's view overlay during the transition by default. // That causes the favourite fab being drawn behind the flag when it is scaled up. // Setting the change transform not using overlay addresses this issue. changeTransform.setReparentWithOverlay(false); return new TransitionSet() .addTransition(new TransitionSet().addTransition(new ChangeBounds()) .addTransition(new ChangeClipBounds()).addTransition(changeTransform) .addTransition(new ChangeImageTransform()).setDuration(300)) .addTransition(new Slide().addTarget(detailView.detailGroup).setStartDelay(150)) .addTransition(new Scale().addTarget(detailView.favouriteFab).setStartDelay(300)) .setInterpolator(new FastOutSlowInInterpolator()); }
From source file:net.mm2d.dmsexplorer.ServerDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.frg_server_detail, container, false); final String udn = getArguments().getString(Const.EXTRA_UDN); final DataHolder dataHolder = DataHolder.getInstance(); final MediaServer server = dataHolder.getMsControlPoint().getMediaServer(udn); if (server == null) { getActivity().finish();/*from www. j a v a2 s. c om*/ return rootView; } final TextView titleView = (TextView) rootView.findViewById(R.id.title); if (titleView != null) { titleView.setText(server.getFriendlyName()); titleView.setBackgroundColor(ThemeUtils.getAccentColor(server.getFriendlyName())); } final RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.server_detail); final PropertyAdapter adapter = new PropertyAdapter(getContext()); setupPropertyAdapter(adapter, server); adapter.setOnItemLinkClickListener(this); recyclerView.setAdapter(adapter); FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fab); if (fab == null) { fab = (FloatingActionButton) getActivity().findViewById(R.id.fab); } if (fab != null) { fab.setOnClickListener(view -> { final Intent intent = CdsListActivity.makeIntent(getContext(), udn); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { final TransitionSet ts = new TransitionSet(); ts.addTransition(new Slide(Gravity.START)); ts.addTransition(new Fade()); getActivity().getWindow().setExitTransition(ts); startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(getActivity(), view, "share").toBundle()); } else { startActivity(intent); } }); } return rootView; }
From source file:com.melkir.ourstreets.fragment.GalleryFragment.java
public GalleryFragment() { final Fade fade = new Fade(); fade.addTarget(R.id.appbar);//from w w w .j ava2s . c om Explode explode = new Explode(); explode.excludeTarget(R.id.appbar, true); Elevation elevation = new Elevation(); elevation.addTarget(R.id.gallery_card); elevation.setStartDelay(250); // arbitrarily chosen delay TransitionSet exit = new TransitionSet(); exit.addTransition(fade); exit.addTransition(explode); exit.addTransition(elevation); setExitTransition(exit); }
From source file:syncthing.android.ui.login.ManagePresenter.java
@TargetApi(21) private void applyFragmentTransitions(Fragment f) { if (VersionUtils.hasLollipop()) { TransitionSet set = new TransitionSet(); set.addTransition(new Slide(Gravity.BOTTOM)); set.addTransition(new Fade(Fade.IN)); f.setEnterTransition(set);/*from w w w.j ava2 s . co m*/ } }
From source file:net.mm2d.dmsexplorer.CdsListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { final TransitionSet ts = new TransitionSet(); ts.addTransition(new Slide(Gravity.END)); ts.addTransition(new Fade()); getWindow().setEnterTransition(ts); }//w w w. j ava 2 s .c o m mHandler = new Handler(); final String udn = getIntent().getStringExtra(Const.EXTRA_UDN); mServer = mDataHolder.getMsControlPoint().getMediaServer(udn); if (mServer == null) { finish(); return; } final String name = mServer.getFriendlyName(); if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(ThemeUtils.getAccentDarkColor(name)); } setContentView(R.layout.act_cds_list); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setBackgroundColor(ThemeUtils.getAccentColor(name)); final ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(name); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh); mSwipeRefreshLayout.setColorSchemeResources(R.color.progress1, R.color.progress2, R.color.progress3, R.color.progress4); mSwipeRefreshLayout.setOnRefreshListener(() -> { mDataHolder.popCache(); reload(); }); mCdsListAdapter = new CdsListAdapter(this); mCdsListAdapter.setOnItemClickListener(this::onCdsItemClick); mRecyclerView = (RecyclerView) findViewById(R.id.cds_list); mRecyclerView.setAdapter(mCdsListAdapter); mRecyclerView.addItemDecoration(new DividerItemDecoration(this)); if (findViewById(R.id.cds_detail_container) != null) { mTwoPane = true; } if (savedInstanceState == null) { browse(0, "0", "", true); } }
From source file:com.bullmobi.message.ui.fragments.EasyNotificationFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Resources res = getResources(); mConfigWidgetPinDuration = res.getInteger(R.integer.config_maxPinTime); mConfigWidgetSelectDelay = res.getInteger(R.integer.config_iconSelectDelayMillis); ViewConfiguration vc = ViewConfiguration.get(getActivity()); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); // Clock widget mClockWidget = new ClockWidget(this, this); // Media widget mMediaController = MediaController2.newInstance(getActivity()); mMediaWidget = new MediaWidget(this, this); // Transitions if (Device.hasKitKatApi()) { mTransitionJit = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER) .addTransition(new Fade()).addTransition(new ChangeBounds()); mTransitionSwitchScene = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER) .addTransition(new Fade(Fade.OUT).setDuration(200)) .addTransition(new Fade(Fade.IN).setStartDelay(80)) .addTransition(new ChangeBounds().setStartDelay(80)); }/* w w w.j av a 2 s .c om*/ // Timeout mTimeout = isNotDemo() ? mActivityAcd.getTimeout() : new Timeout(); }
From source file:com.achep.acdisplay.ui.fragments.AcDisplayFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Resources res = getResources(); mConfigWidgetPinDuration = res.getInteger(R.integer.config_maxPinTime); mConfigWidgetSelectDelay = res.getInteger(R.integer.config_iconSelectDelayMillis); ViewConfiguration vc = ViewConfiguration.get(getActivity()); mMaxFlingVelocity = vc.getScaledMaximumFlingVelocity(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); // Clock widget mClockWidget = getConfig().isCustomWidgetEnabled() ? new HostWidget(this, this) : new ClockWidget(this, this); // Media widget mMediaController = MediaController2.newInstance(getActivity()).asyncWrap(); mMediaWidget = new MediaWidget(this, this); // Transitions if (Device.hasKitKatApi()) { mTransitionJit = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER) .addTransition(new Fade()).addTransition(new ChangeBounds()); mTransitionSwitchScene = new TransitionSet().setOrdering(TransitionSet.ORDERING_TOGETHER) .addTransition(new Fade(Fade.OUT).setDuration(200)) .addTransition(new Fade(Fade.IN).setStartDelay(80)) .addTransition(new ChangeBounds().setStartDelay(80)); }//from w w w . java 2 s . c om // Timeout mTimeout = isNotDemo() ? mActivityAcd.getTimeout() : new Timeout(); }
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 . j ava 2 s . co m*/ 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; }