mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-11 10:40:48 +01:00
clear the download queue
This commit is contained in:
parent
4be0b2502e
commit
50d71d1395
3 changed files with 19 additions and 9 deletions
|
@ -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<DownloadPresenter> {
|
||||
|
||||
|
@ -66,6 +61,10 @@ public class DownloadFragment extends BaseRxFragment<DownloadPresenter> {
|
|||
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<DownloadPresenter> {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -14,4 +14,9 @@
|
|||
android:visible="false"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
<item android:title="@string/action_clear"
|
||||
android:id="@+id/clear_queue"
|
||||
android:visible="false"
|
||||
app:showAsAction="never"/>
|
||||
|
||||
</menu>
|
|
@ -36,6 +36,7 @@
|
|||
<string name="action_start">Start</string>
|
||||
<string name="action_stop">Stop</string>
|
||||
<string name="action_pause">Pause</string>
|
||||
<string name="action_clear">Clear</string>
|
||||
<string name="action_previous_chapter">Previous chapter</string>
|
||||
<string name="action_next_chapter">Next chapter</string>
|
||||
<string name="action_retry">Retry</string>
|
||||
|
|
Loading…
Reference in a new issue