mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-26 08:37:29 +00:00
Replace gif with webp for animated media
This commit is contained in:
parent
abd6dd1143
commit
2c1f4aea9d
@ -45,7 +45,7 @@ configurations.all {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.10'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.0'
|
||||||
|
|
||||||
def appcompat_version = "1.2.0"
|
def appcompat_version = "1.2.0"
|
||||||
def nav_version = '2.3.1'
|
def nav_version = '2.3.1'
|
||||||
@ -74,7 +74,8 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'org.jsoup:jsoup:1.13.1'
|
implementation 'org.jsoup:jsoup:1.13.1'
|
||||||
implementation 'com.facebook.fresco:fresco:2.3.0'
|
implementation 'com.facebook.fresco:fresco:2.3.0'
|
||||||
implementation 'com.facebook.fresco:animated-gif:2.3.0'
|
implementation 'com.facebook.fresco:animated-webp:2.3.0'
|
||||||
|
implementation 'com.facebook.fresco:webpsupport:2.3.0'
|
||||||
|
|
||||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||||
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
|
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package awais.instagrabber.adapters.viewholder.directmessages;
|
package awais.instagrabber.adapters.viewholder.directmessages;
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
@ -8,9 +7,6 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.core.util.Pair;
|
import androidx.core.util.Pair;
|
||||||
|
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||||
import com.facebook.imagepipeline.common.ResizeOptions;
|
|
||||||
import com.facebook.imagepipeline.request.ImageRequest;
|
|
||||||
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|
||||||
|
|
||||||
import awais.instagrabber.R;
|
import awais.instagrabber.R;
|
||||||
import awais.instagrabber.databinding.LayoutDmAnimatedMediaBinding;
|
import awais.instagrabber.databinding.LayoutDmAnimatedMediaBinding;
|
||||||
@ -31,15 +27,15 @@ public class DirectMessageAnimatedMediaViewHolder extends DirectMessageItemViewH
|
|||||||
super(baseBinding, onClickListener);
|
super(baseBinding, onClickListener);
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
maxHeight = itemView.getResources().getDimensionPixelSize(R.dimen.dm_media_img_max_height);
|
maxHeight = itemView.getResources().getDimensionPixelSize(R.dimen.dm_media_img_max_height);
|
||||||
maxWidth = (int) (Utils.displayMetrics.widthPixels - Utils.convertDpToPx(64) - getItemMargin());
|
maxWidth = Utils.displayMetrics.widthPixels - Utils.convertDpToPx(64) - getItemMargin();
|
||||||
setItemView(binding.getRoot());
|
setItemView(binding.getRoot());
|
||||||
removeElevation();
|
setupForAnimatedMedia();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void bindItem(final DirectItemModel directItemModel) {
|
public void bindItem(final DirectItemModel directItemModel) {
|
||||||
final DirectItemModel.DirectItemAnimatedMediaModel animatedMediaModel = directItemModel.getAnimatedMediaModel();
|
final DirectItemModel.DirectItemAnimatedMediaModel animatedMediaModel = directItemModel.getAnimatedMediaModel();
|
||||||
final String url = animatedMediaModel.getGifUrl();
|
final String url = animatedMediaModel.getWebpUrl();
|
||||||
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
final Pair<Integer, Integer> widthHeight = NumberUtils.calculateWidthHeight(
|
||||||
animatedMediaModel.getHeight(),
|
animatedMediaModel.getHeight(),
|
||||||
animatedMediaModel.getWidth(),
|
animatedMediaModel.getWidth(),
|
||||||
@ -53,11 +49,8 @@ public class DirectMessageAnimatedMediaViewHolder extends DirectMessageItemViewH
|
|||||||
layoutParams.width = width;
|
layoutParams.width = width;
|
||||||
layoutParams.height = height;
|
layoutParams.height = height;
|
||||||
binding.ivAnimatedMessage.requestLayout();
|
binding.ivAnimatedMessage.requestLayout();
|
||||||
final ImageRequest request = ImageRequestBuilder.newBuilderWithSource(Uri.parse(url))
|
|
||||||
.setResizeOptions(ResizeOptions.forDimensions(width, height))
|
|
||||||
.build();
|
|
||||||
binding.ivAnimatedMessage.setController(Fresco.newDraweeControllerBuilder()
|
binding.ivAnimatedMessage.setController(Fresco.newDraweeControllerBuilder()
|
||||||
.setImageRequest(request)
|
.setUri(url)
|
||||||
.setAutoPlayAnimations(true)
|
.setAutoPlayAnimations(true)
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,8 @@ public abstract class DirectMessageItemViewHolder extends RecyclerView.ViewHolde
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeElevation() {
|
protected void setupForAnimatedMedia() {
|
||||||
binding.messageCard.setCardElevation(0);
|
binding.messageCard.setCardElevation(0);
|
||||||
|
binding.messageCard.setCardBackgroundColor(itemView.getResources().getColor(android.R.color.transparent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user