faterhenry 6 лет назад
Родитель
Сommit
2a99c5bb44

+ 25 - 5
src/main/java/com/bomostory/sceneeditmodule/SceneEditActivity.kt

@@ -114,9 +114,8 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         sceneEditView.layoutParams = layoutPrams
         project.story?.let {
             it.scenes?.let{
-                it[0].sceneWidth = monitorSize.widthPixels
-                for (i in 0 until INIT_SCENE_NUMBER){
-                    addScene(0)
+                for (i in 0 until it.size) {
+                    it[i].sceneWidth = monitorSize.widthPixels
                 }
                 sceneEditView.scene = it[0]
             }
@@ -353,7 +352,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
             navigationBar.removeAllViews()
             paint_view.visibility = View.INVISIBLE
             startRecord.visibility = View.VISIBLE
-            initNavigationBarView(currentSceneIndex)
+            //initNavigationBarView(currentSceneIndex)
+            navigationBar.removeAllViews()
+            initNavigationFunction()
             FileUtils.saveBitmapForActor(this, paint_view.bitmap, System.currentTimeMillis().toString())
             project.story?.let {
                 it.scenes?.let{
@@ -390,6 +391,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
         var actorRecyclerView = selectActorView.findViewById<RecyclerView>(R.id.select_actor_recycler_view)
         actorRecyclerView.layoutManager = layoutManager
         actorRecyclerView.adapter = actorAdapter
+        actorRecyclerView.isNestedScrollingEnabled = false
         viewContainer.addView(selectActorView)
         selectActorView.layoutParams.width = monitorSize.widthPixels
         selectActorView.btn_object.setOnClickListener {
@@ -888,6 +890,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.opacity.setOnClickListener {
             popupWindow.dismiss()
@@ -907,6 +910,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                         it.scenes?.let {
                             it[currentSceneIndex].layers[currentLayerIndex].actors[actor.positionZ].opacity = p1.toFloat().div(100)
                             sceneEditView.scene = it[currentSceneIndex]
+                            sceneEditView.setLayerVisible(currentLayerIndex)
                         }
                     }
                 }
@@ -917,7 +921,9 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
             })
             popupView.tv_opacity_dialog_ok.setOnClickListener {
                 popupWindow.dismiss()
+                sceneEditView.setLayerVisible(currentLayerIndex)
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.Mirror.setOnClickListener {
             project.story?.let {
@@ -928,17 +934,19 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.bring_to_front.setOnClickListener{
             project.story?.let {
                 it.scenes?.let {
-                    it[currentSceneIndex].layers[currentLayerIndex].actors.remove(actor)
+                    it[currentSceneIndex].layers[currentLayerIndex].actors.removeAt(actor.positionZ)
                     it[currentSceneIndex].layers[currentLayerIndex].actors.add(actor)
                     setActorPositionZ(it[currentLayerIndex].layers[currentLayerIndex].actors)
                     sceneEditView.scene = it[currentSceneIndex]
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.send_to_back.setOnClickListener{
             project.story?.let {
@@ -950,15 +958,18 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.delete.setOnClickListener{
             project.story?.let {
                 it.scenes?.let {
                     it[currentSceneIndex].layers[currentLayerIndex].actors.removeAt(actor.positionZ)
+                    setActorPositionZ(it[currentLayerIndex].layers[currentLayerIndex].actors)
                     sceneEditView.scene = it[currentSceneIndex]
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         return popupView
     }
@@ -975,6 +986,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.duplicate_dialogue.setOnClickListener{
             project.story?.let {
@@ -1000,6 +1012,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.Mirror_dialogue.setOnClickListener {
             project.story?.let {
@@ -1010,6 +1023,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.layout_dialogue_dialog_color.setOnClickListener {
             popupWindow.dismiss()
@@ -1094,12 +1108,14 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
             }
             popupView.tv_color_dialog_ok.setOnClickListener {
                 popupWindow.dismiss()
+                sceneEditView.setLayerVisible(currentLayerIndex)
             }
             popupWindow.width = ViewGroup.LayoutParams.WRAP_CONTENT
             popupWindow.height = ViewGroup.LayoutParams.WRAP_CONTENT
             popupWindow.contentView = popupView
             popupWindow.isOutsideTouchable = false
             popupWindow.showAtLocation(sceneEditView, Gravity.START,actor.positionX,0)
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.bring_to_front_dialogue.setOnClickListener{
             project.story?.let {
@@ -1111,6 +1127,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.send_to_back_dialogue.setOnClickListener{
             project.story?.let {
@@ -1122,15 +1139,18 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.delete_dialogue.setOnClickListener{
             project.story?.let {
                 it.scenes?.let {
                     it[currentSceneIndex].layers[currentLayerIndex].actors.removeAt(actor.positionZ)
+                    setActorPositionZ(it[currentLayerIndex].layers[currentLayerIndex].actors)
                     sceneEditView.scene = it[currentSceneIndex]
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         return popupView
     }

+ 42 - 7
src/main/java/com/bomostory/sceneeditmodule/navigationbar/actor/ActorAdapter.kt

@@ -6,6 +6,7 @@ import android.content.Context
 import android.graphics.drawable.Drawable
 import android.support.v7.widget.LinearLayoutManager
 import android.support.v7.widget.RecyclerView
+import android.util.Log
 import android.view.*
 import android.widget.ImageView
 import android.widget.LinearLayout
@@ -81,17 +82,52 @@ class ActorAdapter(var context : Context, var data: ArrayList<ArrayList<String>>
             itemView.findViewById<ImageView>(R.id.actor_image).setOnTouchListener(boMoOnTouchListener(position,0))
             //itemView.findViewById<LinearLayout>(R.id.actor_rotate).removeAllViews()
             itemView.actor_rotate.apply {
-                var onClickListeners = ArrayList<View.OnClickListener>()
+//                var onClickListeners = ArrayList<View.OnClickListener>()
+//                for (i in 0 until data.size) {
+//                    onClickListeners.add(View.OnClickListener {
+//                        itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(Drawable.createFromPath(data[i]))
+//                        itemView.findViewById<ImageView>(R.id.actor_image).setOnTouchListener(boMoOnTouchListener(position,i))
+//                    })
+//                }
+                var onTouchListeners =  ArrayList<View.OnTouchListener>()
                 for (i in 0 until data.size) {
-                    onClickListeners.add(View.OnClickListener {
-                        itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(Drawable.createFromPath(data[i]))
-                        itemView.findViewById<ImageView>(R.id.actor_image).setOnTouchListener(boMoOnTouchListener(position,i))
+                    var positionX = 0
+                    var positionY = 0
+                    var clickPeriod = 0L
+                    var mx: Int
+                    onTouchListeners.add(View.OnTouchListener { v, event ->
+                        when(event.action){
+                            MotionEvent.ACTION_DOWN -> {
+                                clickPeriod = System.currentTimeMillis()
+                                positionX = event.x.toInt()
+                                Log.d("TEST12345", "xQQ = " + positionX)
+                                positionY = event.y.toInt()
+                            }
+                            MotionEvent.ACTION_MOVE -> {
+//                                if (!(Math.abs(event.x - positionX) < 1 && Math.abs(event.y - positionY) < 1)) {
+                                    mx = event.x.toInt() - positionX
+                                    this.smoothScrollBy(-mx *5,0)
+
+                                Log.d("TEST12345", "xKK = " + event.x.toInt())
+//                                }
+                            }
+                            MotionEvent.ACTION_UP -> {
+                                Log.d("TEST12345", "xJJ = " + event.x)
+                                if ((Math.abs(event.x - positionX) < 1 && Math.abs(event.y - positionY) < 1)) {
+                                    itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(Drawable.createFromPath(data[i]))
+                                    itemView.findViewById<ImageView>(R.id.actor_image).setOnTouchListener(boMoOnTouchListener(position,i))
+                                }
+                            }
+                        }
+                        return@OnTouchListener true
                     })
                 }
-                adapter = ActorPoseAdapter(data, onClickListeners)
+                adapter = ActorPoseAdapter(data, onTouchListeners)
                 layoutManager = LinearLayoutManager(context).apply {
                     orientation = LinearLayoutManager.HORIZONTAL
                 }
+                isNestedScrollingEnabled = false
+
             }
 //            for (i in 0 until data.size) {
 //                itemView.findViewById<LinearLayout>(R.id.actor_rotate).addView(data[i])
@@ -102,8 +138,7 @@ class ActorAdapter(var context : Context, var data: ArrayList<ArrayList<String>>
 //                var lParams = data[i].layoutParams
 //                lParams.height = 100
 //                lParams.width = 100
-//                data[i].layoutParams = lParams
-//            }
+//                data[i].layoutParams = lParams //           }
         }
         private fun boMoOnTouchListener(position: Int, index: Int) : View.OnTouchListener {
             return View.OnTouchListener {view, motionEvent ->

+ 5 - 4
src/main/java/com/bomostory/sceneeditmodule/navigationbar/actor/ActorPoseAdapter.kt

@@ -6,9 +6,10 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import com.example.tfat.myapplication.R
+import kotlinx.android.synthetic.main.actor_pose_item.view.*
 import kotlinx.android.synthetic.main.item_actor.view.*
 
-class ActorPoseAdapter(var data: ArrayList<String>, var onClickListeners: ArrayList<View.OnClickListener>): RecyclerView.Adapter<ActorPoseAdapter.ViewHolder>() {
+class ActorPoseAdapter(var data: ArrayList<String>, var onClickListeners: ArrayList<View.OnTouchListener>): RecyclerView.Adapter<ActorPoseAdapter.ViewHolder>() {
 
 
     override fun getItemCount(): Int {
@@ -25,9 +26,9 @@ class ActorPoseAdapter(var data: ArrayList<String>, var onClickListeners: ArrayL
     }
 
     class ViewHolder (view : View) : RecyclerView.ViewHolder(view) {
-        fun bind(ObjectResource: String, onClickListener: View.OnClickListener) {
-            itemView.actor_image.setImageDrawable(Drawable.createFromPath(ObjectResource))
-            itemView.actor_image.setOnClickListener(onClickListener)
+        fun bind(ObjectResource: String, onClickListener: View.OnTouchListener) {
+            itemView.iv_actor_pose_image.setImageDrawable(Drawable.createFromPath(ObjectResource))
+            itemView.layout_actor_pose.setOnTouchListener(onClickListener)
         }
     }
 }

+ 8 - 5
src/main/res/layout/actor_pose_item.xml

@@ -1,12 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/actor"
+    android:id="@+id/layout_actor_pose"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content">
     <ImageView
-        android:id="@+id/actor_image"
+        android:id="@+id/iv_actor_pose_image"
         android:scaleType="center"
-        android:layout_marginLeft="4dp"
-        android:layout_width="40dp"
-        android:layout_height="40dp"/>
+        android:layout_marginRight="16dp"
+        android:layout_marginLeft="16dp"
+        android:layout_marginTop="8dp"
+        android:layout_marginBottom="8dp"
+        android:layout_width="45dp"
+        android:layout_height="45dp"/>
 </LinearLayout>

+ 3 - 2
src/main/res/layout/item_actor.xml

@@ -15,8 +15,9 @@
             android:layout_height="96dp"/>
         <android.support.v7.widget.RecyclerView
             android:id="@+id/actor_rotate"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+            android:nestedScrollingEnabled="false"
+            android:layout_width="200dp"
+            android:layout_height="159dp"
             android:orientation="horizontal">
         </android.support.v7.widget.RecyclerView>
     </LinearLayout>

+ 11 - 11
src/main/res/layout/layer_management_fragment.xml

@@ -23,13 +23,13 @@
             android:background="#33000000"/>
     </LinearLayout>
     <LinearLayout
-        android:id="@+id/layout_layer_management_layer1"
+        android:id="@+id/layout_layer_management_layer5"
         android:layout_width="match_parent"
         android:layout_height="121dp"
         android:orientation="vertical"
         app:layout_constraintTop_toBottomOf="@+id/tv_layer_management_title">
         <android.support.v7.widget.RecyclerView
-            android:id="@+id/rv_layer_management_layer1"
+            android:id="@+id/rv_layer_management_layer5"
             android:layout_width="wrap_content"
             android:layout_height="120dp"/>
         <View
@@ -38,13 +38,13 @@
             android:background="#33000000"/>
     </LinearLayout>
     <LinearLayout
-        android:id="@+id/layout_layer_management_layer2"
+        android:id="@+id/layout_layer_management_layer4"
         android:layout_width="match_parent"
         android:layout_height="121dp"
         android:orientation="vertical"
-        app:layout_constraintTop_toBottomOf="@id/layout_layer_management_layer1">
+        app:layout_constraintTop_toBottomOf="@id/layout_layer_management_layer5">
         <android.support.v7.widget.RecyclerView
-            android:id="@+id/rv_layer_management_layer2"
+            android:id="@+id/rv_layer_management_layer4"
             android:layout_width="wrap_content"
             android:layout_height="120dp"/>
         <View
@@ -57,7 +57,7 @@
         android:layout_width="match_parent"
         android:layout_height="121dp"
         android:orientation="vertical"
-        app:layout_constraintTop_toBottomOf="@id/layout_layer_management_layer2">
+        app:layout_constraintTop_toBottomOf="@id/layout_layer_management_layer4">
         <android.support.v7.widget.RecyclerView
             android:id="@+id/rv_layer_management_layer3"
             android:layout_width="wrap_content"
@@ -68,13 +68,13 @@
             android:background="#33000000"/>
     </LinearLayout>
     <LinearLayout
-        android:id="@+id/layout_layer_management_layer4"
+        android:id="@+id/layout_layer_management_layer2"
         android:layout_width="match_parent"
         android:layout_height="121dp"
         android:orientation="vertical"
         app:layout_constraintTop_toBottomOf="@id/layout_layer_management_layer3">
         <android.support.v7.widget.RecyclerView
-            android:id="@+id/rv_layer_management_layer4"
+            android:id="@+id/rv_layer_management_layer2"
             android:layout_width="wrap_content"
             android:layout_height="120dp"/>
         <View
@@ -83,13 +83,13 @@
             android:background="#33000000"/>
     </LinearLayout>
     <LinearLayout
-        android:id="@+id/layout_layer_management_layer5"
+        android:id="@+id/layout_layer_management_layer1"
         android:layout_width="match_parent"
         android:layout_height="121dp"
         android:orientation="vertical"
-        app:layout_constraintTop_toBottomOf="@id/layout_layer_management_layer4">
+        app:layout_constraintTop_toBottomOf="@id/layout_layer_management_layer2">
         <android.support.v7.widget.RecyclerView
-            android:id="@+id/rv_layer_management_layer5"
+            android:id="@+id/rv_layer_management_layer1"
             android:layout_width="wrap_content"
             android:layout_height="120dp"/>
         <View