Search in sources :

Example 51 with ViewStub

use of android.view.ViewStub in project ActionBarSherlock by JakeWharton.

the class ActionBarSherlockCompat method startActionMode.

@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
    if (ActionBarSherlock.DEBUG)
        Log.d(TAG, "[startActionMode] callback: " + callback);
    if (mActionMode != null) {
        mActionMode.finish();
    }
    final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
    ActionMode mode = null;
    //Emulate Activity's onWindowStartingActionMode:
    initActionBar();
    if (aActionBar != null) {
        mode = aActionBar.startActionMode(wrappedCallback);
    }
    if (mode != null) {
        mActionMode = mode;
    } else {
        if (mActionModeView == null) {
            ViewStub stub = (ViewStub) mDecor.findViewById(R.id.abs__action_mode_bar_stub);
            if (stub != null) {
                mActionModeView = (ActionBarContextView) stub.inflate();
            }
        }
        if (mActionModeView != null) {
            mActionModeView.killMode();
            mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true);
            if (callback.onCreateActionMode(mode, mode.getMenu())) {
                mode.invalidate();
                mActionModeView.initForMode(mode);
                mActionModeView.setVisibility(View.VISIBLE);
                mActionMode = mode;
                mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
            } else {
                mActionMode = null;
            }
        }
    }
    if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) {
        ((OnActionModeStartedListener) mActivity).onActionModeStarted(mActionMode);
    }
    return mActionMode;
}
Also used : StandaloneActionMode(com.actionbarsherlock.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) StandaloneActionMode(com.actionbarsherlock.internal.view.StandaloneActionMode) ActionMode(com.actionbarsherlock.view.ActionMode)

Example 52 with ViewStub

use of android.view.ViewStub in project Ushahidi_Android by ushahidi.

the class ActionBarSherlockCompat method startActionMode.

@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
    if (ActionBarSherlock.DEBUG)
        Log.d(TAG, "[startActionMode] callback: " + callback);
    if (mActionMode != null) {
        mActionMode.finish();
    }
    final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
    ActionMode mode = null;
    //Emulate Activity's onWindowStartingActionMode:
    initActionBar();
    if (aActionBar != null) {
        mode = aActionBar.startActionMode(wrappedCallback);
    }
    if (mode != null) {
        mActionMode = mode;
    } else {
        if (mActionModeView == null) {
            ViewStub stub = (ViewStub) mDecor.findViewById(R.id.abs__action_mode_bar_stub);
            if (stub != null) {
                mActionModeView = (ActionBarContextView) stub.inflate();
            }
        }
        if (mActionModeView != null) {
            mActionModeView.killMode();
            mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true);
            if (callback.onCreateActionMode(mode, mode.getMenu())) {
                mode.invalidate();
                mActionModeView.initForMode(mode);
                mActionModeView.setVisibility(View.VISIBLE);
                mActionMode = mode;
                mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
            } else {
                mActionMode = null;
            }
        }
    }
    if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) {
        ((OnActionModeStartedListener) mActivity).onActionModeStarted(mActionMode);
    }
    return mActionMode;
}
Also used : StandaloneActionMode(com.actionbarsherlock.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) StandaloneActionMode(com.actionbarsherlock.internal.view.StandaloneActionMode) ActionMode(com.actionbarsherlock.view.ActionMode)

Example 53 with ViewStub

use of android.view.ViewStub in project AndroidChromium by JackyAndroid.

the class LocationBarLayout method initOmniboxResultsContainer.

private void initOmniboxResultsContainer() {
    if (mOmniboxResultsContainer != null)
        return;
    ViewStub overlayStub = (ViewStub) getRootView().findViewById(R.id.omnibox_results_container_stub);
    mOmniboxResultsContainer = (ViewGroup) overlayStub.inflate();
    mOmniboxResultsContainer.setBackgroundColor(CONTENT_OVERLAY_COLOR);
    mOmniboxResultsContainer.setOnClickListener(this);
}
Also used : ViewStub(android.view.ViewStub)

Example 54 with ViewStub

use of android.view.ViewStub in project AndroidChromium by JackyAndroid.

the class ChromeActivity method setContentView.

/**
     * This function builds the {@link CompositorViewHolder}.  Subclasses *must* call
     * super.setContentView() before using {@link #getTabModelSelector()} or
     * {@link #getCompositorViewHolder()}.
     */
@Override
protected final void setContentView() {
    final long begin = SystemClock.elapsedRealtime();
    TraceEvent.begin("onCreate->setContentView()");
    enableHardwareAcceleration();
    setLowEndTheme();
    int controlContainerLayoutId = getControlContainerLayoutId();
    WarmupManager warmupManager = WarmupManager.getInstance();
    if (warmupManager.hasBuiltOrClearViewHierarchyWithToolbar(controlContainerLayoutId)) {
        View placeHolderView = new View(this);
        setContentView(placeHolderView);
        ViewGroup contentParent = (ViewGroup) placeHolderView.getParent();
        WarmupManager.getInstance().transferViewHierarchyTo(contentParent);
        contentParent.removeView(placeHolderView);
    } else {
        // Allow disk access for the content view and toolbar container setup.
        // On certain android devices this setup sequence results in disk writes outside
        // of our control, so we have to disable StrictMode to work. See crbug.com/639352.
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
        try {
            setContentView(R.layout.main);
            if (controlContainerLayoutId != NO_CONTROL_CONTAINER) {
                ViewStub toolbarContainerStub = ((ViewStub) findViewById(R.id.control_container_stub));
                toolbarContainerStub.setLayoutResource(controlContainerLayoutId);
                toolbarContainerStub.inflate();
            }
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }
    }
    TraceEvent.end("onCreate->setContentView()");
    mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin;
    // Set the status bar color to black by default. This is an optimization for
    // Chrome not to draw under status and navigation bars when we use the default
    // black status bar
    ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK);
    ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView();
    mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder);
    mCompositorViewHolder.setRootView(rootView);
    // Setting fitsSystemWindows to false ensures that the root view doesn't consume the insets.
    rootView.setFitsSystemWindows(false);
    // Add a custom view right after the root view that stores the insets to access later.
    // ContentViewCore needs the insets to determine the portion of the screen obscured by
    // non-content displaying things such as the OSK.
    mInsetObserverView = InsetObserverView.create(this);
    rootView.addView(mInsetObserverView, 0);
}
Also used : StrictMode(android.os.StrictMode) ViewStub(android.view.ViewStub) ViewGroup(android.view.ViewGroup) DistilledPagePrefsView(org.chromium.chrome.browser.dom_distiller.DistilledPagePrefsView) View(android.view.View) ContentVideoView(org.chromium.content.browser.ContentVideoView) SuppressLint(android.annotation.SuppressLint)

Example 55 with ViewStub

use of android.view.ViewStub in project AndroidChromium by JackyAndroid.

the class WarmupManager method initializeViewHierarchy.

/**
     * Inflates and constructs the view hierarchy that the app will use.
     * @param baseContext The base context to use for creating the ContextWrapper.
     * @param toolbarContainerId Id of the toolbar container.
     */
public void initializeViewHierarchy(Context baseContext, int toolbarContainerId) {
    TraceEvent.begin("WarmupManager.initializeViewHierarchy");
    // Inflating the view hierarchy causes StrictMode violations on some
    // devices. Since layout inflation should happen on the UI thread, allow
    // the disk reads. crbug.com/644243.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        ThreadUtils.assertOnUiThread();
        if (mMainView != null && mToolbarContainerId == toolbarContainerId)
            return;
        ContextThemeWrapper context = new ContextThemeWrapper(baseContext, ChromeActivity.getThemeId());
        FrameLayout contentHolder = new FrameLayout(context);
        mMainView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.main, contentHolder);
        mToolbarContainerId = toolbarContainerId;
        if (toolbarContainerId != ChromeActivity.NO_CONTROL_CONTAINER) {
            ViewStub stub = (ViewStub) mMainView.findViewById(R.id.control_container_stub);
            stub.setLayoutResource(toolbarContainerId);
            stub.inflate();
        }
    } catch (InflateException e) {
        // See crbug.com/606715.
        Log.e(TAG, "Inflation exception.", e);
        mMainView = null;
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
        TraceEvent.end("WarmupManager.initializeViewHierarchy");
    }
}
Also used : StrictMode(android.os.StrictMode) ViewStub(android.view.ViewStub) ContextThemeWrapper(android.view.ContextThemeWrapper) FrameLayout(android.widget.FrameLayout) InflateException(android.view.InflateException)

Aggregations

ViewStub (android.view.ViewStub)79 View (android.view.View)46 UiThreadTest (android.test.UiThreadTest)18 MediumTest (android.test.suitebuilder.annotation.MediumTest)18 StubbedView (android.view.StubbedView)18 TextView (android.widget.TextView)8 StandaloneActionMode (com.actionbarsherlock.internal.view.StandaloneActionMode)7 ActionMode (com.actionbarsherlock.view.ActionMode)7 Context (android.content.Context)6 Resources (android.content.res.Resources)6 ContextThemeWrapper (android.view.ContextThemeWrapper)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ObjectAnimator (android.animation.ObjectAnimator)5 Paint (android.graphics.Paint)5 TypedValue (android.util.TypedValue)5 ActionMode (android.view.ActionMode)5 PopupWindow (android.widget.PopupWindow)5 FloatingActionMode (com.android.internal.view.FloatingActionMode)5 StandaloneActionMode (com.android.internal.view.StandaloneActionMode)5