Skip to content

Adding optional images for left-to-right languages#1

Merged
capezzbr merged 4 commits into
masterfrom
mattc-add-images
Aug 16, 2018
Merged

Adding optional images for left-to-right languages#1
capezzbr merged 4 commits into
masterfrom
mattc-add-images

Conversation

@mcleinman

Copy link
Copy Markdown

Please review @capezzbr
Attn: @Expensify/mobile

This adds images for our Android Tag View.

  • The parent TagContainerLayout takes a default image, which then propagates to the TagViews.
  • If images are present, cells resize appropriately. Images are tucked into the left side of the TagView, leaving space for the border around them.
  • Images only work on LTR languages. RTL languages should never display images - I added a check in the logic to prevent display.
  • The sample project now incorporates Glide to show how we can dynamically pull in images, along with a default/backup image. This is, of course, how we'll use the updated library in our app.

Please make sure to try changing the image URL in the test project - I was having some issues in with image requests from new servers (that the simulator had not used before) failing, which may be related to some sort of caching from Glide. (If I relaunched the simulator, it would resolve itself for those same images.) I've seen reports of similar behavior when searching for a solution, but after a clean build it started working just fine. This should still be well-tested, though.

@mcleinman mcleinman self-assigned this Aug 16, 2018
@mcleinman mcleinman requested a review from capezzbr August 16, 2018 00:54

@capezzbr capezzbr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff, left some comments, let me know what you think

final int index = i;
Glide.with(mTagContainerLayout1.getContext())
.asBitmap()
.load("https://d1marr3m5x4iac.cloudfront.net/images/block/movies/17214/17214_aa.jpg")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the image is a big one, remember to ask Glide to resize it for you, so that this will get cached resized, which will improve performances

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
mTagContainerLayout1.getTagView(index).setImage(resource);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might want to update the code to:

  • move the for loop within this block

or

  • add a sleep after each iteration

since as it is right now, I'm afraid can be inclined to some concurrency issues

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving for loop as is, as I meant to showcase various images - I've updated the code to do this.

I added a sleep in, and refactored this code a bit (because that function was getting giant).

Can you explain a bit more about why you're concerned about concurrency here?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I was just worried about the fact that we're asking Glide to fetch the same assets in a for loop. For this demo purpose I really like your updated solution, 👍

@capezzbr

Copy link
Copy Markdown

LGTM 👍 thanks for updating 🙌

@capezzbr capezzbr merged commit 71a8ca0 into master Aug 16, 2018
@capezzbr capezzbr deleted the mattc-add-images branch August 16, 2018 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants