Commit 89fe6434 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix cache directory path to delete

parent d01c7933
...@@ -7,6 +7,7 @@ import com.biganto.visual.roompark.util.extensions.asInt ...@@ -7,6 +7,7 @@ import com.biganto.visual.roompark.util.extensions.asInt
import com.google.gson.JsonElement import com.google.gson.JsonElement
import dagger.Module import dagger.Module
import io.reactivex.Observable import io.reactivex.Observable
import kotlinx.io.IOException
import timber.log.Timber import timber.log.Timber
import java.io.File import java.io.File
import javax.inject.Inject import javax.inject.Inject
...@@ -65,15 +66,15 @@ class FileModule @Inject constructor(val context: Application) { ...@@ -65,15 +66,15 @@ class FileModule @Inject constructor(val context: Application) {
fun deleteAllCacheObservable() = fun deleteAllCacheObservable() =
Observable.create<Pair<Int, Int>> {emitter -> Observable.create<Pair<Int, Int>> {emitter ->
val foldersToDelete = listOf( val foldersToDelete = listOf(
FileDirectory.Albums().dir, FileDirectory.Albums(),
FileDirectory.FeedsDir().dir, FileDirectory.FeedsDir(),
FileDirectory.PlanTypeDir().dir, FileDirectory.PlanTypeDir(),
FileDirectory.ToursDir().dir FileDirectory.ToursDir()
) )
foldersToDelete.forEachIndexed{ index,dir -> foldersToDelete.forEachIndexed { index, dir ->
if (File(dir).deleteRecursively()) if (getDirectory(context,dir).deleteRecursively())
emitter.onNext(Pair(index,foldersToDelete.size)) emitter.onNext(Pair(index, foldersToDelete.size-1))
else emitter.onError(error("Error occurred on files deleting!")) else emitter.onError(IOException("Error occurred on files deleting!"))
} }
emitter.onComplete() emitter.onComplete()
} }
......
...@@ -16,6 +16,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListA ...@@ -16,6 +16,7 @@ import com.biganto.visual.roompark.presentation.screen.settings.util.CahcedListA
import com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter import com.biganto.visual.roompark.presentation.screen.settings.util.PushListAdapter
import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController import com.biganto.visual.roompark.presentation.screen.splash.SplashScreenController
import com.biganto.visual.roompark.util.extensions.bytesToSize import com.biganto.visual.roompark.util.extensions.bytesToSize
import com.biganto.visual.roompark.util.extensions.setGone
import com.bluelinelabs.conductor.RouterTransaction import com.bluelinelabs.conductor.RouterTransaction
import com.bluelinelabs.conductor.changehandler.FadeChangeHandler import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
...@@ -83,6 +84,8 @@ class SettingsScreenController : ...@@ -83,6 +84,8 @@ class SettingsScreenController :
@BindView(R.id.clear_cache_button) @BindView(R.id.clear_cache_button)
lateinit var clearCacheButton:MaterialTextView lateinit var clearCacheButton:MaterialTextView
@BindView(R.id.progress_lock_background)
lateinit var progressShame:View
private fun setToolbar(){ private fun setToolbar(){
toolBar.appBar.liftOnScrollTargetViewId = R.id.nestedScrollContainer toolBar.appBar.liftOnScrollTargetViewId = R.id.nestedScrollContainer
...@@ -124,6 +127,7 @@ class SettingsScreenController : ...@@ -124,6 +127,7 @@ class SettingsScreenController :
is SettingsScreenViewState.LoadSettingsList -> render(viewState) is SettingsScreenViewState.LoadSettingsList -> render(viewState)
is SettingsScreenViewState.SomeError -> render(viewState) is SettingsScreenViewState.SomeError -> render(viewState)
is SettingsScreenViewState.SignOut -> render(viewState) is SettingsScreenViewState.SignOut -> render(viewState)
is SettingsScreenViewState.OnCacheDeleting -> render(viewState)
} }
} }
...@@ -131,7 +135,12 @@ class SettingsScreenController : ...@@ -131,7 +135,12 @@ class SettingsScreenController :
showError(viewState.exception) showError(viewState.exception)
private fun render(viewState: SettingsScreenViewState.Idle){ private fun render(viewState: SettingsScreenViewState.Idle){
progressShame.setGone(true)
}
private fun render(viewState: SettingsScreenViewState.OnCacheDeleting){
progressShame.setGone(viewState.progress>=1f)
} }
private fun render(viewState: SettingsScreenViewState.SignOut){ private fun render(viewState: SettingsScreenViewState.SignOut){
......
...@@ -147,5 +147,24 @@ ...@@ -147,5 +147,24 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="32dp" /> 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> </LinearLayout>
</androidx.core.widget.NestedScrollView> </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