androidx.annotation.LayoutRes Java Examples
The following examples show how to use
androidx.annotation.LayoutRes.
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: AlertController.java From HaoReader with GNU General Public License v3.0 | 6 votes |
public void setView(@LayoutRes int layoutResId, FrameLayout.LayoutParams params) { mViewLayoutResId = layoutResId; mViewParams = params; if (mContentFrame != null) { mContentFrame.removeAllViews(); if (mViewLayoutResId != 0) { if (mViewParams == null) { mViewParams = new FrameLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT); } View customView = mInflater.inflate(mViewLayoutResId, mContentFrame, false); mContentFrame.setVisibility(View.VISIBLE); mNoCustomDivider.setVisibility(View.GONE); mContentFrame.addView(customView, mViewParams); } } }
Example #2
Source File: CachedInflater.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@MainThread void cacheUntilLimit(Context context, @LayoutRes int layoutRes, @Nullable ViewGroup parent, int limit) { AsyncLayoutInflater inflater = new AsyncLayoutInflater(context); int existingCount = Util.getOrDefault(cache, layoutRes, Collections.emptyList()).size(); int inflateCount = Math.max(limit - existingCount, 0); for (int i = 0; i < inflateCount; i++) { final long enqueueTime = System.currentTimeMillis(); inflater.inflate(layoutRes, parent, (view, resId, p) -> { Util.assertMainThread(); if (enqueueTime < lastClearTime) { Log.d(TAG, "Prefetch is no longer valid. Ignoring."); return; } List<View> views = cache.get(resId); views = views == null ? new LinkedList<>() : views; views.add(view); cache.put(resId, views); }); } }
Example #3
Source File: DynamicPresetsView.java From dynamic-support with Apache License 2.0 | 6 votes |
/** * Set a presets adapter for the recycler view. * * @param owner The life cycle owner of this view. * @param layout The layout resource containing the theme preview. * @param dynamicPresetsListener The listener to receive the preset events. * * @see ThemePreview * @see androidx.lifecycle.LifecycleOwner * @see ViewModelStoreOwner */ public void setPresetsAdapter(@Nullable Fragment owner, @LayoutRes int layout, @Nullable DynamicPresetsView.DynamicPresetsListener<T> dynamicPresetsListener) { this.mLifecycleOwner = owner; this.mDynamicPresetsListener = dynamicPresetsListener; mPresetsAdapter = new DynamicPresetsAdapter<>(getContext(), getType(), layout); mPresetsAdapter.setDynamicPresetsListener(dynamicPresetsListener); setAdapter(mPresetsAdapter); if (owner != null) { owner.getLifecycle().addObserver(this); } loadPresets(); }
Example #4
Source File: ConversationAdapter.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
private static @LayoutRes int getLayoutForViewType(int viewType) { switch (viewType) { case MESSAGE_TYPE_OUTGOING_TEXT: return R.layout.conversation_item_sent_text_only; case MESSAGE_TYPE_OUTGOING_MULTIMEDIA: return R.layout.conversation_item_sent_multimedia; case MESSAGE_TYPE_INCOMING_TEXT: return R.layout.conversation_item_received_text_only; case MESSAGE_TYPE_INCOMING_MULTIMEDIA: return R.layout.conversation_item_received_multimedia; case MESSAGE_TYPE_UPDATE: return R.layout.conversation_item_update; default: throw new IllegalArgumentException("Unknown type!"); } }
Example #5
Source File: ArtistAdapter.java From Music-Player with GNU General Public License v3.0 | 5 votes |
public ArtistAdapter(@NonNull AppCompatActivity activity, List<Artist> dataSet, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder) { super(activity, cabHolder, R.menu.menu_media_selection); this.activity = activity; this.dataSet = dataSet; this.itemLayoutRes = itemLayoutRes; this.usePalette = usePalette; setHasStableIds(true); }
Example #6
Source File: SnackbarUtil.java From weather with Apache License 2.0 | 5 votes |
/** * Add view to the snackbar. * <p>Call it after {@link #show()}</p> * * @param layoutId The id of layout. * @param params The params. */ public static void addView(@LayoutRes final int layoutId, @NonNull final ViewGroup.LayoutParams params) { final View view = getView(); if (view != null) { view.setPadding(0, 0, 0, 0); Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) view; View child = LayoutInflater.from(view.getContext()).inflate(layoutId, null); layout.addView(child, -1, params); } }
Example #7
Source File: DNSRecordsAdapter.java From DNSHero with GNU General Public License v3.0 | 5 votes |
ViewHolder(ViewGroup parent, @LayoutRes int headerRes) { super(inflater.inflate(R.layout.item_dns_record, parent, false)); name = itemView.findViewById(R.id.dnsRecordItem_name); ttl = itemView.findViewById(R.id.dnsRecordItem_ttl); toggle = itemView.findViewById(R.id.dnsRecordItem_toggle); details = itemView.findViewById(R.id.dnsRecordItem_details); sources = itemView.findViewById(R.id.dnsRecordItem_sources); header = itemView.findViewById(R.id.dnsRecordItem_header); inflater.inflate(headerRes, header, true); }
Example #8
Source File: FieldViewFactory.java From ground-android with Apache License 2.0 | 5 votes |
private static @LayoutRes int getLayoutId(Field.Type fieldType) { switch (fieldType) { case TEXT: return R.layout.text_input_field; case MULTIPLE_CHOICE: return R.layout.multiple_choice_input_field; case PHOTO: return R.layout.photo_input_field; default: throw new IllegalArgumentException("Unsupported field type: " + fieldType); } }
Example #9
Source File: AlbumAdapter.java From Music-Player with GNU General Public License v3.0 | 5 votes |
public AlbumAdapter(@NonNull AppCompatActivity activity, List<Album> dataSet, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder) { super(activity, cabHolder, R.menu.menu_media_selection); this.activity = activity; this.dataSet = dataSet; this.itemLayoutRes = itemLayoutRes; this.usePalette = usePalette; setHasStableIds(true); }
Example #10
Source File: AMPMTimePopupWithHeader.java From arcusandroid with Apache License 2.0 | 5 votes |
@Override @Nullable @LayoutRes public Integer headerSectionLayout() { if (isTimeOnlyPicker() || isHourOnlyPicker()) { return null; } else { return R.layout.floating_start_end_all_day_content_header; } }
Example #11
Source File: IToastImpl.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 设置 Toast 显示的 View * @param layoutId R.layout.id */ @Override public void setView(@LayoutRes final int layoutId) { if (mConfigToast != null) { try { setView(View.inflate(mConfigToast.getView().getContext().getApplicationContext(), layoutId, null)); } catch (Exception e) { } // 如果是 null, 则抛出异常 if (mConfigToast.isEmptyMessageView()) { // 如果设置的布局没有包含一个 TextView 则抛出异常, 必须要包含一个 TextView 作为 Message View throw new IllegalArgumentException("The layout must contain a TextView"); } } }
Example #12
Source File: ViewUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 获取 View * @param resource R.layout.id * @param root {@link ViewGroup} * @param attachToRoot 是否添加到 root 上 * @return {@link View} */ public static View inflate(@LayoutRes final int resource, final ViewGroup root, final boolean attachToRoot) { try { return LayoutInflater.from(DevUtils.getContext()).inflate(resource, root, attachToRoot); } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "inflate"); } return null; }
Example #13
Source File: SongAdapter.java From Music-Player with GNU General Public License v3.0 | 5 votes |
public SongAdapter(AppCompatActivity activity, List<Song> dataSet, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder, boolean showSectionName) { super(activity, cabHolder, R.menu.menu_media_selection); this.activity = activity; this.dataSet = dataSet; this.itemLayoutRes = itemLayoutRes; this.usePalette = usePalette; this.showSectionName = showSectionName; setHasStableIds(true); }
Example #14
Source File: ViewUtil.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") public static <T extends View> T inflate(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent, @LayoutRes int layoutResId) { return (T)(inflater.inflate(layoutResId, parent, false)); }
Example #15
Source File: DynamicEmptyView.java From dynamic-support with Apache License 2.0 | 4 votes |
@Override protected @LayoutRes int getLayoutRes() { return R.layout.ads_empty_view; }
Example #16
Source File: PlaylistSongAdapter.java From Music-Player with GNU General Public License v3.0 | 4 votes |
public PlaylistSongAdapter(AppCompatActivity activity, @NonNull List<Song> dataSet, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder) { super(activity, dataSet, itemLayoutRes, usePalette, cabHolder, false); setMultiSelectMenuRes(R.menu.menu_cannot_delete_single_songs_playlist_songs_selection); }
Example #17
Source File: Container.java From SugarAdapter with Apache License 2.0 | 4 votes |
@LayoutRes int getLayoutRes() { return mLayoutRes; }
Example #18
Source File: ThemedAppCompatPreferenceActivity.java From lrkFM with MIT License | 4 votes |
@Override public void setContentView(@LayoutRes int layoutResID) { getDelegate().setContentView(layoutResID); }
Example #19
Source File: DynamicThemePreview.java From dynamic-support with Apache License 2.0 | 4 votes |
@Override protected @LayoutRes int getLayoutRes() { return R.layout.ads_theme_preview; }
Example #20
Source File: MenuWidget.java From FirefoxReality with Mozilla Public License 2.0 | 4 votes |
private void initialize(Context aContext, @LayoutRes int layout, ArrayList<MenuItem> aItems) { mLayoutRes = layout; updateUI(); }
Example #21
Source File: AlertDialog.java From HaoReader with GNU General Public License v3.0 | 4 votes |
public Builder setView(@LayoutRes int layoutResId) { P.mViewLayoutResId = layoutResId; return this; }
Example #22
Source File: MenuWidget.java From FirefoxReality with Mozilla Public License 2.0 | 4 votes |
public MenuWidget(Context aContext, @LayoutRes int layout) { super(aContext); initialize(aContext, layout, null); }
Example #23
Source File: NotificationManager.java From FirefoxReality with Mozilla Public License 2.0 | 4 votes |
public Builder withLayout(@LayoutRes int res) { this.layoutRes = res; return this; }
Example #24
Source File: AbsLibraryPagerRecyclerViewFragment.java From Music-Player with GNU General Public License v3.0 | 4 votes |
@LayoutRes protected int getLayoutRes() { return R.layout.fragment_main_activity_recycler_view; }
Example #25
Source File: DynamicThemePreference.java From dynamic-support with Apache License 2.0 | 4 votes |
@Override protected @LayoutRes int getLayoutRes() { return R.layout.ads_preference_theme; }
Example #26
Source File: BaseActivity.java From guarda-android-wallets with GNU General Public License v3.0 | 4 votes |
protected abstract @LayoutRes int getLayout();
Example #27
Source File: PlayingQueueAdapter.java From Music-Player with GNU General Public License v3.0 | 4 votes |
public PlayingQueueAdapter(AppCompatActivity activity, List<Song> dataSet, int current, @LayoutRes int itemLayoutRes, boolean usePalette, @Nullable CabHolder cabHolder) { super(activity, dataSet, itemLayoutRes, usePalette, cabHolder); this.current = current; }
Example #28
Source File: BaseFragment.java From guarda-android-wallets with GNU General Public License v3.0 | 4 votes |
abstract protected @LayoutRes int getLayout();
Example #29
Source File: DynamicSeekBarCompact.java From dynamic-support with Apache License 2.0 | 4 votes |
@Override protected @LayoutRes int getLayoutRes() { return R.layout.ads_seek_bar_compact; }
Example #30
Source File: DynamicPresetsView.java From dynamic-support with Apache License 2.0 | 4 votes |
@Override protected @LayoutRes int getLayoutRes() { return R.layout.ads_theme_presets; }