1/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package com.android.test.uibench;
17
18import android.app.ActivityOptions;
19import android.content.Intent;
20import android.graphics.Color;
21import android.graphics.drawable.ColorDrawable;
22import android.graphics.drawable.Drawable;
23import android.os.Bundle;
24import android.support.v7.app.AppCompatActivity;
25import android.view.View;
26import android.widget.ImageView;
27
28import com.android.test.uibench.ActivityTransition;
29import com.android.test.uibench.R;
30
31
32public class ActivityTransitionDetails extends AppCompatActivity {
33    private static final String KEY_ID = "ViewTransitionValues:id";
34    private int mImageResourceId = R.drawable.ducky;
35    private String mName = "ducky";
36
37    @Override
38    protected void onCreate(Bundle savedInstanceState) {
39        super.onCreate(savedInstanceState);
40        getWindow().setBackgroundDrawable(new ColorDrawable(Color.DKGRAY));
41        setContentView(R.layout.activity_transition_details);
42        ImageView titleImage = findViewById(R.id.titleImage);
43        titleImage.setImageDrawable(getHeroDrawable());
44    }
45
46    private Drawable getHeroDrawable() {
47        String name = getIntent().getStringExtra(KEY_ID);
48        if (name != null) {
49            mName = name;
50            mImageResourceId = ActivityTransition.getDrawableIdForKey(name);
51        }
52
53        return getResources().getDrawable(mImageResourceId);
54    }
55
56    public void clicked(View v) {
57        Intent intent = new Intent(this, ActivityTransition.class);
58        intent.putExtra(KEY_ID, mName);
59        ActivityOptions activityOptions = ActivityOptions.makeSceneTransitionAnimation(
60                this, v, "hero");
61        startActivity(intent, activityOptions.toBundle());
62    }
63}
64