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

add refresh call on clear cache

parent 89fe6434
......@@ -10,5 +10,6 @@ import io.reactivex.Observable
interface SettingsScreen : BigantoBaseContract<SettingsScreenViewState> {
fun signOut(): Observable<Int>
fun clearCache(): Observable<Int>
fun refreshCacheInfo(): Observable<Int>
}
......@@ -21,6 +21,7 @@ import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.textview.MaterialTextView
import com.jakewharton.rxbinding3.view.clicks
import com.jakewharton.rxrelay2.BehaviorRelay
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import timber.log.Timber
......@@ -48,6 +49,8 @@ class SettingsScreenController :
.map { Timber.d("Clicked clear cache button"); 1 }
.observeOn(AndroidSchedulers.mainThread())
private val refreshEmitter = BehaviorRelay.create<Int>()
override fun refreshCacheInfo(): Observable<Int> = refreshEmitter
override fun injectDependencies() {
getComponent()
......@@ -136,11 +139,15 @@ class SettingsScreenController :
private fun render(viewState: SettingsScreenViewState.Idle){
progressShame.setGone(true)
clearCacheButton.setGone(false)
}
private fun render(viewState: SettingsScreenViewState.OnCacheDeleting){
progressShame.setGone(viewState.progress>=1f)
val isProgressed = viewState.progress>=1f
progressShame.setGone(isProgressed)
clearCacheButton.setGone(!isProgressed)
refreshEmitter.accept(1)
}
private fun render(viewState: SettingsScreenViewState.SignOut){
......
......@@ -42,6 +42,10 @@ class SettingsScreenPresenter @Inject constructor(
.onErrorReturn(::parseError)
}
val refreshInfo = intent(SettingsScreen::refreshCacheInfo)
.flatMap {fetchSettings}
val onClearCache = intent(SettingsScreen::clearCache)
.flatMap {
interactor.deleteCacheFiles()
......@@ -52,6 +56,7 @@ class SettingsScreenPresenter @Inject constructor(
}
.startWith(SettingsScreenViewState.OnCacheDeleting(0f))
.onErrorReturn(::parseError)
}
......@@ -59,6 +64,7 @@ class SettingsScreenPresenter @Inject constructor(
.mergeWith(fetchSettings)
.mergeWith(onSignOut)
.mergeWith(onClearCache)
.mergeWith(refreshInfo)
.doOnError{ Timber.e(it)}
.subscribeOn(Schedulers.io())
.onErrorReturn(::parseError)
......
......@@ -126,8 +126,30 @@
android:id="@+id/clear_cache_button"
style="@style/Default_TextView.Clear_Cache_Text"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="16dp"
android:textAlignment="center" />
<FrameLayout
android:id="@+id/progress_lock_background"
android:background="@color/colorOpacityBackgroundInv"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="16dp"
android:backgroundTint="@color/colorPrimary"
android:visibility="gone"
>
<ProgressBar
android:id="@+id/settings_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="32dp" />
android:indeterminate="true"
android:layout_gravity="center"/>
</FrameLayout>
<com.google.android.material.textview.MaterialTextView
......@@ -147,24 +169,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="32dp" />
<FrameLayout
android:id="@+id/progress_lock_background"
android:background="@color/colorOpacityBackgroundInv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"
>
<ProgressBar
android:id="@+id/settings_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:layout_gravity="center"/>
</FrameLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
\ No newline at end of file
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