Search in sources :

Example 6 with ActionBarContextView

use of com.actionbarsherlock.internal.widget.ActionBarContextView in project AndroidTraining by mixi-inc.

the class ActionBarSherlockCompat method installDecor.

private void installDecor() {
    if (BuildConfig.DEBUG)
        Log.d(TAG, "[installDecor]");
    if (mDecor == null) {
        mDecor = (ViewGroup) mActivity.getWindow().getDecorView().findViewById(android.R.id.content);
    }
    if (mContentParent == null) {
        //Since we are not operating at the window level we need to take
        //into account the fact that the true decor may have already been
        //initialized and had content attached to it. If that is the case,
        //copy over its children to our new content container.
        List<View> views = null;
        if (mDecor.getChildCount() > 0) {
            //Usually there's only one child
            views = new ArrayList<View>(1);
            for (int i = 0, children = mDecor.getChildCount(); i < children; i++) {
                View child = mDecor.getChildAt(0);
                mDecor.removeView(child);
                views.add(child);
            }
        }
        mContentParent = generateLayout();
        //Copy over the old children. See above for explanation.
        if (views != null) {
            for (View child : views) {
                mContentParent.addView(child);
            }
        }
        wActionBar = (ActionBarView) mDecor.findViewById(R.id.abs__action_bar);
        if (wActionBar != null) {
            wActionBar.setWindowCallback(this);
            if (wActionBar.getTitle() == null) {
                wActionBar.setWindowTitle(mActivity.getTitle());
            }
            if (hasFeature(Window.FEATURE_PROGRESS)) {
                wActionBar.initProgress();
            }
            if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
                wActionBar.initIndeterminateProgress();
            }
            //Since we don't require onCreate dispatching, parse for uiOptions here
            int uiOptions = loadUiOptionsFromManifest(mActivity);
            if (uiOptions != 0) {
                mUiOptions = uiOptions;
            }
            boolean splitActionBar = false;
            final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0;
            if (splitWhenNarrow) {
                splitActionBar = getResources_getBoolean(mActivity, R.bool.abs__split_action_bar_is_narrow);
            } else {
                splitActionBar = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme).getBoolean(R.styleable.SherlockTheme_windowSplitActionBar, false);
            }
            final ActionBarContainer splitView = (ActionBarContainer) mDecor.findViewById(R.id.abs__split_action_bar);
            if (splitView != null) {
                wActionBar.setSplitView(splitView);
                wActionBar.setSplitActionBar(splitActionBar);
                wActionBar.setSplitWhenNarrow(splitWhenNarrow);
                mActionModeView = (ActionBarContextView) mDecor.findViewById(R.id.abs__action_context_bar);
                mActionModeView.setSplitView(splitView);
                mActionModeView.setSplitActionBar(splitActionBar);
                mActionModeView.setSplitWhenNarrow(splitWhenNarrow);
            } else if (splitActionBar) {
                Log.e(TAG, "Requested split action bar with incompatible window decor! Ignoring request.");
            }
            // Post the panel invalidate for later; avoid application onCreateOptionsMenu
            // being called in the middle of onCreate or similar.
            mDecor.post(new Runnable() {

                @Override
                public void run() {
                    //Invalidate if the panel menu hasn't been created before this.
                    if (!mIsDestroyed && !mActivity.isFinishing() && mMenu == null) {
                        dispatchInvalidateOptionsMenu();
                    }
                }
            });
        }
    }
}
Also used : ActionBarContainer(com.actionbarsherlock.internal.widget.ActionBarContainer) ActionBarContextView(com.actionbarsherlock.internal.widget.ActionBarContextView) ActionBarView(com.actionbarsherlock.internal.widget.ActionBarView) View(android.view.View)

Example 7 with ActionBarContextView

use of com.actionbarsherlock.internal.widget.ActionBarContextView in project Ushahidi_Android by ushahidi.

the class ActionBarSherlockCompat method installDecor.

private void installDecor() {
    if (ActionBarSherlock.DEBUG)
        Log.d(TAG, "[installDecor]");
    if (mDecor == null) {
        mDecor = (ViewGroup) mActivity.getWindow().getDecorView().findViewById(android.R.id.content);
    }
    if (mContentParent == null) {
        //Since we are not operating at the window level we need to take
        //into account the fact that the true decor may have already been
        //initialized and had content attached to it. If that is the case,
        //copy over its children to our new content container.
        List<View> views = null;
        if (mDecor.getChildCount() > 0) {
            //Usually there's only one child
            views = new ArrayList<View>(1);
            for (int i = 0, children = mDecor.getChildCount(); i < children; i++) {
                View child = mDecor.getChildAt(0);
                mDecor.removeView(child);
                views.add(child);
            }
        }
        mContentParent = generateLayout();
        //Copy over the old children. See above for explanation.
        if (views != null) {
            for (View child : views) {
                mContentParent.addView(child);
            }
        }
        wActionBar = (ActionBarView) mDecor.findViewById(R.id.abs__action_bar);
        if (wActionBar != null) {
            wActionBar.setWindowCallback(this);
            if (wActionBar.getTitle() == null) {
                wActionBar.setWindowTitle(mActivity.getTitle());
            }
            if (hasFeature(Window.FEATURE_PROGRESS)) {
                wActionBar.initProgress();
            }
            if (hasFeature(Window.FEATURE_INDETERMINATE_PROGRESS)) {
                wActionBar.initIndeterminateProgress();
            }
            //Since we don't require onCreate dispatching, parse for uiOptions here
            int uiOptions = loadUiOptionsFromManifest(mActivity);
            if (uiOptions != 0) {
                mUiOptions = uiOptions;
            }
            boolean splitActionBar = false;
            final boolean splitWhenNarrow = (mUiOptions & ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW) != 0;
            if (splitWhenNarrow) {
                splitActionBar = getResources_getBoolean(mActivity, R.bool.abs__split_action_bar_is_narrow);
            } else {
                splitActionBar = mActivity.getTheme().obtainStyledAttributes(R.styleable.SherlockTheme).getBoolean(R.styleable.SherlockTheme_windowSplitActionBar, false);
            }
            final ActionBarContainer splitView = (ActionBarContainer) mDecor.findViewById(R.id.abs__split_action_bar);
            if (splitView != null) {
                wActionBar.setSplitView(splitView);
                wActionBar.setSplitActionBar(splitActionBar);
                wActionBar.setSplitWhenNarrow(splitWhenNarrow);
                mActionModeView = (ActionBarContextView) mDecor.findViewById(R.id.abs__action_context_bar);
                mActionModeView.setSplitView(splitView);
                mActionModeView.setSplitActionBar(splitActionBar);
                mActionModeView.setSplitWhenNarrow(splitWhenNarrow);
            } else if (splitActionBar) {
                Log.e(TAG, "Requested split action bar with incompatible window decor! Ignoring request.");
            }
            // Post the panel invalidate for later; avoid application onCreateOptionsMenu
            // being called in the middle of onCreate or similar.
            mDecor.post(new Runnable() {

                @Override
                public void run() {
                    //Invalidate if the panel menu hasn't been created before this.
                    if (!mIsDestroyed && !mActivity.isFinishing() && mMenu == null) {
                        dispatchInvalidateOptionsMenu();
                    }
                }
            });
        }
    }
}
Also used : ActionBarContainer(com.actionbarsherlock.internal.widget.ActionBarContainer) ActionBarContextView(com.actionbarsherlock.internal.widget.ActionBarContextView) ActionBarView(com.actionbarsherlock.internal.widget.ActionBarView) View(android.view.View)

Aggregations

View (android.view.View)7 ActionBarContainer (com.actionbarsherlock.internal.widget.ActionBarContainer)7 ActionBarContextView (com.actionbarsherlock.internal.widget.ActionBarContextView)7 ActionBarView (com.actionbarsherlock.internal.widget.ActionBarView)7 FrameLayout (android.widget.FrameLayout)2 TextView (android.widget.TextView)2