android.support.v7.widget.ViewStubCompat Java Examples

The following examples show how to use android.support.v7.widget.ViewStubCompat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EasyIntroCarouselFragment.java    From EasyIntro with Apache License 2.0 5 votes vote down vote up
private void addIndicator() {
    if (mIndicatorRes != -1) {
        ViewStubCompat viewStub = (ViewStubCompat) mIndicatorsContainer.findViewById(R.id.pageIndicator);
        viewStub.setLayoutResource(mIndicatorRes);
        viewStub.setOnInflateListener(new ViewStubCompat.OnInflateListener() {
            @Override
            public void onInflate(ViewStubCompat stub, View inflated) {
                setViewPagerToPageIndicator();
            }
        });
        View view = viewStub.inflate();
        view.setVisibility(mPageIndicatorVisibility ? View.VISIBLE : View.GONE);
    }
}
 
Example #2
Source File: EasyIntroCarouselFragment.java    From EasyIntro with Apache License 2.0 4 votes vote down vote up
private void inflateIndicatorContainer(final View view) {
    final ViewStubCompat indicatorContainerStub = (ViewStubCompat) view.findViewById(R.id.indicatorContainer);

    // set gravity
    FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) indicatorContainerStub.getLayoutParams();
    params.gravity = mIndicatorContainerGravity;
    indicatorContainerStub.setLayoutParams(params);

    indicatorContainerStub.setLayoutResource(mIndicatorContainer);
    indicatorContainerStub.setOnInflateListener(new ViewStubCompat.OnInflateListener() {
        @Override
        public void onInflate(ViewStubCompat stub, View inflated) {
            // there must be predefined ids
            if (inflated.findViewById(R.id.leftIndicator) == null) {
                throw new RuntimeException(getString(R.string.exception_left_indicator_id));
            } else if (inflated.findViewById(R.id.rightIndicator) == null) {
                throw new RuntimeException(getString(R.string.exception_right_indicator_id));
            } else if (inflated.findViewById(R.id.pageIndicator) == null) {
                throw new RuntimeException(getString(R.string.exception_page_indicator_id));
            }
            // check indicators instanceof
            else if (!(inflated.findViewById(R.id.leftIndicator) instanceof LeftToggleIndicator)) {
                throw new RuntimeException(getString(R.string.exception_previous_indicator_instanceof));
            } else if (!(inflated.findViewById(R.id.rightIndicator) instanceof RightToggleIndicator)) {
                throw new RuntimeException(getString(R.string.exception_next_indicator_instanceof));
            }

            mIndicatorsContainer = inflated;

            // must be initialized after inflating indicator container
            mRightIndicator = (RightToggleIndicator) mIndicatorsContainer.findViewById(R.id.rightIndicator);
            mLeftIndicator = (LeftToggleIndicator) mIndicatorsContainer.findViewById(R.id.leftIndicator);
            mRightIndicator.setListener(EasyIntroCarouselFragment.this);
            mRightIndicator.withDisabled(mRightIndicatorEnabled);
            mLeftIndicator.setListener(EasyIntroCarouselFragment.this);
            mLeftIndicator.withDisabled(mLeftIndicatorEnabled);

            addIndicator();
            updateToggleIndicators();
        }
    });
    indicatorContainerStub.inflate();
}
 
Example #3
Source File: AppCompatv7DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult viewStubCompat() {
  return BaseDSL.v(ViewStubCompat.class);
}
 
Example #4
Source File: AppCompatv7DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void viewStubCompat(Anvil.Renderable r) {
  return BaseDSL.v(ViewStubCompat.class, r);
}
 
Example #5
Source File: AppCompatv7DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void onInflate(ViewStubCompat.OnInflateListener arg) {
  return BaseDSL.attr("onInflate", arg);
}