mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 06:17:57 +01:00 
			
		
		
		
	Remove some relayed chapter info from main manga info view
This commit is contained in:
		| @@ -14,7 +14,6 @@ import eu.kanade.tachiyomi.source.Source | ||||
| import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter | ||||
| import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource | ||||
| import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed | ||||
| import java.util.Date | ||||
| import rx.Observable | ||||
| import rx.Subscription | ||||
| import rx.android.schedulers.AndroidSchedulers | ||||
| @@ -22,6 +21,7 @@ import rx.schedulers.Schedulers | ||||
| import timber.log.Timber | ||||
| import uy.kohesive.injekt.Injekt | ||||
| import uy.kohesive.injekt.api.get | ||||
| import java.util.Date | ||||
|  | ||||
| /** | ||||
|  * Presenter of [ChaptersController]. | ||||
| @@ -90,14 +90,6 @@ class ChaptersPresenter( | ||||
|  | ||||
|                     // Listen for download status changes | ||||
|                     observeDownloads() | ||||
|  | ||||
|                     // Emit the number of chapters to the info tab. | ||||
|                     chapterCountRelay.call(chapters.maxBy { it.chapter_number }?.chapter_number | ||||
|                             ?: 0f) | ||||
|  | ||||
|                     // Emit the upload date of the most recent chapter | ||||
|                     lastUpdateRelay.call(Date(chapters.maxBy { it.date_upload }?.date_upload | ||||
|                             ?: 0)) | ||||
|                 } | ||||
|                 .subscribe { chaptersRelay.call(it) }) | ||||
|     } | ||||
|   | ||||
| @@ -54,13 +54,11 @@ import eu.kanade.tachiyomi.ui.webview.WebViewActivity | ||||
| import eu.kanade.tachiyomi.util.lang.truncateCenter | ||||
| import eu.kanade.tachiyomi.util.system.toast | ||||
| import eu.kanade.tachiyomi.util.view.snack | ||||
| import java.text.DateFormat | ||||
| import java.text.DecimalFormat | ||||
| import java.util.Date | ||||
| import jp.wasabeef.glide.transformations.CropSquareTransformation | ||||
| import uy.kohesive.injekt.Injekt | ||||
| import uy.kohesive.injekt.api.get | ||||
| import uy.kohesive.injekt.injectLazy | ||||
| import java.text.DateFormat | ||||
|  | ||||
| /** | ||||
|  * Fragment that shows manga information. | ||||
| @@ -85,8 +83,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(), | ||||
|  | ||||
|     override fun createPresenter(): MangaInfoPresenter { | ||||
|         val ctrl = parentController as MangaController | ||||
|         return MangaInfoPresenter(ctrl.manga!!, ctrl.source!!, | ||||
|                 ctrl.chapterCountRelay, ctrl.lastUpdateRelay, ctrl.mangaFavoriteRelay) | ||||
|         return MangaInfoPresenter(ctrl.manga!!, ctrl.source!!, ctrl.mangaFavoriteRelay) | ||||
|     } | ||||
|  | ||||
|     override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View { | ||||
| @@ -268,27 +265,6 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(), | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Update chapter count TextView. | ||||
|      * | ||||
|      * @param count number of chapters. | ||||
|      */ | ||||
|     fun setChapterCount(count: Float) { | ||||
|         if (count > 0f) { | ||||
|             binding.mangaChapters.text = DecimalFormat("#.#").format(count) | ||||
|         } else { | ||||
|             binding.mangaChapters.text = resources?.getString(R.string.unknown) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     fun setLastUpdateDate(date: Date) { | ||||
|         if (date.time != 0L) { | ||||
|             binding.mangaLastUpdate.text = dateFormat.format(date) | ||||
|         } else { | ||||
|             binding.mangaLastUpdate.text = resources?.getString(R.string.unknown) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Toggles the favorite status and asks for confirmation to delete downloaded chapters. | ||||
|      */ | ||||
|   | ||||
| @@ -1,7 +1,6 @@ | ||||
| package eu.kanade.tachiyomi.ui.manga.info | ||||
|  | ||||
| import android.os.Bundle | ||||
| import com.jakewharton.rxrelay.BehaviorRelay | ||||
| import com.jakewharton.rxrelay.PublishRelay | ||||
| import eu.kanade.tachiyomi.data.cache.CoverCache | ||||
| import eu.kanade.tachiyomi.data.database.DatabaseHelper | ||||
| @@ -12,7 +11,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager | ||||
| import eu.kanade.tachiyomi.source.Source | ||||
| import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter | ||||
| import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed | ||||
| import java.util.Date | ||||
| import rx.Observable | ||||
| import rx.Subscription | ||||
| import rx.android.schedulers.AndroidSchedulers | ||||
| @@ -28,8 +26,6 @@ import uy.kohesive.injekt.api.get | ||||
| class MangaInfoPresenter( | ||||
|     val manga: Manga, | ||||
|     val source: Source, | ||||
|     private val chapterCountRelay: BehaviorRelay<Float>, | ||||
|     private val lastUpdateRelay: BehaviorRelay<Date>, | ||||
|     private val mangaFavoriteRelay: PublishRelay<Boolean>, | ||||
|     private val db: DatabaseHelper = Injekt.get(), | ||||
|     private val downloadManager: DownloadManager = Injekt.get(), | ||||
| @@ -50,18 +46,10 @@ class MangaInfoPresenter( | ||||
|         super.onCreate(savedState) | ||||
|         sendMangaToView() | ||||
|  | ||||
|         // Update chapter count | ||||
|         chapterCountRelay.observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .subscribeLatestCache(MangaInfoController::setChapterCount) | ||||
|  | ||||
|         // Update favorite status | ||||
|         mangaFavoriteRelay.observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .subscribe { setFavorite(it) } | ||||
|                 .apply { add(this) } | ||||
|  | ||||
|         // update last update date | ||||
|         lastUpdateRelay.observeOn(AndroidSchedulers.mainThread()) | ||||
|                 .subscribeLatestCache(MangaInfoController::setLastUpdateDate) | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
		Reference in New Issue
	
	Block a user