|
@@ -8,16 +8,19 @@ import android.graphics.Color
|
|
|
import android.os.Bundle
|
|
|
import android.support.v4.app.DialogFragment
|
|
|
import android.support.v7.widget.LinearLayoutManager
|
|
|
+import android.support.v7.widget.helper.ItemTouchHelper
|
|
|
import android.view.*
|
|
|
import com.bomostory.sceneeditmodule.basicdata.Actor
|
|
|
import com.bomostory.sceneeditmodule.basicdata.Scene
|
|
|
+import com.bomostory.sceneeditmodule.layermanagement.ItemTouchHelpCallback
|
|
|
import com.bomostory.sceneeditmodule.layermanagement.LayerAdapter
|
|
|
import com.example.tfat.myapplication.R
|
|
|
import kotlinx.android.synthetic.main.layer_management_fragment.*
|
|
|
import kotlinx.android.synthetic.main.layer_management_fragment.view.*
|
|
|
+import java.util.*
|
|
|
import kotlin.collections.ArrayList
|
|
|
|
|
|
-class LayerManagementDialog : DialogFragment() {
|
|
|
+class LayerManagementDialog : DialogFragment(), LayerAdapter.ItemMoveListener {
|
|
|
|
|
|
private var listener: DialogInterface.OnDismissListener? = null
|
|
|
private var layerChangeListener: OnLayerChange? = null
|
|
@@ -37,6 +40,7 @@ class LayerManagementDialog : DialogFragment() {
|
|
|
private val layer5Listeners = ArrayList<View.OnTouchListener>()
|
|
|
private val layer5Adapter = LayerAdapter(layer5Data, layer5Listeners)
|
|
|
private var selectLayer = 0
|
|
|
+ private var scene: Scene? = null
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
|
|
return inflater.inflate(R.layout.layer_management_fragment, container).apply {
|
|
@@ -47,6 +51,11 @@ class LayerManagementDialog : DialogFragment() {
|
|
|
orientation = LinearLayoutManager.HORIZONTAL
|
|
|
}
|
|
|
}
|
|
|
+ var itemTouchHelperCallBack1 = ItemTouchHelpCallback(layer1Adapter)
|
|
|
+ var itemTouchHelper1 = ItemTouchHelper(itemTouchHelperCallBack1)
|
|
|
+ itemTouchHelper1.attachToRecyclerView(rv_layer_management_layer1)
|
|
|
+ layer1Adapter.listener = this@LayerManagementDialog
|
|
|
+ layer1Adapter.layerNum = 1
|
|
|
layout_layer_management_layer1.apply {
|
|
|
setOnDragListener(onDragListener(1))
|
|
|
setOnClickListener(onClickLayerListener(1))
|
|
@@ -57,6 +66,11 @@ class LayerManagementDialog : DialogFragment() {
|
|
|
orientation = LinearLayoutManager.HORIZONTAL
|
|
|
}
|
|
|
}
|
|
|
+ var itemTouchHelperCallBack2 = ItemTouchHelpCallback(layer2Adapter)
|
|
|
+ var itemTouchHelper2 = ItemTouchHelper(itemTouchHelperCallBack2)
|
|
|
+ itemTouchHelper2.attachToRecyclerView(rv_layer_management_layer2)
|
|
|
+ layer2Adapter.listener = this@LayerManagementDialog
|
|
|
+ layer2Adapter.layerNum = 2
|
|
|
layout_layer_management_layer2.apply {
|
|
|
setOnDragListener(onDragListener(2))
|
|
|
setOnClickListener(onClickLayerListener(2))
|
|
@@ -67,6 +81,11 @@ class LayerManagementDialog : DialogFragment() {
|
|
|
orientation = LinearLayoutManager.HORIZONTAL
|
|
|
}
|
|
|
}
|
|
|
+ var itemTouchHelperCallBack3 = ItemTouchHelpCallback(layer3Adapter)
|
|
|
+ var itemTouchHelper3 = ItemTouchHelper(itemTouchHelperCallBack3)
|
|
|
+ itemTouchHelper3.attachToRecyclerView(rv_layer_management_layer3)
|
|
|
+ layer3Adapter.listener = this@LayerManagementDialog
|
|
|
+ layer3Adapter.layerNum = 3
|
|
|
layout_layer_management_layer3.apply {
|
|
|
setOnDragListener(onDragListener(3))
|
|
|
setOnClickListener(onClickLayerListener(3))
|
|
@@ -77,6 +96,11 @@ class LayerManagementDialog : DialogFragment() {
|
|
|
orientation = LinearLayoutManager.HORIZONTAL
|
|
|
}
|
|
|
}
|
|
|
+ var itemTouchHelperCallBack4 = ItemTouchHelpCallback(layer4Adapter)
|
|
|
+ var itemTouchHelper4 = ItemTouchHelper(itemTouchHelperCallBack4)
|
|
|
+ itemTouchHelper4.attachToRecyclerView(rv_layer_management_layer1)
|
|
|
+ layer4Adapter.listener = this@LayerManagementDialog
|
|
|
+ layer4Adapter.layerNum = 4
|
|
|
layout_layer_management_layer4.apply {
|
|
|
setOnDragListener(onDragListener(4))
|
|
|
setOnClickListener(onClickLayerListener(4))
|
|
@@ -87,6 +111,11 @@ class LayerManagementDialog : DialogFragment() {
|
|
|
orientation = LinearLayoutManager.HORIZONTAL
|
|
|
}
|
|
|
}
|
|
|
+ var itemTouchHelperCallBack5 = ItemTouchHelpCallback(layer5Adapter)
|
|
|
+ var itemTouchHelper5 = ItemTouchHelper(itemTouchHelperCallBack5)
|
|
|
+ itemTouchHelper5.attachToRecyclerView(rv_layer_management_layer5)
|
|
|
+ layer5Adapter.listener = this@LayerManagementDialog
|
|
|
+ layer5Adapter.layerNum = 5
|
|
|
layout_layer_management_layer5.apply {
|
|
|
setOnDragListener(onDragListener(5))
|
|
|
setOnClickListener(onClickLayerListener(5))
|
|
@@ -114,6 +143,7 @@ class LayerManagementDialog : DialogFragment() {
|
|
|
}
|
|
|
|
|
|
fun setData(scene: Scene){
|
|
|
+ this.scene = scene
|
|
|
this.layer1Data.apply {
|
|
|
clear()
|
|
|
addAll(scene.layers[0].actors)
|
|
@@ -199,7 +229,19 @@ class LayerManagementDialog : DialogFragment() {
|
|
|
layout_layer_management_layer3.setBackgroundColor(Color.parseColor("#ffffff"))
|
|
|
layout_layer_management_layer4.setBackgroundColor(Color.parseColor("#ffffff"))
|
|
|
layout_layer_management_layer5.setBackgroundColor(Color.parseColor("#ffffff"))
|
|
|
+ iv_layer_management_edit_layer1.visibility = View.INVISIBLE
|
|
|
+ iv_layer_management_edit_layer2.visibility = View.INVISIBLE
|
|
|
+ iv_layer_management_edit_layer3.visibility = View.INVISIBLE
|
|
|
+ iv_layer_management_edit_layer4.visibility = View.INVISIBLE
|
|
|
+ iv_layer_management_edit_layer5.visibility = View.INVISIBLE
|
|
|
it.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
+ when (selectLayer) {
|
|
|
+// 1 -> iv_layer_management_edit_layer1.visibility = View.VISIBLE
|
|
|
+// 2 -> iv_layer_management_edit_layer2.visibility = View.VISIBLE
|
|
|
+// 3 -> iv_layer_management_edit_layer3.visibility = View.VISIBLE
|
|
|
+// 4 -> iv_layer_management_edit_layer4.visibility = View.VISIBLE
|
|
|
+// 5 -> iv_layer_management_edit_layer5.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -247,17 +289,50 @@ class LayerManagementDialog : DialogFragment() {
|
|
|
layout_layer_management_layer3.setBackgroundColor(Color.parseColor("#ffffff"))
|
|
|
layout_layer_management_layer4.setBackgroundColor(Color.parseColor("#ffffff"))
|
|
|
layout_layer_management_layer5.setBackgroundColor(Color.parseColor("#ffffff"))
|
|
|
+ iv_layer_management_edit_layer1.visibility = View.INVISIBLE
|
|
|
+ iv_layer_management_edit_layer2.visibility = View.INVISIBLE
|
|
|
+ iv_layer_management_edit_layer3.visibility = View.INVISIBLE
|
|
|
+ iv_layer_management_edit_layer4.visibility = View.INVISIBLE
|
|
|
+ iv_layer_management_edit_layer5.visibility = View.INVISIBLE
|
|
|
when (selectLayer) {
|
|
|
- 1 -> layout_layer_management_layer1.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
- 2 -> layout_layer_management_layer2.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
- 3 -> layout_layer_management_layer3.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
- 4 -> layout_layer_management_layer4.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
- 5 -> layout_layer_management_layer5.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
+ 1 -> {
|
|
|
+ layout_layer_management_layer1.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
+ //iv_layer_management_edit_layer1.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ 2 -> {
|
|
|
+ layout_layer_management_layer2.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
+ //iv_layer_management_edit_layer2.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ 3 -> {
|
|
|
+ layout_layer_management_layer3.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
+ //iv_layer_management_edit_layer3.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ 4 -> {
|
|
|
+ layout_layer_management_layer4.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
+ //iv_layer_management_edit_layer4.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ 5 -> {
|
|
|
+ layout_layer_management_layer5.setBackgroundColor(Color.parseColor("#efeae1"))
|
|
|
+ //iv_layer_management_edit_layer5.visibility = View.VISIBLE
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onItemMove(layer: Int,fromPosition: Int, toPosition: Int) {
|
|
|
+ scene?.let {
|
|
|
+ Collections.swap(it.layers[layer - 1].actors,fromPosition,toPosition)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ override fun clearView() {
|
|
|
+ scene?.let {
|
|
|
+ setData(it)
|
|
|
+ layerChangeListener?.onItemChange(it)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
interface OnLayerChange{
|
|
|
fun onLayerChange(layerFrom: Int, layerTo: Int, position: Int)
|
|
|
fun onLayerManagementDialog(layer: Int, position: Int)
|
|
|
+ fun onItemChange(scene: Scene)
|
|
|
}
|
|
|
}
|