From 93fc5944f34ef0be8198ff0d7c3eaca7f3b4454d Mon Sep 17 00:00:00 2001 From: len Date: Mon, 6 Jun 2016 16:53:58 +0200 Subject: [PATCH] Remove unneeded casts --- .../ui/recently_read/RecentlyReadAdapter.kt | 13 +++++++------ .../ui/recently_read/RecentlyReadHolder.kt | 4 ++-- .../ui/recently_read/RecentlyReadPresenter.kt | 17 ++++++++++------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt index ce289a4c6..565ac3b8e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt @@ -1,6 +1,5 @@ package eu.kanade.tachiyomi.ui.recently_read -import android.support.v7.widget.RecyclerView import android.view.ViewGroup import eu.davidea.flexibleadapter.FlexibleAdapter import eu.kanade.tachiyomi.R @@ -15,13 +14,15 @@ import eu.kanade.tachiyomi.util.inflate * @param fragment a RecentlyReadFragment object * @constructor creates an instance of the adapter. */ -class RecentlyReadAdapter(val fragment: RecentlyReadFragment) : FlexibleAdapter() { +class RecentlyReadAdapter(val fragment: RecentlyReadFragment) +: FlexibleAdapter() { + /** * Called when ViewHolder is created * @param parent parent View * @param viewType int containing viewType */ - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder? { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecentlyReadHolder { val view = parent.inflate(R.layout.item_recent_manga) return RecentlyReadHolder(view, this) } @@ -31,9 +32,9 @@ class RecentlyReadAdapter(val fragment: RecentlyReadFragment) : FlexibleAdapter< * @param holder bind holder * @param position position of holder */ - override fun onBindViewHolder(holder: RecyclerView.ViewHolder?, position: Int) { - val item = getItem(position) as MangaChapterHistory - (holder as RecentlyReadHolder).onSetValues(item) + override fun onBindViewHolder(holder: RecentlyReadHolder, position: Int) { + val item = getItem(position) + holder.onSetValues(item) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt index fbc7e6e22..d70fdfcd3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt @@ -22,8 +22,8 @@ import java.text.DecimalFormatSymbols * @param adapter the adapter handling this holder. * @constructor creates a new recent chapter holder. */ -class RecentlyReadHolder(view: View, private val adapter: RecentlyReadAdapter) : - RecyclerView.ViewHolder(view) { +class RecentlyReadHolder(view: View, private val adapter: RecentlyReadAdapter) +: RecyclerView.ViewHolder(view) { /** * DecimalFormat used to display correct chapter number diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadPresenter.kt index 552409be2..c0b837c88 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadPresenter.kt @@ -13,17 +13,20 @@ import java.text.SimpleDateFormat import java.util.* import javax.inject.Inject -/** - * The id of the restartable. - */ -const private val GET_RECENT_MANGA = 1 - /** * Presenter of RecentlyReadFragment. * Contains information and data for fragment. * Observable updates should be called from here. */ class RecentlyReadPresenter : BasePresenter() { + + companion object { + /** + * The id of the restartable. + */ + const private val GET_RECENT_MANGA = 1 + } + /** * Used to connect to database */ @@ -35,9 +38,9 @@ class RecentlyReadPresenter : BasePresenter() { // Used to get recent manga restartableLatestCache(GET_RECENT_MANGA, { getRecentMangaObservable() }, - { recentMangaFragment, manga -> + { view, manga -> // Update adapter to show recent manga's - recentMangaFragment.onNextManga(manga) + view.onNextManga(manga) } )