For #3846 - Pass in updated session icon to tabs
parent
d028c97112
commit
f6285ad5f8
|
@ -16,6 +16,7 @@ fun Session.toTab(context: Context, selected: Boolean? = null, mediaState: Media
|
|||
this.url.urlToTrimmedHost(context),
|
||||
this.title,
|
||||
selected,
|
||||
mediaState
|
||||
mediaState,
|
||||
this.icon
|
||||
)
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ sealed class AdapterItem(@LayoutRes val viewType: Int) {
|
|||
// Tell the adapter exactly what values have changed so it only has to draw those
|
||||
override fun getChangePayload(newItem: AdapterItem): Any? {
|
||||
(newItem as TabItem).let {
|
||||
val shouldUpdateUrl = newItem.tab.url != this.tab.url
|
||||
val shouldUpdateFavicon =
|
||||
newItem.tab.url != this.tab.url || newItem.tab.icon != this.tab.icon
|
||||
val shouldUpdateHostname = newItem.tab.hostname != this.tab.hostname
|
||||
val shouldUpdateTitle = newItem.tab.title != this.tab.title
|
||||
val shouldUpdateSelected = newItem.tab.selected != this.tab.selected
|
||||
|
@ -53,7 +54,7 @@ sealed class AdapterItem(@LayoutRes val viewType: Int) {
|
|||
|
||||
return AdapterItemDiffCallback.TabChangePayload(
|
||||
tab = newItem.tab,
|
||||
shouldUpdateUrl = shouldUpdateUrl,
|
||||
shouldUpdateFavicon = shouldUpdateFavicon,
|
||||
shouldUpdateHostname = shouldUpdateHostname,
|
||||
shouldUpdateTitle = shouldUpdateTitle,
|
||||
shouldUpdateSelected = shouldUpdateSelected,
|
||||
|
@ -129,7 +130,7 @@ class AdapterItemDiffCallback : DiffUtil.ItemCallback<AdapterItem>() {
|
|||
|
||||
data class TabChangePayload(
|
||||
val tab: Tab,
|
||||
val shouldUpdateUrl: Boolean,
|
||||
val shouldUpdateFavicon: Boolean,
|
||||
val shouldUpdateHostname: Boolean,
|
||||
val shouldUpdateTitle: Boolean,
|
||||
val shouldUpdateSelected: Boolean,
|
||||
|
@ -220,7 +221,9 @@ class SessionControlAdapter(
|
|||
|
||||
if (it.shouldUpdateHostname) { holder.updateHostname(it.tab.hostname) }
|
||||
if (it.shouldUpdateTitle) { holder.updateTitle(it.tab.title) }
|
||||
if (it.shouldUpdateUrl) { holder.updateFavIcon(it.tab.url, it.tab.sessionId) }
|
||||
if (it.shouldUpdateFavicon) {
|
||||
holder.updateFavIcon(it.tab.url, it.tab.icon)
|
||||
}
|
||||
if (it.shouldUpdateSelected) { holder.updateSelected(it.tab.selected ?: false) }
|
||||
if (it.shouldUpdateMediaState) {
|
||||
holder.updatePlayPauseButton(it.tab.mediaState ?: MediaState.None)
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package org.mozilla.fenix.home.sessioncontrol
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -50,7 +51,8 @@ data class Tab(
|
|||
val hostname: String,
|
||||
val title: String,
|
||||
val selected: Boolean? = null,
|
||||
var mediaState: MediaState? = null
|
||||
var mediaState: MediaState? = null,
|
||||
val icon: Bitmap? = null
|
||||
)
|
||||
|
||||
fun List<Tab>.toSessionBundle(context: Context): MutableList<Session> {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
package org.mozilla.fenix.home.sessioncontrol.viewholders
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Outline
|
||||
import android.view.View
|
||||
import android.view.ViewOutlineProvider
|
||||
|
@ -93,7 +94,7 @@ class TabViewHolder(
|
|||
updateTab(tab)
|
||||
updateTitle(tab.title)
|
||||
updateHostname(tab.hostname)
|
||||
updateFavIcon(tab.url, tab.sessionId)
|
||||
updateFavIcon(tab.url, tab.icon)
|
||||
updateSelected(tab.selected ?: false)
|
||||
updatePlayPauseButton(tab.mediaState ?: MediaState.None)
|
||||
item_tab.transitionName = "$TAB_ITEM_TRANSITION_NAME${tab.sessionId}"
|
||||
|
@ -130,11 +131,7 @@ class TabViewHolder(
|
|||
hostname.text = text
|
||||
}
|
||||
|
||||
internal fun updateFavIcon(url: String, sessionId: String) {
|
||||
val icon = favicon_image.context.components.core
|
||||
.sessionManager
|
||||
.findSessionById(sessionId)?.icon
|
||||
|
||||
internal fun updateFavIcon(url: String, icon: Bitmap?) {
|
||||
if (icon == null) {
|
||||
favicon_image.context.components.core.icons.loadIntoView(favicon_image, url)
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue