Search in sources :

Example 46 with ViewStub

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();
        }
    };
}
Also used : ViewStub(android.view.ViewStub) ViewAction(android.support.test.espresso.ViewAction) UiController(android.support.test.espresso.UiController) View(android.view.View)

Example 47 with ViewStub

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);
}
Also used : ViewStub(android.view.ViewStub) Bundle(android.os.Bundle)

Example 48 with ViewStub

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);
}
Also used : ViewStub(android.view.ViewStub) SlideClickListener(org.thoughtcrime.securesms.mms.SlideClickListener)

Example 49 with ViewStub

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);
}
Also used : ViewStub(android.view.ViewStub) Test(org.junit.Test)

Example 50 with ViewStub

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;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) Paint(android.graphics.Paint) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionMode(android.view.ActionMode) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) FloatingActionMode(com.android.internal.view.FloatingActionMode) ActionBarContextView(com.android.internal.widget.ActionBarContextView) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

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