List of usage examples for android.transition TransitionManager beginDelayedTransition
public static void beginDelayedTransition(final ViewGroup sceneRoot, Transition transition)
From source file:Main.java
public static void beginDelayedTransition(ViewGroup sceneRoot, Transition transition) { if (transition != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { TransitionManager.beginDelayedTransition(sceneRoot, transition); }/*from ww w.j ava2s.c om*/ } }
From source file:Main.java
@TargetApi(Build.VERSION_CODES.KITKAT) public static void createChangeBoundsAnimation(View disappearingView, View appearingView) { Scene scene;// w w w. ja v a2s . c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { scene = new Scene((ViewGroup) disappearingView.getParent(), appearingView); } else { scene = new Scene((ViewGroup) disappearingView.getParent(), (ViewGroup) appearingView.getParent()); } TransitionManager.beginDelayedTransition((ViewGroup) disappearingView.getParent(), new ChangeBounds()); disappearingView.setLeft(appearingView.getLeft()); }
From source file:MainActivity.java
public void goAnimate(View view) { ViewGroup root = (ViewGroup) findViewById(R.id.layout); Scene scene = new Scene(root); Transition transition = new ChangeBounds(); TransitionManager.beginDelayedTransition(root, transition); TextView textViewTop = (TextView) findViewById(R.id.textViewTop); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textViewTop.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 0); textViewTop.setLayoutParams(params); TextView textViewBottom = (TextView) findViewById(R.id.textViewBottom); params = (RelativeLayout.LayoutParams) textViewBottom.getLayoutParams(); params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); params.addRule(RelativeLayout.ALIGN_PARENT_TOP, 1); textViewBottom.setLayoutParams(params); TransitionManager.go(scene);//w ww . j ava2 s .c o m }
From source file:com.example.kyle.myapplication.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewGroup = (ViewGroup) findViewById(R.id.view_group); textView = (TextView) findViewById(R.id.textView); textView.setText("Animation demo"); imageView = (ImageView) findViewById(R.id.imageView); imageView2 = (ImageView) findViewById(R.id.imageView2); imageView3 = (ImageView) findViewById(R.id.imageView3); button = (Button) findViewById(R.id.button); button.setText("OK"); button.setOnClickListener(new View.OnClickListener() { @Override/*from w ww . j a va 2 s .com*/ public void onClick(View v) { TransitionManager.beginDelayedTransition(viewGroup, new Explode()); toggle(textView, imageView, imageView2, imageView3); } }); }
From source file:us.phyxsi.gameshelf.ui.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();//from w ww .j a va 2s . co m auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); dataManager = new SearchDataManager(this) { @Override public void onDataLoaded(List<? extends Boardgame> data) { if (data != null && data.size() > 0) { if (results.getVisibility() != View.VISIBLE) { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); results.setVisibility(View.VISIBLE); } adapter.addAndResort(data); } else { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } } }; adapter = new FeedAdapter(this, SearchActivity.this, dataManager, columns); results.setAdapter(adapter); GridLayoutManager layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return adapter.getItemColumnSpan(position); } }); results.setLayoutManager(layoutManager); results.setHasFixedSize(true); // extract the search icon's location passed from the launching activity, minus 4dp to // compensate for different paddings in the views searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0); // translate icon to match the launching screen then animate back into position searchBackContainer.setTranslationX(searchBackDistanceX); searchBackContainer.animate().translationX(0f).setDuration(650L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)); // transform from search icon to back icon AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_search_to_back); searchBack.setImageDrawable(searchToBack); searchToBack.start(); // for some reason the animation doesn't always finish (leaving a part arrow!?) so after // the animation set a static drawable. Also animation callbacks weren't added until API23 // so using post delayed :( // TODO fix properly!! searchBack.postDelayed(new Runnable() { @Override public void run() { searchBack.setImageDrawable( ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded)); } }, 600L); // fade in the other search chrome searchBackground.animate().alpha(1f).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchView.requestFocus(); ImeUtils.showIme(searchView); } }); // animate in a scrim over the content behind scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { scrim.getViewTreeObserver().removeOnPreDrawListener(this); AnimatorSet showScrim = new AnimatorSet(); showScrim.playTogether( ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX, searchBackground.getBottom(), 0, (float) Math.hypot(searchBackDistanceX, scrim.getHeight() - searchBackground.getBottom())), ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim))); showScrim.setDuration(400L); showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); showScrim.start(); return false; } }); onNewIntent(getIntent()); }
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;/*w ww. j a va 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:org.goodev.material.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();/*from ww w. j a v a 2 s. c o m*/ if (UI.isLollipop()) { auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); } dataManager = new SearchDataManager(this) { @Override public void onDataLoaded(List<Hit> data) { if (data != null && data.size() > 0) { if (results.getVisibility() != View.VISIBLE) { if (UI.isLollipop()) { TransitionManager.beginDelayedTransition(container, auto); } progress.setVisibility(View.GONE); results.setVisibility(View.VISIBLE); } adapter.addAll(data); if (dataManager.getPage() == 0) { results.scrollToPosition(0); } } else if (adapter.getItemCount() == 0) { if (UI.isLollipop()) { TransitionManager.beginDelayedTransition(container, auto); } progress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } else { adapter.notifyDataSetChanged(); Snackbar.make(results, R.string.no_more_posts, Snackbar.LENGTH_LONG).show(); } } }; adapter = new FeedAdapter(this, dataManager, columns); results.setAdapter(adapter); GridLayoutManager layoutManager = new GridLayoutManager(this, columns); // layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { // @Override // public int getSpanSize(int position) { // return adapter.getItemColumnSpan(position); // } // }); results.setLayoutManager(layoutManager); results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadMore(); } }); results.setHasFixedSize(true); if (UI.isLollipop()) { results.addOnScrollListener(gridScroll); } // extract the search icon's location passed from the launching activity, minus 4dp to // compensate for different paddings in the views searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0); int interpolator = UI.isLollipop() ? android.R.interpolator.fast_out_slow_in : android.R.interpolator.accelerate_decelerate; int backInterpolator = UI.isLollipop() ? android.R.interpolator.linear_out_slow_in : android.R.interpolator.accelerate_decelerate; // translate icon to match the launching screen then animate back into position searchBackContainer.setTranslationX(searchBackDistanceX); searchBackContainer.animate().translationX(0f).setDuration(650L) .setInterpolator(AnimationUtils.loadInterpolator(this, interpolator)); if (UI.isLollipop()) { // transform from search icon to back icon AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_search_to_back); searchBack.setImageDrawable(searchToBack); searchToBack.start(); } else { searchBack.setVisibility(View.INVISIBLE); searchBack.setImageResource(R.drawable.ic_arrow_back_padded); } // for some reason the animation doesn't always finish (leaving a part arrow!?) so after // the animation set a static drawable. Also animation callbacks weren't added until API23 // so using post delayed :( // TODO fix properly!! searchBack.postDelayed(new Runnable() { @Override public void run() { searchBack.setImageDrawable( ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded)); } }, 600); // fade in the other search chrome searchBackground.animate().alpha(1f).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(this, backInterpolator)); searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L) .setInterpolator(AnimationUtils.loadInterpolator(this, backInterpolator)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchView.requestFocus(); ImeUtils.showIme(searchView); } }); if (UI.isLollipop()) { // animate in a scrim over the content behind scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public boolean onPreDraw() { scrim.getViewTreeObserver().removeOnPreDrawListener(this); AnimatorSet showScrim = new AnimatorSet(); showScrim.playTogether( ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX, searchBackground.getBottom(), 0, (float) Math.hypot(searchBackDistanceX, scrim.getHeight() - searchBackground.getBottom())), ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim))); showScrim.setDuration(400L); showScrim.setInterpolator( AnimationUtils.loadInterpolator(SearchActivity.this, backInterpolator)); showScrim.start(); return false; } }); } onNewIntent(getIntent()); }
From source file:com.saulmm.cui.OrderDialogFragment.java
private void startCloneAnimation(View clonedView, View targetView) { clonedView.post(() -> {//from w ww .ja v a 2 s . co m TransitionManager.beginDelayedTransition((ViewGroup) binding.getRoot(), selectedViewTransition); // Fires the transition clonedView.setLayoutParams(SelectedParamsFactory.endParams(clonedView, targetView)); }); }
From source file:io.plaidapp.ui.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();//w w w . ja va 2 s. c o m auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); dataManager = new SearchDataManager(this) { @Override public void onDataLoaded(List<? extends PlaidItem> data) { if (data != null && data.size() > 0) { if (results.getVisibility() != View.VISIBLE) { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); results.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE); fab.setAlpha(0.6f); fab.setScaleX(0f); fab.setScaleY(0f); fab.animate().alpha(1f).scaleX(1f).scaleY(1f).setStartDelay(800L).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); } adapter.addAndResort(data); } else { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } } }; adapter = new FeedAdapter(this, dataManager, PocketUtils.isPocketInstalled(this)); results.setAdapter(adapter); GridLayoutManager layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return position == adapter.getDataItemCount() ? columns : 1; } }); results.setLayoutManager(layoutManager); results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadMore(); } }); results.setHasFixedSize(true); results.addOnScrollListener(gridScroll); // extract the search icon's location passed from the launching activity, minus 4dp to // compensate for different paddings in the views searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0); // translate icon to match the launching screen then animate back into position searchBackContainer.setTranslationX(searchBackDistanceX); searchBackContainer.animate().translationX(0f).setDuration(650L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)); // transform from search icon to back icon AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_search_to_back); searchBack.setImageDrawable(searchToBack); searchToBack.start(); // for some reason the animation doesn't always finish (leaving a part arrow!?) so after // the animation set a static drawable. Also animation callbacks weren't added until API23 // so using post delayed :( // TODO fix properly!! searchBack.postDelayed(new Runnable() { @Override public void run() { searchBack.setImageDrawable( ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded)); } }, 600); // fade in the other search chrome searchBackground.animate().alpha(1f).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchView.requestFocus(); ImeUtils.showIme(searchView); } }); // animate in a scrim over the content behind scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { scrim.getViewTreeObserver().removeOnPreDrawListener(this); AnimatorSet showScrim = new AnimatorSet(); showScrim.playTogether( ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX, searchBackground.getBottom(), 0, (float) Math.hypot(searchBackDistanceX, scrim.getHeight() - searchBackground.getBottom())), ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim))); showScrim.setDuration(400L); showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); showScrim.start(); return false; } }); onNewIntent(getIntent()); }
From source file:io.plaidapp.ui.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();//ww w .j a v a2s . co m auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); dataManager = new SearchDataManager(this) { @Override public void onDataLoaded(List<? extends PlaidItem> data) { if (data != null && data.size() > 0) { if (results.getVisibility() != View.VISIBLE) { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); results.setVisibility(View.VISIBLE); fab.setVisibility(View.VISIBLE); fab.setAlpha(0.6f); fab.setScaleX(0f); fab.setScaleY(0f); fab.animate().alpha(1f).scaleX(1f).scaleY(1f).setStartDelay(800L).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); } adapter.addAndResort(data); } else { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } } }; adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this)); results.setAdapter(adapter); GridLayoutManager layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return adapter.getItemColumnSpan(position); } }); results.setLayoutManager(layoutManager); results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) { @Override public void onLoadMore() { dataManager.loadMore(); } }); results.setHasFixedSize(true); results.addOnScrollListener(gridScroll); // extract the search icon's location passed from the launching activity, minus 4dp to // compensate for different paddings in the views searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0); // translate icon to match the launching screen then animate back into position searchBackContainer.setTranslationX(searchBackDistanceX); searchBackContainer.animate().translationX(0f).setDuration(650L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)); // transform from search icon to back icon AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_search_to_back); searchBack.setImageDrawable(searchToBack); searchToBack.start(); // for some reason the animation doesn't always finish (leaving a part arrow!?) so after // the animation set a static drawable. Also animation callbacks weren't added until API23 // so using post delayed :( // TODO fix properly!! searchBack.postDelayed(new Runnable() { @Override public void run() { searchBack.setImageDrawable( ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded)); } }, 600L); // fade in the other search chrome searchBackground.animate().alpha(1f).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchView.requestFocus(); ImeUtils.showIme(searchView); } }); // animate in a scrim over the content behind scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { scrim.getViewTreeObserver().removeOnPreDrawListener(this); AnimatorSet showScrim = new AnimatorSet(); showScrim.playTogether( ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX, searchBackground.getBottom(), 0, (float) Math.hypot(searchBackDistanceX, scrim.getHeight() - searchBackground.getBottom())), ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim))); showScrim.setDuration(400L); showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); showScrim.start(); return false; } }); onNewIntent(getIntent()); }