|
@@ -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,19 +24,22 @@ 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.bomostory.sceneeditmodule.view.OnTouchSceneListener
|
|
|
+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
|
|
|
|
|
|
class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener, EditActorView.OnActorChangeListener,
|
|
|
OnTouchBoMoSceneListener.OnSceneMoveListener, DialogInterface.OnDismissListener, FileUtils.OnSaveActorImage,
|
|
|
- LayerManagementDialog.OnLayerChange {
|
|
|
+ OnTouchSceneListener.OnSceneTouchListener,LayerManagementDialog.OnLayerChange {
|
|
|
|
|
|
private lateinit var project: Project
|
|
|
private var currentSceneIndex = 0
|
|
@@ -115,6 +117,16 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
private fun initControlBarView() {
|
|
|
controlBarView.setBtnSelected(6)
|
|
|
switchToPreViewLayer()
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ if (it[currentSceneIndex].record != null) {
|
|
|
+ controlBarView.visibility = View.INVISIBLE
|
|
|
+ sceneEditView.setOnTouchListener(null)
|
|
|
+ } else {
|
|
|
+ controlBarView.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
controlBarView.setonClickSwipeLayerBtn(View.OnClickListener {
|
|
|
switchToPreViewLayer()
|
|
|
})
|
|
@@ -169,43 +181,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 +281,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 +339,6 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
viewContainer.removeAllViews()
|
|
|
viewContainer.addView(controlSceneView)
|
|
|
}
|
|
|
-
|
|
|
private fun initRecord(){
|
|
|
startRecord.setOnClickListener(View.OnClickListener {
|
|
|
if (!isRecord) {
|
|
@@ -319,17 +357,45 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
startRecord.setImageDrawable(resources.getDrawable(R.drawable.ic_btn_record))
|
|
|
navigationBar.visibility = View.VISIBLE
|
|
|
+ initControlBarView()
|
|
|
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]
|
|
@@ -342,6 +408,15 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
|
|
|
private fun switchLayer(layerIndex: Int){
|
|
|
viewContainer.removeAllViews()
|
|
|
+ if(currentLayerIndex != 6) {
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ for (i in 0 until it[currentSceneIndex].layers[currentLayerIndex].actors.size) {
|
|
|
+ it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
currentLayerIndex = layerIndex
|
|
|
controlBarView.setBtnSelected(4 - layerIndex)
|
|
|
project.story?.let {
|
|
@@ -358,10 +433,13 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
sceneEditView.scene = it[currentSceneIndex]
|
|
|
}
|
|
|
}
|
|
|
- sceneEditView.setOnTouchListener(null)
|
|
|
+ val sceneListener = OnTouchSceneListener()
|
|
|
+ sceneListener.setCallBack(this)
|
|
|
+ sceneEditView.setOnTouchListener(sceneListener)
|
|
|
sceneEditView.x = 0
|
|
|
setActorDropLayer()
|
|
|
sceneEditView.setLayerVisible(layerIndex)
|
|
@@ -408,7 +486,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
private fun addScene(position: Int): View.OnClickListener {
|
|
|
return View.OnClickListener {
|
|
|
var scene = Scene()
|
|
|
- for (i in 0 until 5){
|
|
|
+ for (i in 5 until 0){
|
|
|
val layer = Layer()
|
|
|
layer.id = i
|
|
|
scene.layers.add(layer)
|
|
@@ -425,6 +503,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)
|
|
@@ -455,6 +545,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
setActorDropLayer()
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
}
|
|
|
|
|
|
private fun addDialogue(positionX: Int, positionY: Int, resource: Int) {
|
|
@@ -486,6 +577,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
sceneEditView.scene = it[currentSceneIndex]
|
|
|
}
|
|
|
}
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
}
|
|
|
|
|
|
override fun onActorSelected(actor: Actor) {
|
|
@@ -502,6 +594,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
sceneEditView.scene = it[currentSceneIndex]
|
|
|
}
|
|
|
}
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
}
|
|
|
|
|
|
override fun onActorLongClick(actor: Actor) {
|
|
@@ -518,6 +611,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
sceneEditView.scene = it[currentSceneIndex]
|
|
|
}
|
|
|
}
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
var popupWindow = PopupWindow(this)
|
|
|
val popupView = LayoutInflater.from(this).inflate(R.layout.control_actor_dialog, null)
|
|
|
popupView.duplicate.setOnClickListener{
|
|
@@ -665,4 +759,20 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
return@OnDragListener true
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ override fun onSceneTouch(){
|
|
|
+ unSelectActor()
|
|
|
+ sceneEditView.setLayerVisible(currentLayerIndex)
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun unSelectActor(){
|
|
|
+ project.story?.let {
|
|
|
+ it.scenes?.let {
|
|
|
+ for(i in 0 until it[currentSceneIndex].layers[currentLayerIndex].actors.size){
|
|
|
+ it[currentSceneIndex].layers[currentLayerIndex].actors[i].isSelect = false
|
|
|
+ }
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|