mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 03:07:25 +01:00
Crash fixes
This commit is contained in:
parent
6ef0573a49
commit
4ee95140e6
@ -1,6 +1,7 @@
|
|||||||
package eu.kanade.mangafeed.data.cache;
|
package eu.kanade.mangafeed.data.cache;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
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
|
// 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
|
// 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) {
|
public void save(String thumbnailUrl, LazyHeaders headers, ImageView imageView) {
|
||||||
|
if (TextUtils.isEmpty(thumbnailUrl))
|
||||||
|
return;
|
||||||
|
|
||||||
GlideUrl url = new GlideUrl(thumbnailUrl, headers);
|
GlideUrl url = new GlideUrl(thumbnailUrl, headers);
|
||||||
Glide.with(context)
|
Glide.with(context)
|
||||||
.load(url)
|
.load(url)
|
||||||
@ -93,6 +97,9 @@ public class CoverCache {
|
|||||||
|
|
||||||
// Delete the cover from cache
|
// Delete the cover from cache
|
||||||
public boolean delete(String thumbnailUrl) {
|
public boolean delete(String thumbnailUrl) {
|
||||||
|
if (TextUtils.isEmpty(thumbnailUrl))
|
||||||
|
return false;
|
||||||
|
|
||||||
File file = new File(cacheDir, DiskUtils.hashKeyForDisk(thumbnailUrl));
|
File file = new File(cacheDir, DiskUtils.hashKeyForDisk(thumbnailUrl));
|
||||||
return file.exists() && file.delete();
|
return file.exists() && file.delete();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import android.os.Bundle;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
import com.pushtorefresh.storio.sqlite.operations.put.PutResult;
|
import com.pushtorefresh.storio.sqlite.operations.put.PutResult;
|
||||||
|
|
||||||
import java.util.List;
|
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.data.source.model.MangasPage;
|
||||||
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
||||||
import eu.kanade.mangafeed.util.RxPager;
|
import eu.kanade.mangafeed.util.RxPager;
|
||||||
|
import icepick.State;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
import rx.schedulers.Schedulers;
|
import rx.schedulers.Schedulers;
|
||||||
@ -34,6 +34,7 @@ public class CataloguePresenter extends BasePresenter<CatalogueFragment> {
|
|||||||
@Inject PreferencesHelper prefs;
|
@Inject PreferencesHelper prefs;
|
||||||
|
|
||||||
private Source source;
|
private Source source;
|
||||||
|
@State int sourceId;
|
||||||
|
|
||||||
private String query;
|
private String query;
|
||||||
|
|
||||||
@ -78,19 +79,14 @@ public class CataloguePresenter extends BasePresenter<CatalogueFragment> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onProcessRestart() {
|
private void onProcessRestart() {
|
||||||
|
source = sourceManager.get(sourceId);
|
||||||
stop(GET_MANGA_LIST);
|
stop(GET_MANGA_LIST);
|
||||||
stop(GET_MANGA_DETAIL);
|
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) {
|
public void startRequesting(Source source) {
|
||||||
this.source = source;
|
this.source = source;
|
||||||
|
sourceId = source.getId();
|
||||||
restartRequest(null);
|
restartRequest(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import android.support.v7.widget.LinearLayoutManager;
|
|||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -62,12 +61,6 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
|||||||
return new ChaptersFragment();
|
return new ChaptersFragment();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedState) {
|
|
||||||
super.onCreate(savedState);
|
|
||||||
setHasOptionsMenu(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
@ -122,22 +115,6 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
|||||||
super.onPause();
|
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<Chapter> chapters) {
|
public void onNextChapters(List<Chapter> chapters) {
|
||||||
// If the list is empty, fetch chapters from source if the conditions are met
|
// If the list is empty, fetch chapters from source if the conditions are met
|
||||||
// We use presenter chapters instead because they are always unfiltered
|
// We use presenter chapters instead because they are always unfiltered
|
||||||
@ -156,8 +133,10 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void fetchChapters() {
|
public void fetchChapters() {
|
||||||
swipeRefresh.setRefreshing(true);
|
if (getPresenter().getManga() != null) {
|
||||||
getPresenter().fetchChaptersFromSource();
|
swipeRefresh.setRefreshing(true);
|
||||||
|
getPresenter().fetchChaptersFromSource();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFetchChaptersDone() {
|
public void onFetchChaptersDone() {
|
||||||
|
@ -21,6 +21,7 @@ import eu.kanade.mangafeed.event.DownloadChaptersEvent;
|
|||||||
import eu.kanade.mangafeed.event.ReaderEvent;
|
import eu.kanade.mangafeed.event.ReaderEvent;
|
||||||
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
||||||
import eu.kanade.mangafeed.util.EventBusHook;
|
import eu.kanade.mangafeed.util.EventBusHook;
|
||||||
|
import icepick.State;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
import rx.schedulers.Schedulers;
|
import rx.schedulers.Schedulers;
|
||||||
@ -40,7 +41,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
|||||||
private boolean sortOrderAToZ = true;
|
private boolean sortOrderAToZ = true;
|
||||||
private boolean onlyUnread = true;
|
private boolean onlyUnread = true;
|
||||||
private boolean onlyDownloaded;
|
private boolean onlyDownloaded;
|
||||||
private boolean hasRequested;
|
@State boolean hasRequested;
|
||||||
|
|
||||||
private PublishSubject<List<Chapter>> chaptersSubject;
|
private PublishSubject<List<Chapter>> chaptersSubject;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public abstract class PagerReader extends BaseReader {
|
|||||||
protected void initializePager(Pager pager) {
|
protected void initializePager(Pager pager) {
|
||||||
this.pager = pager;
|
this.pager = pager;
|
||||||
pager.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
pager.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
|
||||||
pager.setOffscreenPageLimit(2);
|
pager.setOffscreenPageLimit(1);
|
||||||
pager.setId(R.id.view_pager);
|
pager.setId(R.id.view_pager);
|
||||||
pager.setOnChapterBoundariesOutListener(new OnChapterBoundariesOutListener() {
|
pager.setOnChapterBoundariesOutListener(new OnChapterBoundariesOutListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
tools:context=".MangaDetailActivity">
|
|
||||||
<!--I am not sure wee need it, so for a while it will be not visible-->
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_refresh"
|
|
||||||
android:icon="@drawable/ic_action_refresh"
|
|
||||||
android:orderInCategory="1"
|
|
||||||
android:title="@string/action_refresh"
|
|
||||||
android:visible="false"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
</menu>
|
|
@ -13,6 +13,7 @@
|
|||||||
<item name="android:spinnerItemStyle">@style/ActionBarSpinner</item>
|
<item name="android:spinnerItemStyle">@style/ActionBarSpinner</item>
|
||||||
<item name="android:spinnerDropDownItemStyle">@style/ActionBarSpinnerItem</item>
|
<item name="android:spinnerDropDownItemStyle">@style/ActionBarSpinnerItem</item>
|
||||||
<item name="actionModeBackground">@color/colorPrimarySuperDark</item>
|
<item name="actionModeBackground">@color/colorPrimarySuperDark</item>
|
||||||
|
<item name="actionBarPopupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||||
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||||
<item name="colorAccent">@color/white</item>
|
<item name="colorAccent">@color/white</item>
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user