1/* 2 * Copyright (C) 2017 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 com.example.partnersupportsampletvinput; 18 19import android.app.FragmentManager; 20import android.os.Bundle; 21import android.support.annotation.NonNull; 22import android.support.v17.leanback.app.GuidedStepFragment; 23import android.support.v17.leanback.widget.GuidanceStylist; 24import android.support.v17.leanback.widget.GuidanceStylist.Guidance; 25import android.support.v17.leanback.widget.GuidedAction; 26import java.util.List; 27 28/** Welcome Fragment shows welcome information for users */ 29public class WelcomeFragment extends GuidedStepFragment { 30 31 @NonNull 32 @Override 33 public GuidanceStylist.Guidance onCreateGuidance(Bundle savedInstanceState) { 34 return new Guidance("WelcomeFragment Title", "WelcomeFragment Description", null, null); 35 } 36 37 @Override 38 public void onCreateActions(@NonNull List<GuidedAction> actions, Bundle savedInstanceState) { 39 actions.add( 40 new GuidedAction.Builder(getActivity()) 41 .id(GuidedAction.ACTION_ID_NEXT) 42 .title("NEXT") 43 .build()); 44 actions.add( 45 new GuidedAction.Builder(getActivity()) 46 .id(GuidedAction.ACTION_ID_CANCEL) 47 .title("CANCEL") 48 .build()); 49 } 50 51 @Override 52 public void onGuidedActionClicked(GuidedAction action) { 53 if (action == null) { 54 return; 55 } 56 FragmentManager fm = getFragmentManager(); 57 switch ((int) action.getId()) { 58 case (int) GuidedAction.ACTION_ID_NEXT: 59 GuidedStepFragment.add(fm, new LocationFragment()); 60 break; 61 case (int) GuidedAction.ACTION_ID_CANCEL: 62 finishGuidedStepFragments(); 63 break; 64 default: 65 } 66 } 67} 68