|
@@ -6,13 +6,16 @@ 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 com.bomostory.sceneeditmodule.navigationbar.actor.ActorPoseAdapter
|
|
|
import com.bomostory.sceneeditmodule.screen.view.LayerView
|
|
|
|
|
|
import com.example.tfat.myapplication.R
|
|
|
+import kotlinx.android.synthetic.main.actor_pose_item.view.*
|
|
|
import kotlinx.android.synthetic.main.item_actor.view.*
|
|
|
+import pl.droidsonroids.gif.GifDrawable
|
|
|
import kotlin.collections.ArrayList
|
|
|
|
|
|
class ActorAdapter(var context : Context, var data: ArrayList<ArrayList<String>>, layerView: LayerView, onActorDragListener: OnActorDragListener) : RecyclerView.Adapter<ActorAdapter.ViewHolder>() {
|
|
@@ -59,31 +62,28 @@ class ActorAdapter(var context : Context, var data: ArrayList<ArrayList<String>>
|
|
|
return bitmaps
|
|
|
}
|
|
|
|
|
|
- private fun initActorImageView(data: ArrayList<ArrayList<String>>) : ArrayList<ArrayList<ImageView>>{
|
|
|
- var imageViewList = ArrayList<ImageView>()
|
|
|
- var actorImageViewList = ArrayList<ArrayList<ImageView>>()
|
|
|
- for(i in 0 until data.size){
|
|
|
- for(j in 0 until data[i].size){
|
|
|
- var imageView = ImageView(context)
|
|
|
- imageView.setImageDrawable(Drawable.createFromPath(data[i][j]))
|
|
|
- imageViewList.add(imageView)
|
|
|
- }
|
|
|
- actorImageViewList.add(imageViewList)
|
|
|
- imageViewList = ArrayList()
|
|
|
- }
|
|
|
- return actorImageViewList
|
|
|
- }
|
|
|
-
|
|
|
class ViewHolder (view : View) : RecyclerView.ViewHolder(view) {
|
|
|
- fun bind(path: String?, position: Int, data: ArrayList<String>) {
|
|
|
- itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(Drawable.createFromPath(path))
|
|
|
+ fun bind(path: String, position: Int, data: ArrayList<String>) {
|
|
|
+ if (path.toLowerCase().endsWith(".gif")) {
|
|
|
+ var gifDrawable = GifDrawable(path)
|
|
|
+ itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(gifDrawable)
|
|
|
+ gifDrawable?.start()
|
|
|
+ } else {
|
|
|
+ itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(Drawable.createFromPath(path))
|
|
|
+ }
|
|
|
itemView.findViewById<ImageView>(R.id.actor_image).setOnTouchListener(boMoOnTouchListener(position,0))
|
|
|
itemView.actor_rotate.apply {
|
|
|
isNestedScrollingEnabled = false
|
|
|
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]))
|
|
|
+ if (data[i].toLowerCase().endsWith(".gif")) {
|
|
|
+ var gifDrawable = GifDrawable(data[i])
|
|
|
+ itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(gifDrawable)
|
|
|
+ gifDrawable?.start()
|
|
|
+ } else {
|
|
|
+ itemView.findViewById<ImageView>(R.id.actor_image).setImageDrawable(Drawable.createFromPath(data[i]))
|
|
|
+ }
|
|
|
itemView.findViewById<ImageView>(R.id.actor_image).setOnTouchListener(boMoOnTouchListener(position,i))
|
|
|
})
|
|
|
}
|