1 // CHECKSTYLE:OFF Generated code 2 /* This file is auto-generated from ErrorFragment.java. DO NOT MODIFY. */ 3 4 /* 5 * Copyright (C) 2014 The Android Open Source Project 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 8 * in compliance with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software distributed under the License 13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 14 * or implied. See the License for the specific language governing permissions and limitations under 15 * the License. 16 */ 17 package com.example.android.leanback; 18 19 import android.content.Context; 20 import android.os.Bundle; 21 import android.util.Log; 22 import android.view.View; 23 24 import androidx.core.content.res.ResourcesCompat; 25 26 public class ErrorSupportFragment extends androidx.leanback.app.ErrorSupportFragment { 27 private static final String TAG = "leanback.ErrorSupportFragment"; 28 private static final boolean TRANSLUCENT = true; 29 30 @Override onCreate(Bundle savedInstanceState)31 public void onCreate(Bundle savedInstanceState) { 32 Log.i(TAG, "onCreate"); 33 super.onCreate(savedInstanceState); 34 35 setTitle("Leanback Sample App"); 36 final Context context = getActivity(); 37 setImageDrawable(ResourcesCompat.getDrawable(context.getResources(), 38 R.drawable.lb_ic_sad_cloud, context.getTheme())); 39 setMessage("An error occurred."); 40 setDefaultBackground(TRANSLUCENT); 41 42 setButtonText("Dismiss"); 43 setButtonClickListener(new View.OnClickListener() { 44 @Override 45 public void onClick(View arg0) { 46 Log.i(TAG, "button clicked"); 47 getFragmentManager().beginTransaction().remove(ErrorSupportFragment.this).commit(); 48 } 49 }); 50 } 51 } 52