• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.documentsui.inspector;
17 
18 import android.app.Activity;
19 import android.app.FragmentManager;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.view.MenuItem;
23 import android.view.Window;
24 import android.widget.Toolbar;
25 
26 import com.android.documentsui.R;
27 
28 public class InspectorActivity extends Activity {
29 
30     private InspectorFragment mFragment;
31 
32     @Override
onCreate(Bundle savedInstanceState)33     public void onCreate(Bundle savedInstanceState) {
34         super.onCreate(savedInstanceState);
35         requestWindowFeature(Window.FEATURE_ACTION_BAR);
36         setContentView(R.layout.inspector_activity);
37 
38         Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
39         setActionBar(toolbar);
40         getActionBar().setDisplayHomeAsUpEnabled(true);
41 
42         FragmentManager fragmentManager = getFragmentManager();
43         mFragment = (InspectorFragment) fragmentManager.findFragmentById(
44                 R.id.fragment_container);
45 
46         if (mFragment == null) {
47             Intent intent = getIntent();
48             mFragment = InspectorFragment.newInstance(intent);
49             fragmentManager.beginTransaction()
50                     .add(R.id.fragment_container, mFragment)
51                     .commit();
52         }
53     }
54 
55     @Override
onOptionsItemSelected(MenuItem item)56     public boolean onOptionsItemSelected(MenuItem item) {
57         switch (item.getItemId()) {
58             case android.R.id.home:
59                 finish();
60                 return true;
61         }
62         return super.onOptionsItemSelected(item);
63     }
64 }
65