Commit f2a9e182 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix tour launcher

parent 52cea639
...@@ -17,6 +17,7 @@ import com.biganto.visual.roompark.di.dagger.AppComponent ...@@ -17,6 +17,7 @@ import com.biganto.visual.roompark.di.dagger.AppComponent
import com.biganto.visual.roompark.di.dagger.PerScreen import com.biganto.visual.roompark.di.dagger.PerScreen
import com.biganto.visual.roompark.domain.interactor.ToursInteractor import com.biganto.visual.roompark.domain.interactor.ToursInteractor
import com.biganto.visual.roompark.domain.model.TourModel import com.biganto.visual.roompark.domain.model.TourModel
import com.biganto.visual.roompark.domain.model.fromEntity
import com.biganto.visual.roompark.domain.use_case.DownloadUseCase import com.biganto.visual.roompark.domain.use_case.DownloadUseCase
import com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider import com.biganto.visual.roompark.util.view_utils.snackbar.ISnackBarProvider
import com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity import com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity
...@@ -100,8 +101,8 @@ class DownloadTourDialogController : Controller { ...@@ -100,8 +101,8 @@ class DownloadTourDialogController : Controller {
downloadTourTitleText.text = tour.title downloadTourTitleText.text = tour.title
Glide.with(view) Glide.with(view)
.load(tour.previewUrl) .load(tour.previewUrl)
.transform(BlurTransformation(13, 8)) .transform(BlurTransformation(13, 8)
.transform(ColorFilterTransformation(0x99000000.toInt())) ,ColorFilterTransformation(0x99000000.toInt()))
.into(downloaderBg) .into(downloaderBg)
disposables.add( disposables.add(
...@@ -114,7 +115,10 @@ class DownloadTourDialogController : Controller { ...@@ -114,7 +115,10 @@ class DownloadTourDialogController : Controller {
{ model -> { model ->
updateProgressBar(model.downloadedFiles, model.overallFiles) updateProgressBar(model.downloadedFiles, model.overallFiles)
if (model.overallFiles == model.downloadedFiles) if (model.overallFiles == model.downloadedFiles)
activity?.let{ startPlayer(it,tour) } activity?.let{
startPlayer(it, fromEntity(model))
handleBack()
}
} }
,{error -> ,{error ->
Timber.e(error) Timber.e(error)
......
...@@ -33,9 +33,14 @@ class FileModule @Inject constructor(val context: Application) { ...@@ -33,9 +33,14 @@ class FileModule @Inject constructor(val context: Application) {
fun getFile(fileUri: String): File { fun getFile(fileUri: String): File {
try { try {
val fileName =if (fileUri.contains("/")) fileUri.substring(fileUri.lastIndexOf("/")) else fileUri val fileName =
val fileDir = if (fileUri.contains("/")) fileUri.substring(0, fileUri.lastIndexOf("/")) else "" if (fileUri.contains("/")) fileUri.substring(fileUri.lastIndexOf("/"))
val directory = File(rootFolder, fileDir) else fileUri
val fileDir =
if (fileUri.contains("/"))
fileUri.substring(0, fileUri.lastIndexOf("/"))
else ""
val directory = File(assetsFile(context), fileDir)
directory.mkdirs() directory.mkdirs()
val file = File(directory, fileName) val file = File(directory, fileName)
...@@ -61,7 +66,7 @@ class FileModule @Inject constructor(val context: Application) { ...@@ -61,7 +66,7 @@ class FileModule @Inject constructor(val context: Application) {
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..
} }
fun deleteFile(uri:String)= getFile(uri).delete() // fun deleteFile(uri:String)= getFile(uri).delete()
fun deleteAllCacheObservable() = fun deleteAllCacheObservable() =
Observable.create<Pair<Int, Int>> {emitter -> Observable.create<Pair<Int, Int>> {emitter ->
...@@ -89,9 +94,11 @@ class FileModule @Inject constructor(val context: Application) { ...@@ -89,9 +94,11 @@ class FileModule @Inject constructor(val context: Application) {
fun getDirectory(context: Context, dirType: FileDirectory): File = fun getDirectory(context: Context, dirType: FileDirectory): File =
File(context.filesDir.absolutePath.plus(dirType.dir)) File(context.filesDir.absolutePath.plus(dirType.dir))
fun assetsDirectory(context: Context): String = context.filesDir.absolutePath fun assetsDirectory(context: Context): String =
getDirectory(context,FileDirectory.ToursDir("biganto")).absolutePath
fun assetsFile(context: Context): File = context.filesDir.absoluteFile fun assetsFile(context: Context): File =
getDirectory(context,FileDirectory.ToursDir("biganto"))
} }
......
...@@ -277,7 +277,11 @@ class DownloadUseCase @Inject constructor( ...@@ -277,7 +277,11 @@ class DownloadUseCase @Inject constructor(
tour.let { tour.let {
val metaUri = RevisionString("$META_PREDICTION${tour.id}$META_FILE_TYPE") val metaUri = RevisionString("$META_PREDICTION${tour.id}$META_FILE_TYPE")
it.setMetaFileEntityId(metaUri) it.setMetaFileEntityId(metaUri)
fileModule.saveFileToDisk(fileModule.getFile(metaUri.uri()), meta) fileModule.saveFileToDisk(
File(
FileModule.assetsDirectory(context).plus(metaUri.uri())
),meta
)
} }
} }
?.map { tour } ?.map { tour }
......
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