Commit 633d6223 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

refactoring, remove logs

parent 5ee2709b
...@@ -36,7 +36,7 @@ private const val TIMEOUT_SECONDS=120L ...@@ -36,7 +36,7 @@ private const val TIMEOUT_SECONDS=120L
private const val WRITE_SECONDS=120L private const val WRITE_SECONDS=120L
private const val READ_SECONDS=120L private const val READ_SECONDS=120L
val INTERCEPT_LOG_LEVEL = HttpLoggingInterceptor.Level.HEADERS val INTERCEPT_LOG_LEVEL = HttpLoggingInterceptor.Level.NONE
@Module @Module
class RetrofitModule{ class RetrofitModule{
......
...@@ -60,7 +60,6 @@ class FileModule @Inject constructor(val context: Application) { ...@@ -60,7 +60,6 @@ class FileModule @Inject constructor(val context: Application) {
fun saveFileToDisk(file:File,content: String){ fun saveFileToDisk(file:File,content: String){
Timber.d("write to : $file") Timber.d("write to : $file")
Timber.d("write to : ${file.name}")
// file.createNewFile() // file.createNewFile()
file.parentFile.mkdirs() file.parentFile.mkdirs()
file.writeText(content) //to json array because core unity method parse data like TourData[] Estate[] etc.. file.writeText(content) //to json array because core unity method parse data like TourData[] Estate[] etc..
......
...@@ -175,7 +175,7 @@ class DownloadManagerService @Inject constructor( ...@@ -175,7 +175,7 @@ class DownloadManagerService @Inject constructor(
val sink = Okio.buffer(Okio.appendingSink(fileStorage)) val sink = Okio.buffer(Okio.appendingSink(fileStorage))
val buffer = sink.buffer() val buffer = sink.buffer()
var read = 0L var read = 0L
val step = 4096 val step = 8192
val source = response.source() val source = response.source()
var timer = System.currentTimeMillis() var timer = System.currentTimeMillis()
var stop: Boolean = false var stop: Boolean = false
...@@ -194,7 +194,6 @@ class DownloadManagerService @Inject constructor( ...@@ -194,7 +194,6 @@ class DownloadManagerService @Inject constructor(
} }
} }
model.isDownloaded = (source.exhausted() model.isDownloaded = (source.exhausted()
&& (model.fileDownloadedSize == model.tempOverallFileSize && (model.fileDownloadedSize == model.tempOverallFileSize
|| model.tempOverallFileSize == 0L)) || model.tempOverallFileSize == 0L))
...@@ -268,9 +267,10 @@ class DownloadManagerService @Inject constructor( ...@@ -268,9 +267,10 @@ class DownloadManagerService @Inject constructor(
mergeFiles(fileEntities) mergeFiles(fileEntities)
val jlist = db.getTourFilesJunction(tour.id).toList() val jlist = db.getTourFilesJunction(tour.id).toList()
Timber.d("jlist:: ${jlist?.size} start ${jlist?.firstOrNull()?.id}")
val junctionList = fileEntities val junctionList = fileEntities
.map {file -> .map {file ->
val entity = jlist.firstOrNull{it.tour == tour.id && it.file == file.uri} val entity = jlist.firstOrNull{it.tour == tour.id && it.file.uri() == file.uri.uri()}
?: TourFileJunctionEntity().apply { ?: TourFileJunctionEntity().apply {
setTour(tour.id) setTour(tour.id)
setFile(file.uri) setFile(file.uri)
...@@ -279,8 +279,8 @@ class DownloadManagerService @Inject constructor( ...@@ -279,8 +279,8 @@ class DownloadManagerService @Inject constructor(
totalSize += file.totalSize totalSize += file.totalSize
entity entity
} }
Timber.w("fffff $downloadedSize $totalSize")
Timber.d("junctionList:: ${junctionList.size} start ${junctionList.first().id}")
setDownloadInfo( setDownloadInfo(
raw.id.toString() raw.id.toString()
, tempLoadedFiles = 0 , tempLoadedFiles = 0
...@@ -337,7 +337,6 @@ class DownloadManagerService @Inject constructor( ...@@ -337,7 +337,6 @@ class DownloadManagerService @Inject constructor(
.observeOn(Schedulers.computation()) .observeOn(Schedulers.computation())
// .doOnNext{Timber.d("7 ${it}")} // .doOnNext{Timber.d("7 ${it}")}
.flatMap { model -> .flatMap { model ->
Timber.d(" model __ ${model}")
setDownloadInfo( setDownloadInfo(
model.tourId model.tourId
, totalSizedDiffSize = model.tempTourTotalDiff , totalSizedDiffSize = model.tempTourTotalDiff
...@@ -377,10 +376,13 @@ class DownloadManagerService @Inject constructor( ...@@ -377,10 +376,13 @@ class DownloadManagerService @Inject constructor(
private fun downloadTourFromQueue(): Observable<String> = private fun downloadTourFromQueue(): Observable<String> =
Observable.fromCallable { activeDownloading.set(true);downloadQueue.poll() } Observable.fromCallable { activeDownloading.set(true);downloadQueue.poll() }
.doOnNext { Timber.d("to load tour: ${it}") }
.flatMap { db.getTourPreview(it).observable() } .flatMap { db.getTourPreview(it).observable() }
.filter { .filter {
Timber.d("to load tour: ${it.isDownloaded} ${it.id}")
val forward = it.isDownloaded != DownloadState.Downloaded val forward = it.isDownloaded != DownloadState.Downloaded
activeDownloading.set(forward) activeDownloading.set(forward)
Timber.d("to load tour: $forward")
if (!forward) if (!forward)
notifyDownloadProgress() notifyDownloadProgress()
forward forward
...@@ -519,6 +521,7 @@ class DownloadManagerService @Inject constructor( ...@@ -519,6 +521,7 @@ class DownloadManagerService @Inject constructor(
disposable.add( disposable.add(
toursToDownloadObserver toursToDownloadObserver
.flatMap { db.getTourPreview(it).observable() } .flatMap { db.getTourPreview(it).observable() }
.filter { it.isDownloaded != DownloadState.Downloaded }
.doOnNext { .doOnNext {
it.isDownloaded = DownloadState.Downloading it.isDownloaded = DownloadState.Downloading
it.downloadedFiles = 0 it.downloadedFiles = 0
...@@ -531,18 +534,20 @@ class DownloadManagerService @Inject constructor( ...@@ -531,18 +534,20 @@ class DownloadManagerService @Inject constructor(
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnError(Timber::e) .doOnError(Timber::e)
.subscribe { downloadQueue.add(it) } .subscribe { downloadQueue.add(it) }
) )
} }
private fun getMeta(tour: TourPreviewEntity): Observable<String> = private fun getMeta(tour: TourPreviewEntity): Observable<String> =
api.getTourMetaAsString(tour.id) api.getTourMetaAsString(tour.id)
.doOnNext { meta -> .map { meta ->
tour.let { tour.apply {
val metaUri = RevisionString("$META_PREDICTION${tour.id}$META_FILE_TYPE") val metaUri = RevisionString("$META_PREDICTION${tour.id}$META_FILE_TYPE")
it.setMetaFileEntityId(metaUri) setMetaFileEntityId(metaUri)
fileModule.saveFileToDisk(fileModule.getFile(metaUri.uri()), meta) fileModule.saveFileToDisk(fileModule.getFile(metaUri.uri()), meta)
} }
} }
.flatMap { db.upsertTourPreview(it) }
.map { tour.id } .map { tour.id }
.onErrorReturn { .onErrorReturn {
setTourStatus(tour.id,DownloadState.Crushed) setTourStatus(tour.id,DownloadState.Crushed)
......
...@@ -63,7 +63,7 @@ class DownloadUseCase @Inject constructor( ...@@ -63,7 +63,7 @@ class DownloadUseCase @Inject constructor(
else Okio.buffer(Okio.sink(fileStorage)) else Okio.buffer(Okio.sink(fileStorage))
val buffer = sink.buffer() val buffer = sink.buffer()
var read = 0L var read = 0L
val step = 4096 val step = 8192
val source = response.source() val source = response.source()
var stop: Boolean = token.isCancelled var stop: Boolean = token.isCancelled
sink.use { sink.use {
...@@ -161,7 +161,7 @@ class DownloadUseCase @Inject constructor( ...@@ -161,7 +161,7 @@ class DownloadUseCase @Inject constructor(
val jlist = db.getTourFilesJunction(tour.id).toList() val jlist = db.getTourFilesJunction(tour.id).toList()
val junctionList = fileEntities val junctionList = fileEntities
.map {file -> .map {file ->
val entity = jlist.firstOrNull{it.tour == tour.id && it.file == file.uri} val entity = jlist.firstOrNull{it.tour == tour.id && it.file.uri() == file.uri.uri()}
?: TourFileJunctionEntity() ?: TourFileJunctionEntity()
entity.setTour(tour.id) entity.setTour(tour.id)
entity.setFile(file.uri) entity.setFile(file.uri)
......
...@@ -33,12 +33,16 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -33,12 +33,16 @@ class TourPreviewsUseCase @Inject constructor(
,private val tours:TourContract ,private val tours:TourContract
) { ) {
fun getTourById(tourId:String):Observable<DownloadTourByIdResult> { fun getTourById(tourId: String): Observable<DownloadTourByIdResult> {
val tour = retrieveTour(tourId) val tour = retrieveTour(tourId)
Timber.d("retrieveTour $tourId / $tour") Timber.d("retrieveTour $tourId / $tour")
if (tour != null) { if (tour != null) {
if (tour.downloadState == DownloadState.Downloaded) if (tour.downloadState == DownloadState.Downloaded)
return Observable.just<DownloadTourByIdResult>(DownloadTourByIdResult.ReadyToPlay(tour)) return Observable.just<DownloadTourByIdResult>(
DownloadTourByIdResult.ReadyToPlay(
tour
)
)
return setTourState(tour.tour_id, DownloadState.DownloadQueue) return setTourState(tour.tour_id, DownloadState.DownloadQueue)
.map<DownloadTourByIdResult> { DownloadTourByIdResult.DownloadStarted(tour) } .map<DownloadTourByIdResult> { DownloadTourByIdResult.DownloadStarted(tour) }
...@@ -52,19 +56,19 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -52,19 +56,19 @@ class TourPreviewsUseCase @Inject constructor(
fun retrieveTour(tourId: String) = fun retrieveTour(tourId: String) =
db.getTourPreview(tourId) db.getTourPreview(tourId)
.asSequence() .asSequence()
.map ( ::fromEntity) .map(::fromEntity)
.firstOrNull() .firstOrNull()
private fun setTourState(tourId:String, state: DownloadState): Observable<Boolean> = private fun setTourState(tourId: String, state: DownloadState): Observable<Boolean> =
db.getTourPreview(tourId) db.getTourPreview(tourId)
.observable() .observable()
.doOnNext{ it.isDownloaded=state } .doOnNext { it.isDownloaded = state }
.flatMap { db.upsertTourPreview(it).map{true} } .flatMap { db.upsertTourPreview(it).map { true } }
private fun syncTour(tourId:String, parentId:Int):Observable<TourModel> = private fun syncTour(tourId: String, parentId: Int): Observable<TourModel> =
syncTour(tourId,parentId,calcTargetResolution()) syncTour(tourId, parentId, calcTargetResolution())
private fun syncTour(tourId:String, estateId: Int, targetResolution:Int) private fun syncTour(tourId: String, estateId: Int, targetResolution: Int)
: Observable<TourModel> { : Observable<TourModel> {
val request = ToursRemoteByIdRequestModel( val request = ToursRemoteByIdRequestModel(
arrayListOf(tourId) arrayListOf(tourId)
...@@ -76,15 +80,16 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -76,15 +80,16 @@ class TourPreviewsUseCase @Inject constructor(
.map { .map {
if (it.isNullOrEmpty()) if (it.isNullOrEmpty())
throw CustomApiException.TourByIdNotFoundException() throw CustomApiException.TourByIdNotFoundException()
it.first() } it.first()
}
.doOnNext { it.isDownloaded = DownloadState.DownloadQueue } .doOnNext { it.isDownloaded = DownloadState.DownloadQueue }
.flatMap {db.upsertTourPreview(it)} .flatMap { db.upsertTourPreview(it) }
.map(::fromEntity) .map(::fromEntity)
.doOnError(Timber::e) .doOnError(Timber::e)
} }
private fun calcTargetResolution():Int{ private fun calcTargetResolution(): Int {
val w = Resources.getSystem().displayMetrics.widthPixels val w = Resources.getSystem().displayMetrics.widthPixels
val h = Resources.getSystem().displayMetrics.heightPixels val h = Resources.getSystem().displayMetrics.heightPixels
return w.coerceAtLeast(h) return w.coerceAtLeast(h)
...@@ -93,10 +98,13 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -93,10 +98,13 @@ class TourPreviewsUseCase @Inject constructor(
private fun forceTourUpdate(requestModel: ToursRemoteByIdRequestModel): Observable<List<TourPreviewEntity>> = private fun forceTourUpdate(requestModel: ToursRemoteByIdRequestModel): Observable<List<TourPreviewEntity>> =
api.getToursPreviewById(requestModel.ids) api.getToursPreviewById(requestModel.ids)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.map { fromRaw(it .map {
fromRaw(
it
, requestModel.estateId , requestModel.estateId
, api.provideHttpUrl().toString() , api.provideHttpUrl().toString()
, requestModel.targetResolution) , requestModel.targetResolution
)
} }
...@@ -104,16 +112,15 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -104,16 +112,15 @@ class TourPreviewsUseCase @Inject constructor(
db.getEstateTourPreviews(estateId) db.getEstateTourPreviews(estateId)
.filter { !it.isNullOrEmpty() } .filter { !it.isNullOrEmpty() }
private fun fetchApiTourList(multitourId:Int,estateId: Int) = private fun fetchApiTourList(multitourId: Int, estateId: Int) =
auth.currentUser() auth.currentUser()
.doOnNext { Timber.d("user on next: $it") }
.map { it.targetResolution } .map { it.targetResolution }
.flatMap { res -> .flatMap { res ->
Timber.d("user: $res")
api.getOfferTours(multitourId) api.getOfferTours(multitourId)
.doOnError { Timber.e(it) } .doOnError { Timber.e(it) }
.map { .map {
mergeRaw(it, TourRemoteRequestModel( mergeRaw(
it, TourRemoteRequestModel(
estateId, estateId,
api.provideHttpUrl().toString(), api.provideHttpUrl().toString(),
res res
...@@ -124,36 +131,41 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -124,36 +131,41 @@ class TourPreviewsUseCase @Inject constructor(
.doOnNext { db.blockingUpsert(it) } .doOnNext { db.blockingUpsert(it) }
} }
fun fetchTourOffer(multitourId:Int,parent:Int) = fun fetchTourOffer(multitourId: Int, parent: Int): Observable<List<TourModel>> =
Observable.mergeDelayError( Observable.mergeDelayError(
arrayListOf(fetchDbTourList(parent),fetchApiTourList(multitourId,parent)) arrayListOf(fetchDbTourList(parent), fetchApiTourList(multitourId, parent))
) )
.take(1) .take(1)
.doOnError { Timber.e(it) } .doOnError { Timber.e(it) }
.map (::fromEntity) .map(::fromEntity)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
private fun mergeRaw(raw: List<TourPreviewRaw>, requestRequestModel: TourRemoteRequestModel) = private fun mergeRaw(raw: List<TourPreviewRaw>, requestRequestModel: TourRemoteRequestModel) =
raw.map{ mergeRaw(it, requestRequestModel) } raw.map { mergeRaw(it, requestRequestModel) }
private fun mergeRaw(raw: TourPreviewRaw, requestRequestModel: TourRemoteRequestModel) private fun mergeRaw(raw: TourPreviewRaw, requestRequestModel: TourRemoteRequestModel)
: TourPreviewEntity { : TourPreviewEntity {
Timber.d("got raw: $raw") Timber.d("got raw: $raw")
val entity = db.getTourPreview(raw.id.toString()).firstOrNull() val entity = db.getTourPreview(raw.id.toString()).firstOrNull()
?: return fromRaw(raw ?: return fromRaw(
raw
, requestRequestModel.estateId , requestRequestModel.estateId
, api.provideHttpUrl().toString() , api.provideHttpUrl().toString()
, requestRequestModel.targetResolution) , requestRequestModel.targetResolution
)
val fromApi = fromRaw(raw val fromApi = fromRaw(
raw
, requestRequestModel.estateId , requestRequestModel.estateId
, api.provideHttpUrl().toString() , api.provideHttpUrl().toString()
, requestRequestModel.targetResolution) , requestRequestModel.targetResolution
)
if (fromApi.updated > entity.updated if (fromApi.updated > entity.updated
&& entity.isDownloaded == DownloadState.Downloaded) { && entity.isDownloaded == DownloadState.Downloaded
) {
entity.isDownloaded = entity.isDownloaded =
DownloadState.NotSynced//maxState(entity.isDownloaded, fromApi.isDownloaded) DownloadState.NotSynced//maxState(entity.isDownloaded, fromApi.isDownloaded)
return entity return entity
...@@ -163,19 +175,18 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -163,19 +175,18 @@ class TourPreviewsUseCase @Inject constructor(
// if (fromApi.estate.id!=requestRequestModel.estateId) // if (fromApi.estate.id!=requestRequestModel.estateId)
// entity.estate=fromApi.estate // entity.estate=fromApi.estate
fromApi.setMetaFileEntityId(entity.metaFileEntityId) fromApi.setMetaFileEntityId(entity.metaFileEntityId)
fromApi.targetResolution=entity.targetResolution fromApi.targetResolution = entity.targetResolution
fromApi.isDownloaded=entity.isDownloaded fromApi.isDownloaded = entity.isDownloaded
fromApi.overallSize=entity.overallSize fromApi.overallSize = entity.overallSize
fromApi.downloadedSize=entity.downloadedSize fromApi.downloadedSize = entity.downloadedSize
fromApi.tempSize=entity.tempSize fromApi.tempSize = entity.tempSize
fromApi.overallFiles=entity.overallFiles fromApi.overallFiles = entity.overallFiles
fromApi.downloadedFiles=entity.downloadedFiles fromApi.downloadedFiles = entity.downloadedFiles
return fromApi return fromApi
} }
private fun getUserEstates(user:UserEntity) private fun getUserEstates(user: UserEntity) = user.deals?.map { it.estate }?.plus(
= user.deals?.map { it.estate }?.plus(
user.estates user.estates
?.asSequence() ?.asSequence()
?.filter { it.favorite } ?.filter { it.favorite }
...@@ -185,18 +196,15 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -185,18 +196,15 @@ class TourPreviewsUseCase @Inject constructor(
fun fetchToursSizes(): Observable<Long> = fun fetchToursSizes(): Observable<Long> =
auth.currentUser() auth.currentUser()
.map (::getUserEstates) .map(::getUserEstates)
.map { it.filter { estates -> estates.multitourId!=null }.toList() } .map { it.filter { estates -> estates.multitourId != null }.toList() }
.map { estates -> .map { estates ->
val toursOffersToLoad = mutableListOf<Int>() val toursOffersToLoad = mutableListOf<Int>()
estates.forEach{ estates.forEach {
if (it.tours.isNullOrEmpty()) if (it.tours.isNullOrEmpty())
toursOffersToLoad.add(it.multitourId!!) toursOffersToLoad.add(it.multitourId!!)
} }
Timber.d(" targer estates : " + Pair(estates, toursOffersToLoad)
"${estates.map { it.tours?.size }} " )
Timber.d(" targer toursOffersToLoad : $toursOffersToLoad " )
Pair(estates,toursOffersToLoad)
} }
.flatMap { pair -> .flatMap { pair ->
if (pair.second.isNotEmpty()) { if (pair.second.isNotEmpty()) {
...@@ -206,51 +214,45 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -206,51 +214,45 @@ class TourPreviewsUseCase @Inject constructor(
fetchTourOffer( fetchTourOffer(
it, pair.first.first { estete -> estete.multitourId == it }.id it, pair.first.first { estete -> estete.multitourId == it }.id
).doOnError { Timber.e(it) } ).doOnError { Timber.e(it) }
.doOnNext { tours -> loadedIds.addAll(tours.map{ t -> t.tour_id }) } .doOnNext { tours -> loadedIds.addAll(tours.map { t -> t.tour_id }) }
} }
).takeLast(1) ).takeLast(1)
.doOnNext { db.refreshEntities(pair.first) } .doOnNext { db.refreshEntities(pair.first) }
.map { Pair(pair.first,loadedIds )} .map { Pair(pair.first, loadedIds) }
} } else return@flatMap Observable.just(Pair(pair.first, null))
else return@flatMap Observable.just(Pair(pair.first,null))
} }
.doOnNext { Timber.d(" HERER ") }
.flatMap { pair -> .flatMap { pair ->
val estates = pair.first val estates = pair.first
for (estate in estates) {
Timber.d(" targer estates : ${estate.user} " )
}
val r = (estates.first().user as UserEntity).targetResolution val r = (estates.first().user as UserEntity).targetResolution
Timber.d(" targer R : $r " )
var knownSize = var knownSize =
estates.flatMap { estates.flatMap {
it.tours?.map {t -> t as TourPreviewEntity} it.tours?.map { t -> t as TourPreviewEntity }
?.asIterable()?: arrayListOf() ?.asIterable() ?: arrayListOf()
}.filter{t -> t.overallSize > 0L } }
.onEach { Timber.d("it.overallSize - it.downloadedSize " + .filter { t -> t.overallSize > 0L }
"${it.overallSize}/${it.downloadedSize}") }
.sumByLong { it.overallSize - it.downloadedSize } .sumByLong { it.overallSize - it.downloadedSize }
Timber.d(" targer knownSize : $knownSize " )
val toursToLoadSize = val toursToLoadSize =
estates.flatMap { estates.flatMap {
it.tours?.map {t -> t as TourPreviewEntity} it.tours?.map { t -> t as TourPreviewEntity }
?.asIterable()?: arrayListOf() ?.asIterable() ?: arrayListOf()
}.filter{t -> t.overallSize < 1L } }
.filter { t -> t.overallSize < 1L }
Timber.d(" targer toursToLoadSize : $toursToLoadSize " ) .map { it.id }.toMutableList()
val listIds = toursToLoadSize.map { it.id }.toMutableList()
pair.second?.let { listIds.addAll(it)} pair.second?.let { toursToLoadSize.addAll(it) }
Timber.d(" targer estates : ${listIds} " )
if (listIds.isNullOrEmpty()) return@flatMap Observable.just(knownSize) if (toursToLoadSize.isNullOrEmpty()) return@flatMap Observable.just(knownSize)
else return@flatMap api.getTourFilesSizes( else return@flatMap api.getTourFilesSizes(
listIds,r.toString() toursToLoadSize, r.toString()
) )
.flatMapIterable { it } .flatMapIterable { it }
.flatMap { rawSize -> .flatMap { rawSize ->
db.getTourPreview(rawSize.id.toString()) db.getTourPreview(rawSize.id.toString())
.observable() .observable()
.map {entity -> .map { entity ->
knownSize += rawSize.total_size knownSize += rawSize.total_size
entity.apply { entity.apply {
overallSize = rawSize.total_size overallSize = rawSize.total_size
...@@ -258,7 +260,7 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -258,7 +260,7 @@ class TourPreviewsUseCase @Inject constructor(
} }
entity entity
} }
.doOnNext{ db.upsert(it).blockingGet() } .doOnNext { db.upsert(it).blockingGet() }
}.map { knownSize } }.map { knownSize }
} }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
...@@ -276,7 +278,6 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -276,7 +278,6 @@ class TourPreviewsUseCase @Inject constructor(
auth.currentUser() auth.currentUser()
.map { user -> .map { user ->
val estatesList = getUserEstates(user) val estatesList = getUserEstates(user)
estatesList estatesList
?.asSequence() ?.asSequence()
?.filter { it.multitourId != null } ?.filter { it.multitourId != null }
...@@ -291,26 +292,17 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -291,26 +292,17 @@ class TourPreviewsUseCase @Inject constructor(
) )
} }
} }
.doOnNext { Timber.d("merged list:${it?.size}") }
.map { list -> .map { list ->
list.map { pair -> list.map { pair ->
api.getOfferTours(pair.first) api.getOfferTours(pair.first)
.doOnNext { Timber.d(" gonna merge") }
.map { .map {
mergeRaw( mergeRaw(it, pair.second)
it
, pair.second
)
} }
.map { it } .map { it }
.doOnNext { Timber.d("merged list:${it.size}") }
.blockingFirst() .blockingFirst()
} }
.flatten() .flatten()
} }
// .map { it.flatten() }
.doOnNext { Timber.d("merged flatten list:${it.size}") }
.flatMap { db.upsertTourPreview(it) } .flatMap { db.upsertTourPreview(it) }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
} }
......
...@@ -208,11 +208,6 @@ class SettingsScreenController : ...@@ -208,11 +208,6 @@ class SettingsScreenController :
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
private fun render(viewState: SettingsScreenViewState.LoadSettingsList){ private fun render(viewState: SettingsScreenViewState.LoadSettingsList){
toursDownloaderTitle.text = viewState.settings.offlineStoreData[0].title +
"(${viewState.settings.offlineStoreData[0].amountBytes.bytesToSize()})"
flatDownloaderTitle.text = viewState.settings.offlineStoreData[1].title +
"(${viewState.settings.offlineStoreData[1].amountBytes.bytesToSize()})"
} }
private fun getComponent() = DaggerSettingsScreenComponent.factory() private fun getComponent() = DaggerSettingsScreenComponent.factory()
......
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