Skip to content

Commit

Permalink
Parse & use animated status from dribbble API responses.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Jan 20, 2016
1 parent 5381b10 commit c0cc555
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
15 changes: 13 additions & 2 deletions app/src/main/java/io/plaidapp/data/api/dribbble/model/Shot.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class Shot extends PlaidItem implements Parcelable {
public final String likes_url;
public final String projects_url;
public final String rebounds_url;
public final boolean animated;
public final List<String> tags;
public User user;
public final Team team;
Expand Down Expand Up @@ -84,6 +85,7 @@ public Shot(long id,
String likes_url,
String projects_url,
String rebounds_url,
boolean animated,
List<String> tags,
User user,
Team team) {
Expand All @@ -107,6 +109,7 @@ public Shot(long id,
this.likes_url = likes_url;
this.projects_url = projects_url;
this.rebounds_url = rebounds_url;
this.animated = animated;
this.tags = tags;
this.user = user;
this.team = team;
Expand Down Expand Up @@ -136,6 +139,7 @@ protected Shot(Parcel in) {
likes_url = in.readString();
projects_url = in.readString();
rebounds_url = in.readString();
animated = in.readByte() != 0x00;
tags = new ArrayList<String>();
in.readStringList(tags);
user = (User) in.readValue(User.class.getClassLoader());
Expand Down Expand Up @@ -179,6 +183,7 @@ public static class Builder {
private String likes_url;
private String projects_url;
private String rebounds_url;
private boolean animated;
private List<String> tags;
private User user;
private Team team;
Expand Down Expand Up @@ -288,6 +293,11 @@ public Builder setReboundsUrl(String rebounds_url) {
return this;
}

public Builder setAnimated(boolean animated) {
this.animated = animated;
return this;
}

public Builder setTags(List<String> tags) {
this.tags = tags;
return this;
Expand All @@ -307,8 +317,8 @@ public Shot build() {
return new Shot(id, title, description, width, height, images, views_count,
likes_count, comments_count, attachments_count, rebounds_count,
buckets_count, created_at, updated_at, html_url, attachments_url,
buckets_url, comments_url, likes_url, projects_url, rebounds_url, tags, user,
team);
buckets_url, comments_url, likes_url, projects_url, rebounds_url, animated,
tags, user, team);
}
}

Expand Down Expand Up @@ -356,6 +366,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(likes_url);
dest.writeString(projects_url);
dest.writeString(rebounds_url);
dest.writeByte((byte) (animated ? 0x01 : 0x00));
dest.writeStringList(tags);
dest.writeValue(user);
dest.writeValue(team);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/io/plaidapp/ui/FeedAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ public boolean onException(Exception e, String model, Target<GlideDrawable>
.fitCenter()
.override(imageSize[0], imageSize[1])
.into(new DribbbleTarget(holder.image, false));
holder.image.showBadge(shot.animated);
}

@NonNull
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/io/plaidapp/util/glide/DribbbleTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ public void onResourceReady(GlideDrawable resource, GlideAnimation<? super Glide
Palette.from(((GlideBitmapDrawable) resource).getBitmap())
.clearFilters()
.generate(this);
badgedImageView.showBadge(false);
} else if (resource instanceof GifDrawable) {
Bitmap image = ((GifDrawable) resource).getFirstFrame();
Palette.from(image).clearFilters().generate(this);
badgedImageView.showBadge(true);

// look at the corner to determine the gif badge color
int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics
Expand Down

0 comments on commit c0cc555

Please sign in to comment.