1:优化礼物播放和下载方式
2:优化转盘展示效果
This commit is contained in:
@@ -9,7 +9,9 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.GridView;
|
||||
|
||||
@@ -133,7 +135,29 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
setupUIBasedOnUserType();
|
||||
|
||||
}
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 获取屏幕高度
|
||||
android.util.DisplayMetrics displayMetrics = new android.util.DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
// 设置高度为屏幕高度的100%(全屏)
|
||||
int heightInPx = (int) (screenHeight * 0.8);;
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
private void setupUIBasedOnUserType() {
|
||||
switch (userIdType) {
|
||||
case MIRROR_SKY://天空之境
|
||||
@@ -383,6 +407,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
||||
for (GiftCardView gridView : allViewsArray) {
|
||||
gridView.setSelected(false);
|
||||
gridView.stopPulseAnimationWithLayer();
|
||||
gridView.setVisibilitymResultTextView(false);
|
||||
}
|
||||
currentGiftCardView = allViewsArray.get(0);
|
||||
currentGiftCardView.setSelected(true);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.xscm.moduleutil.dialog.giftLottery;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
@@ -70,9 +71,8 @@ public class GiftLotteryDialogFragment extends BaseMvpDialogFragment<GiftLottery
|
||||
android.util.DisplayMetrics displayMetrics = new android.util.DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
|
||||
// 设置高度为屏幕高度的100%(全屏)
|
||||
int heightInPx = screenHeight;
|
||||
int heightInPx = (int) (screenHeight * 0.8);;
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
@@ -80,6 +80,12 @@ public class GiftLotteryDialogFragment extends BaseMvpDialogFragment<GiftLottery
|
||||
window.setWindowAnimations(R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
@@ -111,13 +117,14 @@ public class GiftLotteryDialogFragment extends BaseMvpDialogFragment<GiftLottery
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
page = 1;
|
||||
MvpPre.getMyRecord(giftBagId, page+"", "20",type);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
page++;
|
||||
MvpPre.getMyRecord(giftBagId, page+"", "20",type);
|
||||
}
|
||||
});
|
||||
@@ -170,6 +177,7 @@ public class GiftLotteryDialogFragment extends BaseMvpDialogFragment<GiftLottery
|
||||
setTextViewStyle(mBinding.textView2, true);
|
||||
setTextViewStyle(mBinding.textView1, false);
|
||||
}
|
||||
page=1;
|
||||
data.clear();
|
||||
MvpPre.getMyRecord(giftBagId, page+"", "20",type);
|
||||
}
|
||||
@@ -210,6 +218,10 @@ public class GiftLotteryDialogFragment extends BaseMvpDialogFragment<GiftLottery
|
||||
}else {
|
||||
adapter.addData(data);
|
||||
}
|
||||
}else {
|
||||
if (page == 1) {
|
||||
adapter.setNewData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,6 +233,10 @@ public class GiftLotteryDialogFragment extends BaseMvpDialogFragment<GiftLottery
|
||||
}else {
|
||||
adapter.addData(data);
|
||||
}
|
||||
}else {
|
||||
if (page == 1) {
|
||||
adapter.setNewData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -21,18 +22,36 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/8/28
|
||||
*@description: 盲盒转盘奖池弹窗
|
||||
* @author qx
|
||||
* @data 2025/8/28
|
||||
* @description: 盲盒转盘奖池弹窗
|
||||
*/
|
||||
public class PrizePoolDialog extends BaseDialog<DialogPrizePoolBinding> {
|
||||
private Context mContext;
|
||||
private List<GiftBean> gift_list;
|
||||
private int type ;
|
||||
private int type;
|
||||
|
||||
public PrizePoolDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
// 设置对话框从底部弹出并紧贴底部
|
||||
if (getWindow() != null) {
|
||||
getWindow().setGravity(android.view.Gravity.BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getWindow() != null) {
|
||||
// 获取屏幕尺寸
|
||||
android.util.DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
||||
// 设置高度为屏幕高度的80%
|
||||
android.view.WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||
params.height = (int) (displayMetrics.heightPixels * 0.8);
|
||||
params.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
getWindow().setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +62,6 @@ public class PrizePoolDialog extends BaseDialog<DialogPrizePoolBinding> {
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -60,14 +77,14 @@ public class PrizePoolDialog extends BaseDialog<DialogPrizePoolBinding> {
|
||||
}
|
||||
|
||||
// 提供更新数据的方法
|
||||
public void updateData(List<GiftBean> newData ,int type) {
|
||||
if (type==10){
|
||||
public void updateData(List<GiftBean> newData, int type) {
|
||||
if (type == 10) {
|
||||
mBinding.clPrize.setBackgroundResource(R.mipmap.tkzj);
|
||||
mBinding.imJc.setImageResource(R.mipmap.jiangc);
|
||||
}else if (type==11){
|
||||
} else if (type == 11) {
|
||||
mBinding.clPrize.setBackgroundResource(R.mipmap.syzc);
|
||||
mBinding.imJc.setImageResource(R.mipmap.syzc_jc);
|
||||
}else if (type==12){
|
||||
} else if (type == 12) {
|
||||
mBinding.clPrize.setBackgroundResource(R.mipmap.skzj);
|
||||
mBinding.imJc.setImageResource(R.mipmap.skzl_jc);
|
||||
}
|
||||
@@ -77,13 +94,13 @@ public class PrizePoolDialog extends BaseDialog<DialogPrizePoolBinding> {
|
||||
float density = mContext.getResources().getDisplayMetrics().density;
|
||||
|
||||
if (density <= 2.0) { // 低密度屏幕(如mdpi, hdpi)
|
||||
rows = 3;
|
||||
columns = 2;
|
||||
rows = 5;
|
||||
columns = 3;
|
||||
} else if (density <= 3.0) { // 中密度屏幕(如xhdpi)
|
||||
rows = 3;
|
||||
rows = 5;
|
||||
columns = 3;
|
||||
} else { // 高密度屏幕(如xxhdpi, xxxhdpi)
|
||||
rows = 4;
|
||||
rows = 5;
|
||||
columns = 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.logger.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.URL;
|
||||
@@ -56,6 +57,13 @@ import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
|
||||
|
||||
public class AvatarFrameView extends FrameLayout implements IAnimListener {
|
||||
@Override
|
||||
@@ -322,142 +330,151 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
|
||||
return memoryUsage > 0.8 || usedMemory > MAX_MEMORY_THRESHOLD;
|
||||
}
|
||||
|
||||
// public void setSource(String url, int type2) {
|
||||
// if (SpUtil.getOpenEffect()==1) {
|
||||
// playQueue.offer(new PlayItem(url, type2));
|
||||
// if (!isPlaying) {
|
||||
// playNextFromQueue();
|
||||
// }
|
||||
// }else {
|
||||
// playQueue.clear();
|
||||
// isPlaying = false;
|
||||
// }
|
||||
//
|
||||
//// RenderType type = null;
|
||||
//// if ("svga".equalsIgnoreCase(getFileExtension(url))){
|
||||
//// type = RenderType.SVGA;
|
||||
//// }else if ("mp4".equalsIgnoreCase(getFileExtension(url))){
|
||||
//// type = RenderType.MP4;
|
||||
//// }
|
||||
////
|
||||
//// clearPrevious();
|
||||
//// renderType = type;
|
||||
//// mType = type2;
|
||||
//// switch (type) {
|
||||
//// case SVGA:
|
||||
//// mBinding.playView.stopPlay();
|
||||
//// mBinding.playView.setVisibility(View.GONE);
|
||||
//// loadSVGA(url);
|
||||
//// break;
|
||||
//// case MP4:
|
||||
////// loadMP4(url);
|
||||
//// mBinding.playView.setVisibility(View.VISIBLE);
|
||||
//// downloadAndPlayMp4(url);
|
||||
//// break;
|
||||
//// }
|
||||
// }
|
||||
|
||||
boolean isTxk = false;
|
||||
private void downloadAndPlayMp4(String url) {
|
||||
String filePath = PathUtils.getInternalAppCachePath() + Md5Utils.getStringMD5(url) + ".mp4";
|
||||
|
||||
// 提取文件名
|
||||
String fileName = url.substring(url.lastIndexOf("/"));
|
||||
String filePath = getContext().getCacheDir().getAbsolutePath() + fileName;
|
||||
File file = new File(filePath);
|
||||
|
||||
if (file.exists() && file.length() > 0) {
|
||||
playMp4(file);
|
||||
mFile = file;
|
||||
} else {
|
||||
// 删除可能存在的损坏文件
|
||||
// if (file.exists()) {
|
||||
// file.delete();
|
||||
// }
|
||||
DownloadTask task = new DownloadTask.Builder(url, PathUtils.getInternalAppCachePath()
|
||||
, Md5Utils.getStringMD5(url) + ".mp4")
|
||||
.setMinIntervalMillisCallbackProcess(300)
|
||||
.setPassIfAlreadyCompleted(true)
|
||||
.setAutoCallbackToUIThread(true)
|
||||
.setConnectionCount(3) // 增加连接数提高稳定性
|
||||
.setReadBufferSize(1024 * 8) // 增大缓冲区
|
||||
if (!file.exists()) {
|
||||
LogUtils.e("无缓存");
|
||||
// 使用OkHttp进行下载
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.build();
|
||||
if (StatusUtil.isCompleted(task)) {
|
||||
playMp4(task.getFile());
|
||||
mFile = task.getFile();
|
||||
} else if (StatusUtil.isSameTaskPendingOrRunning(task)) {
|
||||
// 如果任务正在进行中,等待完成
|
||||
// 可以通过监听器处理
|
||||
attachToExistingTask(task);
|
||||
} else {
|
||||
task.enqueue(new DownloadListener1() {
|
||||
@Override
|
||||
public void taskStart(@NonNull DownloadTask task, @NonNull Listener1Assist.Listener1Model model) {
|
||||
Logger.e("AvatarFrameView1", model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void retry(@NonNull DownloadTask task, @NonNull ResumeFailedCause cause) {
|
||||
Logger.e("AvatarFrameView2", cause);
|
||||
client.newCall(request).enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
Log.d("sssssssssss", e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connected(@NonNull DownloadTask task, int blockCount, long currentOffset, long totalLength) {
|
||||
Logger.e("AvatarFrameView3", blockCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void progress(@NonNull DownloadTask task, long currentOffset, long totalLength) {
|
||||
Logger.e("AvatarFrameView4", currentOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskEnd(@NonNull DownloadTask task, @NonNull EndCause cause, @Nullable Exception realCause, @NonNull Listener1Assist.Listener1Model model) {
|
||||
Logger.e("AvatarFrameView5", model);
|
||||
// playMp4(task.getFile());
|
||||
// mFile = task.getFile();
|
||||
// if (cause != null && cause != EndCause.COMPLETED) {
|
||||
//// CrashReport.postCatchedException(new RuntimeException("下载任务结束:" + cause == null ? "" : cause.name() + "_realCause:" + realCause == null ? "" : realCause.getMessage()));
|
||||
// }
|
||||
|
||||
if (cause == EndCause.COMPLETED) {
|
||||
File downloadedFile = task.getFile();
|
||||
if (downloadedFile != null && downloadedFile.exists() && downloadedFile.length() > 0) {
|
||||
playMp4(downloadedFile);
|
||||
mFile = downloadedFile;
|
||||
} else {
|
||||
Logger.e(TAG, "Downloaded file is invalid");
|
||||
handleDownloadFailure(url, cause, new IOException("Downloaded file is invalid"));
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
if (response.isSuccessful()) {
|
||||
// 保存文件到缓存目录
|
||||
try (ResponseBody responseBody = response.body()) {
|
||||
if (responseBody != null) {
|
||||
File downloadedFile = new File(filePath);
|
||||
FileOutputStream fos = new FileOutputStream(downloadedFile);
|
||||
fos.write(responseBody.bytes());
|
||||
fos.close();
|
||||
isTxk=true;
|
||||
// 在主线程中播放动画
|
||||
mainHandler.post(() -> {
|
||||
if (isTxk) {
|
||||
mBinding.playView.setLoop(20);
|
||||
}
|
||||
mBinding.playView.startPlay(downloadedFile);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
handleDownloadFailure(url, cause, realCause);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
isTxk=true;
|
||||
LogUtils.e("有缓存");
|
||||
// 直接播放缓存文件
|
||||
if (isTxk) {
|
||||
mBinding.playView.setLoop(20);
|
||||
}
|
||||
mBinding.playView.startPlay(file);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDownloadFailure(String url, EndCause cause, Exception realCause) {
|
||||
Logger.e(TAG, "Download failed: " + cause + ", real cause: " + realCause);
|
||||
|
||||
// 尝试重试一次
|
||||
mainHandler.postDelayed(() -> {
|
||||
// 检查队列是否仍然包含这个项目
|
||||
boolean shouldRetry = false;
|
||||
for (PlayItem item : playQueue) {
|
||||
if (item.url.equals(url)) {
|
||||
shouldRetry = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldRetry) {
|
||||
// 重新添加到队列开头
|
||||
playQueue.add(new PlayItem(url, mType));
|
||||
playNextFromQueue();
|
||||
} else {
|
||||
isPlaying = false;
|
||||
playNextFromQueue();
|
||||
}
|
||||
}, 1000); // 1秒后重试
|
||||
}
|
||||
// private void downloadAndPlayMp4(String url) {
|
||||
// String filePath = PathUtils.getInternalAppCachePath() + Md5Utils.getStringMD5(url) + ".mp4";
|
||||
// File file = new File(filePath);
|
||||
//
|
||||
// if (file.exists() && file.length() > 0) {
|
||||
// playMp4(file);
|
||||
// mFile = file;
|
||||
// } else {
|
||||
// // 删除可能存在的损坏文件
|
||||
//// if (file.exists()) {
|
||||
//// file.delete();
|
||||
//// }
|
||||
//
|
||||
// DownloadTask task = new DownloadTask.Builder(url, PathUtils.getInternalAppCachePath()
|
||||
// , Md5Utils.getStringMD5(url) + ".mp4")
|
||||
// .setMinIntervalMillisCallbackProcess(300)
|
||||
// .setPassIfAlreadyCompleted(true)
|
||||
// .setAutoCallbackToUIThread(true)
|
||||
// .setConnectionCount(3) // 增加连接数提高稳定性
|
||||
// .setReadBufferSize(1024 * 8) // 增大缓冲区
|
||||
// .build();
|
||||
// if (StatusUtil.isCompleted(task)) {
|
||||
// playMp4(task.getFile());
|
||||
// mFile = task.getFile();
|
||||
// } else if (StatusUtil.isSameTaskPendingOrRunning(task)) {
|
||||
// Logger.d(TAG, "Task is pending or running, checking if it's stuck");
|
||||
// // 检查任务是否可能卡住了
|
||||
// // 添加超时机制,如果任务长时间没有进展,则重新开始
|
||||
// checkAndHandleStuckTask(task, url);
|
||||
// } else {
|
||||
// Logger.d(TAG, "Starting new download task");
|
||||
// startNewDownload(task, url);
|
||||
// }
|
||||
//
|
||||
//// else if (StatusUtil.isSameTaskPendingOrRunning(task)) {
|
||||
//// // 如果任务正在进行中,等待完成
|
||||
//// // 可以通过监听器处理
|
||||
//// attachToExistingTask(task);
|
||||
//// } else {
|
||||
//// task.enqueue(new DownloadListener1() {
|
||||
//// @Override
|
||||
//// public void taskStart(@NonNull DownloadTask task, @NonNull Listener1Assist.Listener1Model model) {
|
||||
//// Logger.e("AvatarFrameView1", model);
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void retry(@NonNull DownloadTask task, @NonNull ResumeFailedCause cause) {
|
||||
//// Logger.e("AvatarFrameView2", cause);
|
||||
////
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void connected(@NonNull DownloadTask task, int blockCount, long currentOffset, long totalLength) {
|
||||
//// Logger.e("AvatarFrameView3", blockCount);
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void progress(@NonNull DownloadTask task, long currentOffset, long totalLength) {
|
||||
//// Logger.e("AvatarFrameView4", currentOffset);
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void taskEnd(@NonNull DownloadTask task, @NonNull EndCause cause, @Nullable Exception realCause, @NonNull Listener1Assist.Listener1Model model) {
|
||||
//// Logger.e("AvatarFrameView5", model);
|
||||
////// playMp4(task.getFile());
|
||||
////// mFile = task.getFile();
|
||||
////// if (cause != null && cause != EndCause.COMPLETED) {
|
||||
//////// CrashReport.postCatchedException(new RuntimeException("下载任务结束:" + cause == null ? "" : cause.name() + "_realCause:" + realCause == null ? "" : realCause.getMessage()));
|
||||
////// }
|
||||
////
|
||||
//// if (cause == EndCause.COMPLETED) {
|
||||
//// File downloadedFile = task.getFile();
|
||||
//// if (downloadedFile != null && downloadedFile.exists() && downloadedFile.length() > 0) {
|
||||
//// playMp4(downloadedFile);
|
||||
//// mFile = downloadedFile;
|
||||
//// } else {
|
||||
//// Logger.e(TAG, "Downloaded file is invalid");
|
||||
//// handleDownloadFailure(url, cause, new IOException("Downloaded file is invalid"));
|
||||
//// }
|
||||
//// } else {
|
||||
//// handleDownloadFailure(url, cause, realCause);
|
||||
//// }
|
||||
//// }
|
||||
//// });
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
// 添加检查进行中任务的方法
|
||||
private void attachToExistingTask(DownloadTask task) {
|
||||
// 为已经在队列中的任务附加监听器
|
||||
@@ -802,7 +819,7 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
|
||||
protected boolean removeEldestEntry(Entry<K, V> eldest) {
|
||||
return size() > maxSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,7 @@ public class GiftCardView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
private android.animation.AnimatorSet animatorSet;
|
||||
|
||||
public void startPulseAnimationWithLayer() {
|
||||
if (pulseAnimator != null && pulseAnimator.isRunning()) {
|
||||
@@ -169,7 +170,7 @@ public class GiftCardView extends FrameLayout {
|
||||
scaleYAnimator.setRepeatMode(ObjectAnimator.REVERSE);
|
||||
|
||||
// 组合动画
|
||||
android.animation.AnimatorSet animatorSet = new android.animation.AnimatorSet();
|
||||
animatorSet = new android.animation.AnimatorSet();
|
||||
animatorSet.playTogether(pulseAnimator, scaleYAnimator);
|
||||
animatorSet.start();
|
||||
}
|
||||
@@ -178,8 +179,22 @@ public class GiftCardView extends FrameLayout {
|
||||
if (pulseAnimator != null) {
|
||||
pulseAnimator.cancel();
|
||||
}
|
||||
|
||||
// 停止组合动画
|
||||
if (animatorSet != null && animatorSet.isRunning()) {
|
||||
animatorSet.cancel();
|
||||
}
|
||||
|
||||
// 清除引用
|
||||
animatorSet = null;
|
||||
pulseAnimator = null;
|
||||
|
||||
// 重置缩放
|
||||
this.setScaleX(1f);
|
||||
this.setScaleY(1f);
|
||||
|
||||
// 强制重新绘制
|
||||
this.invalidate();
|
||||
}
|
||||
/**
|
||||
* 设置礼物名称
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
android:layout_marginStart="@dimen/dp_16"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginEnd="@dimen/dp_16"
|
||||
android:layout_marginBottom="@dimen/dp_30"
|
||||
android:background="#80000000"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
@@ -77,7 +76,6 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/dp_16"
|
||||
android:layout_marginBottom="@dimen/dp_30"
|
||||
app:srlEnableLoadMore="true"
|
||||
app:srlEnableRefresh="true">
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
android:id="@+id/lottery_buttons_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/dp_16"
|
||||
android:layout_margin="@dimen/dp_10"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="@dimen/dp_100"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:layout_width="@dimen/dp_90"
|
||||
android:layout_height="@dimen/dp_90"
|
||||
android:id="@+id/iv_prize_pool"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@mipmap/tkzj_z"
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_gift_image"
|
||||
android:layout_width="@dimen/dp_62"
|
||||
android:layout_height="@dimen/dp_62"
|
||||
android:layout_width="@dimen/dp_60"
|
||||
android:layout_height="@dimen/dp_60"
|
||||
app:layout_constraintTop_toTopOf="@+id/iv_prize_pool"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/iv_prize_pool"
|
||||
app:layout_constraintStart_toStartOf="@+id/iv_prize_pool"
|
||||
|
||||
Reference in New Issue
Block a user