Sfoglia il codice sorgente

Merge branch 'feature_progress_view'

Wayne 6 anni fa
parent
commit
b6ef5fc3a9

+ 12 - 15
src/main/java/com/bomostory/sceneeditmodule/MovieEditActivity.kt

@@ -251,13 +251,22 @@ class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener
         val inputSceneStatus = LinkedHashMap<Int, Int>()
         var sceneIndex = -1
         var sceneRepeatCount = 0
+        var sceneCount = 0
+
 
         val movieBuilder = MovieMaker.Builder(mediaHelper)
         movieBuilder.fps = FPS
         movieBuilder.audioSources = generateAudioSource()
+
+        var totalFrame = 0
+        scene?.record?.period?.let {
+             totalFrame = (it/((1f / FPS) * 1000).toLong()).toInt()
+        }
+
         generateMovieFilms()
                 .subscribeOn(Schedulers.io())
                 .subscribe({
+                    Log.d("Debug","progress ${sceneCount++}/$totalFrame")
                     if (it.key == sceneIndex) {
                         sceneRepeatCount++
                     } else {
@@ -298,34 +307,22 @@ class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener
             scene?.apply {
                 record?.apply {
                     var bitmap = drawScene(0)
+                    var bitmapIndex = 0
                     var trackPosition = -1
-                    var isDrawNewScene: Boolean
-
-                    for (t in 0..period step ((1f / FPS.toFloat()) * 1000).toLong()) {
-                        isDrawNewScene = false
 
+                    for (t in 0 .. period step ((1f / FPS) * 1000).toLong()) {
                         for (track in tracks) {
                             if (t >= track.time && tracks.indexOf(track) > trackPosition) {
-                                isDrawNewScene = true
-
                                 preBitmap = bitmap
                                 preBitmap?.recycle()
 
                                 bitmap = drawScene(track.positionX)
                                 trackPosition = tracks.indexOf(track)
-
-                                bitmap?.apply {
-                                    it.onNext(AbstractMap.SimpleEntry(trackPosition + 1, this))
-                                    Log.d("Debug", "Index: ${trackPosition + 1}  Time: $t")
-                                }
                             }
                         }
 
                         bitmap?.apply {
-                            if (!isDrawNewScene) {
-                                it.onNext(AbstractMap.SimpleEntry(trackPosition + 1, this))
-                                Log.d("Debug", "Index: ${trackPosition + 1}  Time: $t")
-                            }
+                                it.onNext(AbstractMap.SimpleEntry(bitmapIndex++, this))
                         }
                     }
                     it.onComplete()

+ 26 - 0
src/main/java/com/bomostory/sceneeditmodule/view/ProgressView.kt

@@ -0,0 +1,26 @@
+package com.bomostory.sceneeditmodule.view
+
+import android.content.Context
+import android.support.constraint.ConstraintLayout
+import android.util.AttributeSet
+import android.view.LayoutInflater
+import com.example.tfat.myapplication.R
+
+class ProgressView :ConstraintLayout{
+
+    constructor(context: Context) : super(context){
+        initView()
+    }
+
+    constructor(context: Context, attrs: AttributeSet) : super(context, attrs){
+        initView()
+    }
+
+    constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle){
+        initView()
+    }
+
+    private fun initView() {
+        LayoutInflater.from(context).inflate(R.layout.progress_view, this)
+    }
+}

+ 6 - 0
src/main/res/layout/activity_movie_edit.xml

@@ -21,4 +21,10 @@
         android:layout_height="wrap_content"
         app:layout_constraintBottom_toBottomOf="parent" />
 
+    <com.bomostory.sceneeditmodule.view.ProgressView
+        android:id="@+id/progressView"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:visibility="invisible" />
+
 </android.support.constraint.ConstraintLayout>

+ 38 - 0
src/main/res/layout/progress_view.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="#80000000">
+
+    <TextView
+        android:id="@+id/progressText"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintBottom_toTopOf="@+id/determinateProgress"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent" />
+
+    <ProgressBar
+        android:id="@+id/determinateProgress"
+        style="@style/Widget.AppCompat.ProgressBar.Horizontal"
+        android:layout_width="240dp"
+        android:layout_height="4dp"
+        android:max="100"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+    <ProgressBar
+        android:id="@+id/inDeterminateProgress"
+        style="@style/Widget.AppCompat.ProgressBar"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:visibility="gone"
+        app:layout_constraintBottom_toBottomOf="parent"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+</android.support.constraint.ConstraintLayout>