diff --git a/app/src/main/java/eu/kanade/mangafeed/data/cache/CoverCache.java b/app/src/main/java/eu/kanade/mangafeed/data/cache/CoverCache.java index c849f9c03..93ffd081a 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/cache/CoverCache.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/cache/CoverCache.java @@ -1,6 +1,7 @@ package eu.kanade.mangafeed.data.cache; import android.content.Context; +import android.text.TextUtils; import android.widget.ImageView; import com.bumptech.glide.Glide; @@ -43,6 +44,9 @@ public class CoverCache { // Download the cover with Glide (it can avoid repeating requests) and save the file on this cache // Optionally, load the image in the given image view when the resource is ready, if not null public void save(String thumbnailUrl, LazyHeaders headers, ImageView imageView) { + if (TextUtils.isEmpty(thumbnailUrl)) + return; + GlideUrl url = new GlideUrl(thumbnailUrl, headers); Glide.with(context) .load(url) @@ -93,6 +97,9 @@ public class CoverCache { // Delete the cover from cache public boolean delete(String thumbnailUrl) { + if (TextUtils.isEmpty(thumbnailUrl)) + return false; + File file = new File(cacheDir, DiskUtils.hashKeyForDisk(thumbnailUrl)); return file.exists() && file.delete(); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CataloguePresenter.java b/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CataloguePresenter.java index b491aaba2..f559dc8e0 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CataloguePresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/catalogue/CataloguePresenter.java @@ -4,7 +4,6 @@ import android.os.Bundle; import android.text.TextUtils; import android.util.Pair; -import com.bumptech.glide.Glide; import com.pushtorefresh.storio.sqlite.operations.put.PutResult; import java.util.List; @@ -20,6 +19,7 @@ import eu.kanade.mangafeed.data.source.base.Source; import eu.kanade.mangafeed.data.source.model.MangasPage; import eu.kanade.mangafeed.ui.base.presenter.BasePresenter; import eu.kanade.mangafeed.util.RxPager; +import icepick.State; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; @@ -34,6 +34,7 @@ public class CataloguePresenter extends BasePresenter { @Inject PreferencesHelper prefs; private Source source; + @State int sourceId; private String query; @@ -78,19 +79,14 @@ public class CataloguePresenter extends BasePresenter { } private void onProcessRestart() { + source = sourceManager.get(sourceId); stop(GET_MANGA_LIST); stop(GET_MANGA_DETAIL); } - @Override - protected void onDestroy() { - // Catalogue covers are probably not going to be needed for a long time - Glide.get(getContext()).clearMemory(); - super.onDestroy(); - } - public void startRequesting(Source source) { this.source = source; + sourceId = source.getId(); restartRequest(null); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java index 4abbfc2bc..adbbaec5e 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java @@ -10,7 +10,6 @@ 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; @@ -62,12 +61,6 @@ public class ChaptersFragment extends BaseRxFragment implemen return new ChaptersFragment(); } - @Override - public void onCreate(Bundle savedState) { - super.onCreate(savedState); - setHasOptionsMenu(true); - } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -122,22 +115,6 @@ public class ChaptersFragment extends BaseRxFragment implemen super.onPause(); } - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - inflater.inflate(R.menu.chapters, menu); - super.onCreateOptionsMenu(menu, inflater); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.action_refresh: - fetchChapters(); - break; - } - return super.onOptionsItemSelected(item); - } - public void onNextChapters(List chapters) { // If the list is empty, fetch chapters from source if the conditions are met // We use presenter chapters instead because they are always unfiltered @@ -156,8 +133,10 @@ public class ChaptersFragment extends BaseRxFragment implemen } public void fetchChapters() { - swipeRefresh.setRefreshing(true); - getPresenter().fetchChaptersFromSource(); + if (getPresenter().getManga() != null) { + swipeRefresh.setRefreshing(true); + getPresenter().fetchChaptersFromSource(); + } } public void onFetchChaptersDone() { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java index 370c9c9a7..362b4e99f 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java @@ -21,6 +21,7 @@ import eu.kanade.mangafeed.event.DownloadChaptersEvent; import eu.kanade.mangafeed.event.ReaderEvent; import eu.kanade.mangafeed.ui.base.presenter.BasePresenter; import eu.kanade.mangafeed.util.EventBusHook; +import icepick.State; import rx.Observable; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; @@ -40,7 +41,7 @@ public class ChaptersPresenter extends BasePresenter { private boolean sortOrderAToZ = true; private boolean onlyUnread = true; private boolean onlyDownloaded; - private boolean hasRequested; + @State boolean hasRequested; private PublishSubject> chaptersSubject; diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReader.java index 419f91402..6c7052882 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReader.java @@ -25,7 +25,7 @@ public abstract class PagerReader extends BaseReader { protected void initializePager(Pager pager) { this.pager = pager; pager.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)); - pager.setOffscreenPageLimit(2); + pager.setOffscreenPageLimit(1); pager.setId(R.id.view_pager); pager.setOnChapterBoundariesOutListener(new OnChapterBoundariesOutListener() { @Override diff --git a/app/src/main/res/menu/chapters.xml b/app/src/main/res/menu/chapters.xml deleted file mode 100644 index a332fcae3..000000000 --- a/app/src/main/res/menu/chapters.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 62f661020..a86901edf 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -13,6 +13,7 @@ @style/ActionBarSpinner @style/ActionBarSpinnerItem @color/colorPrimarySuperDark + @style/ThemeOverlay.AppCompat.Light @style/ThemeOverlay.AppCompat.Light @color/white