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