use of android.view.ViewStub in project material-components-android by material-components.
the class BaseDynamicCoordinatorLayoutTest method inflateViewStub.
/** Inflates the <code>ViewStub</code> with the passed layout resource. */
protected ViewAction inflateViewStub(@LayoutRes final int layoutResId) {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return allOf(isAssignableFrom(ViewStub.class), hasParent());
}
@Override
public String getDescription() {
return "Inflates view stub";
}
@Override
public void perform(UiController uiController, View view) {
uiController.loopMainThreadUntilIdle();
ViewStub viewStub = (ViewStub) view;
viewStub.setLayoutResource(layoutResId);
viewStub.inflate();
mCoordinatorLayout = (CoordinatorLayout) activityTestRule.getActivity().findViewById(viewStub.getInflatedId());
uiController.loopMainThreadUntilIdle();
}
};
}
use of android.view.ViewStub in project native-navigation by airbnb.
the class ReactNativeFragment method onAttachWithReactContext.
private void onAttachWithReactContext() {
Log.d(TAG, "onCreateWithReactContext");
if (getView() == null) {
return;
}
loadingView.setVisibility(View.GONE);
if (!isSuccessfullyInitialized()) {
// ReactNativeUtils.showAlertBecauseChecksFailed(getActivity(), null);
return;
}
String moduleName = getArguments().getString(ReactNativeIntents.EXTRA_MODULE_NAME);
Bundle props = getArguments().getBundle(ReactNativeIntents.EXTRA_PROPS);
if (props == null) {
props = new Bundle();
}
props.putString(INSTANCE_ID_PROP, instanceId);
if (reactRootView == null) {
ViewStub reactViewStub = (ViewStub) getView().findViewById(R.id.react_root_view_stub);
reactRootView = (ReactRootView) reactViewStub.inflate();
}
getImplementation().reconcileNavigationProperties(this, getToolbar(), activity.getSupportActionBar(), ConversionUtil.EMPTY_MAP, renderedConfig, true);
barHeight = getImplementation().getBarHeight(this, getToolbar(), activity.getSupportActionBar(), renderedConfig, true);
reactRootView.startReactApplication(reactInstanceManager, moduleName, props);
}
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 robolectric by robolectric.
the class ViewStubTest method shouldApplyAttributes.
@Test
public void shouldApplyAttributes() throws Exception {
ViewStub viewStub = new ViewStub(ctxt, Robolectric.buildAttributeSet().addAttribute(android.R.attr.inflatedId, "@+id/include_id").addAttribute(android.R.attr.layout, "@layout/media").build());
assertThat(viewStub.getInflatedId()).isEqualTo(R.id.include_id);
assertThat(viewStub.getLayoutResource()).isEqualTo(R.layout.media);
}
use of android.view.ViewStub in project platform_frameworks_base by android.
the class DecorView method createStandaloneActionMode.
private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
endOnGoingFadeAnimation();
cleanupPrimaryActionMode();
// cleanupPrimaryActionMode() invocation above.
if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
if (mWindow.isFloating()) {
// Use the action bar theme.
final TypedValue outValue = new TypedValue();
final Resources.Theme baseTheme = mContext.getTheme();
baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
final Context actionBarContext;
if (outValue.resourceId != 0) {
final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
actionBarTheme.setTo(baseTheme);
actionBarTheme.applyStyle(outValue.resourceId, true);
actionBarContext = new ContextThemeWrapper(mContext, 0);
actionBarContext.getTheme().setTo(actionBarTheme);
} else {
actionBarContext = mContext;
}
mPrimaryActionModeView = new ActionBarContextView(actionBarContext);
mPrimaryActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
mPrimaryActionModePopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION);
mPrimaryActionModePopup.setContentView(mPrimaryActionModeView);
mPrimaryActionModePopup.setWidth(MATCH_PARENT);
actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
mPrimaryActionModeView.setContentHeight(height);
mPrimaryActionModePopup.setHeight(WRAP_CONTENT);
mShowPrimaryActionModePopup = new Runnable() {
public void run() {
mPrimaryActionModePopup.showAtLocation(mPrimaryActionModeView.getApplicationWindowToken(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
endOnGoingFadeAnimation();
if (shouldAnimatePrimaryActionModeView()) {
mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
mFadeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mPrimaryActionModeView.setVisibility(VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
mPrimaryActionModeView.setAlpha(1f);
mFadeAnim = null;
}
});
mFadeAnim.start();
} else {
mPrimaryActionModeView.setAlpha(1f);
mPrimaryActionModeView.setVisibility(VISIBLE);
}
}
};
} else {
ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
if (stub != null) {
mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
mPrimaryActionModePopup = null;
}
}
}
if (mPrimaryActionModeView != null) {
mPrimaryActionModeView.killMode();
ActionMode mode = new StandaloneActionMode(mPrimaryActionModeView.getContext(), mPrimaryActionModeView, callback, mPrimaryActionModePopup == null);
return mode;
}
return null;
}
Aggregations