algo112
04/26/2021, 1:40 PMval listType = object : TypeToken<List<Cookie>>() {}.type
val encodedCookie = sharedPreferences.getString(url.host, null)
val cookies: List<Cookie>? = encodedCookie?.run { gson.fromJson(encodedCookie, listType) }
return cookies ?: ArrayList()Dominaezzz
04/26/2021, 1:53 PMDominaezzz
04/26/2021, 1:54 PMorEmpty() is a thing.Dominaezzz
04/26/2021, 1:55 PMalgo112
04/26/2021, 2:03 PMreturn sharedPreferences.getString(url.host, null)?.run { gson.fromJson(this, listType) } ?: ArrayList()Sinan Gunes
04/26/2021, 2:17 PMemptyList() instead of ArrayListjaqxues
04/26/2021, 3:11 PMjaqxues
04/26/2021, 3:13 PMfun <reified T: Any> gsonTypeToken() = object: TypeToken<T>() {}.typejaqxues
04/26/2021, 3:13 PM