1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00
This commit is contained in:
Ammar Githam 2021-04-14 01:27:31 +09:00
parent af3670e3ec
commit de9891f368

View File

@ -14,8 +14,8 @@ import androidx.appcompat.widget.AppCompatTextView;
import androidx.appcompat.widget.PopupMenu; import androidx.appcompat.widget.PopupMenu;
import com.facebook.drawee.backends.pipeline.Fresco; import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.backends.pipeline.PipelineDraweeControllerBuilder;
import com.facebook.drawee.controller.BaseControllerListener; import com.facebook.drawee.controller.BaseControllerListener;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.imagepipeline.image.ImageInfo; import com.facebook.imagepipeline.image.ImageInfo;
import com.facebook.imagepipeline.request.ImageRequest; import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder; import com.facebook.imagepipeline.request.ImageRequestBuilder;
@ -156,29 +156,33 @@ public class VideoPlayerViewHelper implements Player.EventListener {
private void setThumbnail() { private void setThumbnail() {
binding.thumbnail.setAspectRatio(thumbnailAspectRatio); binding.thumbnail.setAspectRatio(thumbnailAspectRatio);
final ImageRequest thumbnailRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(thumbnailUrl)) ImageRequest thumbnailRequest = null;
.build(); if (thumbnailUrl != null) {
final DraweeController controller = Fresco.newDraweeControllerBuilder() thumbnailRequest = ImageRequestBuilder.newBuilderWithSource(Uri.parse(thumbnailUrl)).build();
.setControllerListener(new BaseControllerListener<ImageInfo>() { }
@Override final PipelineDraweeControllerBuilder builder = Fresco.newDraweeControllerBuilder()
public void onFailure(final String id, final Throwable throwable) { .setControllerListener(new BaseControllerListener<ImageInfo>() {
if (videoPlayerCallback != null) { @Override
videoPlayerCallback.onThumbnailLoaded(); public void onFailure(final String id,
} final Throwable throwable) {
} if (videoPlayerCallback != null) {
videoPlayerCallback.onThumbnailLoaded();
}
}
@Override @Override
public void onFinalImageSet(final String id, public void onFinalImageSet(final String id,
final ImageInfo imageInfo, final ImageInfo imageInfo,
final Animatable animatable) { final Animatable animatable) {
if (videoPlayerCallback != null) { if (videoPlayerCallback != null) {
videoPlayerCallback.onThumbnailLoaded(); videoPlayerCallback.onThumbnailLoaded();
} }
} }
}) });
.setImageRequest(thumbnailRequest) if (thumbnailRequest != null) {
.build(); builder.setImageRequest(thumbnailRequest);
binding.thumbnail.setController(controller); }
binding.thumbnail.setController(builder.build());
} }
private void loadPlayer() { private void loadPlayer() {