Migrate to ViewBinding from Kotlin synthetics in controllers
This commit is contained in:
@@ -18,6 +18,7 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
import eu.kanade.tachiyomi.databinding.MangaControllerBinding
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.ui.base.controller.RxController
|
||||
@@ -29,7 +30,6 @@ import eu.kanade.tachiyomi.ui.manga.track.TrackController
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import java.util.Date
|
||||
import kotlinx.android.synthetic.main.main_activity.tabs
|
||||
import kotlinx.android.synthetic.main.manga_controller.manga_pager
|
||||
import rx.Subscription
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
@@ -68,6 +68,8 @@ class MangaController : RxController, TabbedController {
|
||||
|
||||
val mangaFavoriteRelay: PublishRelay<Boolean> = PublishRelay.create()
|
||||
|
||||
private lateinit var binding: MangaControllerBinding
|
||||
|
||||
private val trackingIconRelay: BehaviorRelay<Boolean> = BehaviorRelay.create()
|
||||
|
||||
private var trackingIconSubscription: Subscription? = null
|
||||
@@ -77,7 +79,8 @@ class MangaController : RxController, TabbedController {
|
||||
}
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
return inflater.inflate(R.layout.manga_controller, container, false)
|
||||
binding = MangaControllerBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
@@ -88,11 +91,11 @@ class MangaController : RxController, TabbedController {
|
||||
requestPermissionsSafe(arrayOf(WRITE_EXTERNAL_STORAGE), 301)
|
||||
|
||||
adapter = MangaDetailAdapter()
|
||||
manga_pager.offscreenPageLimit = 3
|
||||
manga_pager.adapter = adapter
|
||||
binding.mangaPager.offscreenPageLimit = 3
|
||||
binding.mangaPager.adapter = adapter
|
||||
|
||||
if (!fromCatalogue)
|
||||
manga_pager.currentItem = CHAPTERS_CONTROLLER
|
||||
binding.mangaPager.currentItem = CHAPTERS_CONTROLLER
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
@@ -103,7 +106,7 @@ class MangaController : RxController, TabbedController {
|
||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||
super.onChangeStarted(handler, type)
|
||||
if (type.isEnter) {
|
||||
activity?.tabs?.setupWithViewPager(manga_pager)
|
||||
activity?.tabs?.setupWithViewPager(binding.mangaPager)
|
||||
trackingIconSubscription = trackingIconRelay.subscribe { setTrackingIconInternal(it) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.databinding.ChaptersControllerBinding
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.popControllerWithTag
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
@@ -32,12 +33,6 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.getCoordinates
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import kotlinx.android.synthetic.main.chapters_controller.action_toolbar
|
||||
import kotlinx.android.synthetic.main.chapters_controller.fab
|
||||
import kotlinx.android.synthetic.main.chapters_controller.fast_scroller
|
||||
import kotlinx.android.synthetic.main.chapters_controller.recycler
|
||||
import kotlinx.android.synthetic.main.chapters_controller.reveal_view
|
||||
import kotlinx.android.synthetic.main.chapters_controller.swipe_refresh
|
||||
import timber.log.Timber
|
||||
|
||||
class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
@@ -64,6 +59,8 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
|
||||
private var lastClickPosition = -1
|
||||
|
||||
private lateinit var binding: ChaptersControllerBinding
|
||||
|
||||
init {
|
||||
setHasOptionsMenu(true)
|
||||
setOptionsMenuHidden(true)
|
||||
@@ -76,7 +73,8 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
}
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
return inflater.inflate(R.layout.chapters_controller, container, false)
|
||||
binding = ChaptersControllerBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
@@ -85,15 +83,15 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
// Init RecyclerView and adapter
|
||||
adapter = ChaptersAdapter(this, view.context)
|
||||
|
||||
recycler.adapter = adapter
|
||||
recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
recycler.addItemDecoration(DividerItemDecoration(view.context, DividerItemDecoration.VERTICAL))
|
||||
recycler.setHasFixedSize(true)
|
||||
adapter?.fastScroller = fast_scroller
|
||||
binding.recycler.adapter = adapter
|
||||
binding.recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
binding.recycler.addItemDecoration(DividerItemDecoration(view.context, DividerItemDecoration.VERTICAL))
|
||||
binding.recycler.setHasFixedSize(true)
|
||||
adapter?.fastScroller = binding.fastScroller
|
||||
|
||||
swipe_refresh.refreshes().subscribeUntilDestroy { fetchChaptersFromSource() }
|
||||
binding.swipeRefresh.refreshes().subscribeUntilDestroy { fetchChaptersFromSource() }
|
||||
|
||||
fab.clicks().subscribeUntilDestroy {
|
||||
binding.fab.clicks().subscribeUntilDestroy {
|
||||
val item = presenter.getNextUnreadChapter()
|
||||
if (item != null) {
|
||||
// Create animation listener
|
||||
@@ -104,8 +102,8 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
}
|
||||
|
||||
// Get coordinates and start animation
|
||||
val coordinates = fab.getCoordinates()
|
||||
if (!reveal_view.showRevealEffect(coordinates.x, coordinates.y, revealAnimationListener)) {
|
||||
val coordinates = binding.fab.getCoordinates()
|
||||
if (!binding.revealView.showRevealEffect(coordinates.x, coordinates.y, revealAnimationListener)) {
|
||||
openChapter(item.chapter)
|
||||
}
|
||||
} else {
|
||||
@@ -116,7 +114,7 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
destroyActionModeIfNeeded()
|
||||
action_toolbar.destroy()
|
||||
binding.actionToolbar.destroy()
|
||||
adapter = null
|
||||
super.onDestroyView(view)
|
||||
}
|
||||
@@ -125,10 +123,10 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
if (view == null) return
|
||||
|
||||
// Check if animation view is visible
|
||||
if (reveal_view.visibility == View.VISIBLE) {
|
||||
// Show the unReveal effect
|
||||
val coordinates = fab.getCoordinates()
|
||||
reveal_view.hideRevealEffect(coordinates.x, coordinates.y, 1920)
|
||||
if (binding.revealView.visibility == View.VISIBLE) {
|
||||
// Show the unreveal effect
|
||||
val coordinates = binding.fab.getCoordinates()
|
||||
binding.revealView.hideRevealEffect(coordinates.x, coordinates.y, 1920)
|
||||
}
|
||||
super.onActivityResumed(activity)
|
||||
}
|
||||
@@ -267,16 +265,16 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
}
|
||||
|
||||
private fun fetchChaptersFromSource() {
|
||||
swipe_refresh?.isRefreshing = true
|
||||
binding.swipeRefresh.isRefreshing = true
|
||||
presenter.fetchChaptersFromSource()
|
||||
}
|
||||
|
||||
fun onFetchChaptersDone() {
|
||||
swipe_refresh?.isRefreshing = false
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
}
|
||||
|
||||
fun onFetchChaptersError(error: Throwable) {
|
||||
swipe_refresh?.isRefreshing = false
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
activity?.toast(error.message)
|
||||
}
|
||||
|
||||
@@ -285,7 +283,7 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
}
|
||||
|
||||
private fun getHolder(chapter: Chapter): ChapterHolder? {
|
||||
return recycler?.findViewHolderForItemId(chapter.id!!) as? ChapterHolder
|
||||
return binding.recycler.findViewHolderForItemId(chapter.id!!) as? ChapterHolder
|
||||
}
|
||||
|
||||
fun openChapter(chapter: Chapter, hasAnimation: Boolean = false) {
|
||||
@@ -357,7 +355,7 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
private fun createActionModeIfNeeded() {
|
||||
if (actionMode == null) {
|
||||
actionMode = (activity as? AppCompatActivity)?.startSupportActionMode(this)
|
||||
action_toolbar.show(
|
||||
binding.actionToolbar.show(
|
||||
actionMode!!,
|
||||
R.menu.chapter_selection
|
||||
) { onActionItemClicked(actionMode!!, it!!) }
|
||||
@@ -384,15 +382,15 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
mode.title = count.toString()
|
||||
|
||||
val chapters = getSelectedChapters()
|
||||
action_toolbar.findItem(R.id.action_download)?.isVisible = chapters.any { !it.isDownloaded }
|
||||
action_toolbar.findItem(R.id.action_delete)?.isVisible = chapters.any { it.isDownloaded }
|
||||
action_toolbar.findItem(R.id.action_bookmark)?.isVisible = chapters.any { !it.chapter.bookmark }
|
||||
action_toolbar.findItem(R.id.action_remove_bookmark)?.isVisible = chapters.all { it.chapter.bookmark }
|
||||
action_toolbar.findItem(R.id.action_mark_as_read)?.isVisible = chapters.any { !it.chapter.read }
|
||||
action_toolbar.findItem(R.id.action_mark_as_unread)?.isVisible = chapters.all { it.chapter.read }
|
||||
binding.actionToolbar.findItem(R.id.action_download)?.isVisible = chapters.any { !it.isDownloaded }
|
||||
binding.actionToolbar.findItem(R.id.action_delete)?.isVisible = chapters.any { it.isDownloaded }
|
||||
binding.actionToolbar.findItem(R.id.action_bookmark)?.isVisible = chapters.any { !it.chapter.bookmark }
|
||||
binding.actionToolbar.findItem(R.id.action_remove_bookmark)?.isVisible = chapters.all { it.chapter.bookmark }
|
||||
binding.actionToolbar.findItem(R.id.action_mark_as_read)?.isVisible = chapters.any { !it.chapter.read }
|
||||
binding.actionToolbar.findItem(R.id.action_mark_as_unread)?.isVisible = chapters.all { it.chapter.read }
|
||||
|
||||
// Hide FAB to avoid interfering with the bottom action toolbar
|
||||
fab.hide()
|
||||
binding.fab.hide()
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -414,13 +412,13 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
}
|
||||
|
||||
override fun onDestroyActionMode(mode: ActionMode) {
|
||||
action_toolbar.hide()
|
||||
binding.actionToolbar.hide()
|
||||
adapter?.mode = SelectableAdapter.Mode.SINGLE
|
||||
adapter?.clearSelection()
|
||||
selectedItems.clear()
|
||||
actionMode = null
|
||||
|
||||
fab.show()
|
||||
binding.fab.show()
|
||||
}
|
||||
|
||||
override fun onDetach(view: View) {
|
||||
@@ -461,7 +459,7 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
val view = view
|
||||
presenter.downloadChapters(chapters)
|
||||
if (view != null && !presenter.manga.favorite) {
|
||||
recycler?.snack(view.context.getString(R.string.snack_add_to_library), Snackbar.LENGTH_INDEFINITE) {
|
||||
binding.recycler.snack(view.context.getString(R.string.snack_add_to_library), Snackbar.LENGTH_INDEFINITE) {
|
||||
setAction(R.string.action_add) {
|
||||
presenter.addToLibrary()
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.databinding.MangaInfoControllerBinding
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
@@ -57,20 +58,6 @@ import java.text.DateFormat
|
||||
import java.text.DecimalFormat
|
||||
import java.util.Date
|
||||
import jp.wasabeef.glide.transformations.CropSquareTransformation
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.backdrop
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.fab_favorite
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_artist
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_artist_label
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_author
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_chapters
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_cover
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_full_title
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_genres_tags
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_last_update
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_source
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_status
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.manga_summary
|
||||
import kotlinx.android.synthetic.main.manga_info_controller.swipe_refresh
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
@@ -83,15 +70,14 @@ import uy.kohesive.injekt.injectLazy
|
||||
class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
ChangeMangaCategoriesDialog.Listener {
|
||||
|
||||
/**
|
||||
* Preferences helper.
|
||||
*/
|
||||
private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
private val dateFormat: DateFormat by lazy {
|
||||
preferences.dateFormat().getOrDefault()
|
||||
}
|
||||
|
||||
private lateinit var binding: MangaInfoControllerBinding
|
||||
|
||||
init {
|
||||
setHasOptionsMenu(true)
|
||||
setOptionsMenuHidden(true)
|
||||
@@ -104,50 +90,51 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
}
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
return inflater.inflate(R.layout.manga_info_controller, container, false)
|
||||
binding = MangaInfoControllerBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
|
||||
// Set onclickListener to toggle favorite when FAB clicked.
|
||||
fab_favorite.clicks().subscribeUntilDestroy { onFabClick() }
|
||||
binding.fabFavorite.clicks().subscribeUntilDestroy { onFabClick() }
|
||||
|
||||
// Set onLongClickListener to manage categories when FAB is clicked.
|
||||
fab_favorite.longClicks().subscribeUntilDestroy { onFabLongClick() }
|
||||
binding.fabFavorite.longClicks().subscribeUntilDestroy { onFabLongClick() }
|
||||
|
||||
// Set SwipeRefresh to refresh manga data.
|
||||
swipe_refresh.refreshes().subscribeUntilDestroy { fetchMangaFromSource() }
|
||||
binding.swipeRefresh.refreshes().subscribeUntilDestroy { fetchMangaFromSource() }
|
||||
|
||||
manga_full_title.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(view.context.getString(R.string.title), manga_full_title.text.toString())
|
||||
binding.mangaFullTitle.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(view.context.getString(R.string.title), binding.mangaFullTitle.text.toString())
|
||||
}
|
||||
|
||||
manga_full_title.clicks().subscribeUntilDestroy {
|
||||
performGlobalSearch(manga_full_title.text.toString())
|
||||
binding.mangaFullTitle.clicks().subscribeUntilDestroy {
|
||||
performGlobalSearch(binding.mangaFullTitle.text.toString())
|
||||
}
|
||||
|
||||
manga_artist.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(manga_artist_label.text.toString(), manga_artist.text.toString())
|
||||
binding.mangaArtist.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(binding.mangaArtistLabel.text.toString(), binding.mangaArtist.text.toString())
|
||||
}
|
||||
|
||||
manga_artist.clicks().subscribeUntilDestroy {
|
||||
performGlobalSearch(manga_artist.text.toString())
|
||||
binding.mangaArtist.clicks().subscribeUntilDestroy {
|
||||
performGlobalSearch(binding.mangaArtist.text.toString())
|
||||
}
|
||||
|
||||
manga_author.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(manga_author.text.toString(), manga_author.text.toString())
|
||||
binding.mangaAuthor.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(binding.mangaAuthor.text.toString(), binding.mangaAuthor.text.toString())
|
||||
}
|
||||
|
||||
manga_author.clicks().subscribeUntilDestroy {
|
||||
performGlobalSearch(manga_author.text.toString())
|
||||
binding.mangaAuthor.clicks().subscribeUntilDestroy {
|
||||
performGlobalSearch(binding.mangaAuthor.text.toString())
|
||||
}
|
||||
|
||||
manga_summary.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(view.context.getString(R.string.description), manga_summary.text.toString())
|
||||
binding.mangaSummary.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(view.context.getString(R.string.description), binding.mangaSummary.text.toString())
|
||||
}
|
||||
|
||||
manga_cover.longClicks().subscribeUntilDestroy {
|
||||
binding.mangaCover.longClicks().subscribeUntilDestroy {
|
||||
copyToClipboard(view.context.getString(R.string.title), presenter.manga.title)
|
||||
}
|
||||
}
|
||||
@@ -197,21 +184,21 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
val view = view ?: return
|
||||
|
||||
// update full title TextView.
|
||||
manga_full_title.text = if (manga.title.isBlank()) {
|
||||
binding.mangaFullTitle.text = if (manga.title.isBlank()) {
|
||||
view.context.getString(R.string.unknown)
|
||||
} else {
|
||||
manga.title
|
||||
}
|
||||
|
||||
// Update artist TextView.
|
||||
manga_artist.text = if (manga.artist.isNullOrBlank()) {
|
||||
binding.mangaArtist.text = if (manga.artist.isNullOrBlank()) {
|
||||
view.context.getString(R.string.unknown)
|
||||
} else {
|
||||
manga.artist
|
||||
}
|
||||
|
||||
// Update author TextView.
|
||||
manga_author.text = if (manga.author.isNullOrBlank()) {
|
||||
binding.mangaAuthor.text = if (manga.author.isNullOrBlank()) {
|
||||
view.context.getString(R.string.unknown)
|
||||
} else {
|
||||
manga.author
|
||||
@@ -219,7 +206,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
|
||||
// If manga source is known update source TextView.
|
||||
val mangaSource = source?.toString()
|
||||
with(manga_source) {
|
||||
with(binding.mangaSource) {
|
||||
if (mangaSource != null) {
|
||||
text = mangaSource
|
||||
setOnClickListener {
|
||||
@@ -233,7 +220,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
|
||||
// Update genres list
|
||||
if (!manga.genre.isNullOrBlank()) {
|
||||
manga_genres_tags.removeAllViews()
|
||||
binding.mangaGenresTags.removeAllViews()
|
||||
|
||||
manga.genre?.split(", ")?.forEach { genre ->
|
||||
val chip = Chip(view.context).apply {
|
||||
@@ -241,19 +228,19 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
setOnClickListener { performSearch(genre) }
|
||||
}
|
||||
|
||||
manga_genres_tags.addView(chip)
|
||||
binding.mangaGenresTags.addView(chip)
|
||||
}
|
||||
}
|
||||
|
||||
// Update description TextView.
|
||||
manga_summary.text = if (manga.description.isNullOrBlank()) {
|
||||
binding.mangaSummary.text = if (manga.description.isNullOrBlank()) {
|
||||
view.context.getString(R.string.unknown)
|
||||
} else {
|
||||
manga.description
|
||||
}
|
||||
|
||||
// Update status TextView.
|
||||
manga_status.setText(when (manga.status) {
|
||||
binding.mangaStatus.setText(when (manga.status) {
|
||||
SManga.ONGOING -> R.string.ongoing
|
||||
SManga.COMPLETED -> R.string.completed
|
||||
SManga.LICENSED -> R.string.licensed
|
||||
@@ -264,19 +251,19 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
setFavoriteDrawable(manga.favorite)
|
||||
|
||||
// Set cover if it wasn't already.
|
||||
if (manga_cover.drawable == null && !manga.thumbnail_url.isNullOrEmpty()) {
|
||||
if (binding.mangaCover.drawable == null && !manga.thumbnail_url.isNullOrEmpty()) {
|
||||
GlideApp.with(view.context)
|
||||
.load(manga)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.centerCrop()
|
||||
.into(manga_cover)
|
||||
.into(binding.mangaCover)
|
||||
|
||||
if (backdrop != null) {
|
||||
if (binding.backdrop != null) {
|
||||
GlideApp.with(view.context)
|
||||
.load(manga)
|
||||
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
|
||||
.centerCrop()
|
||||
.into(backdrop)
|
||||
.into(binding.backdrop!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,17 +275,17 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
*/
|
||||
fun setChapterCount(count: Float) {
|
||||
if (count > 0f) {
|
||||
manga_chapters?.text = DecimalFormat("#.#").format(count)
|
||||
binding.mangaChapters.text = DecimalFormat("#.#").format(count)
|
||||
} else {
|
||||
manga_chapters?.text = resources?.getString(R.string.unknown)
|
||||
binding.mangaChapters.text = resources?.getString(R.string.unknown)
|
||||
}
|
||||
}
|
||||
|
||||
fun setLastUpdateDate(date: Date) {
|
||||
if (date.time != 0L) {
|
||||
manga_last_update?.text = dateFormat.format(date)
|
||||
binding.mangaLastUpdate.text = dateFormat.format(date)
|
||||
} else {
|
||||
manga_last_update?.text = resources?.getString(R.string.unknown)
|
||||
binding.mangaLastUpdate.text = resources?.getString(R.string.unknown)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,7 +346,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
private fun setFavoriteDrawable(isFavorite: Boolean) {
|
||||
// Set the Favorite drawable to the correct one.
|
||||
// Border drawable if false, filled drawable if true.
|
||||
fab_favorite?.setImageResource(if (isFavorite)
|
||||
binding.fabFavorite.setImageResource(if (isFavorite)
|
||||
R.drawable.ic_bookmark_24dp
|
||||
else
|
||||
R.drawable.ic_add_to_library_24dp)
|
||||
@@ -395,7 +382,7 @@ class MangaInfoController : NucleusController<MangaInfoPresenter>(),
|
||||
* @param value whether it should be refreshing or not.
|
||||
*/
|
||||
private fun setRefreshing(value: Boolean) {
|
||||
swipe_refresh?.isRefreshing = value
|
||||
binding.swipeRefresh.isRefreshing = value
|
||||
}
|
||||
|
||||
private fun onFabClick() {
|
||||
|
||||
@@ -9,11 +9,10 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.jakewharton.rxbinding.support.v4.widget.refreshes
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
import eu.kanade.tachiyomi.databinding.TrackControllerBinding
|
||||
import eu.kanade.tachiyomi.ui.base.controller.NucleusController
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaController
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.android.synthetic.main.track_controller.swipe_refresh
|
||||
import kotlinx.android.synthetic.main.track_controller.track_recycler
|
||||
import timber.log.Timber
|
||||
|
||||
class TrackController : NucleusController<TrackPresenter>(),
|
||||
@@ -24,6 +23,8 @@ class TrackController : NucleusController<TrackPresenter>(),
|
||||
|
||||
private var adapter: TrackAdapter? = null
|
||||
|
||||
private lateinit var binding: TrackControllerBinding
|
||||
|
||||
init {
|
||||
// There's no menu, but this avoids a bug when coming from the catalogue, where the menu
|
||||
// disappears if the searchview is expanded
|
||||
@@ -35,19 +36,18 @@ class TrackController : NucleusController<TrackPresenter>(),
|
||||
}
|
||||
|
||||
override fun inflateView(inflater: LayoutInflater, container: ViewGroup): View {
|
||||
return inflater.inflate(R.layout.track_controller, container, false)
|
||||
binding = TrackControllerBinding.inflate(inflater)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
|
||||
adapter = TrackAdapter(this)
|
||||
with(view) {
|
||||
track_recycler.layoutManager = LinearLayoutManager(context)
|
||||
track_recycler.adapter = adapter
|
||||
swipe_refresh.isEnabled = false
|
||||
swipe_refresh.refreshes().subscribeUntilDestroy { presenter.refresh() }
|
||||
}
|
||||
binding.trackRecycler.layoutManager = LinearLayoutManager(view.context)
|
||||
binding.trackRecycler.adapter = adapter
|
||||
binding.swipeRefresh.isEnabled = false
|
||||
binding.swipeRefresh.refreshes().subscribeUntilDestroy { presenter.refresh() }
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
@@ -58,7 +58,7 @@ class TrackController : NucleusController<TrackPresenter>(),
|
||||
fun onNextTrackings(trackings: List<TrackItem>) {
|
||||
val atLeastOneLink = trackings.any { it.track != null }
|
||||
adapter?.items = trackings
|
||||
swipe_refresh?.isEnabled = atLeastOneLink
|
||||
binding.swipeRefresh.isEnabled = atLeastOneLink
|
||||
(parentController as? MangaController)?.setTrackingIcon(atLeastOneLink)
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ class TrackController : NucleusController<TrackPresenter>(),
|
||||
}
|
||||
|
||||
fun onRefreshDone() {
|
||||
swipe_refresh?.isRefreshing = false
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
}
|
||||
|
||||
fun onRefreshError(error: Throwable) {
|
||||
swipe_refresh?.isRefreshing = false
|
||||
binding.swipeRefresh.isRefreshing = false
|
||||
activity?.toast(error.message)
|
||||
}
|
||||
|
||||
@@ -123,17 +123,17 @@ class TrackController : NucleusController<TrackPresenter>(),
|
||||
|
||||
override fun setStatus(item: TrackItem, selection: Int) {
|
||||
presenter.setStatus(item, selection)
|
||||
swipe_refresh?.isRefreshing = true
|
||||
binding.swipeRefresh.isRefreshing = true
|
||||
}
|
||||
|
||||
override fun setScore(item: TrackItem, score: Int) {
|
||||
presenter.setScore(item, score)
|
||||
swipe_refresh?.isRefreshing = true
|
||||
binding.swipeRefresh.isRefreshing = true
|
||||
}
|
||||
|
||||
override fun setChaptersRead(item: TrackItem, chaptersRead: Int) {
|
||||
presenter.setLastChapterRead(item, chaptersRead)
|
||||
swipe_refresh?.isRefreshing = true
|
||||
binding.swipeRefresh.isRefreshing = true
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
||||
Reference in New Issue
Block a user