react-native-video-trim 1.0.24 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +22 -0
  2. package/android/src/main/AndroidManifest.xml +2 -0
  3. package/android/src/main/java/com/videotrim/VideoTrimModule.java +8 -1
  4. package/android/src/main/java/com/videotrim/interfaces/VideoTrimListener.java +4 -0
  5. package/android/src/main/java/com/videotrim/utils/VideoTrimmerUtil.java +21 -0
  6. package/android/src/main/java/com/videotrim/widgets/VideoTrimmerView.java +406 -295
  7. package/android/src/main/res/drawable/chevron_compact_left.xml +15 -0
  8. package/android/src/main/res/drawable/chevron_compact_right.xml +15 -0
  9. package/android/src/main/res/drawable/chevron_right_with_bg.xml +13 -0
  10. package/android/src/main/res/drawable/pause_fill.xml +15 -0
  11. package/android/src/main/res/drawable/play_fill.xml +15 -0
  12. package/android/src/main/res/drawable/rounded_progress_indicator.xml +16 -0
  13. package/android/src/main/res/drawable/rounded_yellow_left_background.xml +8 -0
  14. package/android/src/main/res/drawable/rounded_yellow_right_background.xml +8 -0
  15. package/android/src/main/res/drawable/yellow_border.xml +9 -0
  16. package/android/src/main/res/layout/video_trimmer_view.xml +148 -76
  17. package/android/src/main/res/values/colors.xml +15 -13
  18. package/ios/VideoTrim.swift +26 -2
  19. package/ios/VideoTrimmerViewController.swift +1 -1
  20. package/package.json +1 -1
  21. package/android/src/main/java/com/videotrim/adapters/VideoTrimmerAdapter.java +0 -54
  22. package/android/src/main/java/com/videotrim/widgets/RangeSeekBarView.java +0 -534
  23. package/android/src/main/java/com/videotrim/widgets/SpacesItemDecoration2.java +0 -33
  24. package/android/src/main/java/com/videotrim/widgets/ZVideoView.java +0 -48
  25. package/android/src/main/res/drawable/ic_video_pause_black.png +0 -0
  26. package/android/src/main/res/drawable/ic_video_play_black.png +0 -0
  27. package/android/src/main/res/drawable/ic_video_thumb_handle.png +0 -0
  28. package/android/src/main/res/drawable/icon_seek_bar.png +0 -0
  29. package/android/src/main/res/layout/video_thumb_item_layout.xml +0 -16
@@ -1,534 +0,0 @@
1
- package com.videotrim.widgets;
2
-
3
- import android.annotation.SuppressLint;
4
- import android.content.Context;
5
- import android.graphics.Bitmap;
6
- import android.graphics.BitmapFactory;
7
- import android.graphics.Canvas;
8
- import android.graphics.Matrix;
9
- import android.graphics.Paint;
10
- import android.graphics.Rect;
11
- import android.os.Bundle;
12
- import android.os.Parcelable;
13
- import android.util.AttributeSet;
14
- import android.view.MotionEvent;
15
- import android.view.View;
16
- import android.view.ViewConfiguration;
17
-
18
- import androidx.annotation.Nullable;
19
-
20
- import com.videotrim.R;
21
- import com.videotrim.utils.VideoTrimmerUtil;
22
-
23
- import java.text.DecimalFormat;
24
-
25
- import iknow.android.utils.DateUtil;
26
- import iknow.android.utils.UnitConverter;
27
-
28
- public class RangeSeekBarView extends View {
29
- private static final String TAG = RangeSeekBarView.class.getSimpleName();
30
- public static final int INVALID_POINTER_ID = 255;
31
- public static final int ACTION_POINTER_INDEX_MASK = 0x0000ff00, ACTION_POINTER_INDEX_SHIFT = 8;
32
- private static final int TextPositionY = UnitConverter.dpToPx(10);
33
- private static final int paddingTop = UnitConverter.dpToPx(10);
34
- private int mActivePointerId = INVALID_POINTER_ID;
35
-
36
- private long mMinShootTime = VideoTrimmerUtil.MIN_SHOOT_DURATION;
37
- private double absoluteMinValuePrim, absoluteMaxValuePrim;
38
- private double normalizedMinValue = 0d;//点坐标占总长度的比例值,范围从0-1
39
- private double normalizedMaxValue = 1d;//点坐标占总长度的比例值,范围从0-1
40
- private double normalizedMinValueTime = 0d;
41
- private double normalizedMaxValueTime = 1d;// normalized:规格化的--点坐标占总长度的比例值,范围从0-1
42
- private int mScaledTouchSlop;
43
- private Bitmap thumbImageLeft;
44
- private Bitmap thumbImageRight;
45
- private Bitmap thumbPressedImage;
46
- private Paint paint;
47
- private Paint rectPaint;
48
- private final Paint mVideoTrimTimePaintL = new Paint();
49
- private final Paint mVideoTrimTimePaintR = new Paint();
50
- private final Paint mShadow = new Paint();
51
- private int thumbWidth;
52
- private float thumbHalfWidth;
53
- private final float padding = 0;
54
- private long mStartPosition = 0;
55
- private long mEndPosition = 0;
56
- private float thumbPaddingTop = 0;
57
- private boolean isTouchDown;
58
- private float mDownMotionX;
59
- private boolean mIsDragging;
60
- private Thumb pressedThumb;
61
- private boolean isMin;
62
- private double min_width = 1;//最小裁剪距离
63
- private boolean notifyWhileDragging = false;
64
- private OnRangeSeekBarChangeListener mRangeSeekBarChangeListener;
65
- private int whiteColorRes = getContext().getResources().getColor(R.color.white);
66
-
67
- public enum Thumb {
68
- MIN, MAX
69
- }
70
-
71
- public RangeSeekBarView(Context context) {
72
- super(context);
73
- }
74
-
75
- public RangeSeekBarView(Context context, @Nullable AttributeSet attrs) {
76
- super(context, attrs);
77
- }
78
-
79
- public RangeSeekBarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
80
- super(context, attrs, defStyleAttr);
81
- }
82
-
83
- public RangeSeekBarView(Context context, long absoluteMinValuePrim, long absoluteMaxValuePrim) {
84
- super(context);
85
- this.absoluteMinValuePrim = absoluteMinValuePrim;
86
- this.absoluteMaxValuePrim = absoluteMaxValuePrim;
87
- setFocusable(true);
88
- setFocusableInTouchMode(true);
89
- init();
90
- }
91
-
92
- private void init() {
93
- mScaledTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
94
- thumbImageLeft = BitmapFactory.decodeResource(getResources(), R.drawable.ic_video_thumb_handle);
95
-
96
- int width = thumbImageLeft.getWidth();
97
- int height = thumbImageLeft.getHeight();
98
- int newWidth = UnitConverter.dpToPx(11);
99
- int newHeight = UnitConverter.dpToPx(55);
100
- float scaleWidth = newWidth * 1.0f / width;
101
- float scaleHeight = newHeight * 1.0f / height;
102
- Matrix matrix = new Matrix();
103
- matrix.postScale(scaleWidth, scaleHeight);
104
- thumbImageLeft = Bitmap.createBitmap(thumbImageLeft, 0, 0, width, height, matrix, true);
105
- thumbImageRight = thumbImageLeft;
106
- thumbPressedImage = thumbImageLeft;
107
- thumbWidth = newWidth;
108
- thumbHalfWidth = thumbWidth / 2;
109
- int shadowColor = getContext().getResources().getColor(R.color.shadow_color);
110
- mShadow.setAntiAlias(true);
111
- mShadow.setColor(shadowColor);
112
-
113
- paint = new Paint(Paint.ANTI_ALIAS_FLAG);
114
- rectPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
115
- rectPaint.setStyle(Paint.Style.FILL);
116
- rectPaint.setColor(whiteColorRes);
117
-
118
- mVideoTrimTimePaintL.setStrokeWidth(3);
119
- mVideoTrimTimePaintL.setARGB(255, 51, 51, 51);
120
- mVideoTrimTimePaintL.setTextSize(28);
121
- mVideoTrimTimePaintL.setAntiAlias(true);
122
- mVideoTrimTimePaintL.setColor(whiteColorRes);
123
- mVideoTrimTimePaintL.setTextAlign(Paint.Align.LEFT);
124
-
125
- mVideoTrimTimePaintR.setStrokeWidth(3);
126
- mVideoTrimTimePaintR.setARGB(255, 51, 51, 51);
127
- mVideoTrimTimePaintR.setTextSize(28);
128
- mVideoTrimTimePaintR.setAntiAlias(true);
129
- mVideoTrimTimePaintR.setColor(whiteColorRes);
130
- mVideoTrimTimePaintR.setTextAlign(Paint.Align.RIGHT);
131
- }
132
-
133
- @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
134
- int width = 300;
135
- if (MeasureSpec.UNSPECIFIED != MeasureSpec.getMode(widthMeasureSpec)) {
136
- width = MeasureSpec.getSize(widthMeasureSpec);
137
- }
138
- int height = 120;
139
- if (MeasureSpec.UNSPECIFIED != MeasureSpec.getMode(heightMeasureSpec)) {
140
- height = MeasureSpec.getSize(heightMeasureSpec);
141
- }
142
- setMeasuredDimension(width, height);
143
- }
144
-
145
- @SuppressLint("DrawAllocation") @Override protected void onDraw(Canvas canvas) {
146
- super.onDraw(canvas);
147
- float bg_middle_left = 0;
148
- float bg_middle_right = getWidth() - getPaddingRight();
149
- float rangeL = normalizedToScreen(normalizedMinValue);
150
- float rangeR = normalizedToScreen(normalizedMaxValue);
151
- Rect leftRect = new Rect((int) bg_middle_left, getHeight(), (int) rangeL, 0);
152
- Rect rightRect = new Rect((int) rangeR, getHeight(), (int) bg_middle_right, 0);
153
- canvas.drawRect(leftRect, mShadow);
154
- canvas.drawRect(rightRect, mShadow);
155
-
156
- canvas.drawRect(rangeL, thumbPaddingTop + paddingTop, rangeR, thumbPaddingTop + UnitConverter.dpToPx(2) + paddingTop, rectPaint);
157
- canvas.drawRect(rangeL, getHeight() - UnitConverter.dpToPx(2), rangeR, getHeight(), rectPaint);
158
-
159
- drawThumb(normalizedToScreen(normalizedMinValue), false, canvas, true);
160
- drawThumb(normalizedToScreen(normalizedMaxValue), false, canvas, false);
161
- drawVideoTrimTimeText(canvas);
162
- }
163
-
164
- private void drawThumb(float screenCoord, boolean pressed, Canvas canvas, boolean isLeft) {
165
- canvas.drawBitmap(pressed ? thumbPressedImage : (isLeft ? thumbImageLeft : thumbImageRight), screenCoord - (isLeft ? 0 : thumbWidth), paddingTop,
166
- paint);
167
- }
168
-
169
- private void drawVideoTrimTimeText(Canvas canvas) {
170
- String leftThumbsTime = DateUtil.convertSecondsToTime(mStartPosition);
171
- String rightThumbsTime = DateUtil.convertSecondsToTime(mEndPosition);
172
- canvas.drawText(leftThumbsTime, normalizedToScreen(normalizedMinValue), TextPositionY, mVideoTrimTimePaintL);
173
- canvas.drawText(rightThumbsTime, normalizedToScreen(normalizedMaxValue), TextPositionY, mVideoTrimTimePaintR);
174
- }
175
-
176
- @Override public boolean onTouchEvent(MotionEvent event) {
177
- if (isTouchDown) {
178
- return super.onTouchEvent(event);
179
- }
180
- if (event.getPointerCount() > 1) {
181
- return super.onTouchEvent(event);
182
- }
183
-
184
- if (!isEnabled()) return false;
185
- if (absoluteMaxValuePrim <= mMinShootTime) {
186
- return super.onTouchEvent(event);
187
- }
188
- int pointerIndex;// 记录点击点的index
189
- final int action = event.getAction();
190
- switch (action & MotionEvent.ACTION_MASK) {
191
- case MotionEvent.ACTION_DOWN:
192
- //记住最后一个手指点击屏幕的点的坐标x,mDownMotionX
193
- mActivePointerId = event.getPointerId(event.getPointerCount() - 1);
194
- pointerIndex = event.findPointerIndex(mActivePointerId);
195
- mDownMotionX = event.getX(pointerIndex);
196
- // 判断touch到的是最大值thumb还是最小值thumb
197
- pressedThumb = evalPressedThumb(mDownMotionX);
198
- if (pressedThumb == null) return super.onTouchEvent(event);
199
- setPressed(true);// 设置该控件被按下了
200
- onStartTrackingTouch();// 置mIsDragging为true,开始追踪touch事件
201
- trackTouchEvent(event);
202
- attemptClaimDrag();
203
- if (mRangeSeekBarChangeListener != null) {
204
- mRangeSeekBarChangeListener.onRangeSeekBarValuesChanged(this, getSelectedMinValue(), getSelectedMaxValue(), MotionEvent.ACTION_DOWN, isMin,
205
- pressedThumb);
206
- }
207
- break;
208
- case MotionEvent.ACTION_MOVE:
209
- if (pressedThumb != null) {
210
- if (mIsDragging) {
211
- trackTouchEvent(event);
212
- } else {
213
- // Scroll to follow the motion event
214
- pointerIndex = event.findPointerIndex(mActivePointerId);
215
- final float x = event.getX(pointerIndex);// 手指在控件上点的X坐标
216
- // 手指没有点在最大最小值上,并且在控件上有滑动事件
217
- if (Math.abs(x - mDownMotionX) > mScaledTouchSlop) {
218
- setPressed(true);
219
- invalidate();
220
- onStartTrackingTouch();
221
- trackTouchEvent(event);
222
- attemptClaimDrag();
223
- }
224
- }
225
- if (notifyWhileDragging && mRangeSeekBarChangeListener != null) {
226
- mRangeSeekBarChangeListener.onRangeSeekBarValuesChanged(this, getSelectedMinValue(), getSelectedMaxValue(), MotionEvent.ACTION_MOVE,
227
- isMin, pressedThumb);
228
- }
229
- }
230
- break;
231
- case MotionEvent.ACTION_UP:
232
- if (mIsDragging) {
233
- trackTouchEvent(event);
234
- onStopTrackingTouch();
235
- setPressed(false);
236
- } else {
237
- onStartTrackingTouch();
238
- trackTouchEvent(event);
239
- onStopTrackingTouch();
240
- }
241
-
242
- invalidate();
243
- if (mRangeSeekBarChangeListener != null) {
244
- mRangeSeekBarChangeListener.onRangeSeekBarValuesChanged(this, getSelectedMinValue(), getSelectedMaxValue(), MotionEvent.ACTION_UP, isMin,
245
- pressedThumb);
246
- }
247
- pressedThumb = null;// 手指抬起,则置被touch到的thumb为空
248
- break;
249
- case MotionEvent.ACTION_POINTER_DOWN:
250
- final int index = event.getPointerCount() - 1;
251
- // final int index = ev.getActionIndex();
252
- mDownMotionX = event.getX(index);
253
- mActivePointerId = event.getPointerId(index);
254
- invalidate();
255
- break;
256
- case MotionEvent.ACTION_POINTER_UP:
257
- onSecondaryPointerUp(event);
258
- invalidate();
259
- break;
260
- case MotionEvent.ACTION_CANCEL:
261
- if (mIsDragging) {
262
- onStopTrackingTouch();
263
- setPressed(false);
264
- }
265
- invalidate(); // see above explanation
266
- break;
267
- default:
268
- break;
269
- }
270
- return true;
271
- }
272
-
273
- private void onSecondaryPointerUp(MotionEvent ev) {
274
- final int pointerIndex = (ev.getAction() & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT;
275
- final int pointerId = ev.getPointerId(pointerIndex);
276
- if (pointerId == mActivePointerId) {
277
- final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
278
- mDownMotionX = ev.getX(newPointerIndex);
279
- mActivePointerId = ev.getPointerId(newPointerIndex);
280
- }
281
- }
282
-
283
- private void trackTouchEvent(MotionEvent event) {
284
- if (event.getPointerCount() > 1) return;
285
- final int pointerIndex = event.findPointerIndex(mActivePointerId);// 得到按下点的index
286
- float x = 0;
287
- try {
288
- x = event.getX(pointerIndex);
289
- } catch (Exception e) {
290
- return;
291
- }
292
- if (Thumb.MIN.equals(pressedThumb)) {
293
- // screenToNormalized(x)-->得到规格化的0-1的值
294
- setNormalizedMinValue(screenToNormalized(x, 0));
295
- } else if (Thumb.MAX.equals(pressedThumb)) {
296
- setNormalizedMaxValue(screenToNormalized(x, 1));
297
- }
298
- }
299
-
300
- private double screenToNormalized(float screenCoord, int position) {
301
- int width = getWidth();
302
- if (width <= 2 * padding) {
303
- // prevent division by zero, simply return 0.
304
- return 0d;
305
- } else {
306
- isMin = false;
307
- double current_width = screenCoord;
308
- float rangeL = normalizedToScreen(normalizedMinValue);
309
- float rangeR = normalizedToScreen(normalizedMaxValue);
310
- double min = mMinShootTime / (absoluteMaxValuePrim - absoluteMinValuePrim) * (width - thumbWidth * 2);
311
-
312
- if (absoluteMaxValuePrim > 5 * 60 * 1000) {//大于5分钟的精确小数四位
313
- DecimalFormat df = new DecimalFormat("0.0000");
314
- min_width = Double.parseDouble(df.format(min));
315
- } else {
316
- min_width = Math.round(min + 0.5d);
317
- }
318
- if (position == 0) {
319
- if (isInThumbRangeLeft(screenCoord, normalizedMinValue, 0.5)) {
320
- return normalizedMinValue;
321
- }
322
-
323
- float rightPosition = (getWidth() - rangeR) >= 0 ? (getWidth() - rangeR) : 0;
324
- double left_length = getValueLength() - (rightPosition + min_width);
325
-
326
- if (current_width > rangeL) {
327
- current_width = rangeL + (current_width - rangeL);
328
- } else if (current_width <= rangeL) {
329
- current_width = rangeL - (rangeL - current_width);
330
- }
331
-
332
- if (current_width > left_length) {
333
- isMin = true;
334
- current_width = left_length;
335
- }
336
-
337
- if (current_width < thumbWidth * 2 / 3) {
338
- current_width = 0;
339
- }
340
-
341
- double resultTime = (current_width - padding) / (width - 2 * thumbWidth);
342
- normalizedMinValueTime = Math.min(1d, Math.max(0d, resultTime));
343
- double result = (current_width - padding) / (width - 2 * padding);
344
- return Math.min(1d, Math.max(0d, result));// 保证该该值为0-1之间,但是什么时候这个判断有用呢?
345
- } else {
346
- if (isInThumbRange(screenCoord, normalizedMaxValue, 0.5)) {
347
- return normalizedMaxValue;
348
- }
349
-
350
- double right_length = getValueLength() - (rangeL + min_width);
351
- if (current_width > rangeR) {
352
- current_width = rangeR + (current_width - rangeR);
353
- } else if (current_width <= rangeR) {
354
- current_width = rangeR - (rangeR - current_width);
355
- }
356
-
357
- double paddingRight = getWidth() - current_width;
358
-
359
- if (paddingRight > right_length) {
360
- isMin = true;
361
- current_width = getWidth() - right_length;
362
- paddingRight = right_length;
363
- }
364
-
365
- if (paddingRight < thumbWidth * 2 / 3) {
366
- current_width = getWidth();
367
- paddingRight = 0;
368
- }
369
-
370
- double resultTime = (paddingRight - padding) / (width - 2 * thumbWidth);
371
- resultTime = 1 - resultTime;
372
- normalizedMaxValueTime = Math.min(1d, Math.max(0d, resultTime));
373
- double result = (current_width - padding) / (width - 2 * padding);
374
- return Math.min(1d, Math.max(0d, result));// 保证该该值为0-1之间,但是什么时候这个判断有用呢?
375
- }
376
- }
377
- }
378
-
379
- private int getValueLength() {
380
- return (getWidth() - 2 * thumbWidth);
381
- }
382
-
383
- /**
384
- * 计算位于哪个Thumb内
385
- *
386
- * @param touchX touchX
387
- * @return 被touch的是空还是最大值或最小值
388
- */
389
- private Thumb evalPressedThumb(float touchX) {
390
- Thumb result = null;
391
- boolean minThumbPressed = isInThumbRange(touchX, normalizedMinValue, 2);// 触摸点是否在最小值图片范围内
392
- boolean maxThumbPressed = isInThumbRange(touchX, normalizedMaxValue, 2);
393
- if (minThumbPressed && maxThumbPressed) {
394
- // 如果两个thumbs重叠在一起,无法判断拖动哪个,做以下处理
395
- // 触摸点在屏幕右侧,则判断为touch到了最小值thumb,反之判断为touch到了最大值thumb
396
- result = (touchX / getWidth() > 0.5f) ? Thumb.MIN : Thumb.MAX;
397
- } else if (minThumbPressed) {
398
- result = Thumb.MIN;
399
- } else if (maxThumbPressed) {
400
- result = Thumb.MAX;
401
- }
402
- return result;
403
- }
404
-
405
- private boolean isInThumbRange(float touchX, double normalizedThumbValue, double scale) {
406
- // 当前触摸点X坐标-最小值图片中心点在屏幕的X坐标之差<=最小点图片的宽度的一般
407
- // 即判断触摸点是否在以最小值图片中心为原点,宽度一半为半径的圆内。
408
- return Math.abs(touchX - normalizedToScreen(normalizedThumbValue)) <= thumbHalfWidth * scale;
409
- }
410
-
411
- private boolean isInThumbRangeLeft(float touchX, double normalizedThumbValue, double scale) {
412
- // 当前触摸点X坐标-最小值图片中心点在屏幕的X坐标之差<=最小点图片的宽度的一般
413
- // 即判断触摸点是否在以最小值图片中心为原点,宽度一半为半径的圆内。
414
- return Math.abs(touchX - normalizedToScreen(normalizedThumbValue) - thumbWidth) <= thumbHalfWidth * scale;
415
- }
416
-
417
- /**
418
- * 试图告诉父view不要拦截子控件的drag
419
- */
420
- private void attemptClaimDrag() {
421
- if (getParent() != null) {
422
- getParent().requestDisallowInterceptTouchEvent(true);
423
- }
424
- }
425
-
426
- void onStartTrackingTouch() {
427
- mIsDragging = true;
428
- }
429
-
430
- void onStopTrackingTouch() {
431
- mIsDragging = false;
432
- }
433
-
434
- public void setMinShootTime(long min_cut_time) {
435
- this.mMinShootTime = min_cut_time;
436
- }
437
-
438
- private float normalizedToScreen(double normalizedCoord) {
439
- return (float) (getPaddingLeft() + normalizedCoord * (getWidth() - getPaddingLeft() - getPaddingRight()));
440
- }
441
-
442
- private double valueToNormalized(long value) {
443
- if (0 == absoluteMaxValuePrim - absoluteMinValuePrim) {
444
- return 0d;
445
- }
446
- return (value - absoluteMinValuePrim) / (absoluteMaxValuePrim - absoluteMinValuePrim);
447
- }
448
-
449
- public void setStartEndTime(long start, long end) {
450
- this.mStartPosition = start / 1000;
451
- this.mEndPosition = end / 1000;
452
- }
453
-
454
- public void setSelectedMinValue(long value) {
455
- if (0 == (absoluteMaxValuePrim - absoluteMinValuePrim)) {
456
- setNormalizedMinValue(0d);
457
- } else {
458
- setNormalizedMinValue(valueToNormalized(value));
459
- }
460
- }
461
-
462
- public void setSelectedMaxValue(long value) {
463
- if (0 == (absoluteMaxValuePrim - absoluteMinValuePrim)) {
464
- setNormalizedMaxValue(1d);
465
- } else {
466
- setNormalizedMaxValue(valueToNormalized(value));
467
- }
468
- }
469
-
470
- public void setNormalizedMinValue(double value) {
471
- normalizedMinValue = Math.max(0d, Math.min(1d, Math.min(value, normalizedMaxValue)));
472
- invalidate();// 重新绘制此view
473
- }
474
-
475
- public void setNormalizedMaxValue(double value) {
476
- normalizedMaxValue = Math.max(0d, Math.min(1d, Math.max(value, normalizedMinValue)));
477
- invalidate();// 重新绘制此view
478
- }
479
-
480
- public long getSelectedMinValue() {
481
- return normalizedToValue(normalizedMinValueTime);
482
- }
483
-
484
- public long getSelectedMaxValue() {
485
- return normalizedToValue(normalizedMaxValueTime);
486
- }
487
-
488
- private long normalizedToValue(double normalized) {
489
- return (long) (absoluteMinValuePrim + normalized * (absoluteMaxValuePrim - absoluteMinValuePrim));
490
- }
491
-
492
- /**
493
- * 供外部activity调用,控制是都在拖动的时候打印log信息,默认是false不打印
494
- */
495
- public boolean isNotifyWhileDragging() {
496
- return notifyWhileDragging;
497
- }
498
-
499
- public void setNotifyWhileDragging(boolean flag) {
500
- this.notifyWhileDragging = flag;
501
- }
502
-
503
- public void setTouchDown(boolean touchDown) {
504
- isTouchDown = touchDown;
505
- }
506
-
507
- @Override protected Parcelable onSaveInstanceState() {
508
- final Bundle bundle = new Bundle();
509
- bundle.putParcelable("SUPER", super.onSaveInstanceState());
510
- bundle.putDouble("MIN", normalizedMinValue);
511
- bundle.putDouble("MAX", normalizedMaxValue);
512
- bundle.putDouble("MIN_TIME", normalizedMinValueTime);
513
- bundle.putDouble("MAX_TIME", normalizedMaxValueTime);
514
- return bundle;
515
- }
516
-
517
- @Override protected void onRestoreInstanceState(Parcelable parcel) {
518
- final Bundle bundle = (Bundle) parcel;
519
- super.onRestoreInstanceState(bundle.getParcelable("SUPER"));
520
- normalizedMinValue = bundle.getDouble("MIN");
521
- normalizedMaxValue = bundle.getDouble("MAX");
522
- normalizedMinValueTime = bundle.getDouble("MIN_TIME");
523
- normalizedMaxValueTime = bundle.getDouble("MAX_TIME");
524
- }
525
-
526
- public interface OnRangeSeekBarChangeListener {
527
- void onRangeSeekBarValuesChanged(RangeSeekBarView bar, long minValue, long maxValue, int action, boolean isMin, Thumb pressedThumb);
528
- }
529
-
530
- public void setOnRangeSeekBarChangeListener(OnRangeSeekBarChangeListener listener) {
531
- this.mRangeSeekBarChangeListener = listener;
532
- }
533
- }
534
-
@@ -1,33 +0,0 @@
1
- package com.videotrim.widgets;
2
-
3
- import android.graphics.Rect;
4
- import android.view.View;
5
-
6
- import androidx.recyclerview.widget.RecyclerView;
7
-
8
- public class SpacesItemDecoration2 extends RecyclerView.ItemDecoration{
9
-
10
- private int space;
11
- private int thumbnailsCount;
12
-
13
- public SpacesItemDecoration2(int space, int thumbnailsCount) {
14
- this.space = space;
15
- this.thumbnailsCount = thumbnailsCount;
16
- }
17
-
18
- @Override
19
- public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
20
- int position = parent.getChildAdapterPosition(view);
21
- if (position == 0) {
22
- outRect.left = space;
23
- outRect.right = 0;
24
- } else if (thumbnailsCount > 10 && position == thumbnailsCount - 1) {
25
- outRect.left = 0;
26
- outRect.right = space;
27
- } else {
28
- outRect.left = 0;
29
- outRect.right = 0;
30
- }
31
- }
32
- }
33
-
@@ -1,48 +0,0 @@
1
- package com.videotrim.widgets;
2
-
3
- import android.content.Context;
4
- import android.media.MediaMetadataRetriever;
5
- import android.net.Uri;
6
- import android.util.AttributeSet;
7
- import android.widget.VideoView;
8
-
9
-
10
- public class ZVideoView extends VideoView {
11
- private int mVideoWidth = 480;
12
- private int mVideoHeight = 480;
13
- private int videoRealW = 1;
14
- private int videoRealH = 1;
15
-
16
- public ZVideoView(Context context) {
17
- super(context);
18
- }
19
-
20
- public ZVideoView(Context context, AttributeSet attrs) {
21
- super(context, attrs);
22
- }
23
-
24
- public ZVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
25
- super(context, attrs, defStyleAttr);
26
- }
27
-
28
- @Override
29
- public void setVideoURI(Uri uri) {
30
- super.setVideoURI(uri);
31
- MediaMetadataRetriever retr = new MediaMetadataRetriever();
32
- retr.setDataSource(uri.getPath());
33
- String height = retr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
34
- String width = retr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
35
- try {
36
- videoRealH = Integer.parseInt(height);
37
- videoRealW = Integer.parseInt(width);
38
- } catch (NumberFormatException e) {
39
- e.printStackTrace();
40
- }
41
- }
42
-
43
- @Override
44
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
45
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
46
- }
47
- }
48
-
@@ -1,16 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <LinearLayout
3
- xmlns:android="http://schemas.android.com/apk/res/android"
4
- xmlns:tools="http://schemas.android.com/tools"
5
- android:layout_width="wrap_content"
6
- android:layout_height="60dp"
7
- android:orientation="vertical"
8
- >
9
-
10
- <ImageView
11
- android:id="@+id/thumb"
12
- android:layout_width="39dp"
13
- android:layout_height="match_parent"
14
- android:scaleType="centerCrop"
15
- tools:src="@color/red"/>
16
- </LinearLayout>