1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-16 14:54:57 +00:00

-Changed detail fragment thumbnail failure to produce a snackbar error rather than a full error activity.

This commit is contained in:
John Zhen Mo 2018-03-22 18:11:59 -07:00
parent 18d019c62a
commit 8b60397f06

View File

@ -43,6 +43,7 @@ import android.widget.Toast;
import com.nirhart.parallaxscroll.views.ParallaxScrollView; import com.nirhart.parallaxscroll.views.ParallaxScrollView;
import com.nostra13.universalimageloader.core.assist.FailReason; import com.nostra13.universalimageloader.core.assist.FailReason;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener; import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
@ -582,27 +583,20 @@ public class VideoDetailFragment
}; };
} }
private void initThumbnailViews(StreamInfo info) { private void initThumbnailViews(@NonNull StreamInfo info) {
thumbnailImageView.setImageResource(R.drawable.dummy_thumbnail_dark); thumbnailImageView.setImageResource(R.drawable.dummy_thumbnail_dark);
if (!TextUtils.isEmpty(info.getThumbnailUrl())) { if (!TextUtils.isEmpty(info.getThumbnailUrl())) {
imageLoader.displayImage( final String infoServiceName = NewPipe.getNameOfService(info.getServiceId());
info.getThumbnailUrl(), final ImageLoadingListener onFailListener = new SimpleImageLoadingListener() {
thumbnailImageView,
ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS,
new SimpleImageLoadingListener() {
@Override @Override
public void onLoadingFailed(String imageUri, View view, FailReason failReason) { public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
ErrorActivity.reportError( showSnackBarError(failReason.getCause(), UserAction.LOAD_IMAGE,
activity, infoServiceName, imageUri, R.string.could_not_load_thumbnails);
failReason.getCause(),
null,
activity.findViewById(android.R.id.content),
ErrorActivity.ErrorInfo.make(UserAction.LOAD_IMAGE,
NewPipe.getNameOfService(currentInfo.getServiceId()),
imageUri,
R.string.could_not_load_thumbnails));
} }
}); };
imageLoader.displayImage(info.getThumbnailUrl(), thumbnailImageView,
ImageDisplayConstants.DISPLAY_THUMBNAIL_OPTIONS, onFailListener);
} }
if (!TextUtils.isEmpty(info.getUploaderAvatarUrl())) { if (!TextUtils.isEmpty(info.getUploaderAvatarUrl())) {