From 50d71d1395d9a7af6bd480341b3cb0cb5254a90b Mon Sep 17 00:00:00 2001 From: Kevin Richter Date: Tue, 9 Feb 2016 16:34:41 +0100 Subject: [PATCH] clear the download queue --- .../ui/download/DownloadFragment.java | 22 +++++++++++-------- app/src/main/res/menu/download_queue.xml | 5 +++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadFragment.java index 57ee5fba4..e2dd46c68 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadFragment.java @@ -4,15 +4,7 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; - -import java.util.List; - +import android.view.*; import butterknife.Bind; import butterknife.ButterKnife; import eu.kanade.tachiyomi.R; @@ -22,6 +14,9 @@ import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment; import nucleus.factory.RequiresPresenter; import rx.Subscription; +import java.util.ArrayList; +import java.util.List; + @RequiresPresenter(DownloadPresenter.class) public class DownloadFragment extends BaseRxFragment { @@ -66,6 +61,10 @@ public class DownloadFragment extends BaseRxFragment { startButton = menu.findItem(R.id.start_queue); pauseButton = menu.findItem(R.id.pause_queue); + if(adapter.getItemCount() > 0) { + menu.findItem(R.id.clear_queue).setVisible(true); + } + // Menu seems to be inflated after onResume in fragments, so we initialize them here startButton.setVisible(!isRunning && !getPresenter().downloadManager.getQueue().isEmpty()); pauseButton.setVisible(isRunning); @@ -80,6 +79,11 @@ public class DownloadFragment extends BaseRxFragment { case R.id.pause_queue: DownloadService.stop(getActivity()); break; + case R.id.clear_queue: // Not sure if this is correct + DownloadService.stop(getActivity()); + getPresenter().downloadManager.getQueue().clear(); + onNextDownloads(new ArrayList<>()); + break; } return super.onOptionsItemSelected(item); } diff --git a/app/src/main/res/menu/download_queue.xml b/app/src/main/res/menu/download_queue.xml index 8de1cd107..118f1b45c 100644 --- a/app/src/main/res/menu/download_queue.xml +++ b/app/src/main/res/menu/download_queue.xml @@ -14,4 +14,9 @@ android:visible="false" app:showAsAction="ifRoom"/> + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8dbfb919f..e23ce60fd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -36,6 +36,7 @@ Start Stop Pause + Clear Previous chapter Next chapter Retry