From 6412ec1d9b7817bae8d8d6a219f1c529153c7fc9 Mon Sep 17 00:00:00 2001 From: inorichi Date: Fri, 18 Dec 2015 16:41:16 +0100 Subject: [PATCH] Remove successful downloads from queue --- .../mangafeed/data/download/DownloadManager.java | 4 ++++ .../data/download/model/DownloadQueue.java | 8 -------- .../mangafeed/ui/base/activity/BaseActivity.java | 6 ++++++ .../eu/kanade/mangafeed/ui/manga/MangaActivity.java | 13 ++----------- app/src/main/res/layout/activity_manga_detail.xml | 4 +--- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/eu/kanade/mangafeed/data/download/DownloadManager.java b/app/src/main/java/eu/kanade/mangafeed/data/download/DownloadManager.java index e5a729ab87..545785d2cd 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/download/DownloadManager.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/download/DownloadManager.java @@ -296,6 +296,10 @@ public class DownloadManager { } download.totalProgress = actualProgress; download.setStatus(status); + // Delete successful downloads from queue after notifying + if (status == Download.DOWNLOADED) { + queue.remove(download); + } } // Return the page list from the chapter's directory if it exists, null otherwise diff --git a/app/src/main/java/eu/kanade/mangafeed/data/download/model/DownloadQueue.java b/app/src/main/java/eu/kanade/mangafeed/data/download/model/DownloadQueue.java index b7040d1b12..0407c589a0 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/download/model/DownloadQueue.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/download/model/DownloadQueue.java @@ -42,14 +42,6 @@ public class DownloadQueue { return queue; } - public void clearSuccessfulDownloads() { - for (Download download : queue) { - if (download.getStatus() == Download.DOWNLOADED) { - remove(download); - } - } - } - public Observable getActiveDownloads() { return Observable.from(queue) .filter(download -> download.getStatus() == Download.DOWNLOADING); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/base/activity/BaseActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/base/activity/BaseActivity.java index b67399a929..8b86f1e651 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/base/activity/BaseActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/base/activity/BaseActivity.java @@ -1,6 +1,7 @@ package eu.kanade.mangafeed.ui.base.activity; import android.content.Context; +import android.os.Build; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.MenuItem; @@ -35,6 +36,11 @@ public class BaseActivity extends AppCompatActivity { getSupportActionBar().setSubtitle(getString(titleResource)); } + public void setToolbarElevation(int elevation) { + if (getSupportActionBar() != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + getSupportActionBar().setElevation(elevation); + } + public Context getActivity() { return this; } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/MangaActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/MangaActivity.java index 014a4165a8..ca911e811f 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/MangaActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/MangaActivity.java @@ -2,7 +2,6 @@ package eu.kanade.mangafeed.ui.manga; import android.content.Context; import android.content.Intent; -import android.os.Build; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.Fragment; @@ -17,8 +16,8 @@ import butterknife.Bind; import butterknife.ButterKnife; import eu.kanade.mangafeed.App; import eu.kanade.mangafeed.R; -import eu.kanade.mangafeed.data.mangasync.MangaSyncManager; import eu.kanade.mangafeed.data.database.models.Manga; +import eu.kanade.mangafeed.data.mangasync.MangaSyncManager; import eu.kanade.mangafeed.data.preference.PreferencesHelper; import eu.kanade.mangafeed.ui.base.activity.BaseRxActivity; import eu.kanade.mangafeed.ui.manga.chapter.ChaptersFragment; @@ -57,7 +56,7 @@ public class MangaActivity extends BaseRxActivity { ButterKnife.bind(this); setupToolbar(toolbar); - disableToolbarElevation(); + setToolbarElevation(0); Intent intent = getIntent(); @@ -70,12 +69,6 @@ public class MangaActivity extends BaseRxActivity { getPresenter().queryManga(manga_id); } - private void disableToolbarElevation() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - toolbar.setElevation(0); - } - } - private void setupViewPager() { adapter = new MangaDetailAdapter( getSupportFragmentManager(), @@ -100,7 +93,6 @@ public class MangaActivity extends BaseRxActivity { private int pageCount; private String tabTitles[]; - private Context context; final static int INFO_FRAGMENT = 0; final static int CHAPTERS_FRAGMENT = 1; @@ -108,7 +100,6 @@ public class MangaActivity extends BaseRxActivity { public MangaDetailAdapter(FragmentManager fm, Context context) { super(fm); - this.context = context; tabTitles = new String[]{ context.getString(R.string.manga_detail_tab), context.getString(R.string.manga_chapters_tab), diff --git a/app/src/main/res/layout/activity_manga_detail.xml b/app/src/main/res/layout/activity_manga_detail.xml index bf7fd3409e..d4a5aadfce 100644 --- a/app/src/main/res/layout/activity_manga_detail.xml +++ b/app/src/main/res/layout/activity_manga_detail.xml @@ -12,9 +12,7 @@ android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppTheme.Dark"> - +