-Changed thumbnail toggle in disabled mode to load dark dummy image.

-Changed play queue items to display service names.
-Fixed Soundcloud playlist not fitting thumbnail.
-Refactored image display options to follow uniform behavior.
-Refactoring and style changes on audio reactor and media button receiver.
This commit is contained in:
John Zhen Mo 2018-03-15 20:07:20 -07:00
parent 2fa9aa04f4
commit 0258726f0a
25 changed files with 206 additions and 271 deletions

View file

@ -1,26 +1,26 @@
package org.schabi.newpipe;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.preference.PreferenceManager;
import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
import org.schabi.newpipe.extractor.NewPipe;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
public class ImageDownloader extends BaseImageDownloader {
private static final ByteArrayInputStream DUMMY_INPUT_STREAM =
new ByteArrayInputStream(new byte[]{});
private final Resources resources;
private final SharedPreferences preferences;
private final String downloadThumbnailKey;
public ImageDownloader(Context context) {
super(context);
this.resources = context.getResources();
this.preferences = PreferenceManager.getDefaultSharedPreferences(context);
this.downloadThumbnailKey = context.getString(R.string.download_thumbnail_key);
}
@ -29,12 +29,18 @@ public class ImageDownloader extends BaseImageDownloader {
return preferences.getBoolean(downloadThumbnailKey, true);
}
protected InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException {
@SuppressLint("ResourceType")
@Override
public InputStream getStream(String imageUri, Object extra) throws IOException {
if (isDownloadingThumbnail()) {
final Downloader downloader = (Downloader) NewPipe.getDownloader();
return downloader.stream(imageUri);
return super.getStream(imageUri, extra);
} else {
return DUMMY_INPUT_STREAM;
return resources.openRawResource(R.drawable.dummy_thumbnail_dark);
}
}
protected InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException {
final Downloader downloader = (Downloader) NewPipe.getDownloader();
return downloader.stream(imageUri);
}
}