Skip to content
Permalink
Browse files

Add AndroidX collections dependency

  • Loading branch information...
chrisbanes committed Aug 23, 2019
1 parent 650051c commit a524b53dd231a6d2628ad86ed6a2962a826cdaf6
@@ -46,6 +46,7 @@ dependencies {

implementation Libs.AndroidX.Fragment.fragment
implementation Libs.AndroidX.coreKtx
implementation Libs.AndroidX.collection

implementation Libs.timber
implementation Libs.threeTenAbp
@@ -17,15 +17,17 @@
package app.tivi

import android.view.View
import androidx.collection.ArrayMap

data class SharedElementHelper(
private val sharedElementViews: MutableMap<View, String?> = mutableMapOf()
) {
val sharedElements: Map<View, String?> = sharedElementViews
class SharedElementHelper {
private val _sharedElements = ArrayMap<View, String?>()

fun addSharedElement(view: View, name: String? = null) {
sharedElementViews[view] = name ?: view.transitionName
val sharedElements: Map<View, String?>
get() = _sharedElements

fun addSharedElement(view: View, transitionName: String? = view.transitionName) {
_sharedElements[view] = transitionName ?: view.transitionName
}

fun isEmpty(): Boolean = sharedElementViews.isEmpty()
fun isEmpty(): Boolean = _sharedElements.isEmpty
}
@@ -73,6 +73,7 @@ object Libs {
object AndroidX {
const val appcompat = "androidx.appcompat:appcompat:1.1.0-rc01"
const val browser = "androidx.browser:browser:1.0.0"
const val collection = "androidx.collection:collection-ktx:1.1.0"
const val palette = "androidx.palette:palette:1.0.0"
const val recyclerview = "androidx.recyclerview:recyclerview:1.1.0-beta03"
const val emoji = "androidx.emoji:emoji:1.0.0"
@@ -32,6 +32,7 @@ dependencies {

api Libs.AndroidX.Room.common
api Libs.AndroidX.Room.ktx
implementation Libs.AndroidX.collection

api Libs.AndroidX.Paging.common

@@ -16,14 +16,15 @@

package app.tivi.data.repositories.search

import androidx.collection.LruCache
import javax.inject.Inject

class SearchStore @Inject constructor() {
private val cache = HashMap<String, LongArray>()
private val cache = LruCache<String, LongArray>(32)

fun getResults(query: String) = cache[query]

fun setResults(query: String, results: LongArray) {
cache[query] = results
cache.put(query, results)
}
}

0 comments on commit a524b53

Please sign in to comment.
You can’t perform that action at this time.