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