Преглед на файлове

Merge branch 'fix-actor-pose'

faterhenry преди 6 години
родител
ревизия
dd8efd0aab

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

@@ -118,9 +118,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]
             }
@@ -357,7 +356,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{
@@ -394,6 +395,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 {
@@ -936,6 +938,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.opacity.setOnClickListener {
             popupWindow.dismiss()
@@ -955,6 +958,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)
                         }
                     }
                 }
@@ -965,7 +969,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 {
@@ -976,17 +982,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 {
@@ -998,15 +1006,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
     }
@@ -1023,6 +1034,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.duplicate_dialogue.setOnClickListener{
             project.story?.let {
@@ -1048,6 +1060,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.Mirror_dialogue.setOnClickListener {
             project.story?.let {
@@ -1058,6 +1071,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.layout_dialogue_dialog_color.setOnClickListener {
             popupWindow.dismiss()
@@ -1142,12 +1156,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 {
@@ -1159,6 +1175,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     popupWindow.dismiss()
                 }
             }
+            sceneEditView.setLayerVisible(currentLayerIndex)
         }
         popupView.send_to_back_dialogue.setOnClickListener{
             project.story?.let {
@@ -1170,15 +1187,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
     }

+ 64 - 13
src/main/java/com/bomostory/sceneeditmodule/navigationbar/actor/ActorAdapter.kt

@@ -4,13 +4,17 @@ import android.content.ClipData
 import android.content.ClipDescription
 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
+import com.bomostory.sceneeditmodule.navigationbar.actor.ActorPoseAdapter
 import com.bomostory.sceneeditmodule.screen.view.LayerView
 
 import com.example.tfat.myapplication.R
+import kotlinx.android.synthetic.main.item_actor.view.*
 import kotlin.collections.ArrayList
 
 class ActorAdapter(var context : Context, var data: ArrayList<ArrayList<String>>, layerView: LayerView, onActorDragListener: OnActorDragListener) : RecyclerView.Adapter<ActorAdapter.ViewHolder>() {
@@ -25,7 +29,7 @@ class ActorAdapter(var context : Context, var data: ArrayList<ArrayList<String>>
     }
 
     override fun onBindViewHolder(holder: ViewHolder, position: Int) {
-        holder.bind(bitmapData?.get(position), position, initActorImageView(data)[position])
+        holder.bind(bitmapData?.get(position), position, data[position])
     }
 
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
@@ -73,21 +77,68 @@ class ActorAdapter(var context : Context, var data: ArrayList<ArrayList<String>>
     }
 
     class ViewHolder (view : View) : RecyclerView.ViewHolder(view) {
-        fun bind(path: String?, position: Int, data: ArrayList<ImageView>) {
+        fun bind(path: String?, position: Int, data: ArrayList<String>) {
             itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(Drawable.createFromPath(path))
             itemView.findViewById<ImageView>(R.id.actor_image).setOnTouchListener(boMoOnTouchListener(position,0))
-            itemView.findViewById<LinearLayout>(R.id.actor_rotate).removeAllViews()
-            for (i in 0 until data.size) {
-                itemView.findViewById<LinearLayout>(R.id.actor_rotate).addView(data[i])
-                data[i].setOnClickListener(View.OnClickListener {
-                    itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(data[i].drawable)
-                    itemView.findViewById<ImageView>(R.id.actor_image).setOnTouchListener(boMoOnTouchListener(position,i))
-                })
-                var lParams = data[i].layoutParams
-                lParams.height = 100
-                lParams.width = 100
-                data[i].layoutParams = lParams
+            //itemView.findViewById<LinearLayout>(R.id.actor_rotate).removeAllViews()
+            itemView.actor_rotate.apply {
+//                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) {
+                    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, 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])
+//                data[i].setOnClickListener(View.OnClickListener {
+//                    itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(data[i].drawable)
+//                    itemView.findViewById<ImageView>(R.id.actor_image).setOnTouchListener(boMoOnTouchListener(position,i))
+//                })
+//                var lParams = data[i].layoutParams
+//                lParams.height = 100
+//                lParams.width = 100
+//                data[i].layoutParams = lParams //           }
         }
         private fun boMoOnTouchListener(position: Int, index: Int) : View.OnTouchListener {
             return View.OnTouchListener {view, motionEvent ->

+ 34 - 0
src/main/java/com/bomostory/sceneeditmodule/navigationbar/actor/ActorPoseAdapter.kt

@@ -0,0 +1,34 @@
+package com.bomostory.sceneeditmodule.navigationbar.actor
+
+import android.graphics.drawable.Drawable
+import android.support.v7.widget.RecyclerView
+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.OnTouchListener>): RecyclerView.Adapter<ActorPoseAdapter.ViewHolder>() {
+
+
+    override fun getItemCount(): Int {
+        return data.size
+    }
+
+    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
+        holder.bind(data?.get(position), onClickListeners[position])
+    }
+
+    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ActorPoseAdapter.ViewHolder {
+        val v1 = LayoutInflater.from(parent.context).inflate(R.layout.actor_pose_item, parent, false)
+        return ViewHolder(v1)
+    }
+
+    class ViewHolder (view : View) : RecyclerView.ViewHolder(view) {
+        fun bind(ObjectResource: String, onClickListener: View.OnTouchListener) {
+            itemView.iv_actor_pose_image.setImageDrawable(Drawable.createFromPath(ObjectResource))
+            itemView.layout_actor_pose.setOnTouchListener(onClickListener)
+        }
+    }
+}

+ 0 - 6
src/main/java/com/bomostory/sceneeditmodule/navigationbar/actor/ObjectAdapter.kt

@@ -17,7 +17,6 @@ class ObjectAdapter(var data: ArrayList<String>, var onTouchListeners: ArrayList
 
     override fun onBindViewHolder(holder: ViewHolder, position: Int) {
         holder.bind(data?.get(position), onTouchListeners[position])
-//        holder.bind(data?.get(position))
     }
 
     override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ObjectAdapter.ViewHolder {
@@ -31,9 +30,4 @@ class ObjectAdapter(var data: ArrayList<String>, var onTouchListeners: ArrayList
             itemView.actor_image.setOnTouchListener(onTouchListener)
         }
     }
-//    class ViewHolder (view : View) : RecyclerView.ViewHolder(view) {
-//        fun bind(ObjectResource: String) {
-//            itemView.actor_image.setImageDrawable(Drawable.createFromPath(ObjectResource))
-//        }
-//    }
 }

+ 15 - 0
src/main/res/layout/actor_pose_item.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/layout_actor_pose"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content">
+    <ImageView
+        android:id="@+id/iv_actor_pose_image"
+        android:scaleType="center"
+        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>

+ 5 - 4
src/main/res/layout/item_actor.xml

@@ -13,12 +13,13 @@
             android:layout_gravity="center"
             android:layout_width="96dp"
             android:layout_height="96dp"/>
-        <LinearLayout
+        <android.support.v7.widget.RecyclerView
             android:id="@+id/actor_rotate"
-            android:layout_width="wrap_content"
-            android:layout_height="60dp"
+            android:nestedScrollingEnabled="false"
+            android:layout_width="200dp"
+            android:layout_height="159dp"
             android:orientation="horizontal">
-        </LinearLayout>
+        </android.support.v7.widget.RecyclerView>
     </LinearLayout>
     <ImageView
         android:layout_width="1dp"

+ 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