Commit 47136304 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix update cache info; add delay to show progress bar

parent abd6e913
...@@ -36,9 +36,9 @@ class SettingsInteractor @Inject constructor( ...@@ -36,9 +36,9 @@ class SettingsInteractor @Inject constructor(
} }
private val plans private val plans : Observable<CachedDataModel>
get() = settingsUseCase.planTypesSize.map { get() = settingsUseCase.planTypesSize.map {
CachedDataModel(activity.resources.getString(R.string.plans_cache),it,1) CachedDataModel(activity.resources.getString(R.string.plans_cache), it, 1)
} }
private val tours private val tours
...@@ -64,7 +64,7 @@ class SettingsInteractor @Inject constructor( ...@@ -64,7 +64,7 @@ class SettingsInteractor @Inject constructor(
fun deleteCacheFiles() = settingsUseCase.clearAllCache() fun deleteCacheFiles() = settingsUseCase.clearAllCache()
fun getCacheInfo() = fun getCacheInfo(): Observable<MutableList<CachedDataModel>> =
Observable.concatArray(plans, tours, feeds, albums, overall).toList().toObservable() Observable.concatArray(plans, tours, feeds, albums, overall).toList().toObservable()
fun fetchSettings(): Observable<SettingsModel> = Observable.just(sampleSettings) fun fetchSettings(): Observable<SettingsModel> = Observable.just(sampleSettings)
......
...@@ -19,18 +19,18 @@ class SettingsUseCase @Inject constructor( ...@@ -19,18 +19,18 @@ class SettingsUseCase @Inject constructor(
fun clearAllCache() = fileContract.deleteAllFiles() fun clearAllCache() = fileContract.deleteAllFiles()
val planTypesSize val planTypesSize
get() = Observable.just(fileContract.getPlansSize()) get() = Observable.defer { Observable.just(fileContract.getPlansSize()) }
val albumsSize val albumsSize
get() = Observable.just(fileContract.getAlbumSize()) get() = Observable.defer { Observable.just(fileContract.getAlbumSize()) }
val feedsSize val feedsSize
get() = Observable.just(fileContract.getFeedSize()) get() = Observable.defer { Observable.just(fileContract.getFeedSize()) }
val toursSize val toursSize
get() = Observable.just(fileContract.getToursSize()) get() = Observable.defer { Observable.just(fileContract.getToursSize()) }
val overallSize val overallSize
get() = Observable.just(fileContract.allCacheSize()) get() = Observable.defer { Observable.just(fileContract.allCacheSize()) }
} }
\ No newline at end of file
...@@ -11,6 +11,7 @@ import io.reactivex.Observable ...@@ -11,6 +11,7 @@ import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import timber.log.Timber import timber.log.Timber
import java.util.concurrent.TimeUnit
import javax.inject.Inject import javax.inject.Inject
/** /**
...@@ -99,6 +100,7 @@ class SettingsScreenPresenter @Inject constructor( ...@@ -99,6 +100,7 @@ class SettingsScreenPresenter @Inject constructor(
it.first / it.second.toFloat() it.first / it.second.toFloat()
) )
} }
.delay(500,TimeUnit.MILLISECONDS)
.startWith(SettingsScreenViewState.OnCacheDeleting(0f)) .startWith(SettingsScreenViewState.OnCacheDeleting(0f))
.doOnError { Timber.e(it) } .doOnError { Timber.e(it) }
} }
......
Markdown is supported
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