[add] 车模扫描动画添加 差进度条动画
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.mogo.module.check.view;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
@@ -7,8 +9,10 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.AnimationSet;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
@@ -24,6 +28,7 @@ import com.mogo.module.check.net.CheckApiServices;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.MogoModulePaths;
|
||||
import com.mogo.module.common.constants.HostConst;
|
||||
import com.mogo.module.common.view.ImageViewClipBounds;
|
||||
import com.mogo.module.common.view.SpacesItemDecoration;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.utils.CommonUtils;
|
||||
@@ -48,13 +53,18 @@ public class CheckActivity extends AppCompatActivity {
|
||||
private static String mSignalStrength;
|
||||
private ImageView mImageView;
|
||||
private String packageName = "com.mogo.launcher.f";
|
||||
//扫描图片
|
||||
private ImageView scanLipImageView;
|
||||
//车辆模型顶部动画图片
|
||||
private ImageView scanTopImageView;
|
||||
//车模
|
||||
private ImageView scanBottomCarImage;
|
||||
//扫描束
|
||||
private ImageView scanLineImage;
|
||||
//车辆模型顶部色值加深车模
|
||||
private ImageViewClipBounds scanTopImageView;
|
||||
//车模顶部小部件图片
|
||||
private ImageViewClipBounds tipsImageView;
|
||||
//动画组
|
||||
private AnimatorSet mAnimatorSet;
|
||||
private AnimatorSet setAnimation = null;
|
||||
private ValueAnimator mValueAnimator;
|
||||
private float movement = 1300f;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -67,10 +77,12 @@ public class CheckActivity extends AppCompatActivity {
|
||||
* 列表View初始化
|
||||
*/
|
||||
public void initView() {
|
||||
mAnimatorSet = new AnimatorSet();
|
||||
setAnimation = new AnimatorSet();
|
||||
mImageView = findViewById(R.id.btnBack);
|
||||
scanLipImageView = findViewById(R.id.scan_lip_image);
|
||||
scanBottomCarImage = findViewById(R.id.scan_car_image);
|
||||
scanLineImage = findViewById(R.id.scan_line_image);
|
||||
scanTopImageView = findViewById(R.id.scan_car_top_image);
|
||||
tipsImageView = findViewById(R.id.scan_car_tips);
|
||||
context = mImageView.getContext();
|
||||
packageName = getPackageName(context);
|
||||
mImageView.setOnClickListener(v -> {
|
||||
@@ -140,18 +152,70 @@ public class CheckActivity extends AppCompatActivity {
|
||||
* **************************************************************************************检测动画
|
||||
*/
|
||||
public void animation() {
|
||||
ObjectAnimator animatorForLip = ObjectAnimator.ofFloat(scanLipImageView, "translationX", 1162f);
|
||||
mValueAnimator = ValueAnimator.ofInt(1162);
|
||||
ObjectAnimator animatorX = ObjectAnimator.ofFloat(scanLineImage, "translationX", scanBottomCarImage.getWidth(), 0);
|
||||
ObjectAnimator animatorAl = ObjectAnimator.ofFloat(scanLineImage, "alpha", 0, 1);
|
||||
setAnimation.playTogether(animatorX, animatorAl);
|
||||
setAnimation.setDuration(800);
|
||||
setAnimation.start();
|
||||
setAnimation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
super.onAnimationEnd(animation);
|
||||
if (scanTopImageView != null) {
|
||||
movement = (float) scanTopImageView.getWidth();
|
||||
scanLineImage.setVisibility(View.VISIBLE);
|
||||
scanTopImageView.setVisibility(View.VISIBLE);
|
||||
tipsImageView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (scanLineImage != null) {
|
||||
scanLineImage
|
||||
.animate()
|
||||
.translationX(movement)
|
||||
.setDuration(5000)
|
||||
.setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
animatorScanCarBorder(true, scanTopImageView.getWidth());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫描动画:实现扫描束位移+顶部深色车模及检测元件的显示
|
||||
*/
|
||||
public void animatorScanCarBorder(boolean show, int weight) {
|
||||
if (show) {
|
||||
mValueAnimator = ValueAnimator.ofInt(0, weight);
|
||||
} else {
|
||||
}
|
||||
mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
scanTopImageView.getLayoutParams().width = (int) animation.getAnimatedValue();
|
||||
scanTopImageView.requestLayout();
|
||||
Rect rect = new Rect(0, 0, (int) mValueAnimator.getAnimatedValue(), scanTopImageView.getHeight());
|
||||
scanTopImageView.setClip(rect);
|
||||
tipsImageView.setClip(rect);
|
||||
}
|
||||
});
|
||||
mAnimatorSet.playTogether(animatorForLip, mValueAnimator);
|
||||
mAnimatorSet.setDuration(5000);
|
||||
mAnimatorSet.start();
|
||||
mValueAnimator.setDuration(5000);
|
||||
mValueAnimator.start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 183 KiB |
@@ -42,33 +42,27 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
<com.mogo.module.common.view.ImageViewClipBounds
|
||||
android:id="@+id/scan_car_top_image"
|
||||
android:layout_width="@dimen/check_scan_width"
|
||||
android:layout_height="@dimen/check_scan_height"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/scan_car_image"
|
||||
app:layout_constraintEnd_toEndOf="@+id/scan_car_image"
|
||||
app:layout_constraintStart_toStartOf="@+id/scan_car_image"
|
||||
app:layout_constraintTop_toTopOf="@+id/scan_car_image">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/scan_car_top_image"
|
||||
android:layout_width="@dimen/dp_150"
|
||||
android:layout_height="@dimen/check_scan_height"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/test_image" />
|
||||
</LinearLayout>
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/check_scan_second"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintLeft_toLeftOf="@id/scan_car_image"
|
||||
app:layout_constraintTop_toTopOf="@id/scan_car_image" />
|
||||
|
||||
|
||||
<ImageView
|
||||
<com.mogo.module.common.view.ImageViewClipBounds
|
||||
android:id="@+id/scan_car_tips"
|
||||
android:layout_width="1px"
|
||||
android:layout_width="@dimen/check_scan_width"
|
||||
android:layout_height="@dimen/check_scan_height"
|
||||
android:layout_marginLeft="@dimen/dp_699"
|
||||
android:layout_marginTop="@dimen/dp_400"
|
||||
android:layout_marginRight="@dimen/dp_699"
|
||||
android:scaleType="fitEnd"
|
||||
android:src="@drawable/check_scan_tips"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
@@ -96,7 +90,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/check_progress_text" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/scan_lip_image"
|
||||
android:id="@+id/scan_line_image"
|
||||
android:layout_width="@dimen/dp_25"
|
||||
android:layout_height="@dimen/dp_652"
|
||||
android:layout_marginTop="@dimen/dp_370"
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.mogo.module.common.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 2019-08-22
|
||||
*/
|
||||
public class ImageViewClipBounds extends AppCompatImageView {
|
||||
Rect mClipBounds = null;
|
||||
|
||||
public ImageViewClipBounds(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public ImageViewClipBounds(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public ImageViewClipBounds(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (mClipBounds != null) {
|
||||
// clip bounds ignore scroll
|
||||
canvas.clipRect(mClipBounds);
|
||||
}
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
|
||||
public void setClip(Rect clipBounds) {
|
||||
if (clipBounds == mClipBounds || (clipBounds != null && clipBounds.equals(mClipBounds))) {
|
||||
return;
|
||||
}
|
||||
if (clipBounds != null) {
|
||||
if (mClipBounds == null) {
|
||||
mClipBounds = new Rect(clipBounds);
|
||||
} else {
|
||||
mClipBounds.set(clipBounds);
|
||||
}
|
||||
} else {
|
||||
mClipBounds = null;
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user