|
@@ -2,6 +2,8 @@ package com.bomostory.sceneeditmodule.screen.movie
|
|
|
|
|
|
import android.app.AlertDialog
|
|
import android.app.AlertDialog
|
|
import android.app.ProgressDialog
|
|
import android.app.ProgressDialog
|
|
|
|
+import android.arch.lifecycle.Observer
|
|
|
|
+import android.arch.lifecycle.ViewModelProviders
|
|
import android.content.DialogInterface
|
|
import android.content.DialogInterface
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
import android.net.Uri
|
|
import android.net.Uri
|
|
@@ -14,20 +16,20 @@ import android.view.View
|
|
import android.widget.CompoundButton
|
|
import android.widget.CompoundButton
|
|
import android.widget.SeekBar
|
|
import android.widget.SeekBar
|
|
import android.widget.Toast
|
|
import android.widget.Toast
|
|
-import com.bomostory.sceneeditmodule.*
|
|
|
|
|
|
+import com.bomostory.sceneeditmodule.Config
|
|
|
|
+import com.bomostory.sceneeditmodule.PdfMaker
|
|
|
|
+import com.bomostory.sceneeditmodule.SuperMovieMaker
|
|
import com.bomostory.sceneeditmodule.basicdata.*
|
|
import com.bomostory.sceneeditmodule.basicdata.*
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicEditDialog
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicEditDialog
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectDialog
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectDialog
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectFragment
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectFragment
|
|
-import com.bomostory.sceneeditmodule.share.ExportPdfDialog
|
|
|
|
import com.bomostory.sceneeditmodule.share.ShareDialog
|
|
import com.bomostory.sceneeditmodule.share.ShareDialog
|
|
-import com.bomostory.sceneeditmodule.utils.MoviePlayer
|
|
|
|
-import com.bomostory.sceneeditmodule.utils.MusicPlayer
|
|
|
|
-import com.bomostory.sceneeditmodule.utils.TimeUtils
|
|
|
|
import com.bomostory.sceneeditmodule.screen.view.AudioTrackGroupView
|
|
import com.bomostory.sceneeditmodule.screen.view.AudioTrackGroupView
|
|
import com.bomostory.sceneeditmodule.screen.view.MovieSelectView
|
|
import com.bomostory.sceneeditmodule.screen.view.MovieSelectView
|
|
|
|
+import com.bomostory.sceneeditmodule.share.ExportPdfDialog
|
|
|
|
+import com.bomostory.sceneeditmodule.utils.MoviePlayerV2
|
|
|
|
+import com.bomostory.sceneeditmodule.utils.MusicPlayerV2
|
|
import com.example.exportmedia.MediaHelper
|
|
import com.example.exportmedia.MediaHelper
|
|
-import com.example.exportmedia.audio.AudioEditor
|
|
|
|
import com.example.tfat.myapplication.R
|
|
import com.example.tfat.myapplication.R
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
import io.reactivex.Observable
|
|
import io.reactivex.Observable
|
|
@@ -43,35 +45,38 @@ class MovieEditActivity : AppCompatActivity(),
|
|
MusicEditDialog.OnFragmentInteractionListener {
|
|
MusicEditDialog.OnFragmentInteractionListener {
|
|
|
|
|
|
override fun onMusicImportClick(music: Music) {
|
|
override fun onMusicImportClick(music: Music) {
|
|
|
|
+ val musics: ArrayList<Music> = viewModel.musicListLiveData.value as ArrayList<Music>
|
|
musics.add(music)
|
|
musics.add(music)
|
|
- moviePlayer.init()
|
|
|
|
- moviePlayer.addMusic(music)
|
|
|
|
- movieEditView.musics = musics
|
|
|
|
|
|
+ viewModel.musicListLiveData.value = musics
|
|
|
|
+ viewModel.musicLiveData.value = music
|
|
|
|
|
|
val dialogFragment = supportFragmentManager.findFragmentByTag(MUSIC_SELECT_DIALOG_TAG) as DialogFragment
|
|
val dialogFragment = supportFragmentManager.findFragmentByTag(MUSIC_SELECT_DIALOG_TAG) as DialogFragment
|
|
dialogFragment.dismiss()
|
|
dialogFragment.dismiss()
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMusicPreCastClick(music: Music) {
|
|
override fun onMusicPreCastClick(music: Music) {
|
|
- musicPlayer.stop()
|
|
|
|
- musicPlayer.clear()
|
|
|
|
- musicPlayer.add(music)
|
|
|
|
- musicPlayer.play()
|
|
|
|
|
|
+ musicPlayer.apply {
|
|
|
|
+ this.music = music
|
|
|
|
+ stop()
|
|
|
|
+ init()
|
|
|
|
+ start()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMusicPlayClick(music: Music, startPosition: Int) {
|
|
override fun onMusicPlayClick(music: Music, startPosition: Int) {
|
|
- musicPlayer.clear()
|
|
|
|
- musicPlayer.add(music)
|
|
|
|
- musicPlayer.playChangedListener = object : MusicPlayer.OnPlayChangedListener {
|
|
|
|
- override fun onPlayChanged(music: Music, position: Int) {
|
|
|
|
- runOnUiThread {
|
|
|
|
- musicEditDialog?.currentPosition = position
|
|
|
|
|
|
+ musicPlayer.apply {
|
|
|
|
+ this.music = music
|
|
|
|
+ playChangedListener = object : MusicPlayerV2.OnPlayChangedListener {
|
|
|
|
+ override fun OnPlayChanged(position: Int) {
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ musicEditDialog?.currentPosition = position
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+ init()
|
|
|
|
+ seekTo(startPosition)
|
|
|
|
+ start()
|
|
}
|
|
}
|
|
- musicPlayer.play(startPosition)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMusicVolumeChanged(volume: Float) {
|
|
override fun onMusicVolumeChanged(volume: Float) {
|
|
@@ -87,34 +92,42 @@ class MovieEditActivity : AppCompatActivity(),
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMusicEditFinish(music: Music) {
|
|
override fun onMusicEditFinish(music: Music) {
|
|
- if (music.endTime - music.startTime > moviePlayer.totalPeriod) {
|
|
|
|
- music.endTime = music.startTime + moviePlayer.totalPeriod
|
|
|
|
|
|
+ //TODO change path to correct path
|
|
|
|
+ val outputFile = File(Environment.getExternalStorageDirectory(), "test${System.currentTimeMillis()}.mp3")
|
|
|
|
+
|
|
|
|
+ val pd = ProgressDialog(this).apply {
|
|
|
|
+ setMessage("progressing")
|
|
|
|
+ setCancelable(false)
|
|
}
|
|
}
|
|
|
|
|
|
- val builder = AudioEditor.Builder(mediaHelper)
|
|
|
|
- builder.editAudioFile = File(music.path)
|
|
|
|
- builder.startTime = TimeUtils.getEncodeTimeFormt(music.startTime)
|
|
|
|
- builder.endTime = TimeUtils.getEncodeTimeFormt(music.endTime)
|
|
|
|
- builder.volume = music.volume
|
|
|
|
|
|
+ viewModel.exportEditAudio(music, outputFile)
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
+ .doOnSubscribe {
|
|
|
|
+ pd.show()
|
|
|
|
+ }
|
|
|
|
+ .doFinally {
|
|
|
|
+ pd.dismiss()
|
|
|
|
+ }
|
|
|
|
+ .subscribe({
|
|
|
|
+ music.path = outputFile.path
|
|
|
|
|
|
- val fileName = "test${System.currentTimeMillis()}.mp3"
|
|
|
|
- val outputFile = File(Environment.getExternalStorageDirectory(), fileName)
|
|
|
|
- val audioEditor = builder.build()
|
|
|
|
- audioEditor.output(outputFile).subscribe({
|
|
|
|
- }, {
|
|
|
|
- })
|
|
|
|
|
|
+ val musics: ArrayList<Music> = viewModel.musicListLiveData.value as ArrayList<Music>
|
|
|
|
+ musics[musics.indexOf(viewModel.musicLiveData.value)] = music
|
|
|
|
+ viewModel.musicListLiveData.value = musics
|
|
|
|
+ viewModel.musicLiveData.value = music
|
|
|
|
+ }, {
|
|
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
override fun onDismiss(dialog: DialogInterface?) {
|
|
override fun onDismiss(dialog: DialogInterface?) {
|
|
musicPlayer.stop()
|
|
musicPlayer.stop()
|
|
- musicPlayer.release()
|
|
|
|
-
|
|
|
|
delayedHide(100)
|
|
delayedHide(100)
|
|
}
|
|
}
|
|
|
|
|
|
- private val shareDialog = ShareDialog()
|
|
|
|
private var musicEditDialog: MusicEditDialog? = null
|
|
private var musicEditDialog: MusicEditDialog? = null
|
|
|
|
+ private val shareDialog = ShareDialog()
|
|
|
|
|
|
private val mHideHandler = Handler()
|
|
private val mHideHandler = Handler()
|
|
private val mHidePart2Runnable = Runnable {
|
|
private val mHidePart2Runnable = Runnable {
|
|
@@ -133,50 +146,9 @@ class MovieEditActivity : AppCompatActivity(),
|
|
hide()
|
|
hide()
|
|
}
|
|
}
|
|
|
|
|
|
- private var project: Project? = null
|
|
|
|
- set(value) {
|
|
|
|
- field = value
|
|
|
|
- value?.let {
|
|
|
|
- story = it.story
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private var story: Story? = null
|
|
|
|
- set(value) {
|
|
|
|
- field = value
|
|
|
|
- moviePlayer.story = value
|
|
|
|
- movieEditView.story = value
|
|
|
|
- value?.let {
|
|
|
|
- scene = it.scenes[0]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private var scene: Scene? = null
|
|
|
|
- set(value) {
|
|
|
|
- field = value
|
|
|
|
- value?.let {
|
|
|
|
- movieView.scene = value
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private var isLoop = false
|
|
|
|
- set(value) {
|
|
|
|
- field = value
|
|
|
|
- movieEditView.isLoop = value
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private var currentAudioPosition = 0
|
|
|
|
- set(value) {
|
|
|
|
- field = value
|
|
|
|
- movieEditView.currentAudioPosition = value
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ private val moviePlayer = MoviePlayerV2()
|
|
|
|
|
|
- private val moviePlayer = MoviePlayer()
|
|
|
|
-
|
|
|
|
- private val musicPlayer = MusicPlayer()
|
|
|
|
-
|
|
|
|
- private val musics = ArrayList<Music>()
|
|
|
|
|
|
+ private val musicPlayer = MusicPlayerV2()
|
|
|
|
|
|
private val mediaHelper = MediaHelper()
|
|
private val mediaHelper = MediaHelper()
|
|
|
|
|
|
@@ -188,13 +160,42 @@ class MovieEditActivity : AppCompatActivity(),
|
|
private const val UI_ANIMATION_DELAY = 300
|
|
private const val UI_ANIMATION_DELAY = 300
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private lateinit var viewModel: MovieEditViewModel
|
|
|
|
+
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
setContentView(R.layout.activity_movie_edit)
|
|
setContentView(R.layout.activity_movie_edit)
|
|
|
|
|
|
- supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
|
|
|
|
|
+ mediaHelper.init(this)
|
|
|
|
+
|
|
|
|
+ viewModel = ViewModelProviders.of(this).get(MovieEditViewModel::class.java)
|
|
|
|
+ viewModel.mediaHelper = mediaHelper
|
|
|
|
+ viewModel.project = Gson().fromJson<Project>(intent.extras.getString(PROJECT_KEY), Project::class.java)
|
|
|
|
+ viewModel.storyLiveData.observe(this, Observer {
|
|
|
|
+ movieEditView.story = it
|
|
|
|
+ moviePlayer.story = it
|
|
|
|
+ })
|
|
|
|
+ viewModel.storyPeriodLiveData.observe(this, Observer {
|
|
|
|
+ movieEditView.period = it ?: 0
|
|
|
|
+ moviePlayer.period = it ?: 0
|
|
|
|
+ })
|
|
|
|
+ viewModel.sceneLiveData.observe(this, Observer {
|
|
|
|
+ movieView.scene = it
|
|
|
|
+ })
|
|
|
|
+ viewModel.musicListLiveData.observe(this, Observer {
|
|
|
|
+ movieEditView.musics = it as ArrayList<Music>
|
|
|
|
+ movieEditView.isAudioTrackGroupViewVisible = it.isNotEmpty()
|
|
|
|
+ moviePlayer.musicList = it
|
|
|
|
+ moviePlayer.init()
|
|
|
|
|
|
- project = Gson().fromJson<Project>(intent.extras.getString(PROJECT_KEY), Project::class.java)
|
|
|
|
|
|
+ })
|
|
|
|
+ viewModel.musicLiveData.observe(this, Observer {
|
|
|
|
+ viewModel.musicListLiveData.value?.apply {
|
|
|
|
+ movieEditView.currentAudioPosition = indexOf(it)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
|
|
|
|
|
movieEditView.onPlayClickListener = View.OnClickListener(this::playMovie)
|
|
movieEditView.onPlayClickListener = View.OnClickListener(this::playMovie)
|
|
movieEditView.onPauseClickListener = View.OnClickListener(this::pauseMovie)
|
|
movieEditView.onPauseClickListener = View.OnClickListener(this::pauseMovie)
|
|
@@ -205,7 +206,7 @@ class MovieEditActivity : AppCompatActivity(),
|
|
movieEditView.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
|
movieEditView.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
|
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
|
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
|
if (fromUser) {
|
|
if (fromUser) {
|
|
- moviePlayer.seekTo(progress)
|
|
|
|
|
|
+ moviePlayer.seekTo(progress.toLong())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -217,51 +218,71 @@ class MovieEditActivity : AppCompatActivity(),
|
|
}
|
|
}
|
|
movieEditView.onMovieSelectListener = object : MovieSelectView.OnMovieSelectListener {
|
|
movieEditView.onMovieSelectListener = object : MovieSelectView.OnMovieSelectListener {
|
|
override fun onMoveSelect(scene: Scene) {
|
|
override fun onMoveSelect(scene: Scene) {
|
|
- this@MovieEditActivity.scene = scene
|
|
|
|
|
|
+ viewModel.sceneLiveData.value = scene
|
|
}
|
|
}
|
|
}
|
|
}
|
|
movieEditView.onAudioTrackSelectListener = object : AudioTrackGroupView.OnAudioTrackSelectListener {
|
|
movieEditView.onAudioTrackSelectListener = object : AudioTrackGroupView.OnAudioTrackSelectListener {
|
|
override fun onAudioTrackSelect(position: Int) {
|
|
override fun onAudioTrackSelect(position: Int) {
|
|
- currentAudioPosition = position
|
|
|
|
|
|
+ viewModel.musicListLiveData.value?.let {
|
|
|
|
+ viewModel.musicLiveData.value = it[position]
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
movieEditView.onAudioTrackScrollListener = object : AudioTrackGroupView.OnAudioTrackScrollListener {
|
|
movieEditView.onAudioTrackScrollListener = object : AudioTrackGroupView.OnAudioTrackScrollListener {
|
|
override fun onAudioTrackScroll(position: Int, scrollRatio: Double) {
|
|
override fun onAudioTrackScroll(position: Int, scrollRatio: Double) {
|
|
- scene?.record?.period?.let {
|
|
|
|
- musics[position].offsetTime = (it * scrollRatio).toLong()
|
|
|
|
- }
|
|
|
|
|
|
+ viewModel.musicListLiveData.value?.get(position)?.offsetTime = ((viewModel.storyPeriodLiveData.value
|
|
|
|
+ ?: 0) * scrollRatio).toLong()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ movieEditView.onAudioTrackLoopScrollListener = object : AudioTrackGroupView.OnAudioTrackScrollListener {
|
|
|
|
+ override fun onAudioTrackScroll(position: Int, scrollRatio: Double) {
|
|
|
|
+ viewModel.musicListLiveData.value?.get(position)?.loopDuration = ((viewModel.storyPeriodLiveData.value
|
|
|
|
+ ?: 0) * scrollRatio).toLong()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
movieEditView.onLoopSwitchChangedListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
|
|
movieEditView.onLoopSwitchChangedListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
|
|
- isLoop = isChecked
|
|
|
|
|
|
+ val musics: ArrayList<Music> = viewModel.musicListLiveData.value as ArrayList<Music>
|
|
|
|
+ for (music in musics) {
|
|
|
|
+ music.isLoop = isChecked
|
|
|
|
+ }
|
|
|
|
+ viewModel.musicListLiveData.value = musics
|
|
}
|
|
}
|
|
|
|
|
|
- moviePlayer.moviePlayListener = object : MoviePlayer.OnMoviePlayListener {
|
|
|
|
|
|
+ moviePlayer.moviePlayListener = object : MoviePlayerV2.OnMoviePlayListener {
|
|
override fun onMovieSceneUpdate(scene: Scene) {
|
|
override fun onMovieSceneUpdate(scene: Scene) {
|
|
- if (scene != this@MovieEditActivity.scene) {
|
|
|
|
- this@MovieEditActivity.scene = scene
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ if (viewModel.sceneLiveData.value != scene) {
|
|
|
|
+ viewModel.sceneLiveData.value = scene
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMoviePlayComplete() {
|
|
override fun onMoviePlayComplete() {
|
|
- story?.scenes?.let {
|
|
|
|
- this@MovieEditActivity.scene = it[0]
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ viewModel.project?.story?.let {
|
|
|
|
+ viewModel.sceneLiveData.value = it.scenes[0]
|
|
|
|
+ }
|
|
|
|
+ movieEditView.isBtnPanelEnable = true
|
|
}
|
|
}
|
|
- movieEditView.isBtnPanelEnable = true
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMoviePlayViewUpdate(x: Int) {
|
|
override fun onMoviePlayViewUpdate(x: Int) {
|
|
- movieView.x = x
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ movieView.x = x
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMoviePlayTimeUpdate(time: Long) {
|
|
override fun onMoviePlayTimeUpdate(time: Long) {
|
|
- movieEditView.playTime = time
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ movieEditView.playTime = time
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- mediaHelper.init(this)
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
override fun onPostResume() {
|
|
override fun onPostResume() {
|
|
super.onPostResume()
|
|
super.onPostResume()
|
|
delayedHide(100)
|
|
delayedHide(100)
|
|
@@ -279,7 +300,7 @@ class MovieEditActivity : AppCompatActivity(),
|
|
}
|
|
}
|
|
|
|
|
|
private fun playMovie(view: View) {
|
|
private fun playMovie(view: View) {
|
|
- moviePlayer.play()
|
|
|
|
|
|
+ moviePlayer.start()
|
|
movieEditView.isBtnPanelEnable = false
|
|
movieEditView.isBtnPanelEnable = false
|
|
}
|
|
}
|
|
|
|
|
|
@@ -289,39 +310,26 @@ class MovieEditActivity : AppCompatActivity(),
|
|
}
|
|
}
|
|
|
|
|
|
private fun addMusic(view: View) {
|
|
private fun addMusic(view: View) {
|
|
- val libraryPaths = ArrayList<String>()
|
|
|
|
-
|
|
|
|
- project?.let {
|
|
|
|
- val assetFolder = it.assetFolder.path
|
|
|
|
- it.themeAssetIndex.contains.music.values.forEach {
|
|
|
|
- libraryPaths.add("$assetFolder/$it")
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ viewModel.parseDeviceMusic(contentResolver)
|
|
|
|
|
|
- val musicSource = DataParser.parseMusicSource(contentResolver, libraryPaths)
|
|
|
|
- val musicSelectDialog = MusicSelectDialog.newInstance(Gson().toJson(musicSource))
|
|
|
|
|
|
+ val musicSelectDialog = MusicSelectDialog.newInstance(Gson().toJson(viewModel.musicSource))
|
|
musicSelectDialog.show(supportFragmentManager, MUSIC_SELECT_DIALOG_TAG)
|
|
musicSelectDialog.show(supportFragmentManager, MUSIC_SELECT_DIALOG_TAG)
|
|
}
|
|
}
|
|
|
|
|
|
private fun editMusic(view: View) {
|
|
private fun editMusic(view: View) {
|
|
- musicEditDialog = MusicEditDialog.newInstance(Gson().toJson(musics[currentAudioPosition]))
|
|
|
|
|
|
+ musicEditDialog = MusicEditDialog.newInstance(Gson().toJson(viewModel.musicLiveData.value))
|
|
musicEditDialog?.show(supportFragmentManager, MUSIC_EDIT_DIALOG_TAG)
|
|
musicEditDialog?.show(supportFragmentManager, MUSIC_EDIT_DIALOG_TAG)
|
|
}
|
|
}
|
|
|
|
|
|
private fun deleteMusic(view: View) {
|
|
private fun deleteMusic(view: View) {
|
|
- if (currentAudioPosition in 0 until musics.size) {
|
|
|
|
- moviePlayer.init()
|
|
|
|
- moviePlayer.removeMusic(musics[currentAudioPosition])
|
|
|
|
-
|
|
|
|
- musics.removeAt(currentAudioPosition)
|
|
|
|
-
|
|
|
|
- movieEditView.musics = musics
|
|
|
|
- }
|
|
|
|
|
|
+ val musics: ArrayList<Music> = viewModel.musicListLiveData.value as ArrayList<Music>
|
|
|
|
+ musics.remove(viewModel.musicLiveData.value)
|
|
|
|
+ viewModel.musicListLiveData.value = musics
|
|
}
|
|
}
|
|
|
|
|
|
private fun onClickSaveAndShareBtn(view: View) {
|
|
private fun onClickSaveAndShareBtn(view: View) {
|
|
shareDialog.apply {
|
|
shareDialog.apply {
|
|
- project = this@MovieEditActivity.project ?: return@apply
|
|
|
|
|
|
+ project = viewModel.project ?: return@apply
|
|
onClickBomo = Runnable { saveMovie() }
|
|
onClickBomo = Runnable { saveMovie() }
|
|
onClickExportPdf = Runnable { onClickExportPdf() }
|
|
onClickExportPdf = Runnable { onClickExportPdf() }
|
|
}.show(supportFragmentManager)
|
|
}.show(supportFragmentManager)
|
|
@@ -329,28 +337,28 @@ class MovieEditActivity : AppCompatActivity(),
|
|
|
|
|
|
private fun onClickExportPdf() {
|
|
private fun onClickExportPdf() {
|
|
ExportPdfDialog().also { exportPdfDialog ->
|
|
ExportPdfDialog().also { exportPdfDialog ->
|
|
- exportPdfDialog.image1Path = project?.scene1File?.path ?: ""
|
|
|
|
- exportPdfDialog.image2Path = project?.scene2File?.path ?: ""
|
|
|
|
|
|
+ exportPdfDialog.image1Path = viewModel.project?.scene1File?.path ?: ""
|
|
|
|
+ exportPdfDialog.image2Path = viewModel.project?.scene2File?.path ?: ""
|
|
exportPdfDialog.onClickPrint = Runnable {
|
|
exportPdfDialog.onClickPrint = Runnable {
|
|
when (exportPdfDialog.type) {
|
|
when (exportPdfDialog.type) {
|
|
ExportPdfDialog.Type.Standard -> {
|
|
ExportPdfDialog.Type.Standard -> {
|
|
- val name = "standard_${project?.name}_${System.currentTimeMillis()}.pdf"
|
|
|
|
|
|
+ val name = "standard_${viewModel.project?.name}_${System.currentTimeMillis()}.pdf"
|
|
if (!Config.PDF_FOLDER.exists()) {
|
|
if (!Config.PDF_FOLDER.exists()) {
|
|
Config.PDF_FOLDER.mkdirs()
|
|
Config.PDF_FOLDER.mkdirs()
|
|
}
|
|
}
|
|
val file = File(Config.PDF_FOLDER, name)
|
|
val file = File(Config.PDF_FOLDER, name)
|
|
file.createNewFile()
|
|
file.createNewFile()
|
|
- val observable = PdfMaker.makeStandard(this@MovieEditActivity, project!!, file)
|
|
|
|
|
|
+ val observable = PdfMaker.makeStandard(this@MovieEditActivity, viewModel.project!!, file)
|
|
Pair(file, observable)
|
|
Pair(file, observable)
|
|
}
|
|
}
|
|
ExportPdfDialog.Type.Booklet -> {
|
|
ExportPdfDialog.Type.Booklet -> {
|
|
- val name = "booklet_${project?.name}_${System.currentTimeMillis()}.pdf"
|
|
|
|
|
|
+ val name = "booklet_${viewModel.project?.name}_${System.currentTimeMillis()}.pdf"
|
|
if (!Config.PDF_FOLDER.exists()) {
|
|
if (!Config.PDF_FOLDER.exists()) {
|
|
Config.PDF_FOLDER.mkdirs()
|
|
Config.PDF_FOLDER.mkdirs()
|
|
}
|
|
}
|
|
val file = File(Config.PDF_FOLDER, name)
|
|
val file = File(Config.PDF_FOLDER, name)
|
|
file.createNewFile()
|
|
file.createNewFile()
|
|
- val observable = PdfMaker.makeBooklet(this@MovieEditActivity, project!!, file)
|
|
|
|
|
|
+ val observable = PdfMaker.makeBooklet(this@MovieEditActivity, viewModel.project!!, file)
|
|
Pair(file, observable)
|
|
Pair(file, observable)
|
|
}
|
|
}
|
|
}.apply {
|
|
}.apply {
|
|
@@ -369,7 +377,7 @@ class MovieEditActivity : AppCompatActivity(),
|
|
val scaleHeight = resources.getDimensionPixelSize(R.dimen.movie_height)
|
|
val scaleHeight = resources.getDimensionPixelSize(R.dimen.movie_height)
|
|
|
|
|
|
val pd = ProgressDialog(this).apply {
|
|
val pd = ProgressDialog(this).apply {
|
|
- val t = scene?.record?.period ?: 0
|
|
|
|
|
|
+ val t = viewModel.storyPeriodLiveData.value ?: 0
|
|
max = (t / 33).toInt()
|
|
max = (t / 33).toInt()
|
|
setMessage("progressing")
|
|
setMessage("progressing")
|
|
setCancelable(false)
|
|
setCancelable(false)
|
|
@@ -377,13 +385,13 @@ class MovieEditActivity : AppCompatActivity(),
|
|
|
|
|
|
val fileName = "test${System.currentTimeMillis()}.mp4"
|
|
val fileName = "test${System.currentTimeMillis()}.mp4"
|
|
val outputFile = File(Environment.getExternalStorageDirectory(), fileName)
|
|
val outputFile = File(Environment.getExternalStorageDirectory(), fileName)
|
|
- val project = project ?: return
|
|
|
|
|
|
+ val project = viewModel.project ?: return
|
|
|
|
|
|
SuperMovieMaker().make(
|
|
SuperMovieMaker().make(
|
|
this,
|
|
this,
|
|
outputFile,
|
|
outputFile,
|
|
project,
|
|
project,
|
|
- musics,
|
|
|
|
|
|
+ viewModel.musicListLiveData.value?:ArrayList(),
|
|
scaledWidth,
|
|
scaledWidth,
|
|
scaleHeight,
|
|
scaleHeight,
|
|
mediaHelper)
|
|
mediaHelper)
|
|
@@ -465,5 +473,4 @@ class MovieEditActivity : AppCompatActivity(),
|
|
}
|
|
}
|
|
}.show()
|
|
}.show()
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|