Bläddra i källkod

fix record process

faterhenry 6 år sedan
förälder
incheckning
969f31097c

+ 100 - 33
src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt

@@ -11,7 +11,6 @@ import android.graphics.drawable.Drawable
 import android.support.v7.widget.RecyclerView
 import android.view.*
 import android.widget.PopupWindow
-import com.bomostory.sceneeditmodule.MovieEditActivity
 import com.example.tfat.myapplication.navigationbar.NavigationBarView
 import com.example.tfat.myapplication.navigationbar.actor.ActorAdapter
 import com.example.tfat.myapplication.navigationbar.scene.AddSceneAdapter
@@ -25,12 +24,14 @@ import com.bomostory.sceneeditmodule.basicdata.*
 import com.bomostory.sceneeditmodule.navigationbar.dialogue.DialogueView
 import com.bomostory.sceneeditmodule.view.EditActorView
 import com.bomostory.sceneeditmodule.view.OnTouchBoMoSceneListener
-import com.example.tfat.myapplication.navigationbar.RecordFinishView
 import com.example.tfat.myapplication.navigationbar.actor.LayerManagementDialog
 import kotlinx.android.synthetic.main.control_actor_dialog.view.*
 import com.bomostory.sceneeditmodule.utils.FileUtils
 import com.bomostory.sceneeditmodule.view.LayerView
 import android.util.DisplayMetrics
+import com.bomostory.sceneeditmodule.MovieEditActivity
+import com.example.tfat.myapplication.navigationbar.EditSceneView
+import com.example.tfat.myapplication.navigationbar.RecordFinishView
 import io.reactivex.android.schedulers.AndroidSchedulers
 import io.reactivex.schedulers.Schedulers
 import java.util.concurrent.CopyOnWriteArrayList
@@ -146,6 +147,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         })
     }
 
+    //TFAT
     private fun initNavigationBarView() {
         project.story?.let {
             it.scenes?.let {
@@ -169,43 +171,66 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     })
                 } else {
                     navigationBar.removeAllViews()
-                    var recordFinishView = RecordFinishView(this)
-                    recordFinishView.setOnNextSceneClickListener(View.OnClickListener {
-                        currentSceneIndex++
+                    var editSceneView = EditSceneView(this)
+                    navigationBar.addView(editSceneView)
+                    setControlSceneView()
+                    editSceneView.setOnClickDoneListener(View.OnClickListener {
+                        val pd = ProgressDialog(this).apply {
+                                     setCancelable(false)
+                                 }
+                    FileUtils.saveProject(project, 1920,1080)
+                             .subscribeOn(Schedulers.io())
+                             .observeOn(AndroidSchedulers.mainThread())
+                             .doOnSubscribe { pd.show() }
+                             .doFinally { pd.dismiss() }
+                             .subscribe {
+                                 listeners.forEach {it.run()}
+                             }
+                    val intent = Intent(this, MovieEditActivity::class.java)
+                    intent.putExtra(MovieEditActivity.PROJECT_KEY, Gson().toJson(project))
+                    startActivity(intent)
+                    })
+                    editSceneView.setOnClickStartOverListener(View.OnClickListener {
                         project.story?.let {
                             it.scenes?.let{
-                                when(currentSceneIndex < it.size){
+                                it[currentSceneIndex].record = null
+                                sceneEditView.scene = it[currentSceneIndex]
+                                initNavigationBarView()
+                            }
+                        }
+                    })
+                    editSceneView.setOnClickReplaceListener(View.OnClickListener {
+                        viewContainer.removeAllViews()
+                        var addSceneView = AddSceneView(this)
+                        viewContainer.addView(addSceneView)
+                        val layoutManager = LinearLayoutManager(this)
+                        layoutManager.orientation = LinearLayoutManager.HORIZONTAL
+                        var onSceneSelectedArrayList = ArrayList<View.OnClickListener>()
+                        for (i in 0 until resourceThemeBitmap.size) {
+                            onSceneSelectedArrayList.add(replaceScene(i))
+                        }
+                        var addSceneAdapter = AddSceneAdapter(this, resourceThemeBitmap, onSceneSelectedArrayList)
+                        var newSceneRecyclerView = addSceneView.findViewById<RecyclerView>(R.id.new_scene_recycler_view)
+                        newSceneRecyclerView.layoutManager = layoutManager
+                        newSceneRecyclerView.adapter = addSceneAdapter
+                    })
+                    editSceneView.setOnClickDeleteListener(View.OnClickListener {
+                        project.story?.let {
+                            it.scenes?.let{
+                                if (it.size <= 1) { return@let }
+                                it.removeAt(currentSceneIndex)
+                                when(currentSceneIndex >= it.size){
                                     true -> {
-                                        switchToPreViewLayer()
-                                        sceneEditView.scene = it[currentSceneIndex]
-                                    }
-                                    false -> {
                                         currentSceneIndex = 0
-                                        sceneEditView.scene = it[currentSceneIndex]
+                                        sceneEditView.scene = it[0]
                                     }
+                                    false -> sceneEditView.scene = it[currentSceneIndex]
                                 }
+                                initNavigationBarView()
+                                initControlSceneView()
                             }
                         }
-                        initControlBarView()
-                        initNavigationBarView()
-                    })
-                    recordFinishView.setOnFinishClickListener(View.OnClickListener {
-                        val pd = ProgressDialog(this).apply {
-                            setCancelable(false)
-                        }
-                        FileUtils.saveProject(project, 1920,1080)
-                                .subscribeOn(Schedulers.io())
-                                .observeOn(AndroidSchedulers.mainThread())
-                                .doOnSubscribe { pd.show() }
-                                .doFinally { pd.dismiss() }
-                                .subscribe {
-                                    listeners.forEach {it.run()}
-                                }
-                        val intent = Intent(this, MovieEditActivity::class.java)
-                        intent.putExtra(MovieEditActivity.PROJECT_KEY, Gson().toJson(project))
-                        startActivity(intent)
                     })
-                    navigationBar.addView(recordFinishView)
                 }
             }
         }
@@ -246,6 +271,10 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
             viewContainer.removeAllViews()
             return
         }
+        setControlSceneView()
+    }
+
+    private fun setControlSceneView(){
         var projectBitmaps = ArrayList<Drawable>()
         var onSceneSelectedArrayList = ArrayList<View.OnClickListener>()
         project.story?.let {
@@ -300,7 +329,6 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         viewContainer.removeAllViews()
         viewContainer.addView(controlSceneView)
     }
-
     private fun initRecord(){
         startRecord.setOnClickListener(View.OnClickListener {
             if (!isRecord) {
@@ -320,16 +348,43 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                 startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_record))
                 navigationBar.visibility = View.VISIBLE
                 initControlSceneView()
-                initNavigationBarView()
+                initRecordFinishView()
             }
         })
     }
 
 
+    private fun initRecordFinishView(){
+        navigationBar.removeAllViews()
+        var recordFinishView = RecordFinishView(this)
+        recordFinishView.setOnNextSceneClickListener(View.OnClickListener {
+            currentSceneIndex++
+            project.story?.let {
+                it.scenes?.let{
+                    when(currentSceneIndex < it.size){
+                        true -> {
+                            switchToPreViewLayer()
+                            sceneEditView.scene = it[currentSceneIndex]
+                        }
+                        false -> {
+                            currentSceneIndex = 0
+                            sceneEditView.scene = it[currentSceneIndex]
+                        }
+                    }
+                }
+            }
+            initControlBarView()
+            initNavigationBarView()
+        })
+        recordFinishView.setOnFinishClickListener(View.OnClickListener {
+            initNavigationBarView()
+        })
+        navigationBar.addView(recordFinishView)
+    }
     private fun switchScene(position: Int): View.OnClickListener {
         return View.OnClickListener {
             currentSceneIndex = position
-            switchLayer(6)
+            switchToPreViewLayer()
             project.story?.let {
                 it.scenes?.let{
                     sceneEditView.scene = it[position]
@@ -425,6 +480,18 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         }
     }
 
+    private fun replaceScene(position: Int): View.OnClickListener {
+        return View.OnClickListener {
+            project.story?.let {
+                it.scenes?.let{
+                    it[currentSceneIndex].backgroundPath = resourceThemeBitmap[position]
+                    sceneEditView.scene = it[currentSceneIndex]
+                }
+            }
+            initControlSceneView()
+            initNavigationBarView()
+        }
+    }
     private fun setActorPositionZ(actors: ArrayList<Actor>){
         for (actor in actors) {
             actor.positionZ = actors.indexOf(actor)

+ 45 - 0
src/main/java/com/bomostory/sceneeditmodule/navigationbar/EditSceneView.kt

@@ -0,0 +1,45 @@
+package com.example.tfat.myapplication.navigationbar
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.LayoutInflater
+import android.widget.RelativeLayout
+import com.example.tfat.myapplication.R
+import kotlinx.android.synthetic.main.view_edit_scene.view.*
+
+class EditSceneView : RelativeLayout{
+
+    constructor(context : Context) : super(context) {
+        initView()
+    }
+
+    constructor(context: Context, attrs: AttributeSet): super(context, attrs) {
+        initView()
+    }
+
+    constructor(context: Context, attrs: AttributeSet, defStyle: Int): super(context, attrs, defStyle) {
+        initView()
+    }
+
+    private fun initView(){
+        val inflater = LayoutInflater.from(context)
+        inflater.inflate(R.layout.view_edit_scene, this, true)
+    }
+
+    fun setOnClickDoneListener(onClickListener: OnClickListener) {
+        btn_edit_scene_done.setOnClickListener(onClickListener)
+    }
+
+    fun setOnClickStartOverListener(onClickListener: OnClickListener) {
+        btn_edit_scene_start_over.setOnClickListener(onClickListener)
+    }
+
+    fun setOnClickReplaceListener(onClickListener: OnClickListener) {
+        btn_edit_scene_replace.setOnClickListener(onClickListener)
+    }
+
+    fun setOnClickDeleteListener(onClickListener: OnClickListener) {
+        btn_edit_scene_delete.setOnClickListener(onClickListener)
+    }
+
+}

BIN
src/main/res/drawable/green.png


BIN
src/main/res/drawable/hill.png


+ 2 - 6
src/main/res/drawable/ic_delete_w.xml

@@ -4,17 +4,13 @@
     android:viewportWidth="24"
     android:viewportHeight="24">
   <path
-      android:pathData="M8,9h8v10h-8z"
+      android:pathData="M8,9h8v10H8z"
       android:strokeAlpha="0.3"
       android:fillColor="#FFF"
       android:fillType="nonZero"
       android:fillAlpha="0.3"/>
   <path
-      android:pathData="M15.5,4l-1,-1l-5,0l-1,1l-3.5,0l0,2l14,0l0,-2z"
-      android:fillColor="#FFF"
-      android:fillType="nonZero"/>
-  <path
-      android:pathData="M6,19C6,20.1 6.9,21 8,21L16,21C17.1,21 18,20.1 18,19L18,7L6,7L6,19ZM8,9L16,9L16,19L8,19L8,9Z"
+      android:pathData="M15.5,4l-1,-1h-5l-1,1H5v2h14V4zM6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM8,9h8v10H8V9z"
       android:fillColor="#FFF"
       android:fillType="nonZero"/>
 </vector>

+ 10 - 0
src/main/res/drawable/ic_replace.xml

@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+  <path
+      android:pathData="M11,6c1.38,0 2.63,0.56 3.54,1.46L12,10h6L18,4l-2.05,2.05A6.976,6.976 0,0 0,11 4c-3.53,0 -6.43,2.61 -6.92,6L6.1,10A5,5 0,0 1,11 6zM16.64,15.14A6.89,6.89 0,0 0,17.92 12L15.9,12a5,5 0,0 1,-4.9 4c-1.38,0 -2.63,-0.56 -3.54,-1.46L10,12L4,12v6l2.05,-2.05A6.976,6.976 0,0 0,11 18c1.55,0 2.98,-0.51 4.14,-1.36L20,21.49 21.49,20l-4.85,-4.86z"
+      android:fillColor="#4E342E"
+      android:fillType="nonZero"/>
+</vector>

+ 14 - 0
src/main/res/drawable/ic_startover.xml

@@ -0,0 +1,14 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+  <path
+      android:pathData="M13,3a9,9 0,0 0,-9 9H1l4,3.99L9,12H6c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42A8.954,8.954 0,0 0,13 21a9,9 0,0 0,0 -18z"
+      android:fillColor="#4E342E"
+      android:fillType="nonZero"/>
+  <path
+      android:pathData="M12,8v5l4.25,2.52 0.77,-1.28 -3.52,-2.09V8z"
+      android:fillColor="#4E342E"
+      android:fillType="nonZero"/>
+</vector>

BIN
src/main/res/drawable/sky.png


+ 1 - 1
src/main/res/layout/record_finish_view.xml

@@ -3,7 +3,7 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
     android:layout_height="64dp"
-    android:background="#60000000">
+    android:background="#212121">
 
     <Button
     android:id="@+id/finish"

+ 65 - 0
src/main/res/layout/view_edit_scene.xml

@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="64dp"
+    android:background="#212121">
+
+    <Button
+        android:id="@+id/btn_edit_scene_done"
+        android:layout_width="144dp"
+        android:layout_height="36dp"
+        android:layout_marginBottom="14dp"
+        android:layout_marginEnd="8dp"
+        android:background="@drawable/btn_round_corner_main"
+        android:drawableLeft="@drawable/ic_done"
+        android:paddingLeft="16dp"
+        android:paddingRight="16dp"
+        android:text="DONE"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toRightOf="parent"/>
+
+    <Button
+        android:id="@+id/btn_edit_scene_start_over"
+        android:layout_width="144dp"
+        android:layout_height="36dp"
+        android:layout_marginBottom="14dp"
+        android:layout_marginEnd="8dp"
+        android:background="@drawable/btn_round_corner_main"
+        android:drawableLeft="@drawable/ic_startover"
+        android:paddingLeft="16dp"
+        android:paddingRight="16dp"
+        android:text="START OVER"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toLeftOf="@+id/btn_edit_scene_done"/>
+
+    <Button
+        android:id="@+id/btn_edit_scene_replace"
+        android:layout_width="144dp"
+        android:layout_height="36dp"
+        android:layout_marginBottom="14dp"
+        android:layout_marginEnd="8dp"
+        android:background="@drawable/btn_round_corner_main"
+        android:drawableLeft="@drawable/ic_replace"
+        android:paddingLeft="16dp"
+        android:paddingRight="16dp"
+        android:text="REPLACE"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toLeftOf="@+id/btn_edit_scene_start_over" />
+
+    <Button
+        android:id="@+id/btn_edit_scene_delete"
+        android:layout_width="144dp"
+        android:layout_height="36dp"
+        android:layout_marginBottom="14dp"
+        android:layout_marginEnd="8dp"
+        android:background="@drawable/btn_round_corner_red"
+        android:drawableLeft="@drawable/ic_delete_w"
+        android:paddingLeft="16dp"
+        android:paddingRight="16dp"
+        android:text="DELETE"
+        android:textColor="#ffffff"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintRight_toLeftOf="@+id/btn_edit_scene_replace" />
+
+</android.support.constraint.ConstraintLayout>