/** * returns the type of the Item. Can be a hardcoded INT, but preferred is a defined id * * @return */ @IdRes int getType();
public static <T> T findOptionalViewAsType(View source, @IdRes int id, String who, Class<T> cls) { View view = source.findViewById(id); return castView(view, id, who, cls); }
/** * Asynchronously fulfills the request into the specified {@link RemoteViews} object with the * given {@code viewId}. This is used for loading bitmaps into a {@link Notification}. */ public void into(@NonNull RemoteViews remoteViews, @IdRes int viewId, int notificationId, @NonNull Notification notification, @Nullable String notificationTag) { into(remoteViews, viewId, notificationId, notification, notificationTag, null); }
/** * Asynchronously fulfills the request into the specified {@link RemoteViews} object with the * given {@code viewId}. This is used for loading bitmaps into all instances of a widget. */ public void into(@NonNull RemoteViews remoteViews, @IdRes int viewId, int appWidgetId, @Nullable Callback callback) { into(remoteViews, viewId, new int[] { appWidgetId }, callback); }
/** * Asynchronously fulfills the request into the specified {@link RemoteViews} object with the * given {@code viewId}. This is used for loading bitmaps into all instances of a widget. */ public void into(@NonNull RemoteViews remoteViews, @IdRes int viewId, int appWidgetId) { into(remoteViews, viewId, new int[] { appWidgetId }, null); }
/** * Asynchronously fulfills the request into the specified {@link RemoteViews} object with the * given {@code viewId}. This is used for loading bitmaps into a {@link Notification}. */ public void into(@NonNull RemoteViews remoteViews, @IdRes int viewId, int notificationId, @NonNull Notification notification) { into(remoteViews, viewId, notificationId, notification, null); }
/** * Asynchronously fulfills the request into the specified {@link RemoteViews} object with the * given {@code viewId}. This is used for loading bitmaps into all instances of a widget. */ public void into(@NonNull RemoteViews remoteViews, @IdRes int viewId, @NonNull int[] appWidgetIds) { into(remoteViews, viewId, appWidgetIds, null); }
public static <T> T castView(View view, @IdRes int id, String who, Class<T> cls) { try { return cls.cast(view); } catch (ClassCastException e) { String name = getResourceEntryName(view, id); throw new IllegalStateException("View '" + name + "' with ID " + id + " for " + who + " was of the wrong type. See cause for more info.", e); } }
public static View findRequiredView(View source, @IdRes int id, String who) { View view = source.findViewById(id); if (view != null) { return view; } String name = getResourceEntryName(source, id); throw new IllegalStateException("Required view '" + name + "' with ID " + id + " for " + who + " was not found. If this view is optional add '@Nullable' (fields) or '@Optional'" + " (methods) annotation."); }
/** * Sets the rootView which will host the DrawerLayout * The content of this view will be extracted and added as the new content inside the drawerLayout * * @param rootViewRes the id of a view which will get switched out by the DrawerLayout and added as its child */ public DrawerBuilder withRootView(@IdRes int rootViewRes) { if (mActivity == null) { throw new RuntimeException("please pass an activity first to use this call"); } return withRootView((ViewGroup) mActivity.findViewById(rootViewRes)); }
private static String getResourceEntryName(View view, @IdRes int id) { if (view.isInEditMode()) { return "<unavailable while editing>"; } return view.getContext().getResources().getResourceEntryName(id); }
/** Return a tap target for the menu item from the given toolbar **/ public static TapTarget forToolbarMenuItem(android.widget.Toolbar toolbar, @IdRes int menuItemId, CharSequence title, @Nullable CharSequence description) { return new ToolbarTapTarget(toolbar, menuItemId, title, description); }
/** Return a tap target for the menu item from the given toolbar **/ public static TapTarget forToolbarMenuItem(Toolbar toolbar, @IdRes int menuItemId, CharSequence title, @Nullable CharSequence description) { return new ToolbarTapTarget(toolbar, menuItemId, title, description); }
/** Return a tap target for the menu item from the given toolbar **/ public static TapTarget forToolbarMenuItem(Toolbar toolbar, @IdRes int menuItemId, CharSequence title) { return forToolbarMenuItem(toolbar, menuItemId, title, null); }
/** Return a tap target for the menu item from the given toolbar **/ public static TapTarget forToolbarMenuItem(android.widget.Toolbar toolbar, @IdRes int menuItemId, CharSequence title) { return forToolbarMenuItem(toolbar, menuItemId, title, null); }
ToolbarTapTarget(android.widget.Toolbar toolbar, @IdRes int menuItemId, CharSequence title, @Nullable CharSequence description) { super(toolbar.findViewById(menuItemId), title, description); }
ToolbarTapTarget(Toolbar toolbar, @IdRes int menuItemId, CharSequence title, @Nullable CharSequence description) { super(toolbar.findViewById(menuItemId), title, description); }
public static <T> T findRequiredViewAsType(View source, @IdRes int id, String who, Class<T> cls) { View view = findRequiredView(source, id, who); return castView(view, id, who, cls); }
@IdRes private int hostId; private String tag; private boolean isDetachFrozen;
/** * Cancel any existing requests for the specified {@link RemoteViews} target with the given {@code * viewId}. */ public void cancelRequest(@NonNull RemoteViews remoteViews, @IdRes int viewId) { // checkMain() is called from cancelExistingRequest() checkNotNull(remoteViews, "remoteViews == null"); cancelExistingRequest(new RemoteViewsAction.RemoteViewsTarget(remoteViews, viewId)); }