1def91eaec25417523827df321d2e3babbcd40a36Craig Stout/*
2def91eaec25417523827df321d2e3babbcd40a36Craig Stout * Copyright (C) 2014 The Android Open Source Project
3def91eaec25417523827df321d2e3babbcd40a36Craig Stout *
4def91eaec25417523827df321d2e3babbcd40a36Craig Stout * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5def91eaec25417523827df321d2e3babbcd40a36Craig Stout * in compliance with the License. You may obtain a copy of the License at
6def91eaec25417523827df321d2e3babbcd40a36Craig Stout *
7def91eaec25417523827df321d2e3babbcd40a36Craig Stout * http://www.apache.org/licenses/LICENSE-2.0
8def91eaec25417523827df321d2e3babbcd40a36Craig Stout *
9def91eaec25417523827df321d2e3babbcd40a36Craig Stout * Unless required by applicable law or agreed to in writing, software distributed under the License
10def91eaec25417523827df321d2e3babbcd40a36Craig Stout * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11def91eaec25417523827df321d2e3babbcd40a36Craig Stout * or implied. See the License for the specific language governing permissions and limitations under
12def91eaec25417523827df321d2e3babbcd40a36Craig Stout * the License.
13def91eaec25417523827df321d2e3babbcd40a36Craig Stout */
14def91eaec25417523827df321d2e3babbcd40a36Craig Stoutpackage com.example.android.leanback;
15def91eaec25417523827df321d2e3babbcd40a36Craig Stout
16def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.app.Activity;
17def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.app.Fragment;
18def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.os.Bundle;
19def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.os.Handler;
20def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.view.Gravity;
21def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.view.LayoutInflater;
22def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.view.View;
23def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.view.ViewGroup;
24def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.widget.FrameLayout;
25def91eaec25417523827df321d2e3babbcd40a36Craig Stoutimport android.widget.ProgressBar;
26def91eaec25417523827df321d2e3babbcd40a36Craig Stout
27def91eaec25417523827df321d2e3babbcd40a36Craig Stoutpublic class BrowseErrorActivity extends Activity
28def91eaec25417523827df321d2e3babbcd40a36Craig Stout{
29def91eaec25417523827df321d2e3babbcd40a36Craig Stout    /** Called when the activity is first created. */
30def91eaec25417523827df321d2e3babbcd40a36Craig Stout    @Override
31def91eaec25417523827df321d2e3babbcd40a36Craig Stout    public void onCreate(Bundle savedInstanceState)
32def91eaec25417523827df321d2e3babbcd40a36Craig Stout    {
33def91eaec25417523827df321d2e3babbcd40a36Craig Stout        super.onCreate(savedInstanceState);
346f0d24aab5d9668c489097d26d4c3643f575b0c8Kris Giesing        setContentView(R.layout.browse);
35def91eaec25417523827df321d2e3babbcd40a36Craig Stout
36def91eaec25417523827df321d2e3babbcd40a36Craig Stout        testError();
37def91eaec25417523827df321d2e3babbcd40a36Craig Stout    }
38def91eaec25417523827df321d2e3babbcd40a36Craig Stout
39def91eaec25417523827df321d2e3babbcd40a36Craig Stout    private void testError() {
40def91eaec25417523827df321d2e3babbcd40a36Craig Stout        Handler handler = new Handler();
41def91eaec25417523827df321d2e3babbcd40a36Craig Stout        handler.postDelayed(new Runnable() {
42def91eaec25417523827df321d2e3babbcd40a36Craig Stout            @Override
43def91eaec25417523827df321d2e3babbcd40a36Craig Stout            public void run() {
4453e230dfe568d0f713f797be09cdac4ab1a21d28Craig Stout                if (getFragmentManager().isDestroyed()) {
4553e230dfe568d0f713f797be09cdac4ab1a21d28Craig Stout                    return;
4653e230dfe568d0f713f797be09cdac4ab1a21d28Craig Stout                }
47b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu                getFragmentManager().beginTransaction().add(R.id.main_frame,
48b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu                        new ErrorFragment()).commit();
49def91eaec25417523827df321d2e3babbcd40a36Craig Stout            }
50def91eaec25417523827df321d2e3babbcd40a36Craig Stout        }, 3000);
51def91eaec25417523827df321d2e3babbcd40a36Craig Stout    }
52def91eaec25417523827df321d2e3babbcd40a36Craig Stout
53def91eaec25417523827df321d2e3babbcd40a36Craig Stout    static public class SpinnerFragment extends Fragment {
54def91eaec25417523827df321d2e3babbcd40a36Craig Stout        @Override
55def91eaec25417523827df321d2e3babbcd40a36Craig Stout        public View onCreateView(LayoutInflater inflater, ViewGroup container,
56def91eaec25417523827df321d2e3babbcd40a36Craig Stout                    Bundle savedInstanceState) {
57def91eaec25417523827df321d2e3babbcd40a36Craig Stout            ProgressBar progressBar = new ProgressBar(container.getContext());
58def91eaec25417523827df321d2e3babbcd40a36Craig Stout            if (container instanceof FrameLayout) {
59b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu                FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(100, 100,
60b7087e036a48f5a3db28d02ff7f9b97fbbc46c4fDake Gu                        Gravity.CENTER);
61def91eaec25417523827df321d2e3babbcd40a36Craig Stout                progressBar.setLayoutParams(layoutParams);
62def91eaec25417523827df321d2e3babbcd40a36Craig Stout            }
63def91eaec25417523827df321d2e3babbcd40a36Craig Stout            return progressBar;
64def91eaec25417523827df321d2e3babbcd40a36Craig Stout        }
65def91eaec25417523827df321d2e3babbcd40a36Craig Stout    }
66def91eaec25417523827df321d2e3babbcd40a36Craig Stout}
67