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 17package android.support.design.widget; 18 19import android.os.Bundle; 20import android.support.v7.app.AppCompatActivity; 21import android.view.WindowManager; 22 23abstract class BaseTestActivity extends AppCompatActivity { 24 25 private boolean mDestroyed; 26 27 @Override 28 protected void onCreate(Bundle savedInstanceState) { 29 super.onCreate(savedInstanceState); 30 overridePendingTransition(0, 0); 31 32 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 33 final int contentView = getContentViewLayoutResId(); 34 if (contentView > 0) { 35 setContentView(contentView); 36 } 37 onContentViewSet(); 38 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); 39 } 40 41 @Override 42 public void finish() { 43 super.finish(); 44 overridePendingTransition(0, 0); 45 } 46 47 protected abstract int getContentViewLayoutResId(); 48 49 protected void onContentViewSet() {} 50 51 @Override 52 protected void onDestroy() { 53 super.onDestroy(); 54 mDestroyed = true; 55 } 56 57 @Override 58 public boolean isDestroyed() { 59 return mDestroyed; 60 } 61} 62