• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  */
16 package com.android.test.uibench;
17 
18 import android.app.ActivityOptions;
19 import android.content.Intent;
20 import android.graphics.Color;
21 import android.graphics.drawable.ColorDrawable;
22 import android.graphics.drawable.Drawable;
23 import android.os.Bundle;
24 import android.support.v7.app.AppCompatActivity;
25 import android.view.View;
26 import android.widget.ImageView;
27 
28 import com.android.test.uibench.ActivityTransition;
29 import com.android.test.uibench.R;
30 
31 
32 public 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
onCreate(Bundle savedInstanceState)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 
getHeroDrawable()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 
clicked(View v)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