Example usage for android.app ActionBar onDestroy

List of usage examples for android.app ActionBar onDestroy

Introduction

In this page you can find the example usage for android.app ActionBar onDestroy.

Prototype

public void onDestroy() 

Source Link

Usage

From source file:android.support.v7ox.app.AppCompatDelegateImplV7.java

@Override
public void setSupportActionBar(Toolbar toolbar) {
    if (!(mOriginalWindowCallback instanceof Activity)) {
        // Only Activities support custom Action Bars
        return;/*w w w.  j  a  v  a  2s  . c o m*/
    }

    final ActionBar ab = getSupportActionBar();
    if (ab instanceof WindowDecorActionBar) {
        throw new IllegalStateException("This Activity already has an action bar supplied "
                + "by the window decor. Do not request Window.FEATURE_SUPPORT_ACTION_BAR and set "
                + "windowActionBar to false in your theme to use a Toolbar instead.");
    }

    // If we reach here then we're setting a new action bar
    // First clear out the MenuInflater to make sure that it is valid for the new Action Bar
    mMenuInflater = null;

    // If we have an action bar currently, destroy it
    if (ab != null) {
        ab.onDestroy();
    }

    if (toolbar != null) {
        final ToolbarActionBar tbab = new ToolbarActionBar(toolbar, ((Activity) mContext).getTitle(),
                mAppCompatWindowCallback);
        mActionBar = tbab;
        mWindow.setCallback(tbab.getWrappedWindowCallback());
    } else {
        mActionBar = null;
        // Re-set the original window callback since we may have already set a Toolbar wrapper
        mWindow.setCallback(mAppCompatWindowCallback);
    }

    invalidateOptionsMenu();
}