Unverified Commit 9c1a9213 authored by Jonathan Almeida's avatar Jonathan Almeida
Browse files

Issue #7313: Update sample browser to use thumbnail loader

parent 0a95c91d
......@@ -112,6 +112,7 @@ dependencies {
implementation project(':support-utils')
implementation project(':feature-downloads')
implementation project(':support-images')
implementation project(':support-ktx')
implementation project(':support-webextensions')
implementation project(':support-rustlog')
......
......@@ -9,11 +9,16 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import mozilla.components.browser.state.state.WebExtensionState
import mozilla.components.browser.tabstray.BrowserTabsTray
import mozilla.components.browser.tabstray.DefaultTabViewHolder
import mozilla.components.browser.tabstray.TabsAdapter
import mozilla.components.browser.tabstray.ViewHolderProvider
import mozilla.components.browser.thumbnails.loader.ThumbnailLoader
import mozilla.components.concept.engine.EngineView
import mozilla.components.concept.tabstray.TabsTray
import mozilla.components.feature.intent.ext.getSessionId
......@@ -81,7 +86,7 @@ open class BrowserActivity : AppCompatActivity(), ComponentCallbacks2 {
share(it)
}
}.asView()
TabsTray::class.java.name -> BrowserTabsTray(context, attrs)
TabsTray::class.java.name -> createTabsTray(context, attrs)
else -> super.onCreateView(parent, name, context, attrs)
}
......@@ -92,4 +97,23 @@ open class BrowserActivity : AppCompatActivity(), ComponentCallbacks2 {
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
}
private fun createTabsTray(context: Context, attrs: AttributeSet): BrowserTabsTray {
val thumbnailLoader = ThumbnailLoader(components.thumbnailStorage)
val viewHolderProvider: ViewHolderProvider = { viewGroup, tabsTray ->
DefaultTabViewHolder(
LayoutInflater.from(viewGroup.context).inflate(
R.layout.mozac_browser_tabstray_item,
viewGroup,
false
),
tabsTray,
thumbnailLoader
)
}
val adapter = TabsAdapter(thumbnailLoader, viewHolderProvider)
return BrowserTabsTray(context, attrs, 0, adapter)
}
}
......@@ -114,7 +114,7 @@ open class DefaultComponents(private val applicationContext: Context) {
private val sessionStorage by lazy { SessionStorage(applicationContext, engine) }
private val thumbnailStorage by lazy { ThumbnailStorage(applicationContext) }
val thumbnailStorage by lazy { ThumbnailStorage(applicationContext) }
val store by lazy {
BrowserStore(middleware = listOf(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment