mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 20:57:24 +01:00
Merge pull request #94 from NoodleMage/local_cover_small_fix
Small fix for local cover loading
This commit is contained in:
commit
d0580d0df1
@ -201,7 +201,7 @@ public class CoverCache {
|
||||
* @param imageView imageView where picture should be displayed.
|
||||
* @param file file to load. Must exist!.
|
||||
*/
|
||||
public void loadFromCache(ImageView imageView, File file) {
|
||||
private void loadFromCache(ImageView imageView, File file) {
|
||||
Glide.with(context)
|
||||
.load(file)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||
|
@ -26,8 +26,8 @@ import butterknife.ButterKnife;
|
||||
import eu.kanade.tachiyomi.R;
|
||||
import eu.kanade.tachiyomi.data.cache.CoverCache;
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga;
|
||||
import eu.kanade.tachiyomi.data.source.base.Source;
|
||||
import eu.kanade.tachiyomi.data.io.IOHandler;
|
||||
import eu.kanade.tachiyomi.data.source.base.Source;
|
||||
import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment;
|
||||
import eu.kanade.tachiyomi.util.ToastUtil;
|
||||
import nucleus.factory.RequiresPresenter;
|
||||
@ -35,6 +35,7 @@ import nucleus.factory.RequiresPresenter;
|
||||
@RequiresPresenter(MangaInfoPresenter.class)
|
||||
public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> {
|
||||
|
||||
private static final int REQUEST_IMAGE_OPEN = 101;
|
||||
@Bind(R.id.swipe_refresh) SwipeRefreshLayout swipeRefresh;
|
||||
@Bind(R.id.manga_artist) TextView artist;
|
||||
@Bind(R.id.manga_author) TextView author;
|
||||
@ -47,8 +48,6 @@ public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> {
|
||||
@Bind(R.id.action_favorite) Button favoriteBtn;
|
||||
@Bind(R.id.fab_edit) FloatingActionButton fabEdit;
|
||||
|
||||
private static final int REQUEST_IMAGE_OPEN = 101;
|
||||
|
||||
public static MangaInfoFragment newInstance() {
|
||||
return new MangaInfoFragment();
|
||||
}
|
||||
@ -165,8 +164,9 @@ public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> {
|
||||
File picture = new File(result != null ? result : "");
|
||||
|
||||
try {
|
||||
// Update cover to selected file
|
||||
getPresenter().editCoverWithLocalFile(picture, cover);
|
||||
// Update cover to selected file, show error if something went wrong
|
||||
if (!getPresenter().editCoverWithLocalFile(picture, cover))
|
||||
ToastUtil.showShort(getContext(), R.string.notification_manga_update_failed);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -149,11 +149,16 @@ public class MangaInfoPresenter extends BasePresenter<MangaInfoFragment> {
|
||||
/**
|
||||
* Update cover with local file
|
||||
*/
|
||||
public void editCoverWithLocalFile(File file, ImageView imageView) throws IOException {
|
||||
public boolean editCoverWithLocalFile(File file, ImageView imageView) throws IOException {
|
||||
if (!manga.initialized)
|
||||
return false;
|
||||
|
||||
if (manga.favorite) {
|
||||
coverCache.copyToLocalCache(manga.thumbnail_url, file);
|
||||
coverCache.loadFromCache(imageView, file);
|
||||
coverCache.saveOrLoadFromCache(imageView, manga.thumbnail_url, source.getGlideHeaders());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void onMangaFavoriteChange(boolean isFavorite) {
|
||||
|
Loading…
Reference in New Issue
Block a user