|
@@ -1,6 +1,7 @@
|
|
|
package com.example.tfat.myapplication
|
|
|
|
|
|
import android.app.Activity
|
|
|
+import android.app.ProgressDialog
|
|
|
import android.content.DialogInterface
|
|
|
import android.content.Intent
|
|
|
import android.support.v7.app.AppCompatActivity
|
|
@@ -10,7 +11,6 @@ import android.graphics.drawable.Drawable
|
|
|
import android.support.v7.widget.RecyclerView
|
|
|
import android.view.*
|
|
|
import android.widget.PopupWindow
|
|
|
-import com.bomostory.sceneeditmodule.Config
|
|
|
import com.bomostory.sceneeditmodule.MovieEditActivity
|
|
|
import com.example.tfat.myapplication.navigationbar.NavigationBarView
|
|
|
import com.example.tfat.myapplication.navigationbar.actor.ActorAdapter
|
|
@@ -28,14 +28,12 @@ import com.bomostory.sceneeditmodule.view.OnTouchBoMoSceneListener
|
|
|
import com.example.tfat.myapplication.navigationbar.RecordFinishView
|
|
|
import com.example.tfat.myapplication.navigationbar.actor.LayerManagementDialog
|
|
|
import kotlinx.android.synthetic.main.control_actor_dialog.view.*
|
|
|
-import java.io.File
|
|
|
-import java.io.FileWriter
|
|
|
import com.bomostory.sceneeditmodule.utils.FileUtils
|
|
|
import com.bomostory.sceneeditmodule.view.LayerView
|
|
|
import android.util.DisplayMetrics
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+import io.reactivex.android.schedulers.AndroidSchedulers
|
|
|
+import io.reactivex.schedulers.Schedulers
|
|
|
+import java.util.concurrent.CopyOnWriteArrayList
|
|
|
|
|
|
class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener, EditActorView.OnActorChangeListener,
|
|
|
OnTouchBoMoSceneListener.OnSceneMoveListener, DialogInterface.OnDismissListener, FileUtils.OnSaveActorImage,
|
|
@@ -61,6 +59,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
const val ACTOR_INIT_POSITION_X = 200
|
|
|
const val ACTOR_INIT_POSITION_Y = 200
|
|
|
const val BACKGROUND_MOVE_RATE = 32
|
|
|
+ val listeners = CopyOnWriteArrayList<Runnable>()
|
|
|
}
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
@@ -81,7 +80,19 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
}
|
|
|
}
|
|
|
ic_scene_edit_activity_back.setOnClickListener {
|
|
|
- this.onBackPressed()
|
|
|
+ val pd = ProgressDialog(this).apply {
|
|
|
+ setCancelable(false)
|
|
|
+ }
|
|
|
+ FileUtils.saveProject(project, 1920,1080)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .doOnSubscribe { pd.show() }
|
|
|
+ .doFinally {
|
|
|
+ pd.dismiss()
|
|
|
+ this.onBackPressed()}
|
|
|
+ .subscribe {
|
|
|
+ listeners.forEach {it.run()}
|
|
|
+ }
|
|
|
}
|
|
|
initControlBarView()
|
|
|
initNavigationBarView()
|
|
@@ -160,30 +171,36 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
navigationBar.removeAllViews()
|
|
|
var recordFinishView = RecordFinishView(this)
|
|
|
recordFinishView.setOnNextSceneClickListener(View.OnClickListener {
|
|
|
- switchScene(currentSceneIndex + 1)
|
|
|
- })
|
|
|
- recordFinishView.setOnFinishClickListener(View.OnClickListener {
|
|
|
+ currentSceneIndex++
|
|
|
project.story?.let {
|
|
|
- it.scenes?.let {
|
|
|
- when (it.size) {
|
|
|
- 1 -> project.scene1 = it[0].backgroundPath
|
|
|
- else -> {
|
|
|
- project.scene1 = it[0].backgroundPath
|
|
|
- project.scene2 = it[1].backgroundPath
|
|
|
+ it.scenes?.let{
|
|
|
+ when(currentSceneIndex < it.size){
|
|
|
+ true -> {
|
|
|
+ switchToPreViewLayer()
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
+ }
|
|
|
+ false -> {
|
|
|
+ currentSceneIndex = 0
|
|
|
+ sceneEditView.scene = it[currentSceneIndex]
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- val dir = File(Config.PROJECTS_FOLDER,"")
|
|
|
- dir.mkdir()
|
|
|
- val file = File(Config.PROJECTS_FOLDER, project.name + ".json")
|
|
|
- try {
|
|
|
- val fileWriter = FileWriter(file)
|
|
|
- fileWriter.write(Gson().toJson(project))
|
|
|
- fileWriter.flush()
|
|
|
- } catch (e: Exception) {
|
|
|
- e.printStackTrace()
|
|
|
+ initControlBarView()
|
|
|
+ initNavigationBarView()
|
|
|
+ })
|
|
|
+ recordFinishView.setOnFinishClickListener(View.OnClickListener {
|
|
|
+ val pd = ProgressDialog(this).apply {
|
|
|
+ setCancelable(false)
|
|
|
}
|
|
|
+ FileUtils.saveProject(project, 1920,1080)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .doOnSubscribe { pd.show() }
|
|
|
+ .doFinally { pd.dismiss() }
|
|
|
+ .subscribe {
|
|
|
+ listeners.forEach {it.run()}
|
|
|
+ }
|
|
|
val intent = Intent(this, MovieEditActivity::class.java)
|
|
|
intent.putExtra(MovieEditActivity.PROJECT_KEY, Gson().toJson(project))
|
|
|
startActivity(intent)
|
|
@@ -399,6 +416,7 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
scene.backgroundPath = resourceThemeBitmap[position]
|
|
|
project.story?.let {
|
|
|
it.scenes?.let{
|
|
|
+ scene.sceneWidth = monitorSize.widthPixels
|
|
|
it.add(scene)
|
|
|
}
|
|
|
}
|
|
@@ -562,12 +580,12 @@ class SceneEditActivity : AppCompatActivity(), ActorAdapter.OnActorDragListener,
|
|
|
|
|
|
|
|
|
override fun onSceneMove(dX: Int) {
|
|
|
- if ( (BACKGROUND_MOVE_RATE * 69) >= (swipeX + dX) && (swipeX + dX) > (-(BACKGROUND_MOVE_RATE * 69))) {
|
|
|
+ if ( (BACKGROUND_MOVE_RATE * 35) >= (swipeX + dX) && (swipeX + dX) > (-(BACKGROUND_MOVE_RATE * 35))) {
|
|
|
sceneEditView.x = swipeX + dX
|
|
|
if (isRecord) {
|
|
|
record?.tracks.let {
|
|
|
val track = Track()
|
|
|
- track.positionX = dX
|
|
|
+ track.positionX = swipeX + dX
|
|
|
track.time = System.currentTimeMillis() - startRecordTime
|
|
|
record.tracks.add(track)
|
|
|
}
|