Search in sources :

Example 1 with TextSharedElementCallback

use of com.google.samples.apps.topeka.widget.TextSharedElementCallback in project android-topeka by googlesamples.

the class QuizActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    mCountingIdlingResource = new CountingIdlingResource("Quiz");
    String categoryId = getIntent().getStringExtra(Category.TAG);
    mInterpolator = new FastOutSlowInInterpolator();
    if (null != savedInstanceState) {
        mSavedStateIsPlaying = savedInstanceState.getBoolean(STATE_IS_PLAYING);
    }
    super.onCreate(savedInstanceState);
    populate(categoryId);
    int categoryNameTextSize = getResources().getDimensionPixelSize(R.dimen.category_item_text_size);
    int paddingStart = getResources().getDimensionPixelSize(R.dimen.spacing_double);
    final int startDelay = getResources().getInteger(R.integer.toolbar_transition_duration);
    ActivityCompat.setEnterSharedElementCallback(this, new TextSharedElementCallback(categoryNameTextSize, paddingStart) {

        @Override
        public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
            super.onSharedElementStart(sharedElementNames, sharedElements, sharedElementSnapshots);
            mToolbarBack.setScaleX(0f);
            mToolbarBack.setScaleY(0f);
        }

        @Override
        public void onSharedElementEnd(List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) {
            super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots);
            // Make sure to perform this animation after the transition has ended.
            ViewCompat.animate(mToolbarBack).setStartDelay(startDelay).scaleX(1f).scaleY(1f).alpha(1f);
        }
    });
}
Also used : CountingIdlingResource(android.support.test.espresso.contrib.CountingIdlingResource) FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) TextSharedElementCallback(com.google.samples.apps.topeka.widget.TextSharedElementCallback) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)1 CountingIdlingResource (android.support.test.espresso.contrib.CountingIdlingResource)1 FastOutSlowInInterpolator (android.support.v4.view.animation.FastOutSlowInInterpolator)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 TextSharedElementCallback (com.google.samples.apps.topeka.widget.TextSharedElementCallback)1