类androidx.annotation.DrawableRes源码实例Demo

下面列出了怎么用androidx.annotation.DrawableRes的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: mollyim-android   文件: TransportOption.java
public TransportOption(@NonNull  Type type,
                       @DrawableRes int drawable,
                       int backgroundColor,
                       @NonNull String text,
                       @NonNull String composeHint,
                       @NonNull CharacterCalculator characterCalculator,
                       @NonNull Optional<CharSequence> simName,
                       @NonNull Optional<Integer> simSubscriptionId)
{
  this.type                = type;
  this.drawable            = drawable;
  this.backgroundColor     = backgroundColor;
  this.text                = text;
  this.composeHint         = composeHint;
  this.characterCalculator = characterCalculator;
  this.simName             = simName;
  this.simSubscriptionId   = simSubscriptionId;
}
 
源代码2 项目: lttrs-android   文件: QueryItemTouchHelper.java
@Override
public int getSwipeDirs(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
    if (viewHolder instanceof ThreadOverviewAdapter.ThreadOverviewViewHolder) {
        final ThreadOverviewAdapter.ThreadOverviewViewHolder threadOverviewViewHolder = (ThreadOverviewAdapter.ThreadOverviewViewHolder) viewHolder;
        if (onQueryItemSwipe != null) {
            final Swipable swipable = onQueryItemSwipe.onQueryItemSwipe(viewHolder.getAdapterPosition());
            if (swipable == Swipable.NO) {
                return 0;
            }
            @DrawableRes final int resource;
            switch (swipable) {
                case ARCHIVE:
                    resource = R.drawable.ic_archive_white_24dp;
                    break;
                case REMOVE_FLAGGED:
                    resource = R.drawable.ic_star_border_white_24dp;
                    break;
                default:
                    resource = R.drawable.ic_label_off_white_24dp;
                    break;

            }
            threadOverviewViewHolder.binding.endSwipeActionIndicator.setImageResource(resource);
            threadOverviewViewHolder.binding.startSwipeActionIndicator.setImageResource(resource);
            return ItemTouchHelper.RIGHT | ItemTouchHelper.LEFT;
        }
    }
    return 0;
}
 
源代码3 项目: media-samples   文件: MainActivity.java
/**
 * Update the state of pause/resume action item in Picture-in-Picture mode.
 *
 * @param iconId The icon to be used.
 * @param title The title text.
 * @param controlType The type of the action. either {@link #CONTROL_TYPE_PLAY} or {@link
 *     #CONTROL_TYPE_PAUSE}.
 * @param requestCode The request code for the {@link PendingIntent}.
 */
void updatePictureInPictureActions(
        @DrawableRes int iconId, String title, int controlType, int requestCode) {
    final ArrayList<RemoteAction> actions = new ArrayList<>();

    // This is the PendingIntent that is invoked when a user clicks on the action item.
    // You need to use distinct request codes for play and pause, or the PendingIntent won't
    // be properly updated.
    final PendingIntent intent =
            PendingIntent.getBroadcast(
                    MainActivity.this,
                    requestCode,
                    new Intent(ACTION_MEDIA_CONTROL).putExtra(EXTRA_CONTROL_TYPE, controlType),
                    0);
    final Icon icon = Icon.createWithResource(MainActivity.this, iconId);
    actions.add(new RemoteAction(icon, title, title, intent));

    // Another action item. This is a fixed action.
    actions.add(
            new RemoteAction(
                    Icon.createWithResource(MainActivity.this, R.drawable.ic_info_24dp),
                    getString(R.string.info),
                    getString(R.string.info_description),
                    PendingIntent.getActivity(
                            MainActivity.this,
                            REQUEST_INFO,
                            new Intent(
                                    Intent.ACTION_VIEW,
                                    Uri.parse(getString(R.string.info_uri))),
                            0)));

    mPictureInPictureParamsBuilder.setActions(actions);

    // This is how you can update action items (or aspect ratio) for Picture-in-Picture mode.
    // Note this call can happen even when the app is not in PiP mode. In that case, the
    // arguments will be used for at the next call of #enterPictureInPictureMode.
    setPictureInPictureParams(mPictureInPictureParamsBuilder.build());
}
 
源代码4 项目: candybar   文件: Setting.java
public Setting(@DrawableRes int icon, String title, String subtitle, String content, String footer,
               @NonNull Setting.Type type, @IntRange(from = -1, to = 1) int checkState) {
    mIcon = icon;
    mTitle = title;
    mSubtitle = subtitle;
    mContent = content;
    mFooter = footer;
    mType = type;
    mCheckState = checkState;
}
 
源代码5 项目: mollyim-android   文件: RationaleDialog.java
public static AlertDialog.Builder createFor(@NonNull Context context, @NonNull String message, @DrawableRes int... drawables) {
  View      view   = LayoutInflater.from(context).inflate(R.layout.permissions_rationale_dialog, null);
  ViewGroup header = view.findViewById(R.id.header_container);
  TextView  text   = view.findViewById(R.id.message);

  for (int i=0;i<drawables.length;i++) {
    Drawable drawable = ContextCompat.getDrawable(context, drawables[i]);
    DrawableCompat.setTint(drawable, ContextCompat.getColor(context, R.color.white));
    ImageView imageView = new ImageView(context);
    imageView.setImageDrawable(drawable);
    imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    header.addView(imageView);

    if (i != drawables.length - 1) {
      TextView plus = new TextView(context);
      plus.setText("+");
      plus.setTextSize(TypedValue.COMPLEX_UNIT_SP, 40);
      plus.setTextColor(Color.WHITE);

      LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      layoutParams.setMargins(ViewUtil.dpToPx(context, 20), 0, ViewUtil.dpToPx(context, 20), 0);

      plus.setLayoutParams(layoutParams);
      header.addView(plus);
    }
  }

  text.setText(message);

  return new AlertDialog.Builder(context, ThemeUtil.isDarkTheme(context) ? R.style.Theme_Signal_AlertDialog_Dark_Cornered : R.style.Theme_Signal_AlertDialog_Light_Cornered)
                        .setView(view);
}
 
源代码6 项目: mollyim-android   文件: TransportOption.java
public TransportOption(@NonNull  Type type,
                       @DrawableRes int drawable,
                       int backgroundColor,
                       @NonNull String text,
                       @NonNull String composeHint,
                       @NonNull CharacterCalculator characterCalculator)
{
  this(type, drawable, backgroundColor, text, composeHint, characterCalculator,
       Optional.<CharSequence>absent(), Optional.<Integer>absent());
}
 
源代码7 项目: mollyim-android   文件: VerifyIdentityActivity.java
private Bitmap createVerifiedBitmap(int width, int height, @DrawableRes int id) {
  Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmap);
  Bitmap check  = BitmapFactory.decodeResource(getResources(), id);
  float  offset = (width - check.getWidth()) / 2;

  canvas.drawBitmap(check, offset, offset, null);

  return bitmap;
}
 
public static NotificationController startForegroundTask(@NonNull Context context, @NonNull String task, @NonNull String channelId, @DrawableRes int iconRes) {
  final int id = NEXT_ID.getAndIncrement();

  Intent intent = new Intent(context, GenericForegroundService.class);
  intent.setAction(ACTION_START);
  intent.putExtra(EXTRA_TITLE, task);
  intent.putExtra(EXTRA_CHANNEL_ID, channelId);
  intent.putExtra(EXTRA_ICON_RES, iconRes);
  intent.putExtra(EXTRA_ID, id);

  ContextCompat.startForegroundService(context, intent);

  return new NotificationController(context, id);
}
 
private Entry(@NonNull String title, @NonNull String channelId, @DrawableRes int iconRes, int id, int progressMax, int progress, boolean indeterminate) {
  this.title         = title;
  this.channelId     = channelId;
  this.iconRes       = iconRes;
  this.id            = id;
  this.progress      = progress;
  this.progressMax   = progressMax;
  this.indeterminate = indeterminate;
}
 
源代码10 项目: mollyim-android   文件: AvatarUtil.java
public static GlideRequest<Drawable> getSelfAvatarOrFallbackIcon(@NonNull Context context, @DrawableRes int fallbackIcon) {
  return GlideApp.with(context)
                 .asDrawable()
                 .load(new ProfileContactPhoto(Recipient.self(), Recipient.self().getProfileAvatar()))
                 .error(fallbackIcon)
                 .circleCrop()
                 .diskCacheStrategy(DiskCacheStrategy.ALL);
}
 
源代码11 项目: mollyim-android   文件: CallNotificationBuilder.java
private static NotificationCompat.Action getActivityNotificationAction(@NonNull Context context, @NonNull String action,
                                                                       @DrawableRes int iconResId, @StringRes int titleResId)
{
  Intent intent = new Intent(context, WebRtcCallActivity.class);
  intent.setAction(action);

  PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

  return new NotificationCompat.Action(iconResId, context.getString(titleResId), pendingIntent);
}
 
源代码12 项目: arcusandroid   文件: AbstractSetting.java
public AbstractSetting(String title, String description, @Nullable @DrawableRes Integer abstractIcon, int layoutId) {
    this.title = title;
    this.description = description;
    this.layoutId = layoutId;
    this.selectionAbstract = null;
    this.abstractIconResource = abstractIcon;
}
 
源代码13 项目: arcusandroid   文件: ArcusFloatingFragment.java
public void setCloseButtonIcon(@DrawableRes int buttonIcon) {
    if (closeBtn == null) {
        return;
    }

    closeBtn.setImageResource(buttonIcon);
}
 
源代码14 项目: Twire   文件: DialogService.java
private static MaterialSimpleListItem getThemeDialogAdapterItem(@StringRes int title, @DrawableRes int icon, Activity activity) {
    MaterialSimpleListItem.Builder builder = new MaterialSimpleListItem.Builder(activity)
            .content(title)
            .icon(icon);

    return builder.build();
}
 
源代码15 项目: RichEditor   文件: RichEditText.java
public void insertBlockImage(@DrawableRes int resourceId, @NonNull BlockImageSpanVm blockImageSpanVm,
                             OnImageClickListener onImageClickListener) {
    try {
        Drawable drawable = AppCompatResources.getDrawable(mActivity, resourceId);
        insertBlockImage(drawable, blockImageSpanVm, onImageClickListener);
    } catch (Exception e) {
        LogUtil.e(TAG, "Unable to find resource: " + resourceId);
    }
}
 
private Bitmap[] generateIconBitmaps(@DrawableRes int origin) {
  if (origin == -1) {
    return null;
  }
  BitmapFactory.Options options = new BitmapFactory.Options();
  options.inJustDecodeBounds = true;
  BitmapFactory.decodeResource(getResources(), origin, options);
  int size = Math.max(options.outWidth, options.outHeight);
  options.inSampleSize = size > iconSize ? size / iconSize : 1;
  options.inJustDecodeBounds = false;
  return generateIconBitmaps(BitmapFactory.decodeResource(getResources(), origin, options));
}
 
源代码17 项目: animation-samples   文件: ImageFragment.java
public static ImageFragment newInstance(@DrawableRes int drawableRes) {
  ImageFragment fragment = new ImageFragment();
  Bundle argument = new Bundle();
  argument.putInt(KEY_IMAGE_RES, drawableRes);
  fragment.setArguments(argument);
  return fragment;
}
 
源代码18 项目: Twire   文件: AppearanceSettingsFragment.java
private Drawable getColorPreviewFromTheme(String themeTitle) {
    @DrawableRes int drawableRes = R.drawable.circle_theme_blue_chooser;

    if (themeTitle.equals(getString(R.string.purple_theme_name))) {
        drawableRes = R.drawable.circle_theme_purple_chooser;
    } else if (themeTitle.equals(getString(R.string.black_theme_name))) {
        drawableRes = R.drawable.circle_theme_black_chooser;
    } else if (themeTitle.equals(getString(R.string.night_theme_name))) {
        drawableRes = R.drawable.circle_theme_night_chooser;
    }

    return ContextCompat.getDrawable(getContext(), drawableRes);
}
 
源代码19 项目: BaldPhone   文件: BatteryView.java
public void setLevel(int level, boolean charged) {
    percentage = level;
    @DrawableRes int drawableRes = R.drawable.battery_unknown_on_background;
    if (charged) {
        if (level < 20) {
            drawableRes = R.drawable.battery_20_c_on_background;
        } else if (level < 30) {
            drawableRes = R.drawable.battery_30_c_on_background;
        } else if (level < 50) {
            drawableRes = R.drawable.battery_50_c_on_background;
        } else if (level < 60) {
            drawableRes = R.drawable.battery_60_c_on_background;
        } else if (level < 80) {
            drawableRes = R.drawable.battery_80_c_on_background;
        } else if (level < 90) {
            drawableRes = R.drawable.battery_90_c_on_background;
        } else if (level < 100) {
            drawableRes = R.drawable.battery_100_charging;
        } else
            drawableRes = R.drawable.battery_full_on_background;
    } else {
        if (level < D.LOW_BATTERY_LEVEL) {
            drawableRes = R.drawable.battery_20_on_background;
        } else if (level < 30) {
            drawableRes = R.drawable.battery_30_on_background;
        } else if (level < 50) {
            drawableRes = R.drawable.battery_50_on_background;
        } else if (level < 60) {
            drawableRes = R.drawable.battery_60_on_background;
        } else if (level < 80) {
            drawableRes = R.drawable.battery_80_on_background;
        } else if (level < 90) {
            drawableRes = R.drawable.battery_90_on_background;
        } else if (level <= 100) {
            drawableRes = R.drawable.battery_full_on_background;
        }

    }
    setImageResource(drawableRes);
}
 
源代码20 项目: MHViewer   文件: DrawableManager.java
public static Drawable getVectorDrawable(@NonNull Resources res,
        @DrawableRes int resId, @Nullable Resources.Theme theme) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return res.getDrawable(resId, theme);
    } else {
        return VectorDrawableCompat.create(res, resId, theme);
    }
}
 
源代码21 项目: worldCountryData   文件: Country.java
void setFlagResource(@DrawableRes final int flagResource) {
  this.flagResource = flagResource;
}
 
源代码22 项目: crashx   文件: CrashConfig.java
@Nullable
@DrawableRes
public Integer getErrorDrawable() {
    return errorDrawable;
}
 
源代码23 项目: crashx   文件: CrashConfig.java
public void setErrorDrawable(@Nullable @DrawableRes Integer errorDrawable) {
    this.errorDrawable = errorDrawable;
}
 
源代码24 项目: wearmouse   文件: OnboardingResources.java
private OnboardingResources(
        @DrawableRes int icon, @StringRes int title, @StringRes int message) {
    iconResId = icon;
    titleResId = title;
    messageResId = message;
}
 
源代码25 项目: BaldPhone   文件: FirstPageAppIcon.java
public void setImageResource(@DrawableRes int resId) {
    imageView.setImageResource(resId);
}
 
源代码26 项目: candybar   文件: PopupItem.java
public PopupItem setIcon(@DrawableRes int icon) {
    mIcon = icon;
    return this;
}
 
源代码27 项目: candybar   文件: PopupItem.java
@DrawableRes
public int getIcon() {
    return mIcon;
}
 
源代码28 项目: BaldPhone   文件: SettingsActivity.java
BDBSettingsItem(@StringRes int textResId, BDB bdb, @DrawableRes int drawableResId) {
    super(textResId, drawableResId);
    this.bdb = bdb;
}
 
源代码29 项目: tv-samples   文件: ChannelContents.java
/**
 * Channel Logo for published program
 */
private void createChannelLogo(Context context, long channelId,
                               @DrawableRes int drawableId) {
    Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), drawableId);
    ChannelLogoUtils.storeChannelLogo(context, channelId, bitmap);
}
 
源代码30 项目: BaldPhone   文件: HelpRecyclerViewAdapter.java
public HelpRecyclerViewAdapter(@NonNull final Context context, @StringRes final int[] texts, @DrawableRes final int[] pics) {
    inflater = LayoutInflater.from(context);
    this.pics = pics;
    this.texts = texts;
}