From fdaae4ef581687bf5071e3cbf9a714bf10606f27 Mon Sep 17 00:00:00 2001 From: AndroidDeveloperLB Date: Mon, 11 Feb 2019 15:33:36 +0200 Subject: [PATCH] fixed layout params issues. --- app/src/main/res/layout/video_trimmer.xml | 27 ++++++------ .../BaseVideoTrimmerView.kt | 43 ++++++++++++------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/app/src/main/res/layout/video_trimmer.xml b/app/src/main/res/layout/video_trimmer.xml index b95d51c..a64a1eb 100644 --- a/app/src/main/res/layout/video_trimmer.xml +++ b/app/src/main/res/layout/video_trimmer.xml @@ -26,23 +26,26 @@ app:layout_constraintBottom_toTopOf="@id/timeTextContainer" app:layout_constraintEnd_toEndOf="parent" app:srcCompat="@android:drawable/ic_menu_crop" tools:ignore="RtlCompat"/> - + - - + + + + + if (videoTrimmingListener != null) @@ -154,7 +158,7 @@ abstract class BaseVideoTrimmerView @JvmOverloads constructor(context: Context, private fun setUpMargins() { val marge = rangeSeekBarView.thumbWidth val lp: MarginLayoutParams = timeLineView.layoutParams as MarginLayoutParams - lp.setMargins(marge, 0, marge, 0) + lp.setMargins(marge, lp.topMargin, marge, lp.bottomMargin) timeLineView.layoutParams = lp } @@ -164,7 +168,8 @@ abstract class BaseVideoTrimmerView @JvmOverloads constructor(context: Context, pauseVideo() val mediaMetadataRetriever = MediaMetadataRetriever() mediaMetadataRetriever.setDataSource(context, src) - val metadataKeyDuration = java.lang.Long.parseLong(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)) + val metadataKeyDuration = + java.lang.Long.parseLong(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)) if (timeVideo < MIN_TIME_FRAME) { if (metadataKeyDuration - endPosition > MIN_TIME_FRAME - timeVideo) { endPosition += MIN_TIME_FRAME - timeVideo @@ -176,15 +181,23 @@ abstract class BaseVideoTrimmerView @JvmOverloads constructor(context: Context, if (videoTrimmingListener != null) videoTrimmingListener!!.onTrimStarted() BackgroundExecutor.execute( - object : BackgroundExecutor.Task(null, 0L, null) { - override fun execute() { - try { - TrimVideoUtils.startTrim(context, src!!, dstFile!!, startPosition.toLong(), endPosition.toLong(), duration.toLong(), videoTrimmingListener!!) - } catch (e: Throwable) { - Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e) - } + object : BackgroundExecutor.Task(null, 0L, null) { + override fun execute() { + try { + TrimVideoUtils.startTrim( + context, + src!!, + dstFile!!, + startPosition.toLong(), + endPosition.toLong(), + duration.toLong(), + videoTrimmingListener!! + ) + } catch (e: Throwable) { + Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e) } } + } ) }