Browse Source

bug-fix-12-10

faterhenry 6 years ago
parent
commit
c577c22557
1 changed files with 42 additions and 23 deletions
  1. 42 23
      src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt

+ 42 - 23
src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt

@@ -103,25 +103,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                 WindowManager.LayoutParams.FLAG_FULLSCREEN)
         actionBar?.hide()
         supportActionBar?.hide()
-        project = Gson().fromJson<Project>(intent.getStringExtra("project"), Project::class.java)
-        resourceThemeBitmap = project.sceneResource as ArrayList<String>
-        resourceThemeBitmap.add(File(Config.ASSETS_FOLDER, Config.PROJECT_WHITE_FILE_NAME).path)
-        resourceActorBitmap = when(intent.getStringExtra("resource_actor")) {
-            null -> { project.actorResource as ArrayList<ArrayList<String>>}
-            else -> { Gson().fromJson<ThemeActorResource>(intent.getStringExtra("resource_actor"), ThemeActorResource::class.java).actorPath}
-        }
-        resourceObjectPath = when(intent.getStringArrayListExtra("resource_object")) {
-            null -> {
-                ArrayList<String>().apply {
-                    project.themeAssetIndex.contains.obj.values.forEach {
-                        val path = "${project.assetFolder.path}/${it.smallFile}"
-                        add(path)
-                    }
-                }
-            }
-            else -> { intent.getStringArrayListExtra("resource_object")}
-        }
         windowManager.defaultDisplay.getMetrics(monitorSize)
+        project = Gson().fromJson<Project>(intent.getStringExtra("project"), Project::class.java)
+        initResource()
         var layoutPrams = sceneEditView.layoutParams
         layoutPrams.width = monitorSize.widthPixels
         layoutPrams.height = monitorSize.widthPixels.div(2)
@@ -150,7 +134,18 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     }
         }
         initControlBarView()
-        initNavigationFunction()
+        project.story?.let {
+            it.scenes?.let {
+                when (it[0].record) {
+                    null -> {
+                        initNavigationFunction()
+                    }
+                    else -> {
+                        initNavigationBarView(0)
+                    }
+                }
+            }
+        }
         initRecord()
     }
 
@@ -167,6 +162,27 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         }
     }
 
+    private fun initResource(){
+        resourceThemeBitmap = project.sceneResource as ArrayList<String>
+        if (!resourceThemeBitmap.contains(File(Config.ASSETS_FOLDER, Config.PROJECT_WHITE_FILE_NAME).path)){
+            resourceThemeBitmap.add(File(Config.ASSETS_FOLDER, Config.PROJECT_WHITE_FILE_NAME).path)
+        }
+        resourceActorBitmap = when(intent.getStringExtra("resource_actor")) {
+            null -> { project.actorResource as ArrayList<ArrayList<String>>}
+            else -> { Gson().fromJson<ThemeActorResource>(intent.getStringExtra("resource_actor"), ThemeActorResource::class.java).actorPath}
+        }
+        resourceObjectPath = when(intent.getStringArrayListExtra("resource_object")) {
+            null -> {
+                ArrayList<String>().apply {
+                    project.themeAssetIndex.contains.obj.values.forEach {
+                        val path = "${project.assetFolder.path}/${it.smallFile}"
+                        add(path)
+                    }
+                }
+            }
+            else -> { intent.getStringArrayListExtra("resource_object")}
+        }
+    }
     private fun initControlBarView() {
         controlBarView.setBtnSelected(6)
         switchToPreViewLayer()
@@ -227,6 +243,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     setControlSceneView()
                     editSceneView.setOnClickDoneListener(View.OnClickListener {
                         if (!isSceneRecorded) initNavigationFunction()
+                        else setControlSceneView()
                     })
                     editSceneView.setOnClickStartOverListener(View.OnClickListener {
                         project.story?.let {
@@ -1529,10 +1546,12 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         var otherThemes =  OtherThemes()
         SuperAppModule.themeManager.themes.forEach {
             if (SuperAppModule.themeManager.canUse(it) && SuperAppModule.themeManager.isDownloaded(it)) {
-                val index = SuperAppModule.themeManager.loadThemeAssetIndex(it).blockingGet()
-                val data = it
-                var theme = Theme(index,SuperAppModule.themeManager.getAssetFolder(data))
-                otherThemes.themes.add(theme)
+                SuperAppModule.themeManager.loadThemeAssetIndex(it)
+                        .subscribe { index ->
+                            val data = it
+                            var theme = Theme(index,SuperAppModule.themeManager.getAssetFolder(data))
+                            otherThemes.themes.add(theme)
+                        }
             }
         }
         val json = Gson().toJson(project)