1 /* AppCompatPreferenceActivity.java
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 package de.dhbwloe.campusapp;
18 import android.content.res.Configuration;
19 import android.os.Bundle;
20 import android.preference.PreferenceActivity;
21 import android.support.annotation.LayoutRes;
22 import android.support.annotation.Nullable;
23 import android.support.v7.app.ActionBar;
24 import android.support.v7.app.AppCompatDelegate;
25 import android.support.v7.widget.Toolbar;
26 import android.view.MenuInflater;
27 import android.view.View;
28 import android.view.ViewGroup;
31 * A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
32 * to be used with AppCompat.
34 public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
36 private AppCompatDelegate mDelegate;
39 protected void onCreate(Bundle savedInstanceState) {
40 getDelegate().installViewFactory();
41 getDelegate().onCreate(savedInstanceState);
42 super.onCreate(savedInstanceState);
46 protected void onPostCreate(Bundle savedInstanceState) {
47 super.onPostCreate(savedInstanceState);
48 getDelegate().onPostCreate(savedInstanceState);
51 public ActionBar getSupportActionBar() {
52 return getDelegate().getSupportActionBar();
55 public void setSupportActionBar(@Nullable Toolbar toolbar) {
56 getDelegate().setSupportActionBar(toolbar);
60 public MenuInflater getMenuInflater() {
61 return getDelegate().getMenuInflater();
65 public void setContentView(@LayoutRes int layoutResID) {
66 getDelegate().setContentView(layoutResID);
70 public void setContentView(View view) {
71 getDelegate().setContentView(view);
75 public void setContentView(View view, ViewGroup.LayoutParams params) {
76 getDelegate().setContentView(view, params);
80 public void addContentView(View view, ViewGroup.LayoutParams params) {
81 getDelegate().addContentView(view, params);
85 protected void onPostResume() {
87 getDelegate().onPostResume();
91 protected void onTitleChanged(CharSequence title, int color) {
92 super.onTitleChanged(title, color);
93 getDelegate().setTitle(title);
97 public void onConfigurationChanged(Configuration newConfig) {
98 super.onConfigurationChanged(newConfig);
99 getDelegate().onConfigurationChanged(newConfig);
103 protected void onStop() {
105 getDelegate().onStop();
109 protected void onDestroy() {
111 getDelegate().onDestroy();
114 public void invalidateOptionsMenu() {
115 getDelegate().invalidateOptionsMenu();
118 private AppCompatDelegate getDelegate() {
119 if (mDelegate == null) {
120 mDelegate = AppCompatDelegate.create(this, null);