@@ -39,17 +39,17 @@ import com.lb.video_trimmer_library.utils.BackgroundExecutor
3939import com.lb.video_trimmer_library.utils.UiThreadExecutor
4040
4141open class TimeLineView @JvmOverloads constructor(context : Context , attrs : AttributeSet ? , defStyleAttr : Int = 0 ) : View(context, attrs, defStyleAttr) {
42- private var mVideoUri : Uri ? = null
42+ private var videoUri : Uri ? = null
4343 @Suppress(" LeakingThis" )
44- private var mHeightView : Int = initHeightView()
45- private var mBitmapList : LongSparseArray <Bitmap >? = null
44+ private var heightView : Int = initHeightView()
45+ private var bitmapList : LongSparseArray <Bitmap >? = null
4646
4747 open fun initHeightView (): Int = TypedValue .applyDimension(TypedValue .COMPLEX_UNIT_DIP , 40f , context.resources.displayMetrics).toInt().coerceAtLeast(1 )
4848
4949 override fun onMeasure (widthMeasureSpec : Int , heightMeasureSpec : Int ) {
5050 val minW = paddingLeft + paddingRight + suggestedMinimumWidth
5151 val w = View .resolveSizeAndState(minW, widthMeasureSpec, 1 )
52- val minH = paddingBottom + paddingTop + mHeightView
52+ val minH = paddingBottom + paddingTop + heightView
5353 val h = View .resolveSizeAndState(minH, heightMeasureSpec, 1 )
5454 setMeasuredDimension(w, h)
5555 }
@@ -66,11 +66,11 @@ open class TimeLineView @JvmOverloads constructor(context: Context, attrs: Attri
6666 try {
6767 val thumbnailList = LongSparseArray <Bitmap >()
6868 val mediaMetadataRetriever = MediaMetadataRetriever ()
69- mediaMetadataRetriever.setDataSource(context, mVideoUri )
69+ mediaMetadataRetriever.setDataSource(context, videoUri )
7070 // Retrieve media data
7171 val videoLengthInMs = (Integer .parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever .METADATA_KEY_DURATION )) * 1000 ).toLong()
7272 // Set thumbnail properties (Thumbs are squares)
73- val thumbSize = mHeightView
73+ val thumbSize = heightView
7474 val numThumbs = Math .ceil((viewWidth.toFloat() / thumbSize).toDouble()).toInt()
7575 val interval = videoLengthInMs / numThumbs
7676 for (i in 0 until numThumbs) {
@@ -96,18 +96,18 @@ open class TimeLineView @JvmOverloads constructor(context: Context, attrs: Attri
9696
9797 private fun returnBitmaps (thumbnailList : LongSparseArray <Bitmap >) {
9898 UiThreadExecutor .runTask(" " , Runnable {
99- mBitmapList = thumbnailList
99+ bitmapList = thumbnailList
100100 invalidate()
101101 }, 0L )
102102 }
103103
104104 override fun onDraw (canvas : Canvas ) {
105105 super .onDraw(canvas)
106- if (mBitmapList != null ) {
106+ if (bitmapList != null ) {
107107 canvas.save()
108108 var x = 0
109- for (i in 0 until mBitmapList !! .size()) {
110- val bitmap = mBitmapList !! .get(i.toLong())
109+ for (i in 0 until bitmapList !! .size()) {
110+ val bitmap = bitmapList !! .get(i.toLong())
111111 if (bitmap != null ) {
112112 canvas.drawBitmap(bitmap, x.toFloat(), 0f , null )
113113 x + = bitmap.width
@@ -117,6 +117,6 @@ open class TimeLineView @JvmOverloads constructor(context: Context, attrs: Attri
117117 }
118118
119119 fun setVideo (data : Uri ) {
120- mVideoUri = data
120+ videoUri = data
121121 }
122122}
0 commit comments