List of usage examples for android.transition TransitionInflater from
public static TransitionInflater from(Context context)
From source file:com.hannesdorfmann.search.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); setRetainInstance(true);/*from w w w .j a v a2s . c o m*/ ButterKnife.bind(this); setupSearchView(); auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); adapter = new FeedAdapter(this, 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) { @Override public void onLoadMore() { if (!adapter.isLoadingMore()) { presenter.searchMore(searchView.getQuery().toString()); } } }); 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:org.xbmc.kore.ui.sections.video.PVRActivity.java
/** * Callback from list fragment when the channel guide should be displayed. * Setup action bar and repolace list fragment * @param channelId Channel selected//w w w . j a v a2s .c o m * @param channelTitle Title */ @TargetApi(21) public void onChannelGuideSelected(int channelId, String channelTitle) { selectedChannelId = channelId; selectedChannelTitle = channelTitle; // Replace list fragment PVRChannelEPGListFragment pvrEPGFragment = PVRChannelEPGListFragment.newInstance(channelId); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { pvrEPGFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); pvrEPGFragment.setReturnTransition(null); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, pvrEPGFragment).addToBackStack(null).commit(); updateActionBar(getActionBarTitle(), true); }
From source file:org.xbmc.kore.ui.BaseMediaActivity.java
@Override @TargetApi(21)//from w w w . j a v a 2 s .c o m protected void onCreate(Bundle savedInstanceState) { // Request transitions on lollipop if (Utils.isLollipopOrLater()) { getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); } super.onCreate(savedInstanceState); setContentView(R.layout.activity_generic_media); ButterKnife.inject(this); // Set up the drawer. navigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); navigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); Toolbar toolbar = (Toolbar) findViewById(R.id.default_toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { String actionBarTitle; boolean naviconIsArrow = false; if (savedInstanceState != null) { actionBarTitle = savedInstanceState.getString(ACTIONBAR_TITLE); naviconIsArrow = savedInstanceState.getBoolean(NAVICON_ISARROW); } else { actionBarTitle = getActionBarTitle(); } actionBar.setDisplayHomeAsUpEnabled(true); updateActionBar(actionBarTitle, naviconIsArrow); } String fragmentTitle = getActionBarTitle(); Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container); if (fragment == null) { fragment = createFragment(); if (Utils.isLollipopOrLater()) { fragment.setExitTransition(null); fragment.setReenterTransition( TransitionInflater.from(this).inflateTransition(android.R.transition.fade)); } getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, fragment, fragmentTitle) .commit(); } if (Utils.isLollipopOrLater()) { sharedElementTransition.setupExitTransition(this, fragment); } hostManager = HostManager.getInstance(this); }
From source file:com.syncedsynapse.kore2.ui.MoviesActivity.java
/** * Callback from movielist fragment when a movie is selected. * Switch fragment in portrait/*from ww w. j a va 2 s .co m*/ * @param movieId Movie selected * @param movieTitle Title */ @TargetApi(21) public void onMovieSelected(int movieId, String movieTitle) { selectedMovieId = movieId; selectedMovieTitle = movieTitle; MovieDetailsFragment movieDetailsFragment = MovieDetailsFragment.newInstance(movieId); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { movieDetailsFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); movieDetailsFragment.setReturnTransition(null); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, movieDetailsFragment).addToBackStack(null).commit(); setupActionBar(selectedMovieTitle); }
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();// w w w. ja v a 2s.com 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:com.syncedsynapse.kore2.ui.AddonsActivity.java
/** * Callback from list fragment when a addon is selected. * Switch fragment in portrait//from w ww . j a v a 2s .co m * @param addonId Addon selected * @param addonTitle Title */ @TargetApi(21) public void onAddonSelected(String addonId, String addonTitle) { selectedAddonId = addonId; selectedAddonTitle = addonTitle; // Replace list fragment AddonDetailsFragment addonDetailsFragment = AddonDetailsFragment.newInstance(addonId); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { addonDetailsFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); addonDetailsFragment.setReturnTransition(null); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, addonDetailsFragment).addToBackStack(null).commit(); setupActionBar(selectedAddonTitle); }
From source file:org.xbmc.kore.ui.sections.video.TVShowsActivity.java
@TargetApi(21) private void startFragment(AbstractFragment fragment) { // Replace list fragment FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { fragment.setEnterTransition(/* www .ja v a2s .c o m*/ TransitionInflater.from(this).inflateTransition(R.transition.media_details)); fragment.setReturnTransition(null); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, fragment).addToBackStack(null).commit(); }
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 ww w.j a va 2 s .c om 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.andremion.louvre.preview.PreviewActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void setupTransition() { TransitionInflater inflater = TransitionInflater.from(this); Transition sharedElementEnterTransition = inflater.inflateTransition(R.transition.shared_element); sharedElementEnterTransition.addListener(new TransitionCallback() { @Override// w ww. j a v a 2 s. c o m public void onTransitionEnd(Transition transition) { mAdapter.setDontAnimate(false); } }); getWindow().setSharedElementEnterTransition(sharedElementEnterTransition); }
From source file:com.syncedsynapse.kore2.ui.TVShowsActivity.java
/** * Callback from tvshows list fragment when a show is selected. * Switch fragment in portrait/* w w w. j av a2s. c o m*/ * @param tvshowId Selected show * @param tvshowTitle Title */ @TargetApi(21) public void onTVShowSelected(int tvshowId, String tvshowTitle) { selectedTVShowId = tvshowId; selectedTVShowTitle = tvshowTitle; // Replace list fragment TVShowDetailsFragment tvshowDetailsFragment = TVShowDetailsFragment.newInstance(tvshowId); FragmentTransaction fragTrans = getSupportFragmentManager().beginTransaction(); // Set up transitions if (Utils.isLollipopOrLater()) { tvshowDetailsFragment.setEnterTransition( TransitionInflater.from(this).inflateTransition(R.transition.media_details)); tvshowDetailsFragment.setReturnTransition(null); } else { fragTrans.setCustomAnimations(R.anim.fragment_details_enter, 0, R.anim.fragment_list_popenter, 0); } fragTrans.replace(R.id.fragment_container, tvshowDetailsFragment).addToBackStack(null).commit(); setupActionBar(selectedTVShowTitle); }