Fix code analysis errors
This commit is contained in:
parent
e4f42baaed
commit
8e9b14cecc
34 changed files with 71 additions and 79 deletions
|
|
@ -7,13 +7,20 @@ import org.fnives.test.showcase.model.session.Session
|
|||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class SharedPreferencesManagerImpl constructor(private val sharedPreferences: SharedPreferences) : UserDataLocalStorage {
|
||||
class SharedPreferencesManagerImpl(
|
||||
private val sharedPreferences: SharedPreferences
|
||||
) : UserDataLocalStorage {
|
||||
|
||||
override var session: Session? by SessionDelegate(SESSION_KEY)
|
||||
|
||||
private class SessionDelegate(private val key: String) : ReadWriteProperty<SharedPreferencesManagerImpl, Session?> {
|
||||
private class SessionDelegate(private val key: String) :
|
||||
ReadWriteProperty<SharedPreferencesManagerImpl, Session?> {
|
||||
|
||||
override fun setValue(thisRef: SharedPreferencesManagerImpl, property: KProperty<*>, value: Session?) {
|
||||
override fun setValue(
|
||||
thisRef: SharedPreferencesManagerImpl,
|
||||
property: KProperty<*>,
|
||||
value: Session?
|
||||
) {
|
||||
if (value == null) {
|
||||
thisRef.sharedPreferences.edit().remove(key).apply()
|
||||
} else {
|
||||
|
|
@ -25,7 +32,10 @@ class SharedPreferencesManagerImpl constructor(private val sharedPreferences: Sh
|
|||
}
|
||||
}
|
||||
|
||||
override fun getValue(thisRef: SharedPreferencesManagerImpl, property: KProperty<*>): Session? {
|
||||
override fun getValue(
|
||||
thisRef: SharedPreferencesManagerImpl,
|
||||
property: KProperty<*>
|
||||
): Session? {
|
||||
val values = thisRef.sharedPreferences.getStringSet(key, null)?.toList()
|
||||
val accessToken = values?.firstOrNull { it.startsWith(ACCESS_TOKEN_KEY) }
|
||||
?.drop(ACCESS_TOKEN_KEY.length) ?: return null
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ import org.fnives.test.showcase.core.storage.content.FavouriteContentLocalStorag
|
|||
import org.fnives.test.showcase.model.content.ContentId
|
||||
import javax.inject.Inject
|
||||
|
||||
class FavouriteContentLocalStorageImpl @Inject constructor(private val favouriteDao: FavouriteDao) : FavouriteContentLocalStorage {
|
||||
class FavouriteContentLocalStorageImpl @Inject constructor(
|
||||
private val favouriteDao: FavouriteDao
|
||||
) : FavouriteContentLocalStorage {
|
||||
|
||||
override fun observeFavourites(): Flow<List<ContentId>> =
|
||||
favouriteDao.get().map { it.map(FavouriteEntity::contentId).map(::ContentId) }
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import android.os.Bundle
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.fnives.test.showcase.R
|
||||
import org.fnives.test.showcase.databinding.ActivityMainBinding
|
||||
import org.fnives.test.showcase.model.content.ContentId
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue