• 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.app.Activity;
17 import android.app.Fragment;
18 import android.os.Bundle;
19 import android.os.Handler;
20 import android.view.Gravity;
21 import android.view.LayoutInflater;
22 import android.view.View;
23 import android.view.ViewGroup;
24 import android.widget.FrameLayout;
25 import android.widget.ProgressBar;
26 
27 public class BrowseErrorActivity extends Activity
28 {
29     /** Called when the activity is first created. */
30     @Override
onCreate(Bundle savedInstanceState)31     public void onCreate(Bundle savedInstanceState)
32     {
33         super.onCreate(savedInstanceState);
34         setContentView(R.layout.browse);
35 
36         testError();
37     }
38 
testError()39     private void testError() {
40         Handler handler = new Handler();
41         handler.postDelayed(new Runnable() {
42             @Override
43             public void run() {
44                 if (getFragmentManager().isDestroyed()) {
45                     return;
46                 }
47                 getFragmentManager().beginTransaction().add(R.id.main_frame,
48                         new ErrorFragment()).commit();
49             }
50         }, 3000);
51     }
52 
53     static public class SpinnerFragment extends Fragment {
54         @Override
onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)55         public View onCreateView(LayoutInflater inflater, ViewGroup container,
56                     Bundle savedInstanceState) {
57             ProgressBar progressBar = new ProgressBar(container.getContext());
58             if (container instanceof FrameLayout) {
59                 FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(100, 100,
60                         Gravity.CENTER);
61                 progressBar.setLayoutParams(layoutParams);
62             }
63             return progressBar;
64         }
65     }
66 }
67