Home | History | Annotate | Download | only in inspector
      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
     33     public void onCreate(Bundle savedInstanceState) {
     34         super.onCreate(savedInstanceState);
     35         requestWindowFeature(Window.FEATURE_ACTION_BAR);
     36         setContentView(R.layout.document_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 
     49             mFragment = InspectorFragment.newInstance(intent);
     50 
     51 
     52             fragmentManager.beginTransaction()
     53                     .add(R.id.fragment_container, mFragment)
     54                     .commit();
     55         }
     56     }
     57 
     58     @Override
     59     public boolean onOptionsItemSelected(MenuItem item) {
     60         switch (item.getItemId()) {
     61             case android.R.id.home:
     62                 finish();
     63                 return true;
     64         }
     65         return super.onOptionsItemSelected(item);
     66     }
     67 }
     68