Source code
package android.support.v7.app;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.NavUtils;
import android.support.v4.app.TaskStackBuilder;
import android.support.v4.app.TaskStackBuilder.SupportParentable;
import android.support.v7.app.ActionBarDrawerToggle.Delegate;
import android.support.v7.app.ActionBarDrawerToggle.DelegateProvider;
import android.support.v7.view.ActionMode;
import android.support.v7.view.ActionMode.Callback;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
public class AppCompatActivity extends FragmentActivity implements AppCompatCallback, SupportParentable, DelegateProvider {
private AppCompatDelegate mDelegate;
protected void onCreate(@Nullable Bundle savedInstanceState) {
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
}
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
getDelegate().onPostCreate(savedInstanceState);
}
@Nullable
public ActionBar getSupportActionBar() {
return getDelegate().getSupportActionBar();
}
public void setSupportActionBar(@Nullable Toolbar toolbar) {
getDelegate().setSupportActionBar(toolbar);
}
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
}
public void setContentView(@LayoutRes int layoutResID) {
getDelegate().setContentView(layoutResID);
}
public void setContentView(View view) {
getDelegate().setContentView(view);
}
public void setContentView(View view, LayoutParams params) {
getDelegate().setContentView(view, params);
}
public void addContentView(View view, LayoutParams params) {
getDelegate().addContentView(view, params);
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
getDelegate().onConfigurationChanged(newConfig);
}
protected void onStop() {
super.onStop();
getDelegate().onStop();
}
protected void onPostResume() {
super.onPostResume();
getDelegate().onPostResume();
}
public final boolean onMenuItemSelected(int featureId, MenuItem item) {
if (super.onMenuItemSelected(featureId, item)) {
return true;
}
ActionBar ab = getSupportActionBar();
if (item.getItemId() != 16908332 || ab == null || (ab.getDisplayOptions() & 4) == 0) {
return false;
}
return onSupportNavigateUp();
}
protected void onDestroy() {
super.onDestroy();
getDelegate().onDestroy();
}
protected void onTitleChanged(CharSequence title, int color) {
super.onTitleChanged(title, color);
getDelegate().setTitle(title);
}
public boolean supportRequestWindowFeature(int featureId) {
return getDelegate().requestWindowFeature(featureId);
}
public void supportInvalidateOptionsMenu() {
getDelegate().invalidateOptionsMenu();
}
public void invalidateOptionsMenu() {
getDelegate().invalidateOptionsMenu();
}
@CallSuper
public void onSupportActionModeStarted(ActionMode mode) {
}
@CallSuper
public void onSupportActionModeFinished(ActionMode mode) {
}
@Nullable
public ActionMode onWindowStartingSupportActionMode(Callback callback) {
return null;
}
public ActionMode startSupportActionMode(Callback callback) {
return getDelegate().startSupportActionMode(callback);
}
@Deprecated
public void setSupportProgressBarVisibility(boolean visible) {
}
@Deprecated
public void setSupportProgressBarIndeterminateVisibility(boolean visible) {
}
@Deprecated
public void setSupportProgressBarIndeterminate(boolean indeterminate) {
}
@Deprecated
public void setSupportProgress(int progress) {
}
public void onCreateSupportNavigateUpTaskStack(TaskStackBuilder builder) {
builder.addParentStack((Activity) this);
}
public void onPrepareSupportNavigateUpTaskStack(TaskStackBuilder builder) {
}
public boolean onSupportNavigateUp() {
Intent upIntent = getSupportParentActivityIntent();
if (upIntent == null) {
return false;
}
if (supportShouldUpRecreateTask(upIntent)) {
TaskStackBuilder b = TaskStackBuilder.create(this);
onCreateSupportNavigateUpTaskStack(b);
onPrepareSupportNavigateUpTaskStack(b);
b.startActivities();
try {
ActivityCompat.finishAffinity(this);
} catch (IllegalStateException e) {
finish();
}
} else {
supportNavigateUpTo(upIntent);
}
return true;
}
@Nullable
public Intent getSupportParentActivityIntent() {
return NavUtils.getParentActivityIntent(this);
}
public boolean supportShouldUpRecreateTask(Intent targetIntent) {
return NavUtils.shouldUpRecreateTask(this, targetIntent);
}
public void supportNavigateUpTo(Intent upIntent) {
NavUtils.navigateUpTo(this, upIntent);
}
public void onContentChanged() {
onSupportContentChanged();
}
@Deprecated
public void onSupportContentChanged() {
}
@Nullable
public Delegate getDrawerToggleDelegate() {
return getDelegate().getDrawerToggleDelegate();
}
public boolean onMenuOpened(int featureId, Menu menu) {
return super.onMenuOpened(featureId, menu);
}
public void onPanelClosed(int featureId, Menu menu) {
super.onPanelClosed(featureId, menu);
}
public AppCompatDelegate getDelegate() {
if (this.mDelegate == null) {
this.mDelegate = AppCompatDelegate.create((Activity) this, (AppCompatCallback) this);
}
return this.mDelegate;
}
}