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

update to global url usage

parent 2bc434e7
......@@ -71,16 +71,11 @@ android {
}
}
applicationVariants.all { variant ->
if (variant.name.contains("release")) {
variant.outputs.each { output ->
output.outputFileName = new File(
"Expeditor_v")
}
}
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'
}
task renameBundle(type: Copy) {
from "$buildDir/outputs/bundle/release"
into "../../"
......@@ -226,7 +221,6 @@ dependencies {
//RxKotlin
implementation("io.reactivex.rxjava2:rxkotlin:$rxKotlinVersion")
//Arch Lifecycle
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
......
......@@ -78,8 +78,5 @@ class RoomParkApplication : DaggerApplication() {
private class CrashlyticsTree : Timber.Tree() {
override fun log(priority: Int, tag: String?, message: String, throwable: Throwable?) {
if (priority == Log.VERBOSE || priority == Log.DEBUG) return
// Crashlytics.log(priority, tag, message)
// throwable?.let { Crashlytics.logException(it) }
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import com.biganto.visual.roompark.data.repository.file.FileModule
import com.biganto.visual.roompark.domain.model.TourModel
import com.biganto.visual.roompark.player.BigantoPlayerActivity
import com.biganto.visual.roompark.player.unity_utils.LoadTourConfig
import java.io.File
/**
* Created by Vladislav Bogdashkin on 07.04.2020.
......@@ -22,7 +23,7 @@ fun startPlayer(context:Context,tour: TourModel)
val tourConfig = LoadTourConfig(
tour.tour_id.toInt(),
tour.targetResolution,
FileModule.assetsDirectory(context),
FileModule.assetsDirectory(context).plus(File.separator).plus(tour.footageUri),
tour.metaPredict,
tour.previewUrl,
context.resources?.getBoolean(R.bool.isTablet)?.not()?:true,
......
......@@ -8,6 +8,11 @@ import java.util.*
*/
data class LiteTourMetaRaw(
val baseurl:String,
val tour_baseurl:String
)
data class ErrorRaw(
val code:Int,
......
package com.biganto.visual.roompark.data.repository.db.requrey.model
import com.biganto.visual.roompark.data.repository.api.biganto.IBigantoMobileApi.Companion.BASE_URL
import com.biganto.visual.roompark.data.repository.api.biganto.raw.LiteTourMetaRaw
import com.biganto.visual.roompark.data.repository.api.biganto.raw.TourFileRaw
import com.biganto.visual.roompark.data.repository.db.requrey.RevisionString
import com.biganto.visual.roompark.data.repository.db.requrey.utils.RevisionStringConverter
import com.biganto.visual.roompark.data.repository.file.FileModule
import io.requery.*
import java.io.File
/**
* Created by Vladislav Bogdashkin on 15.06.2018.
*/
val domainPredicthMatcher = "^(http|https)://".toRegex()
fun toInitialName(fullPath:String) = fullPath.hashCode().toString()
@Entity
interface File :Persistable {
// @get:Key
......@@ -21,21 +28,43 @@ interface File :Persistable {
val downloadedSize: Long
@get:Nullable
val isDownloaded: Boolean
// @get:ForeignKey(references = Skybox::class)
// @get:ManyToOne(cascade = arrayOf(CascadeAction.NONE))
// var skyboxId:Skybox?
@get:Nullable
val destination: String
}
fun fromRaw(raw: TourFileRaw):FileEntity {
fun fromRaw(raw: TourFileRaw, meta: LiteTourMetaRaw):FileEntity {
val entity = FileEntity()
entity.setDownloaded(false)
entity.setDownloadedSize(0L)
entity.setTotalSize(raw.size)
entity.setUri(RevisionString(raw.url.substring(raw.url.indexOf("asset"))))
var fileUri=raw.url
domainPredicthMatcher.containsMatchIn(raw.url)
val bui = raw.url.indexOf(meta.baseurl)
if (bui>=0) fileUri = toInitialName(meta.baseurl)
.plus(File.separator)
.plus(raw.url.removeRange(0,bui+meta.baseurl.length))
val tui = raw.url.indexOf(meta.tour_baseurl)
if (tui>=0) fileUri = toInitialName(meta.tour_baseurl)
.plus(File.separator)
.plus(raw.url.removeRange(0,tui+meta.tour_baseurl.length))
entity.setUri(RevisionString(FileModule.assetsLocalPath(fileUri)))
entity.setDestination(
if (domainPredicthMatcher.containsMatchIn(raw.url)) raw.url
else BASE_URL+raw.url
)
return entity
}
fun fromRaw(raw: List<TourFileRaw>): List<FileEntity> =List(raw.size) { index-> fromRaw(raw[index]) }
\ No newline at end of file
fun fromRaw(raw: List<TourFileRaw>, meta: LiteTourMetaRaw): List<FileEntity> =
List(raw.size) { index-> fromRaw(raw[index],meta) }
......@@ -60,6 +60,8 @@ interface TourPreview :Persistable {
@get:Convert(RevisionStringConverter::class)
val metaFileEntityId: RevisionString?
val tourBaseUrl: String?
val footageBaseUrl: String?
}
......
......@@ -127,10 +127,15 @@ class FileModule @Inject constructor(val context: Application) {
File(context.filesDir.absolutePath.plus(dirType.dir))
fun assetsDirectory(context: Context): String =
getDirectory(context,FileDirectory.ToursDir("biganto")).absolutePath
getDirectory(context,FileDirectory.ToursDir(BIGANTO_TOURS_FOLDER)).absolutePath
fun assetsFile(context: Context): File =
getDirectory(context,FileDirectory.ToursDir("biganto"))
getDirectory(context,FileDirectory.ToursDir(BIGANTO_TOURS_FOLDER))
fun assetsLocalPath(uri:String): String =
FileDirectory.ToursDir(BIGANTO_TOURS_FOLDER).dir.plus(File.separator).plus(uri)
private const val BIGANTO_TOURS_FOLDER = "biganto"
}
......
......@@ -9,17 +9,21 @@ import androidx.core.math.MathUtils.clamp
import com.biganto.visual.roompark.R
import com.biganto.visual.roompark.base.RoomParkApplication
import com.biganto.visual.roompark.data.repository.api.biganto.IBigantoApi
import com.biganto.visual.roompark.data.repository.api.biganto.raw.LiteTourMetaRaw
import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.db.requrey.RevisionString
import com.biganto.visual.roompark.data.repository.db.requrey.model.FileEntity
import com.biganto.visual.roompark.data.repository.db.requrey.model.TourFileJunctionEntity
import com.biganto.visual.roompark.data.repository.db.requrey.model.fromRaw
import com.biganto.visual.roompark.data.repository.db.requrey.model.toInitialName
import com.biganto.visual.roompark.data.repository.file.FileModule
import com.biganto.visual.roompark.data.service.lifecycle.ForegroundLifecycleObserver
import com.biganto.visual.roompark.data.service.notification.INotificationCenter
import com.biganto.visual.roompark.domain.use_case.TOUR_IDS_TO_DOWNLOAD_KEY
import com.biganto.visual.roomparkvr.data.repository.db.requery.model.DownloadState
import com.biganto.visual.roomparkvr.data.repository.db.requery.model.TourPreviewEntity
import com.google.gson.Gson
import com.google.gson.JsonParser
import com.jakewharton.rxrelay2.PublishRelay
import io.reactivex.BackpressureStrategy
import io.reactivex.Flowable
......@@ -282,7 +286,9 @@ class DownloadManagerService @Inject constructor(
.flatMap { raw ->
var downloadedSize = 0L
var totalSize = 0L
val fileEntities = raw.files.map(::fromRaw)
val meta = getLocalMeta(tour)
val fileEntities = fromRaw(raw.files,meta)
mergeFiles(fileEntities)
val jlist = db.getTourFilesJunction(tour.id).toList()
......@@ -561,12 +567,33 @@ class DownloadManagerService @Inject constructor(
api.getTourMetaAsString(tour.id)
.map { meta ->
tour.apply {
val metaUri = RevisionString("$META_PREDICTION${tour.id}$META_FILE_TYPE")
setMetaFileEntityId(metaUri)
fileModule.saveFileToDisk(fileModule.getFile(metaUri.uri()), meta)
try {
val jMeta = JsonParser().parse(meta).asJsonArray.first()
val metaLite = Gson().fromJson(jMeta, LiteTourMetaRaw::class.java)
val metaUri = RevisionString("$META_PREDICTION${tour.id}$META_FILE_TYPE")
setMetaFileEntityId(metaUri)
setFootageBaseUrl(toInitialName(metaLite.baseurl))
setTourBaseUrl(toInitialName(metaLite.tour_baseurl))
fileModule.saveFileToDisk(
fileModule.getAssetFile(
File.separator
.plus(tour.footageBaseUrl)
.plus(metaUri.uri())
)
, meta
)
} catch (e: Exception) {
Timber.e(e)
}
}
}
.flatMap { db.upsertTourPreview(it) }
.flatMap { db.upsertTourPreview(it) }
.map { tour.id }
.onErrorReturn {
setTourStatus(tour.id,DownloadState.Crushed)
......@@ -576,6 +603,20 @@ class DownloadManagerService @Inject constructor(
//#endregion oldMethod
private fun getLocalMeta(tour: TourPreviewEntity): LiteTourMetaRaw {
return Gson().fromJson(
JsonParser().parse(
fileModule.getAssetFile(
"/${tour.footageBaseUrl}"
.plus("/${tour.metaFileEntityId?.uri()}"
)
).readText()
).asJsonArray.first()
, LiteTourMetaRaw::class.java
)
}
private fun refreshGallery(file: File) {
MediaScannerConnection.scanFile(context, arrayOf(file.path), null
)
......
......@@ -15,7 +15,7 @@ buildscript {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta03'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
......
......@@ -6,16 +6,21 @@
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
kotlin.code.style=official
android.enableD8=true
# org.gradle.jvmargs=-Xmx1536m
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.caching=true
android.enableBuildScriptClasspathCheck=false
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
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