Use glide-like image loading function
parent
ccfaa3826b
commit
88c05a5f43
@ -0,0 +1,11 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.ext
|
||||
|
||||
import android.widget.ImageView
|
||||
import mozilla.components.browser.icons.BrowserIcons
|
||||
import mozilla.components.browser.icons.IconRequest
|
||||
|
||||
fun BrowserIcons.loadIntoView(view: ImageView, url: String) = loadIntoView(view, IconRequest(url))
|
@ -1,38 +0,0 @@
|
||||
package org.mozilla.fenix.utils
|
||||
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlinx.coroutines.Job
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* [RecyclerView.Adapter] with a [Job] for coroutines.
|
||||
* The adapterJob is setup when the adapter is initialized to a RecyclerView and canceled when detached.
|
||||
*/
|
||||
abstract class AdapterWithJob<VH : RecyclerView.ViewHolder> : RecyclerView.Adapter<VH>() {
|
||||
protected var adapterJob: Job = Job()
|
||||
|
||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView)
|
||||
adapterJob.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [ListAdapter] with a [Job] for coroutines.
|
||||
* The adapterJob is setup when the adapter is initialized to a RecyclerView and canceled when detached.
|
||||
*/
|
||||
abstract class ListAdapterWithJob<T, VH : RecyclerView.ViewHolder>(
|
||||
diffCallback: DiffUtil.ItemCallback<T>
|
||||
) : ListAdapter<T, VH>(diffCallback) {
|
||||
protected var adapterJob: Job = Job()
|
||||
|
||||
override fun onDetachedFromRecyclerView(recyclerView: RecyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView)
|
||||
adapterJob.cancel()
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<resources>
|
||||
<item name="TAG_ICON_JOB" type="id" />
|
||||
</resources>
|
Loading…
Reference in New Issue