Java Code Examples for android.view.ViewStub#setLayoutResource()

The following examples show how to use android.view.ViewStub#setLayoutResource() . 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: NewsDetailsFragment.java    From ForPDA with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    baseInflateFragment(inflater, R.layout.fragment_article);
    ViewStub viewStub = (ViewStub) findViewById(R.id.toolbar_content);
    viewStub.setLayoutResource(R.layout.toolbar_news_details);
    viewStub.inflate();
    fragmentsPager = (ViewPager) findViewById(R.id.view_pager);
    webViewContainer = (FrameLayout) findViewById(R.id.swipe_refresh_list);
    progressBar = (ProgressBar) findViewById(R.id.progress_bar);
    detailsImage = (ImageView) findViewById(R.id.article_image);
    detailsTitle = (TextView) findViewById(R.id.article_title);
    detailsNick = (TextView) findViewById(R.id.article_nick);
    detailsCount = (TextView) findViewById(R.id.article_comments_count);
    detailsDate = (TextView) findViewById(R.id.article_date);
    imageProgressBar = (ProgressBar) findViewById(R.id.article_progress_bar);

    detailsImage.setMaxHeight(App.px24 * 10);

    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams();
    params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_EXIT_UNTIL_COLLAPSED);
    toolbarLayout.setLayoutParams(params);

    return view;
}
 
Example 2
Source File: ProfileFragment.java    From ForPDA with GNU General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    baseInflateFragment(inflater, R.layout.fragment_profile);
    ViewStub viewStub = (ViewStub) findViewById(R.id.toolbar_content);
    viewStub.setLayoutResource(R.layout.toolbar_profile);
    viewStub.inflate();
    nick = (TextView) findViewById(R.id.profile_nick);
    group = (TextView) findViewById(R.id.profile_group);
    sign = (TextView) findViewById(R.id.profile_sign);
    avatar = (ImageView) findViewById(R.id.profile_avatar);
    recyclerView = (RecyclerView) findViewById(R.id.profile_list);
    progressView = (CircularProgressView) findViewById(R.id.profile_progress);

    AppBarLayout.LayoutParams params = (AppBarLayout.LayoutParams) toolbarLayout.getLayoutParams();
    params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS_COLLAPSED);
    toolbarLayout.setLayoutParams(params);
    return view;
}
 
Example 3
Source File: ViewHelper.java    From DMusic with Apache License 2.0 6 votes vote down vote up
/**
 * @param parentView
 * @param viewStubId
 * @param inflatedViewId
 * @param inflateLayoutResId
 * @return
 */
@SuppressLint("ResourceType")
public static View findViewFromViewStub(View parentView, int viewStubId, int inflatedViewId, int inflateLayoutResId) {
    if (null == parentView) {
        return null;
    }
    View view = parentView.findViewById(inflatedViewId);
    if (null == view) {
        ViewStub vs = (ViewStub) parentView.findViewById(viewStubId);
        if (null == vs) {
            return null;
        }
        if (vs.getLayoutResource() < 1 && inflateLayoutResId > 0) {
            vs.setLayoutResource(inflateLayoutResId);
        }
        view = vs.inflate();
        if (null != view) {
            view = view.findViewById(inflatedViewId);
        }
    }
    return view;
}
 
Example 4
Source File: AboutActivity.java    From andOTP with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setTitle(R.string.about_activity_title);
    setContentView(R.layout.activity_container);

    Toolbar toolbar = findViewById(R.id.container_toolbar);
    setSupportActionBar(toolbar);

    ViewStub stub = findViewById(R.id.container_stub);
    stub.setLayoutResource(R.layout.component_about);

    View v = stub.inflate();

    ViewPager viewPager = v.findViewById(R.id.viewPager);
    TabLayout tabLayout = v.findViewById(R.id.tabLayout);
    AboutPageAdapter aboutPageAdapter = new AboutPageAdapter(getSupportFragmentManager());

    viewPager.setAdapter(aboutPageAdapter);
    tabLayout.setupWithViewPager(viewPager);
}
 
Example 5
Source File: TestActivity.java    From Android-skin-support with MIT License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test);
    initToolbar();
    ViewStub viewStub = (ViewStub) findViewById(R.id.view_stub);
    viewStub.setLayoutResource(R.layout.fragment_view_stub);
    viewStub.inflate();
    MDFirstFragment fragment = (MDFirstFragment) getSupportFragmentManager().findFragmentById(R.id.md_fragment);
    Log.e("TestActivity", "fragment = " + fragment);
}
 
Example 6
Source File: QmsBlackListFragment.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    ViewStub viewStub = (ViewStub) findViewById(R.id.toolbar_content);
    viewStub.setLayoutResource(R.layout.toolbar_qms_black_list);
    viewStub.inflate();
    nickField = (AppCompatAutoCompleteTextView) findViewById(R.id.qms_black_list_nick_field);
    return view;
}
 
Example 7
Source File: LinkShareViewHolder.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public LinkShareViewHolder(View itemView) {
                super(itemView);
                ViewStub viewStub = (ViewStub) itemView.findViewById(R.id.vs_share_fragment_item_main);
                viewStub.setLayoutResource(R.layout.share_fragment_item_link_layout);
                viewStub.inflate();
//                display = (LinearLayout) viewStub.inflate().findViewById(R.id.ll_share_fragment_item_container);
        }
 
Example 8
Source File: ImageShareInfoHolder.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public ImageShareInfoHolder(View itemView) {
    super(itemView);
    ViewStub viewStub = itemView.findViewById(R.id.vs_item_fragment_share_info_stub);
    viewStub.setLayoutResource(R.layout.item_fragment_share_info_image);
    display = (SuperRecyclerView) viewStub.inflate();
    display.setNestedScrollingEnabled(false);
}
 
Example 9
Source File: BaseSuperAbsListview.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void initView() {
    if (isInEditMode()) {
        return;
    }
    View v = LayoutInflater.from(getContext()).inflate(mSuperListViewMainLayout, this);
    mPtrLayout = (SwipeRefreshLayout) v.findViewById(R.id.ptr_layout);
    mPtrLayout.setEnabled(false);

    mProgress = (ViewStub) v.findViewById(android.R.id.progress);

    mProgress.setLayoutResource(mProgressId);
    mProgress.inflate();

    mMoreProgress = (ViewStub) v.findViewById(R.id.more_progress);
    mMoreProgress.setLayoutResource(mMoreProgressId);
    if (mMoreProgressId != 0)
        mMoreProgress.inflate();
    mMoreProgress.setVisibility(View.GONE);

    mEmpty = (ViewStub) v.findViewById(R.id.empty);
    mEmpty.setLayoutResource(mEmptyId);
    if (mEmptyId != 0)
        mEmpty.inflate();
    mEmpty.setVisibility(View.GONE);

    initAbsListView(v);
}
 
Example 10
Source File: CustomUltimateRecyclerview.java    From UltimateRecyclerView with Apache License 2.0 5 votes vote down vote up
@Override
protected void initViews() {
    //super.initViews();
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.custom_recycler_view_layout, this);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list);
    mSwipeRefreshLayout = null;

    if (mRecyclerView != null) {

        mRecyclerView.setClipToPadding(mClipToPadding);
        if (mPadding != -1.1f) {
            mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
        } else {
            mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
        }
    }

    defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
    setDefaultScrollListener();

    mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
    mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);

    mEmpty.setLayoutResource(mEmptyId);

    mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);

    if (mEmptyId != 0)
        mEmptyView = mEmpty.inflate();
    mEmpty.setVisibility(View.GONE);

    if (mFloatingButtonId != 0) {
        mFloatingButtonView = mFloatingButtonViewStub.inflate();
        mFloatingButtonView.setVisibility(View.VISIBLE);
    }

}
 
Example 11
Source File: SwipeableUltimateRecyclerview.java    From UltimateRecyclerView with Apache License 2.0 4 votes vote down vote up
@Override
protected void initViews() {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.swipeable_ultimate_recycler_view_layout, this);
    mRecyclerView = (SwipeListView) view.findViewById(R.id.ultimate_list);

    mSwipeRefreshLayout = (VerticalSwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
    setScrollbars();
    mSwipeRefreshLayout.setEnabled(false);

    if (mRecyclerView != null) {

        mRecyclerView.setClipToPadding(mClipToPadding);
        if (mPadding != -1.1f) {
            mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
        } else {
            mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
        }
    }

    defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
    setDefaultScrollListener();

    mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
    mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);

    mEmpty.setLayoutResource(mEmptyId);

    mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);

    if (mEmptyId != 0)
        mEmptyView = mEmpty.inflate();
    mEmpty.setVisibility(View.GONE);

    if (mFloatingButtonId != 0) {
        mFloatingButtonView = mFloatingButtonViewStub.inflate();
        mFloatingButtonView.setVisibility(View.VISIBLE);
    }


}
 
Example 12
Source File: SendVideoHolder.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
public SendVideoHolder(View itemView) {
    super(itemView);
    ViewStub viewStub = (ViewStub) getView(R.id.vs_item_activity_chat_send_view_stub);
    viewStub.setLayoutResource(R.layout.item_activity_chat_send_video);
    viewStub.inflate();
}
 
Example 13
Source File: ImageShareViewHolder.java    From TestChat with Apache License 2.0 4 votes vote down vote up
public  ImageShareViewHolder(View itemView) {
        super(itemView);
        ViewStub viewStub = (ViewStub) itemView.findViewById(R.id.vs_share_fragment_item_main);
        viewStub.setLayoutResource(R.layout.share_fragment_item_image_layout);
        display = (ListImageView) viewStub.inflate().findViewById(R.id.liv_share_fragment_item_main_image_display);
}
 
Example 14
Source File: L5Dark.java    From heads-up with GNU General Public License v3.0 4 votes vote down vote up
public L5Dark(ViewStub stub) {
    super(stub);
    stub.setLayoutResource(R.layout.activity_read_inner_dark);
}
 
Example 15
Source File: LayoutSelector.java    From Pocket-Plays-for-Twitch with GNU General Public License v3.0 4 votes vote down vote up
private void init() {
	layoutSelectorView = activity.getLayoutInflater().inflate(R.layout.stream_layout_preview, null);
	final RadioGroup rg = (RadioGroup) layoutSelectorView.findViewById(R.id.layouts_radiogroup);
	final FrameLayout previewWrapper = (FrameLayout) layoutSelectorView.findViewById(R.id.preview_wrapper);

	if (previewMaxHeightRes != -1) {
		LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT,
				(int) activity.getResources().getDimension(previewMaxHeightRes)
		);
		previewWrapper.setLayoutParams(lp);
		//previewWrapper.setMinimumHeight((int) activity.getResources().getDimension(previewMaxHeightRes));
	}

	ViewStub preview = (ViewStub) layoutSelectorView.findViewById(R.id.layout_stub);
	preview.setLayoutResource(previewLayout);
	final View inflated = preview.inflate();

	for (int i = 0; i < layoutTitles.length; i++) {
		final String layoutTitle = layoutTitles[i];

		final AppCompatRadioButton radioButton = new AppCompatRadioButton(activity);
		radioButton.setText(layoutTitle);

		final int finalI = i;
		radioButton.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				selectCallback.onSelected(layoutTitle, finalI, inflated);
			}
		});

		if (textColor != -1) {
			radioButton.setTextColor(Service.getColorAttribute(textColor, R.color.black_text, activity));

			ColorStateList colorStateList = new ColorStateList(
					new int[][]{
							new int[]{-android.R.attr.state_checked},
							new int[]{android.R.attr.state_checked}
					},
					new int[]{

							Color.GRAY, //Disabled
							Service.getColorAttribute(R.attr.colorAccent, R.color.accent, activity), //Enabled
					}
			);
			radioButton.setSupportButtonTintList(colorStateList);
		}


		radioButton.setLayoutParams(new ViewGroup.LayoutParams(
				ViewGroup.LayoutParams.MATCH_PARENT, // Width
				(int) activity.getResources().getDimension(R.dimen.layout_selector_height) // Height
		));


		rg.addView(radioButton, i);


		if ((selectedLayoutIndex != -1 && selectedLayoutIndex == i) || (selectedLayoutTitle != null && selectedLayoutTitle.equals(layoutTitle))) {
			radioButton.performClick();
		}
	}
}
 
Example 16
Source File: AuthenticateActivity.java    From andOTP with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setTitle(R.string.auth_activity_title);

    if (! settings.getScreenshotsEnabled())
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);

    setContentView(R.layout.activity_container);

    Toolbar toolbar = findViewById(R.id.container_toolbar);
    toolbar.setNavigationIcon(null);
    setSupportActionBar(toolbar);

    ViewStub stub = findViewById(R.id.container_stub);
    stub.setLayoutResource(R.layout.content_authenticate);
    View v = stub.inflate();

    Intent callingIntent = getIntent();
    int labelMsg = callingIntent.getIntExtra(Constants.EXTRA_AUTH_MESSAGE, R.string.auth_msg_authenticate);
    newEncryption = callingIntent.getStringExtra(Constants.EXTRA_AUTH_NEW_ENCRYPTION);

    TextView passwordLabel = v.findViewById(R.id.passwordLabel);
    TextInputLayout passwordLayout = v.findViewById(R.id.passwordLayout);
    passwordInput = v.findViewById(R.id.passwordEdit);

    if (settings.getBlockAccessibility())
        passwordLayout.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && settings.getBlockAutofill())
        passwordLayout.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);

    passwordLabel.setText(labelMsg);

    authMethod = settings.getAuthMethod();
    password = settings.getAuthCredentials();

    if (password.isEmpty()) {
        password = settings.getOldCredentials(authMethod);
        oldPassword = true;
    }

    if (authMethod == AuthMethod.PASSWORD) {
        if (password.isEmpty()) {
            Toast.makeText(this, R.string.auth_toast_password_missing, Toast.LENGTH_LONG).show();
            finishWithResult(true, null);
        } else {
            passwordLayout.setHint(getString(R.string.auth_hint_password));
            passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        }
    } else if (authMethod == AuthMethod.PIN) {
        if (password.isEmpty()) {
            Toast.makeText(this, R.string.auth_toast_pin_missing, Toast.LENGTH_LONG).show();
            finishWithResult(true, null);
        } else {
            passwordLayout.setHint(getString(R.string.auth_hint_pin));
            passwordInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
        }
    } else {
        finishWithResult(true, null);
    }

    passwordInput.setTransformationMethod(new PasswordTransformationMethod());
    passwordInput.setOnEditorActionListener(this);

    Button unlockButton = v.findViewById(R.id.buttonUnlock);
    unlockButton.setOnClickListener(this);

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
 
Example 17
Source File: StatusHelper.java    From MeiBaseModule with Apache License 2.0 4 votes vote down vote up
private void setViewStubLayoutRes(@IdRes int stubId, @LayoutRes int layoutResId) {
    ViewStub viewStub = (ViewStub) mView.findViewById(stubId);
    if (viewStub != null) {
        viewStub.setLayoutResource(layoutResId);
    }
}
 
Example 18
Source File: ReceiveImageHolder.java    From NewFastFrame with Apache License 2.0 4 votes vote down vote up
public ReceiveImageHolder(View itemView) {
    super(itemView);
    ViewStub viewStub = (ViewStub) getView(R.id.vs_item_activity_chat_receive_view_stub);
    viewStub.setLayoutResource(R.layout.item_activity_chat_receive_image);
    viewStub.inflate();
}
 
Example 19
Source File: HoloLight.java    From heads-up with GNU General Public License v3.0 4 votes vote down vote up
public HoloLight(ViewStub stub) {
    super(stub);
    stub.setLayoutResource(R.layout.activity_read_inner_holo_light);
}
 
Example 20
Source File: Ubuntu.java    From heads-up with GNU General Public License v3.0 4 votes vote down vote up
public Ubuntu(ViewStub stub) {
    super(stub);
    stub.setLayoutResource(R.layout.activity_read_inner_ubuntu);
}