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

Merge branch 'master' into actor-bound-setter

cooperku_kdanmobile преди 6 години
родител
ревизия
f7211751ac

+ 1 - 1
src/main/java/com/bomostory/sceneeditmodule/screen/movie/MovieEditViewModel.kt

@@ -110,7 +110,7 @@ class MovieEditViewModel : ViewModel() {
         val secret = context.getString(R.string.bomo_cloud_client_secret)
         val author = project.author ?: ""
         val name = project.name ?: ""
-        val category = 0
+        val category = project.category.id
         val filePart = MultipartBody.Part.createFormData("file", file.name, RequestBody.create(MediaType.parse("video/*"), file))
         return BoMoCloud(id, secret).videoService
                 .uploadVideo(author, name, category, filePart)

+ 41 - 0
src/main/java/com/bomostory/sceneeditmodule/screen/view/ActorView.kt

@@ -2,12 +2,14 @@ package com.bomostory.sceneeditmodule.screen.view
 
 import android.content.Context
 import android.graphics.*
+import android.graphics.drawable.BitmapDrawable
 import android.graphics.drawable.Drawable
 import android.util.AttributeSet
 import android.widget.ImageView
 import com.bomostory.sceneeditmodule.DialogueDrawer
 import com.bomostory.sceneeditmodule.basicdata.Actor
 import pl.droidsonroids.gif.GifDrawable
+import kotlin.math.max
 
 class ActorView : ImageView {
 
@@ -45,4 +47,43 @@ class ActorView : ImageView {
             }
         }
     }
+
+    fun GifDrawable.getBitmapAt(milliseconds: Int): Bitmap = seekToPositionAndGet(if (loopCount == 0 || milliseconds < duration * loopCount) max(0, milliseconds % duration) else (duration))
+
+    fun isGif(): Boolean {
+        return drawable is GifDrawable
+    }
+
+    fun isGifPlaying(): Boolean {
+        if (drawable is GifDrawable) {
+            val gifDrawable = drawable as GifDrawable
+            return gifDrawable.isPlaying
+        }
+        return false
+    }
+
+    fun startGifAnimation() {
+        if (drawable is GifDrawable) {
+            val gifDrawable = drawable as GifDrawable
+            gifDrawable.start()
+        }
+    }
+
+    fun stopGifAnimation() {
+        if (drawable is GifDrawable) {
+            val gifDrawable = drawable as GifDrawable
+            gifDrawable.stop()
+        }
+    }
+
+    fun getBitmapAt(milliseconds: Int): Bitmap? {
+        if (drawable is GifDrawable) {
+            val gifDrawable = drawable as GifDrawable
+            return gifDrawable.seekToPositionAndGet(milliseconds)
+        } else if (drawable is BitmapDrawable) {
+            val bitmapDrawable = drawable as BitmapDrawable
+            return bitmapDrawable.bitmap
+        }
+        return null
+    }
 }

+ 5 - 2
src/main/java/com/bomostory/sceneeditmodule/share/ShareDialog.kt

@@ -1,7 +1,6 @@
 package com.bomostory.sceneeditmodule.share
 
 import android.graphics.PorterDuff
-import android.graphics.drawable.Drawable
 import android.media.MediaMetadataRetriever
 import android.os.Bundle
 import android.support.v4.app.DialogFragment
@@ -13,6 +12,7 @@ import android.view.LayoutInflater
 import android.view.View
 import android.view.ViewGroup
 import android.widget.SeekBar
+import com.bomostory.sceneeditmodule.SceneDrawer
 import com.bomostory.sceneeditmodule.basicdata.Project
 import com.bomostory.sceneeditmodule.utils.HorizontalItemDecoration
 import com.bomostory.sceneeditmodule.utils.TimeUtils
@@ -192,7 +192,10 @@ class ShareDialog : DialogFragment() {
             fun bind(p1: Int) {
                 itemView.apply {
                     project.story?.apply {
-                        screenshot.setImageDrawable(Drawable.createFromPath(this.scenes[p1].backgroundPath))
+                        val width = context.resources.getDimension(R.dimen.share_dialog_screenshot_width).toInt()
+                        val height = context.resources.getDimension(R.dimen.share_dialog_screenshot_height).toInt()
+                        val bitmap = SceneDrawer.drawScene(context, scenes[p1], 0, width, height)
+                        screenshot.setImageBitmap(bitmap)
                     }
                 }
             }

+ 3 - 0
src/main/res/values/dimens.xml

@@ -19,4 +19,7 @@
     <dimen name="export_pdf_screenshot_height">72dp</dimen>
     <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>
 </resources>