Commit 403a7924 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

delete tour db data

parent 47136304
package com.biganto.visual.roompark.data.data_provider
import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.file.FileModule
import com.biganto.visual.roompark.domain.contract.TourContract
import com.biganto.visual.roompark.domain.model.AuthInfoModel
import io.reactivex.Completable
import io.reactivex.Observable
import timber.log.Timber
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 29.10.2019.
*/
//@Singleton
class ToursRepository @Inject constructor(
private val files: FileModule,
private val db:IDb
): TourContract {
override fun getMultiTourId(building: Int, number: Int): Observable<AuthInfoModel> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun getOffer(offerId: Int): Observable<AuthInfoModel> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
override fun deleteToursDbInfo(): Completable =
Completable.merge(arrayListOf(
db.dropTourFileJuncTable(),
db.dropFileTable(),
db.dropTourTable()
))
.doOnComplete { Timber.w("Completed --") }
.doOnError { Timber.e(it) }
}
......@@ -69,4 +69,7 @@ interface IDb {
fun getTourPreview(tourId: String): ReactiveResult<TourPreviewEntity>
fun getTourPreviewsObservableResult(estateId: Int): Observable<ReactiveResult<TourPreviewEntity>>
fun getEstateTourPreviews(estateId: Int): Observable<List<TourPreviewEntity>>
fun dropFileTable(): Completable
fun dropTourFileJuncTable(): Completable
fun dropTourTable(): Completable
}
\ No newline at end of file
......@@ -14,6 +14,7 @@ import io.reactivex.BackpressureStrategy
import io.reactivex.Completable
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.rxkotlin.toCompletable
import io.reactivex.schedulers.Schedulers
import io.requery.Persistable
import io.requery.android.sqlite.DatabaseSource
......@@ -51,6 +52,12 @@ class RequeryRepository @Inject constructor(
)
: IDb {
override fun dropTourTable() = store.delete(TourPreviewEntity::class).get().toCompletable()
override fun dropTourFileJuncTable() = store.delete(TourFileJunctionEntity::class).get().toCompletable()
override fun dropFileTable() = store.delete(FileEntity::class).get().toCompletable()
private inline fun <reified T : Persistable> fetchAll() =
store.select(T::class)
......
......@@ -62,6 +62,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun provideUtils():DeviceUtilsContract
fun provideTour():TourContract
fun provideAppContext():Application
fun provideFileSystem(): FileModule
......
......@@ -51,6 +51,10 @@ abstract class ContractRepositoryModule {
@Binds
@Singleton
abstract fun provideDeviceContract(impl: DeviceUtilsRepository): DeviceUtilsContract
@Binds
@Singleton
abstract fun provideTourContract(impl: ToursRepository): TourContract
}
......
package com.biganto.visual.roompark.domain.contract
import com.biganto.visual.roompark.domain.model.AuthInfoModel
import io.reactivex.Completable
import io.reactivex.Observable
......@@ -10,4 +11,5 @@ import io.reactivex.Observable
interface TourContract {
fun getMultiTourId(building:Int, number:Int) : Observable<AuthInfoModel>
fun getOffer(offerId:Int) : Observable<AuthInfoModel>
fun deleteToursDbInfo(): Completable
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.domain.use_case
import com.biganto.visual.roompark.data.data_provider.AuthContractModule
import com.biganto.visual.roompark.domain.contract.FilesContract
import com.biganto.visual.roompark.domain.contract.TourContract
import io.reactivex.Observable
import javax.inject.Inject
......@@ -11,12 +12,14 @@ import javax.inject.Inject
class SettingsUseCase @Inject constructor(
private val authContract: AuthContractModule,
private val fileContract: FilesContract
private val fileContract: FilesContract,
private val tourContract: TourContract
){
fun signOut() = authContract.signOut()
fun clearAllCache() = fileContract.deleteAllFiles()
fun clearAllCache(): Observable<Pair<Int, Int>> =
tourContract.deleteToursDbInfo()
.andThen(fileContract.deleteAllFiles())
val planTypesSize
get() = Observable.defer { Observable.just(fileContract.getPlansSize()) }
......
......@@ -96,6 +96,7 @@ class SettingsScreenPresenter @Inject constructor(
.flatMap {
interactor.deleteCacheFiles()
.map<SettingsScreenViewState> {
Timber.d(" got progress: ${it.first} / ${it.second.toFloat()}")
SettingsScreenViewState.OnCacheDeleting(
it.first / it.second.toFloat()
)
......
......@@ -127,7 +127,7 @@
android:fitsSystemWindows="true"
android:visibility="gone"
app:elevation="0dp"
app:itemBackground="@color/colorOpacityBackgroundInv"
app:itemBackground="@color/colorPrimary"
app:itemHorizontalTranslationEnabled="false"
app:itemIconTint="@drawable/bottom_navigation_icon_selector"
app:labelVisibilityMode="unlabeled"
......
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