1 package com.android.tv.dvr.ui; 2 3 import android.content.Context; 4 import android.os.Bundle; 5 import android.support.v17.leanback.app.GuidedStepFragment; 6 import android.support.v17.leanback.widget.GuidanceStylist; 7 import android.support.v17.leanback.widget.VerticalGridView; 8 import android.view.LayoutInflater; 9 import android.view.View; 10 import android.view.ViewGroup; 11 12 import com.android.tv.MainActivity; 13 import com.android.tv.TvApplication; 14 import com.android.tv.dialog.SafeDismissDialogFragment; 15 import com.android.tv.dvr.DvrManager; 16 import com.android.tv.guide.ProgramManager.TableEntry; 17 import com.android.tv.R; 18 19 public class DvrGuidedStepFragment extends GuidedStepFragment { 20 private final TableEntry mEntry; 21 private DvrManager mDvrManager; 22 23 public DvrGuidedStepFragment(TableEntry entry) { 24 mEntry = entry; 25 } 26 27 protected TableEntry getEntry() { 28 return mEntry; 29 } 30 31 protected DvrManager getDvrManager() { 32 return mDvrManager; 33 } 34 35 @Override 36 public void onAttach(Context context) { 37 super.onAttach(context); 38 mDvrManager = TvApplication.getSingletons(context).getDvrManager(); 39 } 40 41 @Override 42 public View onCreateView(LayoutInflater inflater, ViewGroup container, 43 Bundle savedInstanceState) { 44 View view = super.onCreateView(inflater, container, savedInstanceState); 45 VerticalGridView gridView = getGuidedActionsStylist().getActionsGridView(); 46 gridView.setWindowAlignment(VerticalGridView.WINDOW_ALIGN_BOTH_EDGE); 47 return view; 48 } 49 50 @Override 51 public GuidanceStylist onCreateGuidanceStylist() { 52 // Workaround: b/28448653 53 return new GuidanceStylist() { 54 @Override 55 public int onProvideLayoutId() { 56 return R.layout.halfsized_guidance; 57 } 58 }; 59 } 60 61 @Override 62 public int onProvideTheme() { 63 return R.style.Theme_TV_Dvr_GuidedStep; 64 } 65 66 protected void dismissDialog() { 67 SafeDismissDialogFragment currentDialog = 68 ((MainActivity) getActivity()).getOverlayManager().getCurrentDialog(); 69 if (currentDialog instanceof DvrDialogFragment) { 70 currentDialog.dismiss(); 71 } 72 } 73 } 74