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
import com.google.gson.JsonElement
import dagger.Module
import io.reactivex.Observable
import kotlinx.io.IOException
import timber.log.Timber
import java.io.File
import javax.inject.Inject
......@@ -65,15 +66,15 @@ class FileModule @Inject constructor(val context: Application) {
fun deleteAllCacheObservable() =
Observable.create<Pair<Int, Int>> {emitter ->
val foldersToDelete = listOf(
FileDirectory.Albums().dir,
FileDirectory.FeedsDir().dir,
FileDirectory.PlanTypeDir().dir,
FileDirectory.ToursDir().dir
FileDirectory.Albums(),
FileDirectory.FeedsDir(),
FileDirectory.PlanTypeDir(),
FileDirectory.ToursDir()
)
foldersToDelete.forEachIndexed{ index,dir ->
if (File(dir).deleteRecursively())
emitter.onNext(Pair(index,foldersToDelete.size))
else emitter.onError(error("Error occurred on files deleting!"))
foldersToDelete.forEachIndexed { index, dir ->
if (getDirectory(context,dir).deleteRecursively())
emitter.onNext(Pair(index, foldersToDelete.size-1))
else emitter.onError(IOException("Error occurred on files deleting!"))
}
emitter.onComplete()
}
......
......@@ -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.splash.SplashScreenController
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.changehandler.FadeChangeHandler
import com.google.android.material.textview.MaterialTextView
......@@ -83,6 +84,8 @@ class SettingsScreenController :
@BindView(R.id.clear_cache_button)
lateinit var clearCacheButton:MaterialTextView
@BindView(R.id.progress_lock_background)
lateinit var progressShame:View
private fun setToolbar(){
toolBar.appBar.liftOnScrollTargetViewId = R.id.nestedScrollContainer
......@@ -124,6 +127,7 @@ class SettingsScreenController :
is SettingsScreenViewState.LoadSettingsList -> render(viewState)
is SettingsScreenViewState.SomeError -> render(viewState)
is SettingsScreenViewState.SignOut -> render(viewState)
is SettingsScreenViewState.OnCacheDeleting -> render(viewState)
}
}
......@@ -131,7 +135,12 @@ class SettingsScreenController :
showError(viewState.exception)
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){
......
......@@ -147,5 +147,24 @@
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