Use the new CDN url scheme for thumbnails #1216
12 changed files with 63 additions and 13 deletions
|
@ -2102,7 +2102,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
if (nowPlayingClaimBitmap == null &&
|
if (nowPlayingClaimBitmap == null &&
|
||||||
nowPlayingClaim != null &&
|
nowPlayingClaim != null &&
|
||||||
!Helper.isNullOrEmpty(nowPlayingClaim.getThumbnailUrl())) {
|
!Helper.isNullOrEmpty(nowPlayingClaim.getThumbnailUrl())) {
|
||||||
Glide.with(getApplicationContext()).asBitmap().load(nowPlayingClaim.getThumbnailUrl()).into(new CustomTarget<Bitmap>() {
|
Glide.with(getApplicationContext()).asBitmap().load(nowPlayingClaim.getThumbnailUrl(0, 0, 75)).into(new CustomTarget<Bitmap>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
||||||
nowPlayingClaimBitmap = resource;
|
nowPlayingClaimBitmap = resource;
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class ChannelFilterListAdapter extends RecyclerView.Adapter<ChannelFilter
|
||||||
vh.allView.setVisibility(claim.isPlaceholder() ? View.VISIBLE : View.GONE);
|
vh.allView.setVisibility(claim.isPlaceholder() ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
|
vh.titleView.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
|
||||||
String thumbnailUrl = claim.getThumbnailUrl();
|
String thumbnailUrl = claim.getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85);
|
||||||
if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) {
|
if (!Helper.isNullOrEmpty(thumbnailUrl) && context != null) {
|
||||||
Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
|
Glide.with(context.getApplicationContext()).load(thumbnailUrl).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,7 +334,8 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
|
||||||
if (metadata instanceof Claim.StreamMetadata) {
|
if (metadata instanceof Claim.StreamMetadata) {
|
||||||
streamMetadata = (Claim.StreamMetadata) metadata;
|
streamMetadata = (Claim.StreamMetadata) metadata;
|
||||||
}
|
}
|
||||||
String thumbnailUrl = item.getThumbnailUrl();
|
|
||||||
|
String thumbnailUrl = item.getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85);
|
||||||
long publishTime = (streamMetadata != null && streamMetadata.getReleaseTime() > 0) ? streamMetadata.getReleaseTime() * 1000 : item.getTimestamp() * 1000;
|
long publishTime = (streamMetadata != null && streamMetadata.getReleaseTime() > 0) ? streamMetadata.getReleaseTime() * 1000 : item.getTimestamp() * 1000;
|
||||||
int bgColor = Helper.generateRandomColorForValue(item.getClaimId());
|
int bgColor = Helper.generateRandomColorForValue(item.getClaimId());
|
||||||
if (bgColor == 0) {
|
if (bgColor == 0) {
|
||||||
|
|
|
@ -190,7 +190,7 @@ public class CommentListAdapter extends RecyclerView.Adapter<CommentListAdapter.
|
||||||
int bgColor = Helper.generateRandomColorForValue(comment.getChannelId());
|
int bgColor = Helper.generateRandomColorForValue(comment.getChannelId());
|
||||||
Helper.setIconViewBackgroundColor(holder.noThumbnailView, bgColor, false, context);
|
Helper.setIconViewBackgroundColor(holder.noThumbnailView, bgColor, false, context);
|
||||||
if (hasThumbnail) {
|
if (hasThumbnail) {
|
||||||
Glide.with(context.getApplicationContext()).asBitmap().load(comment.getPoster().getThumbnailUrl()).
|
Glide.with(context.getApplicationContext()).asBitmap().load(comment.getPoster().getThumbnailUrl(holder.thumbnailView.getLayoutParams().width, holder.thumbnailView.getLayoutParams().height, 85)).
|
||||||
apply(RequestOptions.circleCropTransform()).into(holder.thumbnailView);
|
apply(RequestOptions.circleCropTransform()).into(holder.thumbnailView);
|
||||||
}
|
}
|
||||||
holder.alphaView.setText(comment.getChannelName() != null ? comment.getChannelName().substring(1, 2).toUpperCase() : null);
|
holder.alphaView.setText(comment.getChannelName() != null ? comment.getChannelName().substring(1, 2).toUpperCase() : null);
|
||||||
|
|
|
@ -193,7 +193,7 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
|
||||||
vh.thumbnailView.setVisibility(notification.getCommentAuthor() == null ? View.INVISIBLE : View.VISIBLE);
|
vh.thumbnailView.setVisibility(notification.getCommentAuthor() == null ? View.INVISIBLE : View.VISIBLE);
|
||||||
if (notification.getCommentAuthor() != null) {
|
if (notification.getCommentAuthor() != null) {
|
||||||
Glide.with(context.getApplicationContext()).load(
|
Glide.with(context.getApplicationContext()).load(
|
||||||
notification.getCommentAuthor().getThumbnailUrl()).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
|
notification.getCommentAuthor().getThumbnailUrl(vh.thumbnailView.getLayoutParams().width, vh.thumbnailView.getLayoutParams().height, 85)).apply(RequestOptions.circleCropTransform()).into(vh.thumbnailView);
|
||||||
}
|
}
|
||||||
|
|
||||||
vh.iconView.setVisibility(notification.getCommentAuthor() != null ? View.INVISIBLE : View.VISIBLE);
|
vh.iconView.setVisibility(notification.getCommentAuthor() != null ? View.INVISIBLE : View.VISIBLE);
|
||||||
|
|
|
@ -89,7 +89,8 @@ public class SuggestedChannelGridAdapter extends RecyclerView.Adapter<SuggestedC
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(SuggestedChannelGridAdapter.ViewHolder vh, int position) {
|
public void onBindViewHolder(SuggestedChannelGridAdapter.ViewHolder vh, int position) {
|
||||||
Claim claim = items.get(position);
|
Claim claim = items.get(position);
|
||||||
String thumbnailUrl = claim.getThumbnailUrl();
|
ViewGroup.LayoutParams lp = vh.thumbnailView.getLayoutParams();
|
||||||
|
String thumbnailUrl = claim.getThumbnailUrl(lp.width, lp.height, 85);
|
||||||
|
|
||||||
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
|
int bgColor = Helper.generateRandomColorForValue(claim.getClaimId());
|
||||||
Helper.setIconViewBackgroundColor(vh.noThumbnailView, bgColor, false, context);
|
Helper.setIconViewBackgroundColor(vh.noThumbnailView, bgColor, false, context);
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package io.lbry.browser.model;
|
package io.lbry.browser.model;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.gson.FieldNamingPolicy;
|
import com.google.gson.FieldNamingPolicy;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
@ -184,6 +186,21 @@ public class Claim {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the URL from the CDN where getting the image file
|
||||||
|
* @param width Pass zero for width and height for the full size image file
|
||||||
|
* @param height Pass zero for width and height for the full size image file
|
||||||
|
* @param q Desired quality for the image to be retrieved
|
||||||
|
* @return URL from the CDN from where image can be retrieved
|
||||||
|
*/
|
||||||
|
public String getThumbnailUrl(int width, int height, int q) {
|
||||||
|
if (value != null && value.getThumbnail() != null) {
|
||||||
|
ImageCDNUrl imageCDNUrl = new ImageCDNUrl(Math.max(width, 0), Math.max(height, 0), q, null, value.getThumbnail().getUrl());
|
||||||
|
return imageCDNUrl.toString();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCoverUrl() {
|
public String getCoverUrl() {
|
||||||
if (TYPE_CHANNEL.equals(valueType) && value != null && value instanceof ChannelMetadata && ((ChannelMetadata) value).getCover() != null) {
|
if (TYPE_CHANNEL.equals(valueType) && value != null && value instanceof ChannelMetadata && ((ChannelMetadata) value).getCover() != null) {
|
||||||
return ((ChannelMetadata) value).getCover().getUrl();
|
return ((ChannelMetadata) value).getCover().getUrl();
|
||||||
|
@ -491,6 +508,30 @@ public class Claim {
|
||||||
private String url;
|
private String url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object to be instantiated. In order to get the URLto the CDN, call toString() on it
|
||||||
|
*/
|
||||||
|
static class ImageCDNUrl {
|
||||||
|
private String appendedPath = "";
|
||||||
|
|
||||||
|
public ImageCDNUrl(int width, int height, int quality, @Nullable String format, String thumbnailUrl) {
|
||||||
|
if (width != 0 && height != 0)
|
||||||
|
appendedPath = "s:".concat(String.valueOf(width)).concat(":").concat(String.valueOf(height)).concat("/");
|
||||||
|
|
||||||
|
appendedPath = appendedPath.concat("quality:").concat(String.valueOf(quality)).concat("/");
|
||||||
|
|
||||||
|
appendedPath = appendedPath.concat("plain/").concat(thumbnailUrl);
|
||||||
|
|
||||||
|
if (format != null)
|
||||||
|
appendedPath = appendedPath.concat("@").concat(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
String url = "https://image-processor.vanwanet.com/optimize/";
|
||||||
|
return url.concat(appendedPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
@Data
|
@Data
|
||||||
public static class StreamInfo {
|
public static class StreamInfo {
|
||||||
private long duration; // video / audio
|
private long duration; // video / audio
|
||||||
|
|
|
@ -467,7 +467,7 @@ public class ChannelCommentsFragment extends Fragment implements SdkStatusListen
|
||||||
if (hasThumbnail && context != null) {
|
if (hasThumbnail && context != null) {
|
||||||
Glide.with(context.getApplicationContext()).
|
Glide.with(context.getApplicationContext()).
|
||||||
asBitmap().
|
asBitmap().
|
||||||
load(channel.getThumbnailUrl()).
|
load(channel.getThumbnailUrl(commentPostAsThumbnail.getLayoutParams().width, commentPostAsThumbnail.getLayoutParams().height, 85)).
|
||||||
apply(RequestOptions.circleCropTransform()).
|
apply(RequestOptions.circleCropTransform()).
|
||||||
into(commentPostAsThumbnail);
|
into(commentPostAsThumbnail);
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ public class ChannelFormFragment extends BaseFragment implements
|
||||||
coverUrl = currentClaim.getCoverUrl();
|
coverUrl = currentClaim.getCoverUrl();
|
||||||
}
|
}
|
||||||
if (!Helper.isNullOrEmpty(currentClaim.getThumbnailUrl())) {
|
if (!Helper.isNullOrEmpty(currentClaim.getThumbnailUrl())) {
|
||||||
Glide.with(context.getApplicationContext()).load(currentClaim.getThumbnailUrl()).apply(RequestOptions.circleCropTransform()).into(imageThumbnail);
|
Glide.with(context.getApplicationContext()).load(currentClaim.getThumbnailUrl(imageThumbnail.getLayoutParams().width, imageThumbnail.getLayoutParams().height, 85)).apply(RequestOptions.circleCropTransform()).into(imageThumbnail);
|
||||||
thumbnailUrl = currentClaim.getThumbnailUrl();
|
thumbnailUrl = currentClaim.getThumbnailUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -538,11 +538,15 @@ public class ChannelFragment extends BaseFragment implements FetchChannelsListen
|
||||||
else
|
else
|
||||||
buttonTip.setVisibility(View.VISIBLE);
|
buttonTip.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
String thumbnailUrl = claim.getThumbnailUrl();
|
String thumbnailUrl = "";
|
||||||
String coverUrl = claim.getCoverUrl();
|
String coverUrl = claim.getCoverUrl();
|
||||||
textTitle.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
|
textTitle.setText(Helper.isNullOrEmpty(claim.getTitle()) ? claim.getName() : claim.getTitle());
|
||||||
|
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
|
|
||||||
|
if (context != null) {
|
||||||
|
thumbnailUrl = claim.getThumbnailUrl(imageThumbnail.getLayoutParams().width, imageThumbnail.getLayoutParams().height, 85);
|
||||||
|
}
|
||||||
if (context != null && !Helper.isNullOrEmpty(coverUrl)) {
|
if (context != null && !Helper.isNullOrEmpty(coverUrl)) {
|
||||||
Glide.with(context.getApplicationContext()).load(coverUrl).centerCrop().into(imageCover);
|
Glide.with(context.getApplicationContext()).load(coverUrl).centerCrop().into(imageCover);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1566,7 +1566,8 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
int bgColor = Helper.generateRandomColorForValue(signingChannel.getClaimId());
|
int bgColor = Helper.generateRandomColorForValue(signingChannel.getClaimId());
|
||||||
Helper.setIconViewBackgroundColor(root.findViewById(R.id.file_view_publisher_no_thumbnail), bgColor, false, context);
|
Helper.setIconViewBackgroundColor(root.findViewById(R.id.file_view_publisher_no_thumbnail), bgColor, false, context);
|
||||||
if (hasPublisherThumbnail && context != null) {
|
if (hasPublisherThumbnail && context != null) {
|
||||||
Glide.with(context.getApplicationContext()).load(signingChannel.getThumbnailUrl()).
|
ViewGroup.LayoutParams lp = root.findViewById(R.id.file_view_publisher_thumbnail).getLayoutParams();
|
||||||
|
Glide.with(context.getApplicationContext()).load(signingChannel.getThumbnailUrl(lp.width, lp.height, 85)).
|
||||||
apply(RequestOptions.circleCropTransform()).into((ImageView) root.findViewById(R.id.file_view_publisher_thumbnail));
|
apply(RequestOptions.circleCropTransform()).into((ImageView) root.findViewById(R.id.file_view_publisher_thumbnail));
|
||||||
}
|
}
|
||||||
((TextView) root.findViewById(R.id.file_view_publisher_thumbnail_alpha)).
|
((TextView) root.findViewById(R.id.file_view_publisher_thumbnail_alpha)).
|
||||||
|
@ -1606,7 +1607,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
Claim.GenericMetadata metadata = claim.getValue();
|
Claim.GenericMetadata metadata = claim.getValue();
|
||||||
if (!Helper.isNullOrEmpty(claim.getThumbnailUrl())) {
|
if (!Helper.isNullOrEmpty(claim.getThumbnailUrl())) {
|
||||||
ImageView thumbnailView = root.findViewById(R.id.file_view_thumbnail);
|
ImageView thumbnailView = root.findViewById(R.id.file_view_thumbnail);
|
||||||
Glide.with(context.getApplicationContext()).asBitmap().load(claim.getThumbnailUrl()).centerCrop().into(thumbnailView);
|
Glide.with(context.getApplicationContext()).asBitmap().load(claim.getThumbnailUrl(context.getResources().getDisplayMetrics().widthPixels, thumbnailView.getLayoutParams().height, 85)).centerCrop().into(thumbnailView);
|
||||||
} else {
|
} else {
|
||||||
// display first x letters of claim name, with random background
|
// display first x letters of claim name, with random background
|
||||||
}
|
}
|
||||||
|
@ -3243,7 +3244,7 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
if (hasThumbnail && context != null) {
|
if (hasThumbnail && context != null) {
|
||||||
Glide.with(context.getApplicationContext()).
|
Glide.with(context.getApplicationContext()).
|
||||||
asBitmap().
|
asBitmap().
|
||||||
load(channel.getThumbnailUrl()).
|
load(channel.getThumbnailUrl(commentPostAsThumbnail.getLayoutParams().width, commentPostAsThumbnail.getLayoutParams().height, 85)).
|
||||||
apply(RequestOptions.circleCropTransform()).
|
apply(RequestOptions.circleCropTransform()).
|
||||||
into(commentPostAsThumbnail);
|
into(commentPostAsThumbnail);
|
||||||
}
|
}
|
||||||
|
|
|
@ -583,7 +583,9 @@ public class PublishFormFragment extends BaseFragment implements
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
try {
|
try {
|
||||||
Claim.StreamMetadata metadata = (Claim.StreamMetadata) currentClaim.getValue();
|
Claim.StreamMetadata metadata = (Claim.StreamMetadata) currentClaim.getValue();
|
||||||
uploadedThumbnailUrl = currentClaim.getThumbnailUrl();
|
if (context != null) {
|
||||||
|
uploadedThumbnailUrl = currentClaim.getThumbnailUrl(imageThumbnail.getLayoutParams().width, imageThumbnail.getLayoutParams().height, 85);
|
||||||
|
}
|
||||||
if (context != null && !Helper.isNullOrEmpty(uploadedThumbnailUrl)) {
|
if (context != null && !Helper.isNullOrEmpty(uploadedThumbnailUrl)) {
|
||||||
Glide.with(context.getApplicationContext()).load(uploadedThumbnailUrl).centerCrop().into(imageThumbnail);
|
Glide.with(context.getApplicationContext()).load(uploadedThumbnailUrl).centerCrop().into(imageThumbnail);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue