Merge commit '46077ef99f953486550547c15bd60dd02bab9241' into upstream
[debian/openrocket] / android / src / net / sf / openrocket / android / actionbarcompat / ActionBarListActivity.java
1 /*
2  * Copyright (C) 2006 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
17 package net.sf.openrocket.android.actionbarcompat;
18
19 import android.app.Activity;
20 import android.app.ListActivity;
21 import android.os.Bundle;
22 import android.view.Menu;
23 import android.view.MenuInflater;
24
25 public abstract class ActionBarListActivity extends ListActivity {
26     final ActionBarHelper mActionBarHelper = ActionBarHelper.createInstance(this);
27
28     /**
29      * Returns the {@link ActionBarHelper} for this activity.
30      */
31     protected ActionBarHelper getActionBarHelper() {
32         return mActionBarHelper;
33     }
34
35     /**{@inheritDoc}*/
36     @Override
37     public MenuInflater getMenuInflater() {
38         return mActionBarHelper.getMenuInflater(super.getMenuInflater());
39     }
40
41     /**{@inheritDoc}*/
42     @Override
43     protected void onCreate(Bundle savedInstanceState) {
44         super.onCreate(savedInstanceState);
45         mActionBarHelper.onCreate(savedInstanceState);
46     }
47
48     /**{@inheritDoc}*/
49     @Override
50     protected void onPostCreate(Bundle savedInstanceState) {
51         super.onPostCreate(savedInstanceState);
52         mActionBarHelper.onPostCreate(savedInstanceState);
53     }
54
55     /**
56      * Base action bar-aware implementation for
57      * {@link Activity#onCreateOptionsMenu(android.view.Menu)}.
58      *
59      * Note: marking menu items as invisible/visible is not currently supported.
60      */
61     @Override
62     public boolean onCreateOptionsMenu(Menu menu) {
63         boolean retValue = false;
64         retValue |= mActionBarHelper.onCreateOptionsMenu(menu);
65         retValue |= super.onCreateOptionsMenu(menu);
66         return retValue;
67     }
68
69     /**{@inheritDoc}*/
70     @Override
71     protected void onTitleChanged(CharSequence title, int color) {
72         mActionBarHelper.onTitleChanged(title, color);
73         super.onTitleChanged(title, color);
74     }
75 }