use of android.view.ViewStub in project Signal-Android by WhisperSystems.
the class ConversationItem method onFinishInflate.
@Override
protected void onFinishInflate() {
super.onFinishInflate();
initializeAttributes();
this.bodyText = (TextView) findViewById(R.id.conversation_item_body);
this.dateText = (TextView) findViewById(R.id.conversation_item_date);
this.simInfoText = (TextView) findViewById(R.id.sim_info);
this.indicatorText = (TextView) findViewById(R.id.indicator_text);
this.groupStatusText = (TextView) findViewById(R.id.group_message_status);
this.secureImage = (ImageView) findViewById(R.id.secure_indicator);
this.deliveryStatusIndicator = (DeliveryStatusView) findViewById(R.id.delivery_status);
this.alertView = (AlertView) findViewById(R.id.indicators_parent);
this.contactPhoto = (AvatarImageView) findViewById(R.id.contact_photo);
this.bodyBubble = findViewById(R.id.body_bubble);
this.mediaThumbnailStub = new Stub<>((ViewStub) findViewById(R.id.image_view_stub));
this.audioViewStub = new Stub<>((ViewStub) findViewById(R.id.audio_view_stub));
this.expirationTimer = (ExpirationTimerView) findViewById(R.id.expiration_indicator);
setOnClickListener(new ClickListener(null));
bodyText.setOnLongClickListener(passthroughClickListener);
bodyText.setOnClickListener(passthroughClickListener);
}
use of android.view.ViewStub in project platform_frameworks_base by android.
the class ViewStubTest method testInflatedLayoutParams.
@UiThreadTest
@MediumTest
public void testInflatedLayoutParams() throws Exception {
final StubbedView activity = getActivity();
final ViewStub stub = (ViewStub) activity.findViewById(R.id.viewStubWithId);
final View swapped = stub.inflate();
assertNotNull("The inflated view is null", swapped);
assertEquals("Both stub and inflated should same width", stub.getLayoutParams().width, swapped.getLayoutParams().width);
assertEquals("Both stub and inflated should same height", stub.getLayoutParams().height, swapped.getLayoutParams().height);
}
use of android.view.ViewStub in project platform_frameworks_base by android.
the class ViewStubTest method testInflatedId.
@UiThreadTest
@MediumTest
public void testInflatedId() throws Exception {
final StubbedView activity = getActivity();
final ViewStub stub = (ViewStub) activity.findViewById(R.id.viewStubWithId);
final View swapped = stub.inflate();
assertNotNull("The inflated view is null", swapped);
assertTrue("The inflated view has no id", swapped.getId() != View.NO_ID);
assertTrue("The inflated view has the wrong id", swapped.getId() == R.id.stub_inflated);
}
use of android.view.ViewStub in project AndroidTraining by mixi-inc.
the class ActionBarSherlockCompat method startActionMode.
@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
if (BuildConfig.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 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);
}
Aggregations