List of usage examples for android.transition TransitionManager beginDelayedTransition
public static void beginDelayedTransition(final ViewGroup sceneRoot, Transition transition)
From source file:babbq.com.searchplace.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();/*from www . j av a 2 s . co m*/ auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API) .addApi(Places.GEO_DATA_API).addConnectionCallbacks(this).addOnConnectionFailedListener(this) .build(); mAdapter = new TestAdapter(null, v -> { int position = results.getChildLayoutPosition(v); //Toast.makeText(getActivity(), "#" + position, Toast.LENGTH_SHORT).show(); PendingResult result = Places.GeoDataApi.getPlaceById(mGoogleApiClient, String.valueOf(mAdapter.getElementAt(position).placeId)); result.setResultCallback(mCoordinatePlaceDetailsCallback); }, mGoogleApiClient); dataManager = new SearchDataManager(mGoogleApiClient, mCoordinatePlaceDetailsCallback) { @Override public void onDataLoaded(List<? extends PlaceAutocomplete> 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)); } // mAdapter.addAndResort(data); mAdapter.setList(data); } else { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } } }; // mAdapter = new FeedAdapter(this, dataManager, columns); results.setAdapter(mAdapter); GridLayoutManager layoutManager = new GridLayoutManager(this, columns); // layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { // // @Override // public int getSpanSize(int position) { // return mAdapter.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)); } }, 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:im.ene.lab.attiq.ui.activities.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();//from www . j a v a 2s .c o m mAutoTransition = TransitionInflater.from(this).inflateTransition(R.transition.auto) .setInterpolator(LINEAR_OUT_SLOW_INT); mSearchResultCallback = new Callback<List<Article>>() { @Override public void onResponse(Call<List<Article>> call, Response<List<Article>> response) { List<Article> data = response.body(); if (!UIUtil.isEmpty(data)) { if (mRecyclerView.getVisibility() != View.VISIBLE) { TransitionManager.beginDelayedTransition(mMainContainer, mAutoTransition); mProgress.setVisibility(View.GONE); mRecyclerView.setVisibility(View.VISIBLE); } mAdapter.addItems(data); } else { TransitionManager.beginDelayedTransition(mMainContainer, mAutoTransition); mProgress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } } @Override public void onFailure(Call<List<Article>> call, Throwable t) { } }; mAdapter = new ArticleListAdapter() { @Override public void loadItems(boolean isLoadingMore, int page, int pageLimit, @Nullable String query, Callback<List<Article>> callback) { ApiClient.items(page, pageLimit, query).enqueue(callback); } }; mOnResultItemClick = new ArticleListAdapter.OnArticleClickListener() { @Override public void onUserClick(User user) { startActivity(ProfileActivity.createIntent(SearchActivity.this, user.getId())); } @Override public void onItemContentClick(Article item) { startActivity(ItemDetailActivity.createIntent(SearchActivity.this, item.getId())); } }; mAdapter.setOnItemClickListener(mOnResultItemClick); mRecyclerView.setAdapter(mAdapter); mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST)); GridLayoutManager layoutManager = new GridLayoutManager(this, mColumns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { // return mAdapter.getItemColumnSpan(position); return mColumns; } }); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.addOnScrollListener(new EndlessScrollListener(layoutManager) { @Override protected void loadMore() { mHandler.removeMessages(MESSAGE_LOAD_MORE); mHandler.sendEmptyMessageDelayed(MESSAGE_LOAD_MORE, 200); } }); mRecyclerView.setHasFixedSize(true); mRecyclerView.addOnScrollListener(mOnGridScroll); // extract the search icon's location passed from the launching activity, minus 4dp to // compensate for different paddings in the views mSearchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); mSearchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0); // translate icon to match the launching screen then animate back into position mSearchNavButtonContainer.setTranslationX(mSearchBackDistanceX); mSearchNavButtonContainer.animate().translationX(0f).setDuration(650L).setInterpolator(LINEAR_OUT_SLOW_INT); // change from search icon to back icon DrawerArrowDrawable searchToBack = new DrawerArrowDrawable(mSearchNavButton.getContext()); searchToBack.setDirection(DrawerArrowDrawable.ARROW_DIRECTION_LEFT); searchToBack.setProgress(1.f); mSearchNavButton.setImageDrawable(searchToBack); // fade in the other search chrome mSearchBackground.animate().alpha(1f).setDuration(300L).setInterpolator(LINEAR_OUT_SLOW_INT); mSearchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L).setInterpolator(LINEAR_OUT_SLOW_INT) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mSearchView.requestFocus(); ImeUtil.showIme(mSearchView); } }); // animate in a mScrim over the content behind mScrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { mScrim.getViewTreeObserver().removeOnPreDrawListener(this); AnimatorSet showScrim = new AnimatorSet(); showScrim.playTogether( ViewAnimationUtils.createCircularReveal(mScrim, mSearchIconCenterX, mSearchBackground.getBottom(), 0, (float) Math.hypot(mSearchBackDistanceX, mScrim.getHeight() - mSearchBackground.getBottom())), AnimUtil.ofArgb(mScrim, UIUtil.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim))); showScrim.setDuration(400L); showScrim.setInterpolator(LINEAR_OUT_SLOW_INT); showScrim.start(); return false; } }); onNewIntent(getIntent()); }
From source file:com.google.samples.apps.ourstreets.fragment.DetailFragment.java
private void setDescriptionText(@NonNull String title, @NonNull String detail) { View view = getView();/*from w ww .java2 s. co m*/ if (view == null) { return; } TransitionManager.beginDelayedTransition(((ViewGroup) view), mDescriptionChange); ViewUtils.setTextOn(view, R.id.text_title, title); ViewUtils.setTextOn(view, R.id.text_detail, detail); }
From source file:com.joaquimley.faboptions.FabOptions.java
private void open() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.faboptions_ic_menu_animatable, null); mFab.setImageDrawable(drawable); drawable.start();/*from w w w. j a v a2 s . co m*/ } else { mFab.setImageResource(R.drawable.faboptions_ic_close); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { TransitionManager.beginDelayedTransition(this, new OpenMorphTransition(mButtonContainer)); } animateBackground(true); animateButtons(true); // } else { // openCompatAnimation(); // } mIsOpen = true; }
From source file:com.joaquimley.faboptions.FabOptions.java
private void close() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.faboptions_ic_close_animatable, null); mFab.setImageDrawable(drawable); drawable.start();/* w w w .j a va2 s .c om*/ } else { mFab.setImageResource(R.drawable.faboptions_ic_overflow); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { TransitionManager.beginDelayedTransition(this, new CloseMorphTransition(mButtonContainer)); // } else { // closeCompatAnimation(); } animateButtons(false); animateBackground(false); mIsOpen = false; }
From source file:us.phyxsi.gameshelf.ui.SearchActivity.java
private void clearResults() { adapter.clear();/*w w w. j a va 2s . c om*/ dataManager.clear(); TransitionManager.beginDelayedTransition(container, auto); results.setVisibility(View.GONE); progress.setVisibility(View.GONE); resultsScrim.setVisibility(View.GONE); setNoResultsVisibility(View.GONE); }
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 a 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; }
From source file:im.ene.lab.attiq.ui.activities.SearchActivity.java
private void clearResults() { mAdapter.clear();//w w w. j av a2s .co m TransitionManager.beginDelayedTransition(mMainContainer, mAutoTransition); mRecyclerView.setVisibility(View.GONE); mProgress.setVisibility(View.GONE); // mResultsScrim.setVisibility(View.GONE); setNoResultsVisibility(View.GONE); }
From source file:org.goodev.material.SearchActivity.java
private void clearResults() { adapter.clear();/*from www. j av a2s . c om*/ dataManager.clear(); if (UI.isLollipop()) { TransitionManager.beginDelayedTransition(container, auto); } results.setVisibility(View.GONE); progress.setVisibility(View.GONE); resultsScrim.setVisibility(View.GONE); setNoResultsVisibility(View.GONE); }
From source file:com.andremion.music.MusicCoverView.java
private void morphToCircle() { if (mIsMorphing) { return;//from ww w .j av a 2s .com } TransitionManager.beginDelayedTransition((ViewGroup) getParent(), mRectToCircleTransition); setScaleType(ScaleType.CENTER_INSIDE); }