Add images and 'view chapters' to library updates (#785)

* added option to open manga directly from library update
added covers for manga in library update
added ability to click covers to open manga directly from library update

* Removed 3 dot option to open manga
Adjusted covers to circles and material standard for recent chapter

* fixed potential null pointer on cover click

* adjusted circle imageview size for recently read
This commit is contained in:
Carlos 2017-05-08 03:22:49 -04:00 committed by inorichi
parent 2118434823
commit fa8f5bc0d8
4 changed files with 54 additions and 2 deletions

View File

@ -2,10 +2,13 @@ package eu.kanade.tachiyomi.ui.recent_updates
import android.view.View import android.view.View
import android.widget.PopupMenu import android.widget.PopupMenu
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import eu.davidea.viewholders.FlexibleViewHolder import eu.davidea.viewholders.FlexibleViewHolder
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.util.getResourceColor import eu.kanade.tachiyomi.util.getResourceColor
import jp.wasabeef.glide.transformations.CropCircleTransformation
import kotlinx.android.synthetic.main.item_recent_chapters.view.* import kotlinx.android.synthetic.main.item_recent_chapters.view.*
/** /**
@ -41,6 +44,9 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
// correctly positioned. The reason being that the view may change position before the // correctly positioned. The reason being that the view may change position before the
// PopupMenu is shown. // PopupMenu is shown.
view.chapter_menu.setOnClickListener { it.post { showPopupMenu(it) } } view.chapter_menu.setOnClickListener { it.post { showPopupMenu(it) } }
view.manga_cover.setOnClickListener {
adapter.coverClickListener.onCoverClick(adapterPosition)
}
} }
/** /**
@ -57,6 +63,16 @@ class RecentChapterHolder(private val view: View, private val adapter: RecentCha
// Set manga title // Set manga title
view.manga_title.text = item.manga.title view.manga_title.text = item.manga.title
// Set cover
Glide.clear(itemView.manga_cover)
if (!item.manga.thumbnail_url.isNullOrEmpty()) {
Glide.with(itemView.context)
.load(item.manga)
.diskCacheStrategy(DiskCacheStrategy.RESULT)
.bitmapTransform(CropCircleTransformation(view.context))
.into(itemView.manga_cover)
}
// Check if chapter is read and set correct color // Check if chapter is read and set correct color
if (item.chapter.read) { if (item.chapter.read) {
view.chapter_title.setTextColor(readColor) view.chapter_title.setTextColor(readColor)

View File

@ -6,8 +6,14 @@ import eu.davidea.flexibleadapter.items.IFlexible
class RecentChaptersAdapter(val controller: RecentChaptersController) : class RecentChaptersAdapter(val controller: RecentChaptersController) :
FlexibleAdapter<IFlexible<*>>(null, controller, true) { FlexibleAdapter<IFlexible<*>>(null, controller, true) {
val coverClickListener: OnCoverClickListener = controller
init { init {
setDisplayHeadersAtStartUp(true) setDisplayHeadersAtStartUp(true)
setStickyHeaders(true) setStickyHeaders(true)
} }
interface OnCoverClickListener {
fun onCoverClick(position: Int)
}
} }

View File

@ -6,6 +6,8 @@ import android.support.v7.view.ActionMode
import android.support.v7.widget.DividerItemDecoration import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.LinearLayoutManager
import android.view.* import android.view.*
import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.jakewharton.rxbinding.support.v4.widget.refreshes import com.jakewharton.rxbinding.support.v4.widget.refreshes
import com.jakewharton.rxbinding.support.v7.widget.scrollStateChanges import com.jakewharton.rxbinding.support.v7.widget.scrollStateChanges
import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.FlexibleAdapter
@ -15,6 +17,7 @@ import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.data.library.LibraryUpdateService
import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController import eu.kanade.tachiyomi.ui.base.controller.NoToolbarElevationController
import eu.kanade.tachiyomi.ui.base.controller.NucleusController import eu.kanade.tachiyomi.ui.base.controller.NucleusController
import eu.kanade.tachiyomi.ui.manga.MangaController
import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.util.toast import eu.kanade.tachiyomi.util.toast
import kotlinx.android.synthetic.main.fragment_recent_chapters.view.* import kotlinx.android.synthetic.main.fragment_recent_chapters.view.*
@ -31,7 +34,8 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
FlexibleAdapter.OnItemClickListener, FlexibleAdapter.OnItemClickListener,
FlexibleAdapter.OnItemLongClickListener, FlexibleAdapter.OnItemLongClickListener,
FlexibleAdapter.OnUpdateListener, FlexibleAdapter.OnUpdateListener,
ConfirmDeleteChaptersDialog.Listener { ConfirmDeleteChaptersDialog.Listener,
RecentChaptersAdapter.OnCoverClickListener {
/** /**
* Action mode for multiple selection. * Action mode for multiple selection.
@ -247,6 +251,18 @@ class RecentChaptersController : NucleusController<RecentChaptersPresenter>(),
presenter.deleteChapters(listOf(chapter)) presenter.deleteChapters(listOf(chapter))
} }
override fun onCoverClick(position: Int) {
val chapterClicked = adapter?.getItem(position) as? RecentChapterItem ?: return
openManga(chapterClicked)
}
fun openManga(chapter: RecentChapterItem) {
router.pushController(RouterTransaction.with(MangaController(chapter.manga))
.pushChangeHandler(FadeChangeHandler())
.popChangeHandler(FadeChangeHandler()))
}
/** /**
* Called when chapters are deleted * Called when chapters are deleted
*/ */

View File

@ -13,7 +13,9 @@
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
android:paddingRight="?android:attr/listPreferredItemPaddingRight" android:paddingRight="?android:attr/listPreferredItemPaddingRight"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"> android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/manga_cover">
<RelativeLayout <RelativeLayout
android:id="@+id/relativeLayout" android:id="@+id/relativeLayout"
@ -90,5 +92,17 @@
</RelativeLayout> </RelativeLayout>
<ImageView
android:id="@+id/manga_cover"
android:layout_width="@dimen/material_component_lists_single_line_with_avatar_height"
android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
android:layout_centerVertical="true"
android:src="@drawable/branded_logo_icon"
android:clickable="true"
android:paddingLeft="@dimen/material_component_lists_icon_left_padding"
android:paddingStart="@dimen/material_component_lists_icon_left_padding"
android:paddingRight="0dp"
android:paddingEnd="0dp"
android:contentDescription="@string/description_cover"/>
</RelativeLayout> </RelativeLayout>