修改转盘
This commit is contained in:
@@ -9,10 +9,12 @@ import android.media.MediaPlayer;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -43,6 +45,7 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author qx
|
* @author qx
|
||||||
@@ -135,8 +138,66 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
protected void initData() {
|
protected void initData() {
|
||||||
MvpPre.getGiftList(giftBagId, roomId);
|
MvpPre.getGiftList(giftBagId, roomId);
|
||||||
MvpPre.wallet();
|
MvpPre.wallet();
|
||||||
|
mBinding.mirroeSky.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||||
|
isOpenSound= check;
|
||||||
|
if(!check){
|
||||||
|
stopPlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mBinding.cityTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||||
|
isOpenSound= check;
|
||||||
|
if(!check){
|
||||||
|
stopPlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mBinding.pinnacleTime.swLockYx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||||
|
isOpenSound= check;
|
||||||
|
if(!check){
|
||||||
|
stopPlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mBinding.mirroeSky.swTex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||||
|
isOpenSpecial= check;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mBinding.cityTime.swTex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||||
|
isOpenSpecial= check;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mBinding.pinnacleTime.swTex.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean check) {
|
||||||
|
isOpenSpecial= check;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stopPlay(){
|
||||||
|
if(mediaPlayer!=null&&player!=null){
|
||||||
|
player.stop();
|
||||||
|
player.reset();
|
||||||
|
player=null;
|
||||||
|
mediaPlayer.stop();
|
||||||
|
mediaPlayer.reset();
|
||||||
|
mediaPlayer=null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void initView() {
|
protected void initView() {
|
||||||
// 根据不同的用户类型显示不同的界面
|
// 根据不同的用户类型显示不同的界面
|
||||||
@@ -334,10 +395,6 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
} else {
|
} else {
|
||||||
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
com.hjq.toast.ToastUtils.show("正在抽奖中...");
|
||||||
}
|
}
|
||||||
} else if (id == R.id.sw_lock_yx) {//音效
|
|
||||||
isOpenSound = mBinding.mirroeSky.swLockYx.isChecked();
|
|
||||||
} else if (id == R.id.sw_tex) {//特效
|
|
||||||
isOpenSpecial = mBinding.mirroeSky.swTex.isChecked();
|
|
||||||
} else if (id == R.id.tv_gz) {//规则
|
} else if (id == R.id.tv_gz) {//规则
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString("url", getRule_url);
|
bundle.putString("url", getRule_url);
|
||||||
@@ -527,7 +584,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
|
|
||||||
// 停止之前的定时器
|
// 停止之前的定时器
|
||||||
stopFastAnimate();
|
stopFastAnimate();
|
||||||
|
Log.e("isOpenSound===","isOpenSound111"+isOpenSound);
|
||||||
if (isOpenSound) {
|
if (isOpenSound) {
|
||||||
// 假设此处有播放音乐的逻辑
|
// 假设此处有播放音乐的逻辑
|
||||||
playSound("draw_music.mp3");
|
playSound("draw_music.mp3");
|
||||||
@@ -582,19 +639,18 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
iterator.remove(); // 安全地移除元素
|
iterator.remove(); // 安全地移除元素
|
||||||
finishTargetArrayIndex.add(index);
|
finishTargetArrayIndex.add(index);
|
||||||
foundTarget = true;
|
foundTarget = true;
|
||||||
if (!isOpenSpecial || !isOpenSound) {
|
if (isOpenSound) {
|
||||||
playSound("xuanz.mp3");
|
playSound("xuanz.mp3");
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delayTime = 0.03;
|
delayTime = 0.03;
|
||||||
if (targetArrayIndex.isEmpty()) {
|
if (targetArrayIndex.isEmpty()) {
|
||||||
|
|
||||||
MvpPre.giftSend(blind_box_turntable_id);
|
MvpPre.giftSend(blind_box_turntable_id);
|
||||||
MvpPre.wallet();
|
MvpPre.wallet();
|
||||||
isDrawing = false;
|
isDrawing = false;
|
||||||
|
// stopPlay();
|
||||||
stopFastAnimate();
|
stopFastAnimate();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -630,11 +686,11 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
}
|
}
|
||||||
|
|
||||||
private MediaPlayer player;
|
private MediaPlayer player;
|
||||||
|
MediaPlayer mediaPlayer ;
|
||||||
// 播放音频的方法
|
// 播放音频的方法
|
||||||
private void playSound(String fileName) {
|
private void playSound(String fileName) {
|
||||||
try {
|
try {
|
||||||
MediaPlayer mediaPlayer = getPlayer(fileName);
|
mediaPlayer = getPlayer(fileName);
|
||||||
if (mediaPlayer != null) {
|
if (mediaPlayer != null) {
|
||||||
if (mediaPlayer.isPlaying()) {
|
if (mediaPlayer.isPlaying()) {
|
||||||
mediaPlayer.seekTo(0);
|
mediaPlayer.seekTo(0);
|
||||||
@@ -811,22 +867,21 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
|
|||||||
GiftCardView giftCardView = allViewsArray.get(j);
|
GiftCardView giftCardView = allViewsArray.get(j);
|
||||||
GiftBean giftBean = giftLists.get(j);
|
GiftBean giftBean = giftLists.get(j);
|
||||||
giftBean.setCount(reslutList.getCount());
|
giftBean.setCount(reslutList.getCount());
|
||||||
|
|
||||||
if (!isOpenSpecial || !isOpenSound) {
|
|
||||||
giftCardView.setVisibilitymResultTextView(true);
|
giftCardView.setVisibilitymResultTextView(true);
|
||||||
giftCardView.setSelected(true);
|
giftCardView.setSelected(true);
|
||||||
playSound("xuanz.mp3");
|
|
||||||
// 不要设置isDrawing=true,这会影响动画控制
|
// 不要设置isDrawing=true,这会影响动画控制
|
||||||
MvpPre.wallet();
|
MvpPre.wallet();
|
||||||
isDrawing = false;
|
isDrawing = false;
|
||||||
MvpPre.giftSend(blind_box_turntable_id);
|
MvpPre.giftSend(blind_box_turntable_id);
|
||||||
}
|
|
||||||
giftCardView.bindGiftData(giftBean);
|
giftCardView.bindGiftData(giftBean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Log.e("isOpenSound===","isOpenSound1222"+isOpenSound);
|
||||||
if (isOpenSpecial) {
|
if (isOpenSpecial) {
|
||||||
|
Log.e("isOpenSound===","isOpenSound333"+isOpenSound);
|
||||||
startFastAnimate();
|
startFastAnimate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,11 @@
|
|||||||
|
|
||||||
<com.zhpan.bannerview.BannerViewPager
|
<com.zhpan.bannerview.BannerViewPager
|
||||||
android:id="@+id/banner_view_pager"
|
android:id="@+id/banner_view_pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/rl"
|
||||||
app:bvp_indicator_visibility="gone"
|
app:bvp_indicator_visibility="gone"
|
||||||
app:layout_constraintDimensionRatio="H,16:9"
|
app:layout_constraintDimensionRatio="H,16:9"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|||||||
Reference in New Issue
Block a user