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 imageView imageView where picture should be displayed. | ||||||
|      * @param file      file to load. Must exist!. |      * @param file      file to load. Must exist!. | ||||||
|      */ |      */ | ||||||
|     public void loadFromCache(ImageView imageView, File file) { |     private void loadFromCache(ImageView imageView, File file) { | ||||||
|         Glide.with(context) |         Glide.with(context) | ||||||
|                 .load(file) |                 .load(file) | ||||||
|                 .diskCacheStrategy(DiskCacheStrategy.RESULT) |                 .diskCacheStrategy(DiskCacheStrategy.RESULT) | ||||||
|  | |||||||
| @ -26,8 +26,8 @@ import butterknife.ButterKnife; | |||||||
| import eu.kanade.tachiyomi.R; | import eu.kanade.tachiyomi.R; | ||||||
| import eu.kanade.tachiyomi.data.cache.CoverCache; | import eu.kanade.tachiyomi.data.cache.CoverCache; | ||||||
| import eu.kanade.tachiyomi.data.database.models.Manga; | 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.io.IOHandler; | ||||||
|  | import eu.kanade.tachiyomi.data.source.base.Source; | ||||||
| import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment; | import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment; | ||||||
| import eu.kanade.tachiyomi.util.ToastUtil; | import eu.kanade.tachiyomi.util.ToastUtil; | ||||||
| import nucleus.factory.RequiresPresenter; | import nucleus.factory.RequiresPresenter; | ||||||
| @ -35,6 +35,7 @@ import nucleus.factory.RequiresPresenter; | |||||||
| @RequiresPresenter(MangaInfoPresenter.class) | @RequiresPresenter(MangaInfoPresenter.class) | ||||||
| public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> { | public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> { | ||||||
| 
 | 
 | ||||||
|  |     private static final int REQUEST_IMAGE_OPEN = 101; | ||||||
|     @Bind(R.id.swipe_refresh) SwipeRefreshLayout swipeRefresh; |     @Bind(R.id.swipe_refresh) SwipeRefreshLayout swipeRefresh; | ||||||
|     @Bind(R.id.manga_artist) TextView artist; |     @Bind(R.id.manga_artist) TextView artist; | ||||||
|     @Bind(R.id.manga_author) TextView author; |     @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.action_favorite) Button favoriteBtn; | ||||||
|     @Bind(R.id.fab_edit) FloatingActionButton fabEdit; |     @Bind(R.id.fab_edit) FloatingActionButton fabEdit; | ||||||
| 
 | 
 | ||||||
|     private static final int REQUEST_IMAGE_OPEN = 101; |  | ||||||
| 
 |  | ||||||
|     public static MangaInfoFragment newInstance() { |     public static MangaInfoFragment newInstance() { | ||||||
|         return new MangaInfoFragment(); |         return new MangaInfoFragment(); | ||||||
|     } |     } | ||||||
| @ -165,8 +164,9 @@ public class MangaInfoFragment extends BaseRxFragment<MangaInfoPresenter> { | |||||||
|             File picture = new File(result != null ? result : ""); |             File picture = new File(result != null ? result : ""); | ||||||
| 
 | 
 | ||||||
|             try { |             try { | ||||||
|                 // Update cover to selected file |                 // Update cover to selected file, show error if something went wrong | ||||||
|                 getPresenter().editCoverWithLocalFile(picture, cover); |                 if (!getPresenter().editCoverWithLocalFile(picture, cover)) | ||||||
|  |                     ToastUtil.showShort(getContext(), R.string.notification_manga_update_failed); | ||||||
| 
 | 
 | ||||||
|             } catch (IOException e) { |             } catch (IOException e) { | ||||||
|                 e.printStackTrace(); |                 e.printStackTrace(); | ||||||
|  | |||||||
| @ -149,11 +149,16 @@ public class MangaInfoPresenter extends BasePresenter<MangaInfoFragment> { | |||||||
|     /** |     /** | ||||||
|      * Update cover with local file |      * 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) { |         if (manga.favorite) { | ||||||
|             coverCache.copyToLocalCache(manga.thumbnail_url, file); |             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) { |     private void onMangaFavoriteChange(boolean isFavorite) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 inorichi
						inorichi