Skip to content

Commit

Permalink
Remove unnecessary image load from storage calls
Browse files Browse the repository at this point in the history
The LoyaltyCard object itself loads the images itself
  • Loading branch information
TheLastProject committed Dec 5, 2024
1 parent 7b25548 commit 5efa933
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public Flow.Publisher<Control> createPublisherFor(@NonNull List<String> controlI
}

private Bitmap getIcon(Context context, LoyaltyCard loyaltyCard) {
Bitmap cardIcon = Utils.retrieveCardImage(context, loyaltyCard.id, ImageLocationType.icon);
Bitmap cardIcon = loyaltyCard.getImageThumbnail(context);

if (cardIcon != null) {
return cardIcon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void onBindViewHolder(LoyaltyCardListItemViewHolder inputHolder, Cursor i
inputHolder.mDivider.setVisibility(View.GONE);

LoyaltyCard loyaltyCard = LoyaltyCard.fromCursor(mContext, inputCursor);
Bitmap icon = Utils.retrieveCardImage(mContext, loyaltyCard.id, ImageLocationType.icon);
Bitmap icon = loyaltyCard.getImageThumbnail(mContext);

if (mLoyaltyCardListDisplayOptions.showingNameBelowThumbnail() && icon != null) {
showDivider = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public void onStopTrackingTouch(SeekBar seekBar) {
binding.bottomAppBarUpdateBalanceButton.setOnClickListener(view -> showBalanceUpdateDialog());

binding.iconContainer.setOnClickListener(view -> {
if (Utils.retrieveCardImage(this, loyaltyCard.id, ImageLocationType.icon) != null) {
if (loyaltyCard.getImageThumbnail(this) != null) {
openImageInGallery(ImageType.ICON);
} else {
Toast.makeText(LoyaltyCardViewActivity.this, R.string.icon_header_click_text, Toast.LENGTH_LONG).show();
Expand Down Expand Up @@ -719,7 +719,7 @@ protected void onResume() {
editButtonIcon.setTint(Utils.needsDarkForeground(complementaryColor) ? Color.BLACK : Color.WHITE);
binding.fabEdit.setImageDrawable(editButtonIcon);

Bitmap icon = Utils.retrieveCardImage(this, loyaltyCard.id, ImageLocationType.icon);
Bitmap icon = loyaltyCard.getImageThumbnail(this);
Utils.setIconOrTextWithBackground(this, loyaltyCard, icon, binding.iconImage, binding.iconText, 1);

// If the background is very bright, we should use dark icons
Expand Down Expand Up @@ -748,12 +748,12 @@ protected void onResume() {
imageTypes.add(ImageType.BARCODE);
}

frontImageBitmap = Utils.retrieveCardImage(this, loyaltyCard.id, ImageLocationType.front);
frontImageBitmap = loyaltyCard.getImageFront(this);
if (frontImageBitmap != null) {
imageTypes.add(ImageType.IMAGE_FRONT);
}

backImageBitmap = Utils.retrieveCardImage(this, loyaltyCard.id, ImageLocationType.back);
backImageBitmap = loyaltyCard.getImageBack(this);
if (backImageBitmap != null) {
imageTypes.add(ImageType.IMAGE_BACK);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/protect/card_locker/ShortcutHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static ShortcutInfoCompat.Builder createShortcutBuilder(Context context, Loyalty
bundle.putInt(LoyaltyCardViewActivity.BUNDLE_ID, loyaltyCard.id);
intent.putExtras(bundle);

Bitmap iconBitmap = Utils.retrieveCardImage(context, loyaltyCard.id, ImageLocationType.icon);
Bitmap iconBitmap = loyaltyCard.getImageThumbnail(context);
if (iconBitmap == null) {
iconBitmap = Utils.generateIcon(context, loyaltyCard, true).getLetterTile();
} else {
Expand Down

0 comments on commit 5efa933

Please sign in to comment.