1 /* 2 * Copyright (C) 2016 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 17 package com.android.tv.dvr; 18 19 import android.app.Activity; 20 import android.content.Intent; 21 import android.content.res.Configuration; 22 import android.os.Bundle; 23 import android.util.Log; 24 25 import com.android.tv.R; 26 import com.android.tv.TvApplication; 27 import com.android.tv.dvr.ui.DvrPlaybackOverlayFragment; 28 29 /** 30 * Activity to play a {@link RecordedProgram}. 31 */ 32 public class DvrPlaybackActivity extends Activity { 33 private static final String TAG = "DvrPlaybackActivity"; 34 private static final boolean DEBUG = false; 35 36 private DvrPlaybackOverlayFragment mOverlayFragment; 37 38 @Override onCreate(Bundle savedInstanceState)39 public void onCreate(Bundle savedInstanceState) { 40 TvApplication.setCurrentRunningProcess(this, true); 41 if (DEBUG) Log.d(TAG, "onCreate"); 42 super.onCreate(savedInstanceState); 43 setContentView(R.layout.activity_dvr_playback); 44 mOverlayFragment = (DvrPlaybackOverlayFragment) getFragmentManager() 45 .findFragmentById(R.id.dvr_playback_controls_fragment); 46 } 47 48 @Override onVisibleBehindCanceled()49 public void onVisibleBehindCanceled() { 50 if (DEBUG) Log.d(TAG, "onVisibleBehindCanceled"); 51 super.onVisibleBehindCanceled(); 52 finish(); 53 } 54 55 @Override onNewIntent(Intent intent)56 protected void onNewIntent(Intent intent) { 57 mOverlayFragment.onNewIntent(intent); 58 } 59 60 @Override onConfigurationChanged(Configuration newConfig)61 public void onConfigurationChanged(Configuration newConfig) { 62 super.onConfigurationChanged(newConfig); 63 float density = getResources().getDisplayMetrics().density; 64 mOverlayFragment.onWindowSizeChanged((int) (newConfig.screenWidthDp * density), 65 (int) (newConfig.screenHeightDp * density)); 66 } 67 }