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;
}
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;
}
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);
}
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);
}
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");
}
}
Aggregations