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 { ...@@ -69,4 +69,7 @@ interface IDb {
fun getTourPreview(tourId: String): ReactiveResult<TourPreviewEntity> fun getTourPreview(tourId: String): ReactiveResult<TourPreviewEntity>
fun getTourPreviewsObservableResult(estateId: Int): Observable<ReactiveResult<TourPreviewEntity>> fun getTourPreviewsObservableResult(estateId: Int): Observable<ReactiveResult<TourPreviewEntity>>
fun getEstateTourPreviews(estateId: Int): Observable<List<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 ...@@ -14,6 +14,7 @@ import io.reactivex.BackpressureStrategy
import io.reactivex.Completable import io.reactivex.Completable
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.Single import io.reactivex.Single
import io.reactivex.rxkotlin.toCompletable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import io.requery.Persistable import io.requery.Persistable
import io.requery.android.sqlite.DatabaseSource import io.requery.android.sqlite.DatabaseSource
...@@ -51,6 +52,12 @@ class RequeryRepository @Inject constructor( ...@@ -51,6 +52,12 @@ class RequeryRepository @Inject constructor(
) )
: IDb { : 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() = private inline fun <reified T : Persistable> fetchAll() =
store.select(T::class) store.select(T::class)
......
...@@ -62,6 +62,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{ ...@@ -62,6 +62,8 @@ interface AppComponent : AndroidInjector<RoomParkApplication>{
fun provideUtils():DeviceUtilsContract fun provideUtils():DeviceUtilsContract
fun provideTour():TourContract
fun provideAppContext():Application fun provideAppContext():Application
fun provideFileSystem(): FileModule fun provideFileSystem(): FileModule
......
...@@ -51,6 +51,10 @@ abstract class ContractRepositoryModule { ...@@ -51,6 +51,10 @@ abstract class ContractRepositoryModule {
@Binds @Binds
@Singleton @Singleton
abstract fun provideDeviceContract(impl: DeviceUtilsRepository): DeviceUtilsContract abstract fun provideDeviceContract(impl: DeviceUtilsRepository): DeviceUtilsContract
@Binds
@Singleton
abstract fun provideTourContract(impl: ToursRepository): TourContract
} }
......
package com.biganto.visual.roompark.domain.contract package com.biganto.visual.roompark.domain.contract
import com.biganto.visual.roompark.domain.model.AuthInfoModel import com.biganto.visual.roompark.domain.model.AuthInfoModel
import io.reactivex.Completable
import io.reactivex.Observable import io.reactivex.Observable
...@@ -10,4 +11,5 @@ import io.reactivex.Observable ...@@ -10,4 +11,5 @@ import io.reactivex.Observable
interface TourContract { interface TourContract {
fun getMultiTourId(building:Int, number:Int) : Observable<AuthInfoModel> fun getMultiTourId(building:Int, number:Int) : Observable<AuthInfoModel>
fun getOffer(offerId: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 ...@@ -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.data.data_provider.AuthContractModule
import com.biganto.visual.roompark.domain.contract.FilesContract import com.biganto.visual.roompark.domain.contract.FilesContract
import com.biganto.visual.roompark.domain.contract.TourContract
import io.reactivex.Observable import io.reactivex.Observable
import javax.inject.Inject import javax.inject.Inject
...@@ -11,15 +12,17 @@ import javax.inject.Inject ...@@ -11,15 +12,17 @@ import javax.inject.Inject
class SettingsUseCase @Inject constructor( class SettingsUseCase @Inject constructor(
private val authContract: AuthContractModule, private val authContract: AuthContractModule,
private val fileContract: FilesContract private val fileContract: FilesContract,
private val tourContract: TourContract
){ ){
fun signOut() = authContract.signOut() fun signOut() = authContract.signOut()
fun clearAllCache() = fileContract.deleteAllFiles() fun clearAllCache(): Observable<Pair<Int, Int>> =
tourContract.deleteToursDbInfo()
.andThen(fileContract.deleteAllFiles())
val planTypesSize val planTypesSize
get() = Observable.defer { Observable.just(fileContract.getPlansSize()) } get() = Observable.defer { Observable.just(fileContract.getPlansSize()) }
val albumsSize val albumsSize
get() = Observable.defer { Observable.just(fileContract.getAlbumSize()) } get() = Observable.defer { Observable.just(fileContract.getAlbumSize()) }
......
...@@ -96,6 +96,7 @@ class SettingsScreenPresenter @Inject constructor( ...@@ -96,6 +96,7 @@ class SettingsScreenPresenter @Inject constructor(
.flatMap { .flatMap {
interactor.deleteCacheFiles() interactor.deleteCacheFiles()
.map<SettingsScreenViewState> { .map<SettingsScreenViewState> {
Timber.d(" got progress: ${it.first} / ${it.second.toFloat()}")
SettingsScreenViewState.OnCacheDeleting( SettingsScreenViewState.OnCacheDeleting(
it.first / it.second.toFloat() it.first / it.second.toFloat()
) )
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:visibility="gone" android:visibility="gone"
app:elevation="0dp" app:elevation="0dp"
app:itemBackground="@color/colorOpacityBackgroundInv" app:itemBackground="@color/colorPrimary"
app:itemHorizontalTranslationEnabled="false" app:itemHorizontalTranslationEnabled="false"
app:itemIconTint="@drawable/bottom_navigation_icon_selector" app:itemIconTint="@drawable/bottom_navigation_icon_selector"
app:labelVisibilityMode="unlabeled" 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