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.ui;
18 
19 import android.app.Activity;
20 import android.os.Bundle;
21 import android.support.v17.leanback.app.DetailsFragment;
22 
23 import com.android.tv.R;
24 import com.android.tv.TvApplication;
25 
26 /**
27  * Activity to show details view in DVR.
28  */
29 public class DvrDetailsActivity extends Activity {
30     /**
31      * Name of record id added to the Intent.
32      */
33     public static final String RECORDING_ID = "record_id";
34 
35     /**
36      * Name of flag added to the Intent to determine if details view should hide "View schedule"
37      * button.
38      */
39     public static final String HIDE_VIEW_SCHEDULE = "hide_view_schedule";
40 
41     /**
42      * Name of details view's type added to the intent.
43      */
44     public static final String DETAILS_VIEW_TYPE = "details_view_type";
45 
46     /**
47      * Name of shared element between activities.
48      */
49     public static final String SHARED_ELEMENT_NAME = "shared_element";
50 
51     /**
52      * CURRENT_RECORDING_VIEW refers to Current Recordings in DVR.
53      */
54     public static final int CURRENT_RECORDING_VIEW = 1;
55 
56     /**
57      * SCHEDULED_RECORDING_VIEW refers to Scheduled Recordings in DVR.
58      */
59     public static final int SCHEDULED_RECORDING_VIEW = 2;
60 
61     /**
62      * RECORDED_PROGRAM_VIEW refers to Recorded programs in DVR.
63      */
64     public static final int RECORDED_PROGRAM_VIEW = 3;
65 
66     /**
67      * SERIES_RECORDING_VIEW refers to series recording in DVR.
68      */
69     public static final int SERIES_RECORDING_VIEW = 4;
70 
71     @Override
onCreate(Bundle savedInstanceState)72     public void onCreate(Bundle savedInstanceState) {
73         TvApplication.setCurrentRunningProcess(this, true);
74         super.onCreate(savedInstanceState);
75         setContentView(R.layout.activity_dvr_details);
76         long recordId = getIntent().getLongExtra(RECORDING_ID, -1);
77         int detailsViewType = getIntent().getIntExtra(DETAILS_VIEW_TYPE, -1);
78         boolean hideViewSchedule = getIntent().getBooleanExtra(HIDE_VIEW_SCHEDULE, false);
79         if (recordId != -1 && detailsViewType != -1 && savedInstanceState == null) {
80             Bundle args = new Bundle();
81             args.putLong(RECORDING_ID, recordId);
82             DetailsFragment detailsFragment = null;
83             if (detailsViewType == CURRENT_RECORDING_VIEW) {
84                 detailsFragment = new CurrentRecordingDetailsFragment();
85             } else if (detailsViewType == SCHEDULED_RECORDING_VIEW) {
86                 args.putBoolean(HIDE_VIEW_SCHEDULE, hideViewSchedule);
87                 detailsFragment = new ScheduledRecordingDetailsFragment();
88             } else if (detailsViewType == RECORDED_PROGRAM_VIEW) {
89                 detailsFragment = new RecordedProgramDetailsFragment();
90             } else if (detailsViewType == SERIES_RECORDING_VIEW) {
91                 detailsFragment = new SeriesRecordingDetailsFragment();
92             }
93             detailsFragment.setArguments(args);
94             getFragmentManager().beginTransaction()
95                     .replace(R.id.dvr_details_view_frame, detailsFragment).commit();
96         }
97     }
98 }
99