1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 16:40:32 +00:00

-Fixed NPE issues when button views are clicked on local playlist and statistics playlist fragments are out of focus.

-Added disk cache size limit for image loader.
-Fixed button names for playlist rename dialog.
This commit is contained in:
John Zhen Mo 2018-02-03 09:36:40 -08:00
parent 3c3fe7bf83
commit efd4db40ef
4 changed files with 22 additions and 5 deletions

View File

@ -11,8 +11,6 @@ import android.os.Build;
import android.util.Log;
import com.nostra13.universalimageloader.cache.memory.impl.LRULimitedMemoryCache;
import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache;
import com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
@ -83,7 +81,7 @@ public class App extends Application {
initNotificationChannel();
// Initialize image loader
ImageLoader.getInstance().init(getImageLoaderConfigurations(10));
ImageLoader.getInstance().init(getImageLoaderConfigurations(10, 50));
configureRxJavaErrorHandler();
}
@ -121,9 +119,11 @@ public class App extends Application {
});
}
private ImageLoaderConfiguration getImageLoaderConfigurations(final int memoryCacheSizeMb) {
private ImageLoaderConfiguration getImageLoaderConfigurations(final int memoryCacheSizeMb,
final int diskCacheSizeMb) {
return new ImageLoaderConfiguration.Builder(this)
.memoryCache(new LRULimitedMemoryCache(memoryCacheSizeMb * 1024 * 1024))
.diskCacheSize(diskCacheSizeMb * 1024 * 1024)
.build();
}

View File

@ -35,6 +35,7 @@ import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.OnClickGesture;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@ -289,6 +290,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
@Override
public void handleResult(@NonNull List<PlaylistStreamEntry> result) {
super.handleResult(result);
if (itemListAdapter == null) return;
itemListAdapter.clearStreamItemList();
if (result.isEmpty()) {
@ -349,7 +352,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
.setView(dialogView)
.setCancelable(true)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.create, (dialogInterface, i) ->
.setPositiveButton(R.string.rename, (dialogInterface, i) ->
changePlaylistName(nameEdit.getText().toString())
);
@ -382,6 +385,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
}
private void deleteItem(final PlaylistStreamEntry item) {
if (itemListAdapter == null) return;
itemListAdapter.removeItem(item);
setVideoCount(itemListAdapter.getItemsList().size());
saveChanges();
@ -543,6 +548,10 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
}
private PlayQueue getPlayQueue(final int index) {
if (itemListAdapter == null) {
return new SinglePlayQueue(Collections.emptyList(), 0);
}
final List<LocalItem> infoItems = itemListAdapter.getItemsList();
List<StreamInfoItem> streamInfoItems = new ArrayList<>(infoItems.size());
for (final LocalItem item : infoItems) {

View File

@ -27,6 +27,7 @@ import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.OnClickGesture;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import icepick.State;
@ -185,6 +186,8 @@ public abstract class StatisticsPlaylistFragment
@Override
public void handleResult(@NonNull List<StreamStatisticsEntry> result) {
super.handleResult(result);
if (itemListAdapter == null) return;
itemListAdapter.clearStreamItemList();
if (result.isEmpty()) {
@ -275,6 +278,10 @@ public abstract class StatisticsPlaylistFragment
}
private PlayQueue getPlayQueue(final int index) {
if (itemListAdapter == null) {
return new SinglePlayQueue(Collections.emptyList(), 0);
}
final List<LocalItem> infoItems = itemListAdapter.getItemsList();
List<StreamInfoItem> streamInfoItems = new ArrayList<>(infoItems.size());
for (final LocalItem item : infoItems) {

View File

@ -233,6 +233,7 @@
<string name="delete_all">Delete All</string>
<string name="checksum">Checksum</string>
<string name="dismiss">Dismiss</string>
<string name="rename">Rename</string>
<!-- Fragment -->
<string name="add">New mission</string>