From a72f230e9b8e86b98771243ee32d568ced359c2b Mon Sep 17 00:00:00 2001 From: xufuji456 <839789740@qq.com> Date: Sat, 30 Jan 2021 14:41:28 +0800 Subject: [PATCH] change listener to kotlin --- .../frank/ffmpeg/activity/FilterActivity.kt | 22 ++++++++++--------- .../com/frank/ffmpeg/format/VideoLayout.java | 15 ------------- .../com/frank/ffmpeg/format/VideoLayout.kt | 15 +++++++++++++ .../frank/ffmpeg/handler/FFmpegHandler.java | 5 +++++ .../ffmpeg/listener/OnHandleListener.java | 11 ---------- .../frank/ffmpeg/listener/OnHandleListener.kt | 11 ++++++++++ .../ffmpeg/listener/OnItemClickListener.java | 11 ---------- .../ffmpeg/listener/OnItemClickListener.kt | 11 ++++++++++ 8 files changed, 54 insertions(+), 47 deletions(-) delete mode 100644 app/src/main/java/com/frank/ffmpeg/format/VideoLayout.java create mode 100644 app/src/main/java/com/frank/ffmpeg/format/VideoLayout.kt delete mode 100644 app/src/main/java/com/frank/ffmpeg/listener/OnHandleListener.java create mode 100644 app/src/main/java/com/frank/ffmpeg/listener/OnHandleListener.kt delete mode 100644 app/src/main/java/com/frank/ffmpeg/listener/OnItemClickListener.java create mode 100644 app/src/main/java/com/frank/ffmpeg/listener/OnItemClickListener.kt diff --git a/app/src/main/java/com/frank/ffmpeg/activity/FilterActivity.kt b/app/src/main/java/com/frank/ffmpeg/activity/FilterActivity.kt index 415e1d8..d42c24a 100644 --- a/app/src/main/java/com/frank/ffmpeg/activity/FilterActivity.kt +++ b/app/src/main/java/com/frank/ffmpeg/activity/FilterActivity.kt @@ -106,14 +106,16 @@ class FilterActivity : BaseActivity(), SurfaceHolder.Callback { } private fun registerLister() { - horizontalAdapter!!.setOnItemClickListener(OnItemClickListener { position -> - if (!surfaceCreated) - return@OnItemClickListener - if (!FileUtil.checkFileExist(videoPath)) { - showSelectFile() - return@OnItemClickListener + horizontalAdapter!!.setOnItemClickListener(object : OnItemClickListener { + override fun onItemClick(position: Int) { + if (!surfaceCreated) + return + if (!FileUtil.checkFileExist(videoPath)) { + showSelectFile() + return + } + doFilterPlay(position) } - doFilterPlay(position) }) surfaceView!!.setOnClickListener { @@ -167,7 +169,7 @@ class FilterActivity : BaseActivity(), SurfaceHolder.Callback { super.onDestroy() isPlaying = false //FIXME - // videoPlayer.release(); +// videoPlayer?.release() videoPlayer = null horizontalAdapter = null } @@ -187,8 +189,8 @@ class FilterActivity : BaseActivity(), SurfaceHolder.Callback { companion object { - private val MSG_HIDE = 222 - private val DELAY_TIME = 5000 + private const val MSG_HIDE = 222 + private const val DELAY_TIME = 5000 } } diff --git a/app/src/main/java/com/frank/ffmpeg/format/VideoLayout.java b/app/src/main/java/com/frank/ffmpeg/format/VideoLayout.java deleted file mode 100644 index a5c688b..0000000 --- a/app/src/main/java/com/frank/ffmpeg/format/VideoLayout.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.frank.ffmpeg.format; - -/** - * layout of video - * Created by frank on 2018/6/18. - */ - -public class VideoLayout { - - //horizontal join - public final static int LAYOUT_HORIZONTAL = 1; - //vertical join - public final static int LAYOUT_VERTICAL = 2; - -} diff --git a/app/src/main/java/com/frank/ffmpeg/format/VideoLayout.kt b/app/src/main/java/com/frank/ffmpeg/format/VideoLayout.kt new file mode 100644 index 0000000..916c26b --- /dev/null +++ b/app/src/main/java/com/frank/ffmpeg/format/VideoLayout.kt @@ -0,0 +1,15 @@ +package com.frank.ffmpeg.format + +/** + * layout of video + * Created by frank on 2018/6/18. + */ + +object VideoLayout { + + //horizontal join + const val LAYOUT_HORIZONTAL = 1 + //vertical join + const val LAYOUT_VERTICAL = 2 + +} diff --git a/app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java b/app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java index 7e4871a..f6f597a 100644 --- a/app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java +++ b/app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java @@ -130,6 +130,11 @@ public class FFmpegHandler { mHandler.obtainMessage(MSG_BEGIN).sendToTarget(); } + @Override + public void onProgress(int progress, int duration) { + + } + @Override public void onEnd(int resultCode, String resultMsg) { Log.i(TAG, "handle ffprobe onEnd result=" + resultMsg); diff --git a/app/src/main/java/com/frank/ffmpeg/listener/OnHandleListener.java b/app/src/main/java/com/frank/ffmpeg/listener/OnHandleListener.java deleted file mode 100644 index cc54ab5..0000000 --- a/app/src/main/java/com/frank/ffmpeg/listener/OnHandleListener.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.frank.ffmpeg.listener; - -/** - * listener of FFmpeg processing - * Created by frank on 2019/11/11. - */ -public interface OnHandleListener { - void onBegin(); - default void onProgress(int progress, int duration){} - void onEnd(int resultCode, String resultMsg); -} diff --git a/app/src/main/java/com/frank/ffmpeg/listener/OnHandleListener.kt b/app/src/main/java/com/frank/ffmpeg/listener/OnHandleListener.kt new file mode 100644 index 0000000..026be1b --- /dev/null +++ b/app/src/main/java/com/frank/ffmpeg/listener/OnHandleListener.kt @@ -0,0 +1,11 @@ +package com.frank.ffmpeg.listener + +/** + * listener of FFmpeg processing + * Created by frank on 2019/11/11. + */ +interface OnHandleListener { + fun onBegin() + fun onProgress(progress: Int, duration: Int) + fun onEnd(resultCode: Int, resultMsg: String) +} diff --git a/app/src/main/java/com/frank/ffmpeg/listener/OnItemClickListener.java b/app/src/main/java/com/frank/ffmpeg/listener/OnItemClickListener.java deleted file mode 100644 index d46444e..0000000 --- a/app/src/main/java/com/frank/ffmpeg/listener/OnItemClickListener.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.frank.ffmpeg.listener; - -/** - * listener of RecyclerView item clicking - * Created by frank on 2018/6/6. - */ - -public interface OnItemClickListener { - - void onItemClick(int position); -} diff --git a/app/src/main/java/com/frank/ffmpeg/listener/OnItemClickListener.kt b/app/src/main/java/com/frank/ffmpeg/listener/OnItemClickListener.kt new file mode 100644 index 0000000..c6b8553 --- /dev/null +++ b/app/src/main/java/com/frank/ffmpeg/listener/OnItemClickListener.kt @@ -0,0 +1,11 @@ +package com.frank.ffmpeg.listener + +/** + * listener of RecyclerView item clicking + * Created by frank on 2018/6/6. + */ + +interface OnItemClickListener { + + fun onItemClick(position: Int) +}