faterhenry il y a 5 ans
Parent
commit
df98a6dbf3

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

@@ -222,7 +222,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
                     project.themeAssetIndex.contains.actor.forEach {
                         add(ArrayList<String>().apply {
                             it.value.values.forEach {
-                                val path = "${project.assetFolder.path}/${it.smallFile}"
+                                val path = "${project.assetFolder.path}/${it.largeFile}"
                                 add(path)
                             }
                         })

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

@@ -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))
                     })
                 }

+ 2 - 2
src/main/java/com/bomostory/sceneeditmodule/utils/Utils.kt

@@ -20,8 +20,8 @@ object Utils {
         val canvas = Canvas(dst)
         val left = when (alignStyle) {
             AlignStyle.Left -> 0
-            AlignStyle.Center -> -(src.width - dst.width)
-            AlignStyle.Right -> -(src.width - dst.width) / 2
+            AlignStyle.Center -> -(src.width - dst.width) / 2
+            AlignStyle.Right ->  -(src.width - dst.width)
         }
         canvas.drawBitmap(src, left.toFloat(), 0f, null)
         return dst

+ 1 - 1
src/main/res/layout/actor_pose_item.xml

@@ -5,7 +5,7 @@
     android:layout_height="wrap_content">
     <ImageView
         android:id="@+id/iv_actor_pose_image"
-        android:scaleType="center"
+        android:scaleType="fitXY"
         android:layout_marginRight="16dp"
         android:layout_marginLeft="16dp"
         android:layout_marginTop="8dp"

+ 2 - 2
src/main/res/values/dimens.xml

@@ -20,8 +20,8 @@
     <dimen name="export_pdf_cover_width">72dp</dimen>
     <dimen name="export_pdf_cover_height">72dp</dimen>
 
-    <dimen name="share_dialog_screenshot_width">144dp</dimen>
-    <dimen name="share_dialog_screenshot_height">72dp</dimen>
+    <dimen name="share_dialog_screenshot_width">288dp</dimen>
+    <dimen name="share_dialog_screenshot_height">144dp</dimen>
 
     <dimen name="popup_view_set_color_height">288dp</dimen>