1 /*
2  * Copyright (C) 2011 Google Inc.
3  * Licensed to The Android Open Source Project.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * 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
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package com.android.ex.photo;
19 
20 import android.content.Context;
21 import android.content.Intent;
22 import android.os.Bundle;
23 import android.support.annotation.Nullable;
24 import android.support.v4.app.FragmentActivity;
25 import android.view.Menu;
26 import android.view.MenuItem;
27 
28 /**
29  * Activity to view the contents of an album.
30  */
31 public class PhotoViewActivity extends FragmentActivity
32         implements PhotoViewController.ActivityInterface {
33 
34     private PhotoViewController mController;
35     private ActionBarWrapper mActionBar;
36 
37     @Override
onCreate(@ullable Bundle savedInstanceState)38     protected void onCreate(@Nullable Bundle savedInstanceState) {
39         super.onCreate(savedInstanceState);
40         mController = createController();
41         mController.onCreate(savedInstanceState);
42     }
43 
createController()44     public PhotoViewController createController() {
45         return new PhotoViewController(this);
46     }
47 
48     @Override
getController()49     public PhotoViewController getController() {
50         return mController;
51     }
52 
53     @Override
onStart()54     protected void onStart() {
55         super.onStart();
56         mController.onStart();
57     }
58 
59     @Override
onResume()60     protected void onResume() {
61         super.onResume();
62         mController.onResume();
63     }
64 
65     @Override
onPause()66     protected void onPause() {
67         mController.onPause();
68         super.onPause();
69     }
70 
71     @Override
onStop()72     protected void onStop() {
73         mController.onStop();
74         super.onStop();
75     }
76 
77     @Override
onDestroy()78     protected void onDestroy() {
79         mController.onDestroy();
80         super.onDestroy();
81     }
82 
83     @Override
onBackPressed()84     public void onBackPressed() {
85         if (!mController.onBackPressed()) {
86             super.onBackPressed();
87         }
88     }
89 
90     @Override
onSaveInstanceState(Bundle outState)91     public void onSaveInstanceState(Bundle outState) {
92         super.onSaveInstanceState(outState);
93         mController.onSaveInstanceState(outState);
94     }
95 
96     @Override
onCreateOptionsMenu(Menu menu)97     public boolean onCreateOptionsMenu(Menu menu) {
98         return mController.onCreateOptionsMenu(menu) || super.onCreateOptionsMenu(menu);
99     }
100 
101     @Override
onPrepareOptionsMenu(Menu menu)102     public boolean onPrepareOptionsMenu(Menu menu) {
103         return mController.onPrepareOptionsMenu(menu) || super.onPrepareOptionsMenu(menu);
104     }
105 
106     @Override
onOptionsItemSelected(MenuItem item)107     public boolean onOptionsItemSelected(MenuItem item) {
108         return mController.onOptionsItemSelected(item) || super.onOptionsItemSelected(item);
109     }
110 
111     @Override
onActivityResult(int requestCode, int resultCode, Intent data)112     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
113         super.onActivityResult(requestCode, resultCode, data);
114         mController.onActivityResult(requestCode, resultCode, data);
115     }
116 
117     @Override
getContext()118     public Context getContext() {
119         return this;
120     }
121 
122     @Override
getActionBarInterface()123     public ActionBarInterface getActionBarInterface() {
124         if (mActionBar == null) {
125             mActionBar = new ActionBarWrapper(getActionBar());
126         }
127         return mActionBar;
128     }
129 
130 }
131