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