• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.OnItemClickedListener;
24 import android.support.v17.leanback.widget.Row;
25 import android.support.v17.leanback.widget.SearchOrbView;
26 import android.util.Log;
27 import android.view.View;
28 
29 public class ErrorFragment extends android.support.v17.leanback.app.ErrorFragment {
30     private static final String TAG = "leanback.ErrorFragment";
31     private static final boolean TRANSLUCENT = true;
32 
33     @Override
onCreate(Bundle savedInstanceState)34     public void onCreate(Bundle savedInstanceState) {
35         Log.i(TAG, "onCreate");
36         super.onCreate(savedInstanceState);
37 
38         setTitle("Leanback Sample App");
39     }
40 
setErrorContent(Resources resources)41     void setErrorContent(Resources resources) {
42         setImageDrawable(resources.getDrawable(R.drawable.lb_ic_sad_cloud));
43         setMessage("An error occurred.");
44         setDefaultBackground(TRANSLUCENT);
45 
46         setButtonText("Dismiss");
47         setButtonClickListener(new View.OnClickListener() {
48             @Override
49             public void onClick(View arg0) {
50                 Log.i(TAG, "button clicked");
51                 getFragmentManager().beginTransaction().remove(ErrorFragment.this).commit();
52             }
53         });
54     }
55 }
56