|
@@ -8,6 +8,7 @@ import android.graphics.Paint;
|
|
|
import android.graphics.drawable.ColorDrawable;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.util.AttributeSet;
|
|
|
+import android.view.Gravity;
|
|
|
import android.view.MotionEvent;
|
|
|
import android.view.TextureView;
|
|
|
import android.view.View;
|
|
@@ -15,8 +16,8 @@ import android.view.ViewConfiguration;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.FrameLayout;
|
|
|
|
|
|
-import com.cooleshow.base.utils.SizeUtils;
|
|
|
import com.cooleshow.musicmerge.R;
|
|
|
+import com.cooleshow.musicmerge.constants.MusicMergeConfig;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
import androidx.annotation.Nullable;
|
|
@@ -55,6 +56,8 @@ public class RangeSlider extends ViewGroup {
|
|
|
private boolean mComplete;
|
|
|
private long mStartTime;
|
|
|
|
|
|
+ float percent = 0.95f;
|
|
|
+
|
|
|
public RangeSlider(@NonNull Context context) {
|
|
|
this(context, null);
|
|
|
}
|
|
@@ -81,15 +84,18 @@ public class RangeSlider extends ViewGroup {
|
|
|
array.getInteger(R.styleable.RangeSlider_rightThumbIndex, mTickCount));
|
|
|
array.recycle();
|
|
|
videoPlayer = new VideoPlayer();
|
|
|
- View borderView =new View(getContext());
|
|
|
+ View borderView = new View(getContext());
|
|
|
borderView.setBackground(mIcon);
|
|
|
textureView = new TextureView(getContext());
|
|
|
textureView.setVisibility(VISIBLE);
|
|
|
videoPlayer.setTextureView(textureView);
|
|
|
- int i = SizeUtils.dp2px(4);
|
|
|
- FrameLayout.LayoutParams layoutParams =new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.MATCH_PARENT);
|
|
|
- layoutParams.setMargins(i,i,i,i);
|
|
|
- mThumb.addView(textureView,layoutParams);
|
|
|
+
|
|
|
+ int videoWith = (int) (mThumbWidth * percent);
|
|
|
+ int videoHeight = (int) (MusicMergeConfig.getHeightAtRatio16_9(mThumbWidth) * percent);
|
|
|
+
|
|
|
+ FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(videoWith, videoHeight);
|
|
|
+ layoutParams.gravity = Gravity.CENTER;
|
|
|
+ mThumb.addView(textureView, layoutParams);
|
|
|
mThumb.addView(borderView);
|
|
|
addView(mThumb);
|
|
|
setWillNotDraw(false);
|
|
@@ -129,7 +135,7 @@ public class RangeSlider extends ViewGroup {
|
|
|
if (!isEnabled()) {
|
|
|
return false;
|
|
|
}
|
|
|
- if (!mComplete){
|
|
|
+ if (!mComplete) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -149,12 +155,12 @@ public class RangeSlider extends ViewGroup {
|
|
|
if (mRangeChangeListener != null) {
|
|
|
mRangeChangeListener.onKeyDown(TYPE_LEFT);
|
|
|
}
|
|
|
- int moveX = (int) (x - (mThumb.getX()+ mThumb.getWidth()/2));
|
|
|
+ int moveX = (int) (x - (mThumb.getX() + mThumb.getWidth() / 2));
|
|
|
getParent().requestDisallowInterceptTouchEvent(true);
|
|
|
moveLeftThumbByPixel(moveX);
|
|
|
invalidate();
|
|
|
if (mRangeChangeListener != null) {
|
|
|
- mRangeChangeListener.onKeyMove(TYPE_LEFT, mThumb.getRangeIndex(),moveX);
|
|
|
+ mRangeChangeListener.onKeyMove(TYPE_LEFT, mThumb.getRangeIndex(), moveX);
|
|
|
}
|
|
|
}
|
|
|
mLastX = mOriginalX = x;
|