aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java52
1 files changed, 17 insertions, 35 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java
index 4c37beec..49f31141 100644
--- a/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java
+++ b/app/src/main/java/github/daneren2005/dsub/fragments/DownloadFragment.java
@@ -15,7 +15,6 @@
package github.daneren2005.dsub.fragments;
-import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import androidx.recyclerview.widget.ItemTouchHelper;
@@ -69,17 +68,7 @@ public class DownloadFragment extends SelectRecyclerFragment<DownloadFile> imple
super.onStart();
final Handler handler = new Handler();
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- handler.post(new Runnable() {
- @Override
- public void run() {
- update();
- }
- });
- }
- };
+ Runnable runnable = () -> handler.post(this::update);
executorService = Executors.newSingleThreadScheduledExecutor();
executorService.scheduleWithFixedDelay(runnable, 0L, 1000L, TimeUnit.MILLISECONDS);
@@ -105,11 +94,10 @@ public class DownloadFragment extends SelectRecyclerFragment<DownloadFile> imple
public List<DownloadFile> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception {
DownloadService downloadService = getDownloadService();
if(downloadService == null) {
- return new ArrayList<DownloadFile>();
+ return new ArrayList<>();
}
- List<DownloadFile> songList = new ArrayList<DownloadFile>();
- songList.addAll(downloadService.getBackgroundDownloads());
+ List<DownloadFile> songList = new ArrayList<>(downloadService.getBackgroundDownloads());
currentRevision = downloadService.getDownloadListUpdateRevision();
return songList;
}
@@ -147,26 +135,20 @@ public class DownloadFragment extends SelectRecyclerFragment<DownloadFile> imple
return true;
}
- switch (menuItem.getItemId()) {
- case R.id.menu_remove_all:
- Util.confirmDialog(context, R.string.download_menu_remove_all, "", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- new SilentBackgroundTask<Void>(context) {
- @Override
- protected Void doInBackground() throws Throwable {
- getDownloadService().clearBackground();
- return null;
- }
-
- @Override
- protected void done(Void result) {
- update();
- }
- }.execute();
- }
- });
- return true;
+ if (menuItem.getItemId() == R.id.menu_remove_all) {
+ Util.confirmDialog(context, R.string.download_menu_remove_all, "", (dialog, which) -> new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() {
+ getDownloadService().clearBackground();
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ update();
+ }
+ }.execute());
+ return true;
}
return false;