修改BUG

修改飘屏,飘屏不合适
This commit is contained in:
2025-09-05 21:39:42 +08:00
parent cb3b7aa183
commit 7217a9e38e
44 changed files with 748 additions and 380 deletions

View File

@@ -4,10 +4,10 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-09-04T03:41:21.667755Z"> <DropdownSelection timestamp="2025-09-05T11:48:42.014930600Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="PhysicalDevice" identifier="serial=6705124a" /> <DeviceId pluginId="PhysicalDevice" identifier="serial=3142478285001BV" />
</handle> </handle>
</Target> </Target>
</DropdownSelection> </DropdownSelection>

View File

@@ -115,6 +115,7 @@
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<application <application
android:name=".AppContext" android:name=".AppContext"

View File

@@ -1,18 +1,26 @@
package com.xscm.moduleutil.activity; package com.xscm.moduleutil.activity;
import static androidx.core.content.ContextCompat.getSystemService;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding; import androidx.databinding.ViewDataBinding;
@@ -20,6 +28,7 @@ import androidx.databinding.ViewDataBinding;
import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.ActivityUtils; import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.BarUtils; import com.blankj.utilcode.util.BarUtils;
import com.hjq.toast.ToastUtils;
import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo; import com.tencent.qcloud.tuikit.tuichat.bean.ChatInfo;
import com.xscm.moduleutil.R; import com.xscm.moduleutil.R;
import com.xscm.moduleutil.base.CommonAppContext; import com.xscm.moduleutil.base.CommonAppContext;
@@ -29,6 +38,7 @@ import com.xscm.moduleutil.utils.ColorManager;
import com.xscm.moduleutil.utils.DisplayUtil; import com.xscm.moduleutil.utils.DisplayUtil;
import com.xscm.moduleutil.utils.LanguageUtil; import com.xscm.moduleutil.utils.LanguageUtil;
import com.xscm.moduleutil.utils.SpUtil; import com.xscm.moduleutil.utils.SpUtil;
import com.xscm.moduleutil.widget.PiaoPingManager;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@@ -72,7 +82,7 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
ActivityUtils.finishAllActivities(); ActivityUtils.finishAllActivities();
} }
private PiaoPingManager piaoPingManager;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -126,6 +136,44 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
// | View.SYSTEM_UI_FLAG_FULLSCREEN // | View.SYSTEM_UI_FLAG_FULLSCREEN
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); // | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// if (piaoPingManager==null){
// piaoPingManager = PiaoPingManager.getInstance(this);
// }
}
// 在Activity中
private static final int REQUEST_OVERLAY_PERMISSION = 1001;
private void checkAndRequestOverlayPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
new AlertDialog.Builder(this)
.setTitle("需要悬浮窗权限")
.setMessage("应用需要悬浮窗权限才能显示飘屏效果")
.setPositiveButton("去设置", (dialog, which) -> {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, REQUEST_OVERLAY_PERMISSION);
})
.setNegativeButton("取消", null)
.show();
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_OVERLAY_PERMISSION) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Settings.canDrawOverlays(this)) {
ToastUtils.show("已获得悬浮窗权限");
} else {
ToastUtils.show("未获得悬浮窗权限");
}
}
}
} }
public static void finishAll() { public static void finishAll() {

View File

@@ -121,7 +121,7 @@ public class GiftPackAdapter extends BaseAdapter {
viewHolder.item_layout = (ConstraintLayout) convertView.findViewById(R.id.cl_gift); viewHolder.item_layout = (ConstraintLayout) convertView.findViewById(R.id.cl_gift);
viewHolder.ivDownOn = (ImageView) convertView.findViewById(R.id.iv_down_on); viewHolder.ivDownOn = (ImageView) convertView.findViewById(R.id.iv_down_on);
viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on); viewHolder.cl_iv_down_on = (ConstraintLayout) convertView.findViewById(R.id.cl_iv_down_on);
viewHolder.integral = (TextView) convertView.findViewById(R.id.integral);
convertView.setTag(viewHolder); convertView.setTag(viewHolder);
} else { } else {
viewHolder = (GiftPackAdapter.ViewHolder) convertView.getTag(); viewHolder = (GiftPackAdapter.ViewHolder) convertView.getTag();
@@ -129,10 +129,11 @@ public class GiftPackAdapter extends BaseAdapter {
viewHolder.item_layout.setOnClickListener(v -> { viewHolder.item_layout.setOnClickListener(v -> {
// RoonGiftModel clickedModel = (RoonGiftModel) v.getTag(); // RoonGiftModel clickedModel = (RoonGiftModel) v.getTag();
EventBus.getDefault().post(new RoomGiftPackToEvent(this, giftModel, 1)); EventBus.getDefault().post(new RoomGiftPackToEvent(this, giftModel, 2));
}); });
viewHolder.integral.setVisibility(View.VISIBLE);
viewHolder.integral.setText("x"+giftModel.getNum());
//设置礼物名字 //设置礼物名字
viewHolder.tv_gift_name.setText(giftModel.getGift_name()); viewHolder.tv_gift_name.setText(giftModel.getGift_name());
//设置礼物价格 //设置礼物价格
@@ -162,7 +163,7 @@ public class GiftPackAdapter extends BaseAdapter {
static class ViewHolder { static class ViewHolder {
public ConstraintLayout item_layout; public ConstraintLayout item_layout;
public TextView tv_gift_name, tv_gift_price, tv_gift_num; public TextView tv_gift_name, tv_gift_price, integral;
public ImageView iv_gift_pic; public ImageView iv_gift_pic;
public TextView tv_gift_change_love_values; public TextView tv_gift_change_love_values;
public ImageView ivDownOn; public ImageView ivDownOn;

View File

@@ -158,7 +158,7 @@ public class GiftTwoAdapter extends BaseAdapter {
viewHolder.ivDownOn.setVisibility(View.GONE); viewHolder.ivDownOn.setVisibility(View.GONE);
viewHolder.cl_iv_down_on.setBackgroundResource(0); viewHolder.cl_iv_down_on.setBackgroundResource(0);
} }
viewHolder.tv_gift_num.setText(String.format("x%s", giftModel.getNum())); viewHolder.tv_gift_num.setText(String.format("x%s", (giftModel.getNum()!=0?giftModel.getNum():"1")));
//设置 //设置

View File

@@ -1,5 +1,7 @@
package com.xscm.moduleutil.base; package com.xscm.moduleutil.base;
import static androidx.core.app.ActivityCompat.startActivityForResult;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.app.Application; import android.app.Application;
@@ -8,9 +10,11 @@ import android.content.Intent;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.Signature; import android.content.pm.Signature;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.provider.Settings;
import android.util.Base64; import android.util.Base64;
import android.webkit.WebView; import android.webkit.WebView;
@@ -95,7 +99,7 @@ public class CommonAppContext extends MultiDexApplication {
EnvironmentPrefs prefs = new EnvironmentPrefs(this); EnvironmentPrefs prefs = new EnvironmentPrefs(this);
currentEnvironment = prefs.getSelectedEnvironment(); currentEnvironment = prefs.getSelectedEnvironment();
initialization(); initialization();
piaoPingManager = PiaoPingManager.getInstance(this);
} }
@@ -126,11 +130,20 @@ public class CommonAppContext extends MultiDexApplication {
SpUtil.getInstance().setBooleanValue("youth_model_shown", false); SpUtil.getInstance().setBooleanValue("youth_model_shown", false);
} }
} }
piaoPingManager = PiaoPingManager.getInstance(this);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, 100);
}
}
} }
private void startActivityForResult(Intent intent, int i) {
}
private PiaoPingManager piaoPingManager; private PiaoPingManager piaoPingManager;
private void initARouter() { private void initARouter() {

View File

@@ -53,13 +53,16 @@ public class PlaceholderBean {
@Data @Data
public static class ListsBean { public static class ListsBean {
private String user_id; private String user_id;
private String user_code;
private String nickname; private String nickname;
private String nickname1;
private String avatar; private String avatar;
private String total; private String total;
private String rank; private String rank;
private List<String> icon; private List<String> icon;
private String room_name; private String room_name;
private String room_id; private String room_id;
private String room_number;
private String room_cover; private String room_cover;
private int id;//公会id private int id;//公会id

View File

@@ -163,8 +163,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
int screenHeight = displayMetrics.heightPixels; int screenHeight = displayMetrics.heightPixels;
// 设置高度为屏幕高度的100%(全屏) // 设置高度为屏幕高度的100%(全屏)
int heightInPx = (int) (screenHeight * 0.79); int heightInPx = (int) (screenHeight * 0.79);
;
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
window.setBackgroundDrawableResource(android.R.color.transparent); window.setBackgroundDrawableResource(android.R.color.transparent);
// 可选:设置动画样式(从底部弹出) // 可选:设置动画样式(从底部弹出)

View File

@@ -17,7 +17,7 @@ import lombok.Getter;
public class GiftXlhChouAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder> { public class GiftXlhChouAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
private List<GiftBean> giftLists = new ArrayList<>(); private List<GiftBean> giftLists = new ArrayList<>();
private int selectedPosition = -1; private int selectedPosition = -1;
private static final int LOOP_COUNT = 6; // 循环倍数 private static final int LOOP_COUNT = 8; // 循环倍数
public GiftXlhChouAdapter() { public GiftXlhChouAdapter() {
@@ -138,6 +138,10 @@ public class GiftXlhChouAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolde
* @return 原始数据大小 * @return 原始数据大小
*/ */
public int getOriginalDataSize() { public int getOriginalDataSize() {
return giftLists.size(); List<GiftBean> loopData = new ArrayList<>();
for (int i = 0; i < LOOP_COUNT; i++) {
loopData.addAll(giftLists);
}
return loopData.size();
} }
} }

View File

@@ -1,13 +1,20 @@
package com.xscm.moduleutil.dialog.giftLottery; package com.xscm.moduleutil.dialog.giftLottery;
import android.annotation.SuppressLint;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.os.CountDownTimer; import android.os.CountDownTimer;
import android.os.Handler;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater;
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.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@@ -39,6 +46,7 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random;
public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, FragmentTourClubDialogBinding> implements GiftLotteryContacts.View { public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, FragmentTourClubDialogBinding> implements GiftLotteryContacts.View {
private String roomId; private String roomId;
@@ -56,6 +64,14 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
private static final int ITEM_COUNT = 24; private static final int ITEM_COUNT = 24;
private static final int ROTATION_COUNT = 3; private static final int ROTATION_COUNT = 3;
private Handler handler = new Handler();
private boolean isLotteryRunning = false;
private int scrollSpeed = 10; // 滚动速度
private int totalScrollTime = 5000; // 总滚动时间,单位:毫秒
private int targetPosition;
@Override @Override
protected GiftLotteryPresenter bindPresenter() { protected GiftLotteryPresenter bindPresenter() {
return new GiftLotteryPresenter(this, getActivity()); return new GiftLotteryPresenter(this, getActivity());
@@ -109,8 +125,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
int screenHeight = displayMetrics.heightPixels; int screenHeight = displayMetrics.heightPixels;
// 设置高度为屏幕高度的100%(全屏) // 设置高度为屏幕高度的100%(全屏)
int heightInPx = (int) (screenHeight * 0.79); int heightInPx = (int) (screenHeight * 0.79);
; window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
window.setBackgroundDrawableResource(android.R.color.transparent); window.setBackgroundDrawableResource(android.R.color.transparent);
// 可选:设置动画样式(从底部弹出) // 可选:设置动画样式(从底部弹出)
@@ -128,6 +143,8 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
mBinding.tvBd.setOnClickListener(this::onClick); mBinding.tvBd.setOnClickListener(this::onClick);
mBinding.tvJl.setOnClickListener(this::onClick); mBinding.tvJl.setOnClickListener(this::onClick);
giftXlhChouAdapter=new GiftXlhChouAdapter(); giftXlhChouAdapter=new GiftXlhChouAdapter();
// 使用 LinearLayoutManager 横向滚动 // 使用 LinearLayoutManager 横向滚动
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false); LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
@@ -168,14 +185,17 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
com.hjq.toast.ToastUtils.show("奖池数据加载中,请稍后再试"); com.hjq.toast.ToastUtils.show("奖池数据加载中,请稍后再试");
} }
} else if (id == R.id.ll_one) { } else if (id == R.id.ll_one) {
prepareForNewLottery();
num="1"; num="1";
MvpPre.xlhChou(roomId,num); MvpPre.xlhChou(roomId,num);
} else if (id == R.id.ll_ten) { } else if (id == R.id.ll_ten) {
prepareForNewLottery();
num="10"; num="10";
MvpPre.xlhChou(roomId,num); MvpPre.xlhChou(roomId,num);
} else if (id == R.id.ll_hundred) { } else if (id == R.id.ll_hundred) {
prepareForNewLottery();
num="100"; num="100";
MvpPre.xlhChou(roomId,num); MvpPre.xlhChou(roomId,num);
@@ -203,7 +223,6 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
xlhRecordDialog.show(getChildFragmentManager(), "XlhRecordDialog"); xlhRecordDialog.show(getChildFragmentManager(), "XlhRecordDialog");
} }
} }
@Override @Override
protected int getLayoutId() { protected int getLayoutId() {
return R.layout.fragment_tour_club_dialog; return R.layout.fragment_tour_club_dialog;
@@ -248,6 +267,7 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
} }
giftXlhChouAdapter.setNewData(giftLists); giftXlhChouAdapter.setNewData(giftLists);
} }
} }
@@ -351,6 +371,18 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
releaseCountDownTimer(); releaseCountDownTimer();
// 清理所有待执行的任务
clearPendingTasks();
// 清理滚动帮助类
if (scrollHelper != null) {
scrollHelper = null;
}
// 清理适配器引用
if (giftXlhChouAdapter != null) {
giftXlhChouAdapter = null;
}
} }
@@ -380,66 +412,136 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
mBinding.tvIcon.setText(walletBean.getCoin()); mBinding.tvIcon.setText(walletBean.getCoin());
} }
} }
private Runnable pendingLotteryRunnable;
private Runnable pendingCenteringRunnable;
@Override @Override
public void xlhChouSuccess(List<XlhDrawBean> data) { public void xlhChouSuccess(List<XlhDrawBean> data) {
if (data != null){ if (data != null){
// 抽奖完成后执行动画滚动
mBinding.recycleView.postDelayed(() -> {
int winningPosition = findHighestValueWinningPosition(data);
if (winningPosition != -1) {
startLotteryAnimation(winningPosition); // 取消之前可能存在的任务
clearPendingTasks();
// 抽奖完成后执行动画滚动
pendingLotteryRunnable = new Runnable() {
@Override
public void run() {
// 清理之前的状态
if (giftXlhChouAdapter != null) {
giftXlhChouAdapter.clearSelection();
}
int winningPosition = findHighestValueWinningPosition(data);//这是获取到的中奖位置下标
if (winningPosition != -1) {
if (scrollHelper == null) {
scrollHelper = new CenterScrollHelper(mBinding.recycleView);
}
// 计算在循环列表中的目标位置(滚动几圈后停在目标位置)
int loopCount = 4; // 滚动4圈
int originalSize = giftLists.size();///这是列表的总大小
// 计算目标在循环列表中的位置(确保在中间区域)
///这是计算总圈数的大小
int middleBaseIndex = (loopCount * originalSize);
///这里是展示在中奖的位置,加上总圈数的大小,
int targetLoopIndex = middleBaseIndex + (winningPosition % originalSize);
/** // 使用scrollWithCircles方法执行带动画的滚动带完成回调
scrollHelper.scrollWithCircles(
targetLoopIndex, // 在循环列表中的位置
loopCount, // 滚动圈数
200, // 每个item滚动时间200ms控制速度
originalSize, // 原始数据大小
() -> { // 滚动完成回调
// 滚动完成后更新选中状态(使用原始位置)
if (giftXlhChouAdapter != null) {
giftXlhChouAdapter.setSelectedPosition(winningPosition);
}
// 滚动完成后延迟一小段时间再居中确保UI更新完成
pendingCenteringRunnable = new Runnable() {
@Override
public void run() {
// 手动将选中项居中
centerSelectedItem(winningPosition, originalSize);
// 显示结果对话框
// 计算在循环列表中的目标位置(滚动几圈后停在目标位置) getActivity().runOnUiThread(() -> {
int loopCount = 4; // 滚动3圈 scrollHelper = null;
int originalSize = giftXlhChouAdapter.getOriginalDataSize(); showResultDialog(data);
// 计算目标在循环列表中的位置(确保在中间区域) });
}
int middleBaseIndex = (loopCount * originalSize) + (originalSize / 2); };
int targetLoopIndex = middleBaseIndex + (winningPosition % originalSize); mBinding.recycleView.postDelayed(pendingCenteringRunnable, 100);
// 使用scrollWithCircles方法执行带动画的滚动带完成回调
scrollHelper.scrollWithCircles(
targetLoopIndex, // 在循环列表中的位置
loopCount, // 滚动圈数
500, // 每个item滚动时间200ms控制速度
originalSize, // 原始数据大小
() -> { // 滚动完成回调
// 滚动完成后更新选中状态(使用原始位置)
if (giftXlhChouAdapter != null) {
giftXlhChouAdapter.setSelectedPosition(winningPosition);
} }
// 滚动完成后延迟一小段时间再居中确保UI更新完成 );
mBinding.recycleView.postDelayed(() -> {
// 手动将选中项居中
centerSelectedItem(winningPosition, originalSize);
// 显示结果对话框 } else {
getActivity().runOnUiThread(() -> { // 如果没有找到中奖位置,直接显示对话框
showResultDialog(data); showResultDialog(data);
}); }
}, 100);
// 在滚动完成后再显示对话框
// getActivity().runOnUiThread(() -> {
// showResultDialog(data);
// });
}
);
*/
} else {
// 如果没有找到中奖位置,直接显示对话框
showResultDialog(data);
} }
}, 300); };
mBinding.recycleView.postDelayed(pendingLotteryRunnable, 300);
} }
MvpPre.wallet(); MvpPre.wallet();
} }
/**
* 为新的抽奖做准备,清理之前的状态
*/
private void prepareForNewLottery() {
// 取消之前可能存在的任务
clearPendingTasks();
// 清除之前的选择状态
if (giftXlhChouAdapter != null) {
giftXlhChouAdapter.clearSelection();
}
// 重置滚动帮助类
if (scrollHelper != null) {
scrollHelper.reset();
}
// 停止可能正在进行的滚动
mBinding.recycleView.stopScroll();
// 清理可能存在的回调
if (mBinding.recycleView.getHandler() != null) {
mBinding.recycleView.getHandler().removeCallbacksAndMessages(null);
}
// 重新初始化滚动帮助类
scrollHelper = new CenterScrollHelper(mBinding.recycleView);
}
/**
* 清除所有待执行的任务
*/
private void clearPendingTasks() {
// 取消抽奖动画任务
if (pendingLotteryRunnable != null) {
mBinding.recycleView.removeCallbacks(pendingLotteryRunnable);
pendingLotteryRunnable = null;
}
// 取消居中任务
if (pendingCenteringRunnable != null) {
mBinding.recycleView.removeCallbacks(pendingCenteringRunnable);
pendingCenteringRunnable = null;
}
// 停止可能正在进行的滚动
mBinding.recycleView.stopScroll();
// 清理handler中的所有消息
if (mBinding.recycleView.getHandler() != null) {
mBinding.recycleView.getHandler().removeCallbacksAndMessages(null);
}
}
private void startLotteryAnimation(int targetIndex) { private void startLotteryAnimation(int targetIndex) {
// 确保适配器有数据 // 确保适配器有数据
if (giftXlhChouAdapter == null || giftXlhChouAdapter.getOriginalDataSize() <= 0) { if (giftXlhChouAdapter == null || giftXlhChouAdapter.getOriginalDataSize() <= 0) {
@@ -558,32 +660,53 @@ public class TourClubDialogFragment extends BaseMvpDialogFragment<GiftLotteryPre
* @param originalPosition 原始数据中的位置 * @param originalPosition 原始数据中的位置
* @param originalSize 原始数据大小 * @param originalSize 原始数据大小
*/ */
// 新增优化的居中方法
private void centerSelectedItem(int originalPosition, int originalSize) { private void centerSelectedItem(int originalPosition, int originalSize) {
LinearLayoutManager layoutManager = (LinearLayoutManager) mBinding.recycleView.getLayoutManager(); LinearLayoutManager layoutManager = (LinearLayoutManager) mBinding.recycleView.getLayoutManager();
if (layoutManager == null) return; if (layoutManager == null) return;
// 计算出需要滚动到的目标位置 // 计算出需要滚动到的目标位置(确保在中间可见区域)
int targetPosition = originalPosition + 4 * originalSize; int targetPosition = originalPosition + 4 * originalSize;
// 使用smoothScrollToPosition滚动到目标位置 // 滚动到目标位置附近
mBinding.recycleView.smoothScrollToPosition(targetPosition); mBinding.recycleView.scrollToPosition(targetPosition);
// 等待滚动完成 // 使用post确保布局完成后进行精确居中
mBinding.recycleView.postDelayed(() -> { mBinding.recycleView.post(() -> {
// 计算出选中项的偏移量,确保它在中间 View targetView = layoutManager.findViewByPosition(targetPosition);
View view = layoutManager.findViewByPosition(targetPosition); if (targetView == null) {
if (view == null) return; // 如果目标view不可见使用smoothScrollToPosition
mBinding.recycleView.smoothScrollToPosition(targetPosition);
// 再次尝试居中
mBinding.recycleView.postDelayed(() -> {
View refreshedView = layoutManager.findViewByPosition(targetPosition);
if (refreshedView != null) {
performCentering(layoutManager, refreshedView);
}
}, 50);
return;
}
// 计算出RecyclerView的宽度和View的宽度 performCentering(layoutManager, targetView);
int recyclerViewWidth = mBinding.recycleView.getWidth(); });
int viewWidth = view.getWidth(); }
// 计算偏移量确保view居中 // 执行实际的居中操作
int offsetToCenter = (recyclerViewWidth / 2) - (viewWidth / 2) - view.getLeft(); private void performCentering(LinearLayoutManager layoutManager, View targetView) {
// 计算RecyclerView的中心点
int recyclerViewWidth = mBinding.recycleView.getWidth();
int recyclerViewCenter = recyclerViewWidth / 2;
// 调整滚动的位置 // 计算目标view的中心点
mBinding.recycleView.scrollBy(offsetToCenter, 0); int targetViewLeft = targetView.getLeft();
}, 500); // 500毫秒的延迟根据实际情况调整 int targetViewWidth = targetView.getWidth();
int targetViewCenter = targetViewLeft + targetViewWidth / 2;
// 计算需要滚动的偏移量
int offset = targetViewCenter - recyclerViewCenter;
// 精确滚动使目标view居中
mBinding.recycleView.scrollBy(offset, 0);
} }
/** /**

View File

@@ -10,8 +10,10 @@ import lombok.Data;
@Data @Data
public class GiftRewardEvent { public class GiftRewardEvent {
private int points; private int points;
private String zone_id;
public GiftRewardEvent(int points) { public GiftRewardEvent(int points, String zone_id) {
this.points = points; this.points = points;
this.zone_id = zone_id;
} }
} }

View File

@@ -616,7 +616,7 @@ public interface ApiServer {
@FormUrlEncoded @FormUrlEncoded
@POST(Constants.POST_ROOM_INFO) @POST(Constants.POST_ROOM_INFO)
Observable<BaseModel<RoomInfoResp>> postRoomInfo(@Field("room_id") String roomId); Call<BaseModel<RoomInfoResp>> postRoomInfo(@Field("room_id") String roomId);
@FormUrlEncoded @FormUrlEncoded
@POST(Constants.CHANGE_SONG) @POST(Constants.CHANGE_SONG)

View File

@@ -1621,7 +1621,24 @@ public class RetrofitClient {
} }
public void postRoomInfo(String roomId, BaseObserver<RoomInfoResp> observer) { public void postRoomInfo(String roomId, BaseObserver<RoomInfoResp> observer) {
sApiServer.postRoomInfo(roomId).compose(new DefaultTransformer<>()).subscribe(observer); sApiServer.postRoomInfo(roomId).enqueue(new Callback<BaseModel<RoomInfoResp>>() {
@Override
public void onResponse(Call<BaseModel<RoomInfoResp>> call, Response<BaseModel<RoomInfoResp>> response) {
if (response.code() == 200){
BaseModel<RoomInfoResp> baseModel = response.body();
if (baseModel.getCode() != 1){
observer.onNext(null);
}else {
observer.onNext(baseModel.getData());
}
}
}
@Override
public void onFailure(Call<BaseModel<RoomInfoResp>> call, Throwable t) {
}
});
} }
public void getCharmRank(String roomId, BaseObserver<List<RoomCharmRankBean>> observer) { public void getCharmRank(String roomId, BaseObserver<List<RoomCharmRankBean>> observer) {

View File

@@ -8,6 +8,7 @@ import android.widget.Toast;
import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.LogUtils;
import com.google.android.gms.common.api.Api; import com.google.android.gms.common.api.Api;
import com.hjq.toast.ToastUtils;
import com.xscm.moduleutil.utils.logger.DataLogger; import com.xscm.moduleutil.utils.logger.DataLogger;
import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttClient;
@@ -69,20 +70,21 @@ public class MqttConnect {
**/ **/
public void mqttClient() public void mqttClient()
{ {
close(); // close();
handler.postDelayed(new Runnable() { // handler.postDelayed(new Runnable() {
@Override // @Override
public void run() { // public void run() {
try { try {
// uiTip("MQTT开始连接");
MqttConnectOptions options = mqttConnectOptions(); MqttConnectOptions options = mqttConnectOptions();
mqttClient.setCallback(new MqttInitCallback(context, HOST, clientId)); mqttClient.setCallback(new MqttInitCallback(context, HOST, clientId));
mqttClient.connect(options); mqttClient.connect(options);
// sub(topic,qos); // sub(topic,qos);
sub(shutdown); sub(shutdown);
sub(update_app); sub(update_app);
uiTip("MQTT连接成功"); // uiTip("MQTT连接成功");
}catch (MqttException e){ }catch (MqttException e){
uiTip("MQTT连接失败,准备重连。。。:"+e.getMessage()); // uiTip("MQTT连接失败,准备重连。。。:"+e.getMessage());
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -91,8 +93,8 @@ public class MqttConnect {
} }
},3000); },3000);
} }
} // }
},200); // },200);
} }
/** /**
@@ -106,6 +108,7 @@ public class MqttConnect {
public void run() { public void run() {
// Toast.makeText(context.getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); // Toast.makeText(context.getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
LogUtils.e("mqtt","连接成功"); LogUtils.e("mqtt","连接成功");
ToastUtils.show(msg);
} }
}); });
} }
@@ -126,6 +129,7 @@ public class MqttConnect {
return options; return options;
} }
/** /**
* 关闭MQTT连接 * 关闭MQTT连接
*/ */
@@ -137,6 +141,7 @@ public class MqttConnect {
mqttClient = null; mqttClient = null;
} catch (MqttException e) { } catch (MqttException e) {
Log.e(Tag,"关闭MQTT连接报错"+e.getMessage()); Log.e(Tag,"关闭MQTT连接报错"+e.getMessage());
// ToastUtils.show("关闭MQTT连接报错");
} }
}else { }else {
Log.d(Tag,"Mqtt已关闭"); Log.d(Tag,"Mqtt已关闭");
@@ -180,6 +185,7 @@ public class MqttConnect {
mqttClient.subscribe(topic); mqttClient.subscribe(topic);
} catch (MqttException e) { } catch (MqttException e) {
Log.e(Tag,"MQTT主题订阅失败" + e.getMessage()); Log.e(Tag,"MQTT主题订阅失败" + e.getMessage());
// uiTip("MQTT主题订阅失败");
} }
} }

View File

@@ -7,6 +7,7 @@ import android.util.Log;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hjq.toast.ToastUtils;
import com.orhanobut.logger.Logger; import com.orhanobut.logger.Logger;
import com.xscm.moduleutil.bean.XLHBean; import com.xscm.moduleutil.bean.XLHBean;
import com.xscm.moduleutil.event.RoomGiftRunable; import com.xscm.moduleutil.event.RoomGiftRunable;
@@ -33,6 +34,7 @@ public class MqttInitCallback implements MqttCallback {
@Override @Override
public void connectionLost(Throwable cause) { public void connectionLost(Throwable cause) {
Log.d(Tag,"mqtt连接断开,执行重连"); Log.d(Tag,"mqtt连接断开,执行重连");
ToastUtils.show("mqtt连接断开,执行重连");
mqttConnect = MqttConnect.getInstance(context, HOST, clientId); mqttConnect = MqttConnect.getInstance(context, HOST, clientId);
mqttConnect.mqttClient(); mqttConnect.mqttClient();
} }
@@ -48,8 +50,10 @@ public class MqttInitCallback implements MqttCallback {
String messageStr = message.toString(); String messageStr = message.toString();
Logger.e("MQTT", "收到的消息", "主题:" + topic + " 收到的消息:" + messageStr); Logger.e("MQTT", "收到的消息", "主题:" + topic + " 收到的消息:" + messageStr);
if (topic.equals("qx_room_topic")) { if (topic.equals("qx_room_topic")) {
// ToastUtils.show("收到礼物飘屏");
receiveMessage(topic, messageStr); receiveMessage(topic, messageStr);
} else if (topic.equals("qx_xunlehui")) { } else if (topic.equals("qx_xunlehui")) {
// ToastUtils.show("收到轮盘飘屏");
receiveXlhMessage(messageStr); receiveXlhMessage(messageStr);
} }
} }
@@ -65,6 +69,7 @@ public class MqttInitCallback implements MqttCallback {
}); });
} catch (Exception e) { } catch (Exception e) {
Log.e("MQTT", "解析MQTT消息异常", e); Log.e("MQTT", "解析MQTT消息异常", e);
// ToastUtils.show("收到礼物飘屏,解析异常");
} }
} }
@@ -89,6 +94,7 @@ public class MqttInitCallback implements MqttCallback {
}); });
} catch (Exception e) { } catch (Exception e) {
Log.e("MQTT", "解析MQTT消息异常", e); Log.e("MQTT", "解析MQTT消息异常", e);
// ToastUtils.show("收到轮盘飘屏,解析异常");
} }
} }
/** /**

View File

@@ -126,7 +126,7 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener {
currentProcessingCount = Math.max(0, currentProcessingCount - 1); currentProcessingCount = Math.max(0, currentProcessingCount - 1);
// 内存检查和清理 // 内存检查和清理
if (playQueue.size() % 10 == 0) { // 每处理10个动画检查一次内存 if (playQueue.size() % 1 == 0) { // 每处理10个动画检查一次内存
performLightCleanup(); performLightCleanup();
} }

View File

@@ -70,7 +70,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
public String pitNumber; public String pitNumber;
public int pitImageVId; public int pitImageVId;
public ImageView iv_on_line; // public ImageView iv_on_line;
private boolean showGiftAnim = true;//显示麦位动画 private boolean showGiftAnim = true;//显示麦位动画
private ImageView iv_tag_type; private ImageView iv_tag_type;
@@ -99,7 +99,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
tvTime = findViewById(R.id.tv_time); tvTime = findViewById(R.id.tv_time);
tv_time_pk = findViewById(R.id.tv_time_pk); tv_time_pk = findViewById(R.id.tv_time_pk);
mTvNo = findViewById(R.id.tv_no); mTvNo = findViewById(R.id.tv_no);
iv_on_line = findViewById(R.id.iv_online); // iv_on_line = findViewById(R.id.iv_online);
iv_tag_type = findViewById(R.id.iv_tag_type); iv_tag_type = findViewById(R.id.iv_tag_type);
tv_zhul=findViewById(R.id.tv_zhul); tv_zhul=findViewById(R.id.tv_zhul);
setClipChildren(false); setClipChildren(false);
@@ -242,22 +242,11 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
if (!mIvRipple.isAnimating()) { if (!mIvRipple.isAnimating()) {
mIvRipple.startAnimation(); mIvRipple.startAnimation();
} }
iv_on_line.setVisibility(GONE); // iv_on_line.setVisibility(GONE);
// mIvRipple.setSource(getResources().getResourceName(R.raw.ripple3695), 2);
}); });
} }
// if (pitBean.getUser_id().equals(SpUtil.getUserId()) && closePhone) {
// mIvRipple.post(() -> {
// mIvRipple.setVisibility(GONE);
// });
// }
} }
// else {
// mIvRipple.post(() -> {
// mIvRipple.setVisibility(GONE);
// });
// }
} }
@@ -273,8 +262,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
if (!mIvRipple.isAnimating()) { if (!mIvRipple.isAnimating()) {
mIvRipple.startAnimation(); mIvRipple.startAnimation();
} }
iv_on_line.setVisibility(GONE); // iv_on_line.setVisibility(GONE);
// mIvRipple.setSource(getResources().getResourceName(R.raw.ripple3695), 2);
}); });
} }
@@ -284,7 +272,7 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
public void userJoined(int userId, int elapsd) { public void userJoined(int userId, int elapsd) {
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) { if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
if (pitBean.getUser_id().equals(userId + "")) { if (pitBean.getUser_id().equals(userId + "")) {
iv_on_line.setVisibility(GONE); // iv_on_line.setVisibility(GONE);
} }
} }
} }
@@ -293,16 +281,16 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
public void userOffline(int userId, int reason) { public void userOffline(int userId, int reason) {
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) { if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
if (pitBean.getUser_id().equals(userId + "")) { if (pitBean.getUser_id().equals(userId + "")) {
iv_on_line.setVisibility(VISIBLE); // iv_on_line.setVisibility(VISIBLE);
} }
}else if (pitBean.getUser_id()==null || pitBean.getUser_id().equals("0") || pitBean.getUser_id().equals("")){ }else if (pitBean.getUser_id()==null || pitBean.getUser_id().equals("0") || pitBean.getUser_id().equals("")){
iv_on_line.setVisibility(GONE); // iv_on_line.setVisibility(GONE);
} }
} }
}); });
if (pitBean.getUser_id()==null || pitBean.getUser_id().equals("0") || pitBean.getUser_id().equals("") ){ if (pitBean.getUser_id()==null || pitBean.getUser_id().equals("0") || pitBean.getUser_id().equals("") ){
iv_on_line.setVisibility(GONE); // iv_on_line.setVisibility(GONE);
} }
} }
@@ -358,9 +346,9 @@ public abstract class BaseWheatView extends ConstraintLayout implements IBaseWhe
if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) { if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
if (pitBean.getUser_id().equals(isOnline.getUser_id())) { if (pitBean.getUser_id().equals(isOnline.getUser_id())) {
if (isOnline.getIs_online() == 1) { if (isOnline.getIs_online() == 1) {
iv_on_line.setVisibility(GONE); // iv_on_line.setVisibility(GONE);
} else { } else {
iv_on_line.setVisibility(VISIBLE); // iv_on_line.setVisibility(VISIBLE);
} }
} }
} }

View File

@@ -78,6 +78,16 @@ public class CenterScrollHelper {
smoothScroller.setTargetPosition(totalItems); smoothScroller.setTargetPosition(totalItems);
recyclerView.getLayoutManager().startSmoothScroll(smoothScroller); recyclerView.getLayoutManager().startSmoothScroll(smoothScroller);
} }
// 在 CenterScrollHelper 类中添加
public void reset() {
// 清理可能存在的回调或状态
if (recyclerView != null) {
recyclerView.stopScroll();
recyclerView.getHandler().removeCallbacksAndMessages(null);
}
}
/** /**
* 使用缓动函数计算滚动时间,实现加速减速效果 * 使用缓动函数计算滚动时间,实现加速减速效果
* @param dx 滚动距离 * @param dx 滚动距离

View File

@@ -1,12 +1,21 @@
package com.xscm.moduleutil.widget; package com.xscm.moduleutil.widget;
import static com.liulishuo.okdownload.OkDownloadProvider.context;
import static android.app.PendingIntent.getActivity;
import static android.content.Context.WINDOW_SERVICE;
import static androidx.core.content.ContextCompat.getSystemService;
import static com.blankj.utilcode.util.ActivityUtils.startActivityForResult;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Build;
import android.provider.Settings;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
@@ -17,10 +26,12 @@ import android.widget.TextView;
import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.LogUtils; import com.blankj.utilcode.util.LogUtils;
import com.hjq.toast.ToastUtils;
import com.petterp.floatingx.FloatingX; import com.petterp.floatingx.FloatingX;
import com.petterp.floatingx.assist.FxGravity; import com.petterp.floatingx.assist.FxGravity;
import com.petterp.floatingx.assist.helper.FxAppHelper; import com.petterp.floatingx.assist.helper.FxAppHelper;
import com.xscm.moduleutil.R; import com.xscm.moduleutil.R;
import com.xscm.moduleutil.activity.BaseAppCompatActivity;
import com.xscm.moduleutil.bean.XLHBean; import com.xscm.moduleutil.bean.XLHBean;
import com.xscm.moduleutil.event.MqttBean; import com.xscm.moduleutil.event.MqttBean;
import com.xscm.moduleutil.utils.ARouteConstants; import com.xscm.moduleutil.utils.ARouteConstants;
@@ -47,13 +58,19 @@ public class PiaoPingManager {
private Queue<XLHBean> XLHmessageQueue = new ConcurrentLinkedQueue<>(); // 消息队列 private Queue<XLHBean> XLHmessageQueue = new ConcurrentLinkedQueue<>(); // 消息队列
private boolean isAnimating = false; // 动画状态标记 private boolean isAnimating = false; // 动画状态标记
private boolean XLHisAnimating = false; // 动画状态标记 private boolean XLHisAnimating = false; // 动画状态标记
private Context mContext; // 添加成员变量
View floatingView;
private PiaoPingManager(Context context) { private PiaoPingManager(Context context) {
windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); this.mContext = context;
windowManager = (WindowManager) context.getSystemService(WINDOW_SERVICE);
if (windowManager == null) return; if (windowManager == null) return;
// 创建飘屏消息的布局 // 创建飘屏消息的布局
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
piaoPingView = inflater.inflate(R.layout.item_piaoping, null); piaoPingView = inflater.inflate(R.layout.item_piaoping, null);
} }
public static synchronized PiaoPingManager getInstance(Context context) { public static synchronized PiaoPingManager getInstance(Context context) {
@@ -68,11 +85,12 @@ public class PiaoPingManager {
// 添加到队列 // 添加到队列
messageQueue.offer(mqttBean); messageQueue.offer(mqttBean);
// 如果当前没有动画正在进行,则开始处理 // 如果当前没有动画正在进行,则开始处理
if (!isAnimating) { // if (!isAnimating) {
processNextMessage(); processNextMessage();
} // }
} }
private void processNextMessage() { private void processNextMessage() {
if (messageQueue.isEmpty()) { if (messageQueue.isEmpty()) {
isAnimating = false; isAnimating = false;
@@ -81,65 +99,91 @@ public class PiaoPingManager {
isAnimating = true; isAnimating = true;
MqttBean mqttBean = messageQueue.poll(); MqttBean mqttBean = messageQueue.poll();
displayMessage(mqttBean); displayMessage(mqttBean);
} }
private void displayMessage(MqttBean mqttBean) { private void displayMessage(MqttBean mqttBean) {
// 获取悬浮窗视图并设置内容 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
View floatingView = LayoutInflater.from(context).inflate(R.layout.item_piaoping, new FrameLayout(context), false); WindowManager.LayoutParams params = new WindowManager.LayoutParams(
TextView textView = floatingView.findViewById(R.id.tv_name); WindowManager.LayoutParams.WRAP_CONTENT,
TextView textView2 = floatingView.findViewById(R.id.tv_to_name); WindowManager.LayoutParams.WRAP_CONTENT,
textView2.setText("送给" + mqttBean.getList().getToUserName()); WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
textView.setText(mqttBean.getList().getFromUserName()); WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), floatingView.findViewById(R.id.iv_piaoping)); PixelFormat.TRANSLUCENT
TextView tv_time = floatingView.findViewById(R.id.tv_num); );
tv_time.setText("x" + mqttBean.getList().getNumber());
ToastUtils.show("飘屏开始");
// 获取悬浮窗视图并设置内容
floatingView = LayoutInflater.from(mContext).inflate(R.layout.item_piaoping, new FrameLayout(mContext), false);
TextView textView = floatingView.findViewById(R.id.tv_name);
TextView textView2 = floatingView.findViewById(R.id.tv_to_name);
textView2.setText("送给" + mqttBean.getList().getToUserName());
textView.setText(mqttBean.getList().getFromUserName());
ImageUtils.loadHeadCC(mqttBean.getList().getGift_picture(), floatingView.findViewById(R.id.iv_piaoping));
TextView tv_time = floatingView.findViewById(R.id.tv_num);
tv_time.setText("x" + mqttBean.getList().getNumber());
ToastUtils.show("飘屏创建");
WindowManager windowManager = (WindowManager) mContext.getSystemService(WINDOW_SERVICE);
windowManager.addView(floatingView, params);
}else {
}
// 先将视图放置在屏幕右侧外部,避免闪现问题 // 先将视图放置在屏幕右侧外部,避免闪现问题
floatingView.setTranslationX(10000); // 先放到屏幕外 // floatingView.setTranslationX(10000); // 先放到屏幕外
// 在 FloatingX 配置中或者通过其他方式设置
FxAppHelper fxAppHelper = FxAppHelper.builder() // FxAppHelper fxAppHelper = FxAppHelper.builder()
.setContext(context) // .setContext(mContext)
.setLayoutView(floatingView) // .setLayoutView(floatingView)
.setGravity(FxGravity.RIGHT_OR_TOP) // .setGravity(FxGravity.RIGHT_OR_TOP)
.setX(0) // .setX(0)
.setY(100) // .setY(100)
.build(); // .build();
//
FloatingX.install(fxAppHelper).show(); // FloatingX.install(fxAppHelper).show();
ToastUtils.show("飘屏创建2");
// 首先从右侧滑入到屏幕中央 // 首先从右侧滑入到屏幕中央
floatingView.post(() -> { // floatingView.post(() -> {
// 确保初始位置在屏幕右侧外部 // // 确保初始位置在屏幕右侧外部
floatingView.setTranslationX(floatingView.getWidth()); // floatingView.setTranslationX(floatingView.getWidth());
//
// 第一阶段:从右到屏幕右侧边缘(缓慢进入) // // 第一阶段:从右到屏幕右侧边缘(缓慢进入)
ObjectAnimator animator1 = ObjectAnimator.ofFloat(floatingView, "translationX", // ObjectAnimator animator1 = ObjectAnimator.ofFloat(floatingView, "translationX",
floatingView.getWidth(), 0f); // floatingView.getWidth(), 0f);
animator1.setDuration(1500); // 延长动画时间到1.5秒 // animator1.setDuration(1500); // 延长动画时间到1.5秒
animator1.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果 // animator1.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果
animator1.start(); // animator1.start();
// ToastUtils.show("飘屏创建2第一阶段");
// 第二阶段延迟1秒后从当前位置向左滑出 // // 第二阶段延迟1秒后从当前位置向左滑出
floatingView.postDelayed(() -> { // floatingView.postDelayed(() -> {
ObjectAnimator animator2 = ObjectAnimator.ofFloat(floatingView, "translationX", // ObjectAnimator animator2 = ObjectAnimator.ofFloat(floatingView, "translationX",
0f, -floatingView.getWidth()); // 0f, -floatingView.getWidth());
animator2.setDuration(1500); // 延长动画时间到1.5秒 // animator2.setDuration(1500); // 延长动画时间到1.5秒
animator2.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果 // animator2.setInterpolator(new DecelerateInterpolator(2.0f)); // 更平缓的减速效果
animator2.addListener(new AnimatorListenerAdapter() { // animator2.addListener(new AnimatorListenerAdapter() {
@Override // @Override
public void onAnimationEnd(Animator animation) { // public void onAnimationEnd(Animator animation) {
// 动画结束后移除悬浮窗 // // 动画结束后移除悬浮窗
FloatingX.uninstallAll(); // FloatingX.uninstallAll();
// 处理下一个消息 // windowManager.removeView(floatingView);
processNextMessage(); // // 处理下一个消息
} // processNextMessage();
}); // }
animator2.start(); // });
}, 1000); // 停留1秒 // animator2.start();
}); // }, 3000); // 停留1秒
// ToastUtils.show("飘屏创建2第er阶段");
// });
ToastUtils.show("飘屏结束");
} }
public void subscribe() { public void subscribe() {
try { try {
if (!EventBus.getDefault().isRegistered(this)) { if (!EventBus.getDefault().isRegistered(this)) {
@@ -169,7 +213,7 @@ public class PiaoPingManager {
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onMessageReceived(MqttBean mqttBean) { public void onMessageReceived(MqttBean mqttBean) {
showPiaoPingMessage(mqttBean); showPiaoPingMessage(mqttBean);
ToastUtils.show("飘屏");
// FxAppHelper fxAppHelper = FxAppHelper.builder().setContext( context).setLayout(R.layout.item_piaoping).build(); // FxAppHelper fxAppHelper = FxAppHelper.builder().setContext( context).setLayout(R.layout.item_piaoping).build();
// FloatingX.install(fxAppHelper).show(); // FloatingX.install(fxAppHelper).show();
} }
@@ -199,10 +243,11 @@ public class PiaoPingManager {
XLHBean xlhBean = XLHmessageQueue.poll(); XLHBean xlhBean = XLHmessageQueue.poll();
displayMessageXlh(xlhBean); displayMessageXlh(xlhBean);
} }
@SuppressLint({"MissingInflatedId", "LocalSuppress"}) @SuppressLint({"MissingInflatedId", "LocalSuppress"})
private void displayMessageXlh(XLHBean xlhBean) { private void displayMessageXlh(XLHBean xlhBean) {
// 获取悬浮窗视图并设置内容 // 获取悬浮窗视图并设置内容
View floatingView = LayoutInflater.from(context).inflate(R.layout.item_piaoping_xlh, new FrameLayout(context), false); View floatingView = LayoutInflater.from(mContext).inflate(R.layout.item_piaoping_xlh, new FrameLayout(mContext), false);
TextView textView = floatingView.findViewById(R.id.tv_name); TextView textView = floatingView.findViewById(R.id.tv_name);
ImageView xlh_image = floatingView.findViewById(R.id.im_xlh); ImageView xlh_image = floatingView.findViewById(R.id.im_xlh);
// if (xlhBean.getFrom_type() == 1){ // if (xlhBean.getFrom_type() == 1){
@@ -211,7 +256,7 @@ public class PiaoPingManager {
// xlh_image.setImageResource(R.mipmap.xlh_zsks); // xlh_image.setImageResource(R.mipmap.xlh_zsks);
// } // }
xlh_image.setImageDrawable(xlhBean.getFrom_type() == 1 ? context.getResources().getDrawable(R.mipmap.xlh_jjks) : context.getResources().getDrawable(R.mipmap.xlh_zsks)); xlh_image.setImageDrawable(xlhBean.getFrom_type() == 1 ? mContext.getResources().getDrawable(R.mipmap.xlh_jjks) : mContext.getResources().getDrawable(R.mipmap.xlh_zsks));
textView.setText(xlhBean.getText()); textView.setText(xlhBean.getText());
@@ -219,7 +264,7 @@ public class PiaoPingManager {
floatingView.setTranslationX(10000); // 先放到屏幕外 floatingView.setTranslationX(10000); // 先放到屏幕外
FxAppHelper fxAppHelper = FxAppHelper.builder() FxAppHelper fxAppHelper = FxAppHelper.builder()
.setContext(context) .setContext(mContext)
.setLayoutView(floatingView) .setLayoutView(floatingView)
.setGravity(FxGravity.RIGHT_OR_TOP) .setGravity(FxGravity.RIGHT_OR_TOP)
.setX(0) .setX(0)

View File

@@ -22,7 +22,7 @@ public class RoomFriendshipWheatView extends BaseWheatView {
public ImageView mIvTagBoss; public ImageView mIvTagBoss;
public TextView mTvTime; public TextView mTvTime;
public ImageView iv_on_line; // public ImageView iv_on_line;
private ImageView iv_tag_type; private ImageView iv_tag_type;
public WheatCharmView mCharmView; public WheatCharmView mCharmView;
public TextView tv_zhul; public TextView tv_zhul;
@@ -51,7 +51,7 @@ public class RoomFriendshipWheatView extends BaseWheatView {
typedArray.recycle(); typedArray.recycle();
mIvTagBoss = findViewById(R.id.iv_tag_boos); mIvTagBoss = findViewById(R.id.iv_tag_boos);
mTvTime = findViewById(R.id.tv_time); mTvTime = findViewById(R.id.tv_time);
iv_on_line = findViewById(R.id.iv_online); // iv_on_line = findViewById(R.id.iv_online);
iv_tag_type = findViewById(R.id.iv_tag_type); iv_tag_type = findViewById(R.id.iv_tag_type);
mCharmView = findViewById(R.id.charm_view); mCharmView = findViewById(R.id.charm_view);
mRiv.setImageResource(pitImageVId); mRiv.setImageResource(pitImageVId);
@@ -281,9 +281,9 @@ public class RoomFriendshipWheatView extends BaseWheatView {
if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) { if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
if (pitBean.getUser_id().equals(isOnline.getUser_id())) { if (pitBean.getUser_id().equals(isOnline.getUser_id())) {
if (isOnline.getIs_online() == 1) { if (isOnline.getIs_online() == 1) {
iv_on_line.setVisibility(GONE); // iv_on_line.setVisibility(GONE);
} else { } else {
iv_on_line.setVisibility(VISIBLE); // iv_on_line.setVisibility(VISIBLE);
} }
} }
} }

View File

@@ -237,7 +237,7 @@ public class RoomKtvWheatView extends BaseWheatView {
public void userJoined(int userId, int elapsd) { public void userJoined(int userId, int elapsd) {
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) { if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
if (pitBean.getUser_id().equals(userId + "")) { if (pitBean.getUser_id().equals(userId + "")) {
iv_on_line.setVisibility(GONE); // iv_on_line.setVisibility(GONE);
} }
} }
} }
@@ -246,7 +246,7 @@ public class RoomKtvWheatView extends BaseWheatView {
public void userOffline(int userId, int reason) { public void userOffline(int userId, int reason) {
if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) { if (pitBean != null && pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0")) {
if (pitBean.getUser_id().equals(userId + "")) { if (pitBean.getUser_id().equals(userId + "")) {
iv_on_line.setVisibility(VISIBLE); // iv_on_line.setVisibility(VISIBLE);
} }
} }
} }

View File

@@ -19,7 +19,7 @@ public class RoomMakeWheatView extends BaseWheatView {
public ImageView mIvTagBoss; public ImageView mIvTagBoss;
public TextView mTvTime; public TextView mTvTime;
public ImageView iv_zhul; public ImageView iv_zhul;
public ImageView iv_on_line; // public ImageView iv_on_line;
private ImageView iv_tag_type; private ImageView iv_tag_type;
public WheatCharmView mCharmView; public WheatCharmView mCharmView;
private boolean showBoss;//显示老板标识 private boolean showBoss;//显示老板标识
@@ -47,7 +47,7 @@ public class RoomMakeWheatView extends BaseWheatView {
typedArray.recycle(); typedArray.recycle();
mIvTagBoss = findViewById(R.id.iv_tag_boos); mIvTagBoss = findViewById(R.id.iv_tag_boos);
mTvTime = findViewById(R.id.tv_time); mTvTime = findViewById(R.id.tv_time);
iv_on_line=findViewById(R.id.iv_online); // iv_on_line=findViewById(R.id.iv_online);
iv_tag_type=findViewById(R.id.iv_tag_type); iv_tag_type=findViewById(R.id.iv_tag_type);
mCharmView = findViewById(R.id.charm_view); mCharmView = findViewById(R.id.charm_view);
mRiv.setImageResource(pitImageVId); mRiv.setImageResource(pitImageVId);
@@ -204,9 +204,9 @@ public class RoomMakeWheatView extends BaseWheatView {
if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) { if (pitBean.getUser_id() != null && !pitBean.getUser_id().equals("0") && !pitBean.getUser_id().isEmpty()) {
if (pitBean.getUser_id().equals(isOnline.getUser_id())) { if (pitBean.getUser_id().equals(isOnline.getUser_id())) {
if (isOnline.getIs_online() == 1) { if (isOnline.getIs_online() == 1) {
iv_on_line.setVisibility(GONE); // iv_on_line.setVisibility(GONE);
} else { } else {
iv_on_line.setVisibility(VISIBLE); // iv_on_line.setVisibility(VISIBLE);
} }
} }
} }

View File

@@ -46,7 +46,7 @@ public class RoomSingWheatView extends LinearLayout {
public String pitNumber; public String pitNumber;
public int pitImageVId; public int pitImageVId;
public ImageView iv_on_line; // public ImageView iv_on_line;
private boolean showGiftAnim = true;//显示麦位动画 private boolean showGiftAnim = true;//显示麦位动画
private ImageView iv_tag_type; private ImageView iv_tag_type;
@@ -82,7 +82,7 @@ public class RoomSingWheatView extends LinearLayout {
tvTime = findViewById(R.id.tv_time); tvTime = findViewById(R.id.tv_time);
tv_time_pk = findViewById(R.id.tv_time_pk); tv_time_pk = findViewById(R.id.tv_time_pk);
mTvNo = findViewById(R.id.tv_no); mTvNo = findViewById(R.id.tv_no);
iv_on_line = findViewById(R.id.iv_online); // iv_on_line = findViewById(R.id.iv_online);
iv_tag_type = findViewById(R.id.iv_tag_type); iv_tag_type = findViewById(R.id.iv_tag_type);
tv_zhul = findViewById(R.id.tv_zhul); tv_zhul = findViewById(R.id.tv_zhul);

View File

@@ -243,17 +243,17 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPr
} }
} }
if (currentItem == 0) { // if (currentItem == 0) {
//礼物打赏 //礼物打赏
giftNumber = num; giftNumber = num;
MvpPre.reward_zone(circle_id, roonGiftModel.getGift_id(), num, "1"); MvpPre.reward_zone(circle_id, roonGiftModel.getGift_id(), num, "1");
} else { // } else {
//背包礼物打赏 //背包礼物打赏
// giftNumber = num; // giftNumber = num;
// roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 1, giftModel, null); // roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 1, giftModel, null);
// //
// MvpPre.giveBackGift(userId, giftModel.getGift_id(), roomId, pit, num, giftModel, 1); // MvpPre.giveBackGift(userId, giftModel.getGift_id(), roomId, pit, num, giftModel, 1);
} // }
} }
@Override @Override
public void setGiftList(List<RoonGiftModel> roonGiftModels,int type) { public void setGiftList(List<RoonGiftModel> roonGiftModels,int type) {
@@ -273,7 +273,7 @@ public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPr
@Override @Override
public void reward_zone() { public void reward_zone() {
com.blankj.utilcode.util.ToastUtils.showShort("打赏成功"); com.blankj.utilcode.util.ToastUtils.showShort("打赏成功");
EventBus.getDefault().post(new GiftRewardEvent(point)); EventBus.getDefault().post(new GiftRewardEvent(point,circle_id));
dismiss(); dismiss();
} }

View File

@@ -12,7 +12,10 @@
android:id="@+id/lottery_buttons_layout" android:id="@+id/lottery_buttons_layout"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10" android:layout_marginStart="@dimen/dp_10"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_20"
android:gravity="center" android:gravity="center"
android:orientation="horizontal" android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@+id/ll_yx" app:layout_constraintTop_toBottomOf="@+id/ll_yx"

View File

@@ -246,7 +246,6 @@
app:layout_constraintEnd_toEndOf="@+id/gift_l3" app:layout_constraintEnd_toEndOf="@+id/gift_l3"
app:layout_constraintTop_toTopOf="@+id/gift_l3" app:layout_constraintTop_toTopOf="@+id/gift_l3"
android:layout_marginTop="@dimen/dp_2" android:layout_marginTop="@dimen/dp_2"
android:src="@mipmap/ic_launcher"
android:scaleType="fitCenter"/> android:scaleType="fitCenter"/>
<ImageView <ImageView
@@ -277,12 +276,29 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycle_view" android:id="@+id/recycle_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="@dimen/dp_200"
android:layout_marginBottom="@dimen/dp_15" android:layout_marginBottom="@dimen/dp_15"
android:orientation="horizontal" android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintTop_toBottomOf="@+id/cl_gift" app:layout_constraintTop_toBottomOf="@+id/cl_gift"
app:layout_constraintBottom_toTopOf="@+id/exchange_layout"/> app:layout_constraintBottom_toTopOf="@+id/exchange_layout"
/>
<!-- <HorizontalScrollView-->
<!-- android:id="@+id/horizontalScrollView"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="@dimen/dp_200"-->
<!-- android:scrollbars="none"-->
<!-- app:layout_constraintTop_toBottomOf="@+id/cl_gift"-->
<!-- app:layout_constraintBottom_toTopOf="@+id/exchange_layout">-->
<!-- <LinearLayout-->
<!-- android:id="@+id/prizeContainer"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal" />-->
<!-- </HorizontalScrollView>-->
<TextView <TextView
android:id="@+id/tv_option" android:id="@+id/tv_option"

View File

@@ -73,7 +73,19 @@
app:layout_constraintRight_toRightOf="@+id/iv_gift_pic" app:layout_constraintRight_toRightOf="@+id/iv_gift_pic"
app:layout_constraintTop_toBottomOf="@+id/tv_gift_name" /> app:layout_constraintTop_toBottomOf="@+id/tv_gift_name" />
<TextView
android:id="@+id/integral"
android:layout_width="@dimen/dp_35"
android:layout_height="@dimen/dp_13"
android:layout_gravity="center_horizontal"
android:background="@mipmap/text_bj"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:gravity="center"
android:text="x30"
android:textColor="@color/color_FF333333"
android:textSize="@dimen/sp_10"
android:visibility="gone"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -18,13 +18,13 @@
android:id="@+id/tv_name" android:id="@+id/tv_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="60dp" android:layout_marginStart="40dp"
android:layout_marginEnd="@dimen/dp_2" android:layout_marginEnd="@dimen/dp_2"
android:ellipsize="start" android:ellipsize="start"
android:maxLines="1" android:maxLines="1"
android:text="礼品" android:text="礼品"
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="14sp" android:textSize="@dimen/sp_12"
android:textStyle="bold" android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"

View File

@@ -44,5 +44,17 @@
app:layout_constraintTop_toBottomOf="@+id/tv_gift_name" app:layout_constraintTop_toBottomOf="@+id/tv_gift_name"
app:layout_constraintEnd_toEndOf="@+id/tv_gift_name"/> app:layout_constraintEnd_toEndOf="@+id/tv_gift_name"/>
<ImageView
android:id="@+id/selected_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/xlh_xz"
app:layout_constraintStart_toStartOf="@+id/iv_gift_image"
app:layout_constraintEnd_toEndOf="@id/iv_gift_image"
app:layout_constraintTop_toTopOf="@+id/iv_gift_image"
app:layout_constraintBottom_toBottomOf="@id/iv_gift_image"
android:visibility="gone"
/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -187,7 +187,9 @@ public class DynamicDetailActivity extends BaseMvpActivity<CirclePresenter, Acti
} }
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(GiftRewardEvent event) { public void onEvent(GiftRewardEvent event) {
cirleListAdapter.notifyItemChanged(event.getPoints());
MvpPre.topicId(zone_id, 2);
// cirleListAdapter.notifyItemChanged(event.getPoints());
} }
private void onClick(View view) { private void onClick(View view) {
if (view.getId() == R.id.tv_send) { if (view.getId() == R.id.tv_send) {

View File

@@ -154,11 +154,30 @@ public class DynamicListActivity extends BaseMvpActivity<CirclePresenter, Activi
@Override @Override
public void setCircleDetail(CircleListBean bean) { public void setCircleDetail(CircleListBean bean) {
// 更新列表中的单个数据项(仅更新特定字段)
if (cirleListAdapter != null && bean != null) {
List<CircleListBean> dataList = cirleListAdapter.getData();
if (dataList != null) {
// 查找并更新对应的项
for (int i = 0; i < dataList.size(); i++) {
CircleListBean item = dataList.get(i);
// 根据ID匹配需要更新的项
if (item.getId() == bean.getId()) {
// 只更新特定字段
item.setRewards_num(bean.getRewards_num());
// 可以继续更新其他需要的字段
// 局部刷新该位置的数据
cirleListAdapter.notifyItemChanged(i);
break;
}
}
}
}
} }
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(GiftRewardEvent event) { public void onEvent(GiftRewardEvent event) {
cirleListAdapter.notifyItemChanged(event.getPoints()); MvpPre.topicId(event.getZone_id(), 2);
// cirleListAdapter.notifyItemChanged(event.getPoints());
} }
@Override @Override
public void getCommentList(CommentBean commentBean) { public void getCommentList(CommentBean commentBean) {

View File

@@ -57,8 +57,8 @@ public class CircleCategoryFragment extends BaseMvpFragment<CirclePresenter, Fra
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
page=1;
MvpPre.getCategories(); MvpPre.getCategories();
MvpPre.getCircleList("1", "10"); MvpPre.getCircleList("1", "10");
} }
@@ -187,7 +187,7 @@ public class CircleCategoryFragment extends BaseMvpFragment<CirclePresenter, Fra
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(GiftRewardEvent event) { public void onEvent(GiftRewardEvent event) {
cirleListAdapter.notifyItemChanged(event.getPoints()-1); MvpPre.topicId(event.getZone_id(), 2);
} }
private IIndicator getVectorDrawableIndicator() { private IIndicator getVectorDrawableIndicator() {
int dp6 = getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_6); int dp6 = getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_6);
@@ -247,6 +247,25 @@ public class CircleCategoryFragment extends BaseMvpFragment<CirclePresenter, Fra
@Override @Override
public void setCircleDetail(CircleListBean bean) { public void setCircleDetail(CircleListBean bean) {
// 更新列表中的单个数据项(仅更新特定字段)
if (cirleListAdapter != null && bean != null) {
List<CircleListBean> dataList = cirleListAdapter.getData();
if (dataList != null) {
// 查找并更新对应的项
for (int i = 0; i < dataList.size(); i++) {
CircleListBean item = dataList.get(i);
// 根据ID匹配需要更新的项
if (item.getId() == bean.getId()) {
// 只更新特定字段
item.setRewards_num(bean.getRewards_num());
// 可以继续更新其他需要的字段
// 局部刷新该位置的数据
cirleListAdapter.notifyItemChanged(i);
break;
}
}
}
}
} }
@Override @Override

View File

@@ -60,7 +60,7 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_bar_layout" app:layout_constraintTop_toBottomOf="@id/app_bar_layout"
app:srlEnableLoadMore="true" app:srlEnableLoadMore="true"
app:srlEnableRefresh="false"> app:srlEnableRefresh="true">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -339,6 +339,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
sActivityRef = new WeakReference<>(this); sActivityRef = new WeakReference<>(this);
SpUtil.saveMyRoomId(roomId); SpUtil.saveMyRoomId(roomId);
MessageListenerSingleton.getInstance().joinGroup(roomId);
// MvpPre.getRoomIn(roomId, password); // MvpPre.getRoomIn(roomId, password);
// MvpPre.getRoomOnline(roomId, "1", "10"); // MvpPre.getRoomOnline(roomId, "1", "10");
// 在子线程中执行网络请求 // 在子线程中执行网络请求
@@ -1286,7 +1287,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
} }
} else { } else {
updateCharmForAllPitBeans(""); updateCharmForAllPitBeans("");
roomFragment.updateSeatViewExchangedWithPitArray(mRoomInfoResp); roomFragment.upFriendList(mRoomInfoResp.getRoom_info().getPit_list());
} }
@@ -2208,7 +2209,7 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
Log.e("Fragment", "Fragment transaction skipped due to state loss."); Log.e("Fragment", "Fragment transaction skipped due to state loss.");
} }
LogUtils.e("加入", roomId); LogUtils.e("加入", roomId);
MessageListenerSingleton.getInstance().joinGroup(roomId);
CommonAppContext.getInstance().isPlaying = true; CommonAppContext.getInstance().isPlaying = true;
CommonAppContext.getInstance().playId = roomId; CommonAppContext.getInstance().playId = roomId;
CommonAppContext.getInstance().playName = mRoomBean.getRoom_name(); CommonAppContext.getInstance().playName = mRoomBean.getRoom_name();
@@ -2521,7 +2522,8 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
} }
// 添加成员变量来跟踪前后台状态
private boolean isInBackground = false;
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
@@ -2529,7 +2531,23 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
CommonAppContext.getInstance().isPlaying = true; CommonAppContext.getInstance().isPlaying = true;
// 延迟调整布局,确保视图已经完全加载 // 延迟调整布局,确保视图已经完全加载
mBinding.mainContentContainer.post(this::adjustLayoutHeights); mBinding.mainContentContainer.post(this::adjustLayoutHeights);
// MvpPre.postRoomInfo(roomId);
// 检查是否从后台返回
if (isInBackground) {
isInBackground = false;
// 从后台回到前台时调用
if (MvpPre != null && roomId != null) {
MvpPre.postRoomInfo(roomId);
}
}
}
@Override
protected void onStop() {
super.onStop();
// 判断应用是否进入后台
isInBackground = true;
} }
@Override @Override
@@ -2652,6 +2670,14 @@ public class RoomActivity extends BaseMvpActivity<RoomPresenter, ActivityRoomBin
@Override @Override
public void postRoomInfo(RoomInfoResp resp) { public void postRoomInfo(RoomInfoResp resp) {
if (resp == null){
ARouter.getInstance().build(ARouteConstants.ME)
.withFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.navigation();
cleanupResources();
finish();
return;
}
this.mRoomInfoResp = resp; this.mRoomInfoResp = resp;
RoomBean roomBean = resp.getRoom_info(); RoomBean roomBean = resp.getRoom_info();
this.mRoomBean = roomBean; this.mRoomBean = roomBean;

View File

@@ -494,55 +494,53 @@ public class RoomGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPres
return; return;
} }
} }
if (roonGiftModel != null && roonGiftModel.getGift_id() != null) {
if (currentItem != 0) {
//礼物打赏
giftNumber = num;
if (currentItem != 0) { if (userInfo != null) {
//礼物打赏 if (userInfo.getPit_number() != null) {
giftNumber = num; if (userInfo.getPit_number().equals("888") || userInfo.getPit_number().equals("")) {
if (userInfo.getPit_number().isEmpty() || jingp != 1) {
if (userInfo != null) { roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, "");
if (userInfo.getPit_number() != null) { MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", pit, "");
if (userInfo.getPit_number().equals("888") || userInfo.getPit_number().equals("")) { } else {
if (userInfo.getPit_number().isEmpty() || jingp != 1) { roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, userInfo.getAuction_id());
roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, ""); EventBus.getDefault().post(roomGiftGiveEvent);
MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", pit, ""); roomGiftGiveEvent = null;
MvpPre.roomAuctionJoin(userInfo.getAuction_id(), userInfo.getUser_id() + "", roonGiftModel.getGift_id(), num, "1");
dismiss();
}
} else { } else {
roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, userInfo.getAuction_id()); roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, "");
EventBus.getDefault().post(roomGiftGiveEvent); MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", pit, heart_id);
roomGiftGiveEvent = null;
MvpPre.roomAuctionJoin(userInfo.getAuction_id(), userInfo.getUser_id() + "", roonGiftModel.getGift_id(), num, "1");
dismiss();
} }
} else { } else {
roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, ""); roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, "");
MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", pit, heart_id); MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", pit, "");
} }
} else { } else {
if (all) {
MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", null, "");
} else {
MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", pit, "");
}
roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, ""); roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, "");
MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", pit, "");
} }
} else if (currentItem == 0) {
giftNumber = num;
MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "2", pit, heart_id);
} else { } else {
if (all) { //背包礼物打赏
MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", null, "");
} else {
MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", pit, "");
}
roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 0, null, roonGiftModel, heart_id, "");
}
} else if (currentItem == 0) {
// if (all) {
// MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", null);
// } else {
// MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "1", pit);
// }
giftNumber = num;
// roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 1, giftModel, null);
MvpPre.roomGift(roomId, roonGiftModel.getGift_id(), giftNumber, userId, "2", pit, heart_id);
} else {
//背包礼物打赏
// giftNumber = num; // giftNumber = num;
// roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 1, giftModel, null); // roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 1, giftModel, null);
// //
// MvpPre.giveBackGift(userId, giftModel.getGift_id(), roomId, pit, num, giftModel, 1); // MvpPre.giveBackGift(userId, giftModel.getGift_id(), roomId, pit, num, giftModel, 1);
}
} else {
ToastUtils.show("数据错误");
dismiss();
} }
} }
@@ -588,7 +586,10 @@ public class RoomGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPres
EventBus.getDefault().post(roomGiftGiveEvent); EventBus.getDefault().post(roomGiftGiveEvent);
roomGiftGiveEvent = null; roomGiftGiveEvent = null;
dismiss(); dismiss();
return;
} }
dismiss();
} }
@Override @Override

View File

@@ -260,6 +260,25 @@ public class FriendshipRoomFragment extends BaseRoomFragment<FriendshipRoomPrese
} }
public void upFriendList(){
mBinding.wheatView1.pitBean.setCharm("0");
mBinding.wheatView1.setData(mBinding.wheatView1.pitBean);
mBinding.wheatView2.pitBean.setCharm("0");
mBinding.wheatView2.setData(mBinding.wheatView2.pitBean);
mBinding.wheatView3.pitBean.setCharm("0");
mBinding.wheatView3.setData(mBinding.wheatView3.pitBean);
mBinding.wheatView4.pitBean.setCharm("0");
mBinding.wheatView4.setData(mBinding.wheatView4.pitBean);
mBinding.wheatView5.pitBean.setCharm("0");
mBinding.wheatView5.setData(mBinding.wheatView5.pitBean);
mBinding.wheatView6.pitBean.setCharm("0");
mBinding.wheatView6.setData(mBinding.wheatView6.pitBean);
mBinding.wheatView9.pitBean.setCharm("0");
mBinding.wheatView9.setData(mBinding.wheatView9.pitBean);
mBinding.wheatView10.pitBean.setCharm("0");
mBinding.wheatView10.setData(mBinding.wheatView10.pitBean);
}
/** /**
* 处理空麦位点击 * 处理空麦位点击
*/ */

View File

@@ -367,6 +367,13 @@ public class RoomFragment extends BaseMvpFragment<RoomPresenter, FragmentRoomBin
friendshipRoomFragment.friendSeatDidChanged(pitArr); friendshipRoomFragment.friendSeatDidChanged(pitArr);
} }
public void upFriendList(List<RoomPitBean> pitArr){
FriendshipRoomFragment friendshipRoomFragment = findFragmentByTag(FriendshipRoomFragment.class);
if (friendshipRoomFragment != null) {
friendshipRoomFragment.upFriendList();
}
}
/// 小黑屋修改倒计时 /// 小黑屋修改倒计时
public void upCabinFragment(long time) { public void upCabinFragment(long time) {
RoomCabinFragment roomCabinFragment = findFragmentByTag(RoomCabinFragment.class); RoomCabinFragment roomCabinFragment = findFragmentByTag(RoomCabinFragment.class);

View File

@@ -218,17 +218,23 @@ public class RoomPresenter extends BasePresenter<RoomContacts.View> implements R
@Override @Override
public void onNext(RoomInfoResp roomInfoResp) { public void onNext(RoomInfoResp roomInfoResp) {
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
String token = roomInfoResp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
String roomId = roomInfoResp.getRoom_info().getRoom_id(); // 房间 ID
String rtm_token=roomInfoResp.getUser_info().getAgora_rtm_token();
SpUtil.setRtmToken(rtm_token);
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
boolean enableMic = false; // 是否开启麦克风
if (MvpRef==null){ if (MvpRef==null){
MvpRef=new WeakReference<>(mView); MvpRef=new WeakReference<>(mView);
} }
MvpRef.get().postRoomInfo(roomInfoResp); if (roomInfoResp==null){
MvpRef.get().postRoomInfo(null);
}else {
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
String token = roomInfoResp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
String roomId = roomInfoResp.getRoom_info().getRoom_id(); // 房间 ID
String rtm_token = roomInfoResp.getUser_info().getAgora_rtm_token();
SpUtil.setRtmToken(rtm_token);
int uid = SpUtil.getUserId(); // 0 表示由 Agora 自动生成 UID
boolean enableMic = false; // 是否开启麦克风
MvpRef.get().postRoomInfo(roomInfoResp);
}
} }
}); });
} }

View File

@@ -12,11 +12,13 @@ import com.xscm.moduleutil.http.BaseObserver;
import com.xscm.moduleutil.rtc.AgoraManager; import com.xscm.moduleutil.rtc.AgoraManager;
import com.xscm.moduleutil.utils.SpUtil; import com.xscm.moduleutil.utils.SpUtil;
import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View> implements SingSongContacts.IEmotionRoomPre { public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View> implements SingSongContacts.IEmotionRoomPre {
private SingSongContacts.View mView;
public SingSongPresenter(SingSongContacts.View view, Context context) { public SingSongPresenter(SingSongContacts.View view, Context context) {
super(view, context); super(view, context);
} }
@@ -31,6 +33,9 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
@Override @Override
public void onNext(String s) { public void onNext(String s) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().applyPit(); MvpRef.get().applyPit();
} }
}); });
@@ -46,6 +51,9 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
@Override @Override
public void onNext(String string) { public void onNext(String string) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().setMutePit(pitNumber, is_mute); MvpRef.get().setMutePit(pitNumber, is_mute);
} }
}); });
@@ -61,6 +69,9 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
@Override @Override
public void onNext(String string) { public void onNext(String string) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().setLockPit(pitNumber, is_lock); MvpRef.get().setLockPit(pitNumber, is_lock);
} }
}); });
@@ -77,6 +88,9 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
@Override @Override
public void onNext(RoomInfoResp roomInfoResp) { public void onNext(RoomInfoResp roomInfoResp) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId(); String appId = CommonAppContext.getInstance().getCurrentEnvironment().getSwSdkAppId();
String token = roomInfoResp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要 String token = roomInfoResp.getUser_info().getAgora_token(); // 如果启用了鉴权才需要
String roomId = roomInfoResp.getRoom_info().getRoom_id(); // 房间 ID String roomId = roomInfoResp.getRoom_info().getRoom_id(); // 房间 ID
@@ -114,6 +128,9 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
@Override @Override
public void onNext(String s) { public void onNext(String s) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().endPk(); MvpRef.get().endPk();
} }
}); });
@@ -129,6 +146,9 @@ public class SingSongPresenter extends BaseRoomPresenter<SingSongContacts.View>
@Override @Override
public void onNext(List<UserOnlineStatusBean> userOnlineStatusBean) { public void onNext(List<UserOnlineStatusBean> userOnlineStatusBean) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().userOnlineStatus(userOnlineStatusBean); MvpRef.get().userOnlineStatus(userOnlineStatusBean);
} }
}); });

View File

@@ -51,79 +51,18 @@ public class CurrencyExchangeActivity extends BaseMvpActivity<CurrencyExchangePr
mBinding.t5.setOnClickListener(new View.OnClickListener() { mBinding.t5.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (walletBean == null){
return;
}
float earnings_num = Float.parseFloat(walletBean.getEarnings());
int earnings_num_int = (int) Math.floor(earnings_num);
// 获取 earnings 值 // 获取 earnings 值
String earnings = truncateToFirstDecimalPlace(walletBean.getEarnings()); mBinding.etCustomAmount.setText(earnings_num_int+"");
mBinding.etCustomAmount.setText(earnings);
} }
}); });
TextInputEditText etCustomAmount = mBinding.etCustomAmount;
// 限制只能输入数字和小数点后一位
etCustomAmount.setKeyListener(DigitsKeyListener.getInstance("0123456789."));
etCustomAmount.setFilters(new InputFilter[]{ (source, start, end, dest, dstart, dend) -> {
// 防止输入负号
if (source.toString().contains("-")) {
return "";
}
String newText = dest.toString().substring(0, dstart) + source.toString() + dest.toString().substring(dend);
// 检查小数点
if (newText.contains(".")) {
String[] splitResult = newText.split("\\.");
if (splitResult.length > 1 && splitResult[1].length() > 1) {
// 小数点后只能有一位
return "";
}
}
// 可选:限制最大长度
if (newText.length() > 10) {
return "";
}
return null;
}});
// 可选:添加 TextWatcher 来监听输入内容变化
etCustomAmount.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
@Override
public void afterTextChanged(Editable s) {
// 如果以小数点开头,自动补 0
if (s.toString().startsWith(".")) {
s.insert(0, "0");
}
// 如果以多个 0 开头,只保留一个
if (s.toString().startsWith("0") && s.toString().length() > 1 && s.toString().charAt(1) != '.') {
s.delete(0, 1);
}
}
});
} }
private String truncateToFirstDecimalPlace(String value) {
if (TextUtils.isEmpty(value)) return "0.0";
int dotIndex = value.indexOf('.');
if (dotIndex == -1) {
return value + ".0"; // 没有小数点,默认加 .0
}
String integerPart = value.substring(0, dotIndex);
String decimalPart = value.substring(dotIndex + 1);
if (decimalPart.length() >= 1) {
return integerPart + "." + decimalPart.charAt(0); // 只取小数点后一位
} else {
return integerPart + ".0"; // 小数点后为空,默认加 0
}
}
@Override @Override
protected int getLayoutId() { protected int getLayoutId() {
@@ -139,6 +78,7 @@ public class CurrencyExchangeActivity extends BaseMvpActivity<CurrencyExchangePr
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
MvpPre.wallet(); MvpPre.wallet();
MvpPre.getWalletConfig();
} }
@Override @Override

View File

@@ -116,7 +116,7 @@
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:hint="请输入需要兑换的钻石数量" android:hint="请输入需要兑换的钻石数量"
android:textColorHint="@color/color_FF999999" android:textColorHint="@color/color_FF999999"
android:inputType="number|numberDecimal" android:inputType="number"
android:textSize="@dimen/sp_14"/> android:textSize="@dimen/sp_14"/>
<TextView <TextView

View File

@@ -8,62 +8,61 @@
android:layout_marginEnd="@dimen/dp_16" android:layout_marginEnd="@dimen/dp_16"
android:layout_marginBottom="@dimen/dp_10"> android:layout_marginBottom="@dimen/dp_10">
<RelativeLayout <com.xscm.moduleutil.widget.GifAvatarOvalView
android:layout_width="match_parent" android:id="@+id/task_pic"
android:layout_width="@dimen/dp_40"
android:layout_height="@dimen/dp_40"
android:scaleType="fitCenter"
android:src="@mipmap/task_lock"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/task_name"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"> android:layout_marginStart="@dimen/dp_2"
android:layout_marginEnd="@dimen/dp_8"
android:text="任务名称"
android:textColor="@color/color_FF333333"
android:textSize="@dimen/sp_14"
android:maxLines="2"
android:ellipsize="end"
app:layout_constraintEnd_toStartOf="@+id/task_type"
app:layout_constraintStart_toEndOf="@id/task_pic"
app:layout_constraintTop_toTopOf="parent" />
<com.xscm.moduleutil.widget.GifAvatarOvalView <TextView
android:id="@+id/task_pic" android:id="@+id/task_jb"
android:layout_width="@dimen/dp_40" android:layout_width="wrap_content"
android:layout_height="@dimen/dp_40" android:layout_height="@dimen/dp_21"
android:layout_alignParentStart="true" android:layout_marginStart="@dimen/dp_2"
android:layout_centerInParent="true" android:text="金币"
android:src="@mipmap/task_lock" android:textColor="@color/color_FF999999"
android:scaleType="fitCenter"/> android:textSize="@dimen/sp_14"
app:layout_constraintStart_toEndOf="@id/task_pic"
app:layout_constraintTop_toBottomOf="@id/task_name" />
<TextView <TextView
android:id="@+id/task_name" android:id="@+id/task_jb_number"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="@dimen/dp_21" android:layout_height="@dimen/dp_21"
android:layout_marginStart="@dimen/dp_2" android:layout_marginStart="@dimen/dp_4"
android:layout_toEndOf="@id/task_pic" android:text="+10"
android:text="任务名称" android:textColor="#FF8827"
android:textColor="@color/color_FF333333" android:textSize="@dimen/sp_14"
android:textSize="@dimen/sp_14" /> app:layout_constraintStart_toEndOf="@id/task_jb"
app:layout_constraintTop_toBottomOf="@id/task_name" />
<TextView <TextView
android:id="@+id/task_jb" android:id="@+id/task_type"
android:layout_width="wrap_content" android:layout_width="@dimen/dp_60"
android:layout_height="@dimen/dp_21" android:layout_height="@dimen/dp_30"
android:layout_below="@id/task_name" android:gravity="center"
android:layout_marginStart="@dimen/dp_2" android:textColor="#C134EE"
android:layout_toEndOf="@id/task_pic" android:background="@drawable/bg_r99_e24171"
android:text="金币" app:layout_constraintEnd_toEndOf="parent"
android:textColor="@color/color_FF999999" app:layout_constraintTop_toTopOf="parent"
android:textSize="@dimen/sp_14" /> app:layout_constraintBottom_toBottomOf="parent" />
<TextView </androidx.constraintlayout.widget.ConstraintLayout>
android:id="@+id/task_jb_number"
android:layout_width="wrap_content"
android:layout_height="@dimen/dp_21"
android:layout_below="@id/task_name"
android:layout_toEndOf="@id/task_jb"
android:text="+10"
android:textColor="#FF8827"
android:textSize="@dimen/sp_14" />
<TextView
android:id="@+id/task_type"
android:layout_width="@dimen/dp_60"
android:layout_height="@dimen/dp_30"
android:layout_alignParentEnd="true"
android:layout_centerInParent="true"
android:gravity="center"
android:textColor="#C134EE"
android:background="@drawable/bg_r99_e24171" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -364,7 +364,7 @@ public class PlaceholderFragment extends BaseMvpFragment<PlaceholderPresenter, F
if (type.equals("0")) { if (type.equals("0")) {
tvUsername1.setText(data.getRoom_name()); tvUsername1.setText(data.getRoom_name());
ImageUtils.loadHeadCC(data.getRoom_cover(), imUser1); ImageUtils.loadHeadCC(data.getRoom_cover(), imUser1);
tvId1.setText(data.getRoom_id() != null ? "ID:" + data.getRoom_id() : ""); tvId1.setText(data.getRoom_number() != null ? "ID:" + data.getRoom_number() : "");
imUser1.setOnClickListener(new View.OnClickListener() { imUser1.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@@ -374,7 +374,7 @@ public class PlaceholderFragment extends BaseMvpFragment<PlaceholderPresenter, F
} else if (type.equals("1") || type.equals("2")) { } else if (type.equals("1") || type.equals("2")) {
tvUsername1.setText(data.getNickname()); tvUsername1.setText(data.getNickname());
ImageUtils.loadHeadCC(data.getAvatar(), imUser1); ImageUtils.loadHeadCC(data.getAvatar(), imUser1);
tvId1.setText(data.getUser_id() != null ? "ID:" + data.getUser_id() : ""); tvId1.setText(data.getUser_code() != null ? "ID:" + data.getUser_code() : "");
} else if (type.equals("3")) { } else if (type.equals("3")) {
tvUsername1.setText(data.getGuild_name()); tvUsername1.setText(data.getGuild_name());
ImageUtils.loadHeadCC(data.getCover(), imUser1); ImageUtils.loadHeadCC(data.getCover(), imUser1);
@@ -383,7 +383,7 @@ public class PlaceholderFragment extends BaseMvpFragment<PlaceholderPresenter, F
ImageUtils.loadHeadCC(data.getUser_avatar(), ivOneCp1Hhead); ImageUtils.loadHeadCC(data.getUser_avatar(), ivOneCp1Hhead);
ImageUtils.loadHeadCC(data.getUser_avatar1(), ivOneCp2Hhead); ImageUtils.loadHeadCC(data.getUser_avatar1(), ivOneCp2Hhead);
tvUsername1.setText(data.getNickname()); tvUsername1.setText(data.getNickname());
tvId1.setText(data.getUser_id1()); tvId1.setText(data.getNickname1());
} }
} }
@@ -417,11 +417,11 @@ public class PlaceholderFragment extends BaseMvpFragment<PlaceholderPresenter, F
if (type.equals("0")) { if (type.equals("0")) {
tvUsername2.setText(data.getRoom_name()); tvUsername2.setText(data.getRoom_name());
ImageUtils.loadHeadCC(data.getRoom_cover(), imUser2); ImageUtils.loadHeadCC(data.getRoom_cover(), imUser2);
tvId2.setText(data.getRoom_id() != null ? "ID:" + data.getRoom_id() : ""); tvId2.setText(data.getRoom_number() != null ? "ID:" + data.getRoom_number() : "");
} else if (type.equals("1") || type.equals("2")) { } else if (type.equals("1") || type.equals("2")) {
tvUsername2.setText(data.getNickname()); tvUsername2.setText(data.getNickname());
ImageUtils.loadHeadCC(data.getAvatar(), imUser2); ImageUtils.loadHeadCC(data.getAvatar(), imUser2);
tvId2.setText(data.getUser_id() != null ? "ID:" + data.getUser_id() : ""); tvId2.setText(data.getUser_code() != null ? "ID:" + data.getUser_code() : "");
imUser2.setOnClickListener(new View.OnClickListener() { imUser2.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@@ -436,7 +436,7 @@ public class PlaceholderFragment extends BaseMvpFragment<PlaceholderPresenter, F
ImageUtils.loadHeadCC(data.getUser_avatar1(), ivOneCp1Hhead); ImageUtils.loadHeadCC(data.getUser_avatar1(), ivOneCp1Hhead);
ImageUtils.loadHeadCC(data.getUser_avatar1(), ivOneCp2Hhead); ImageUtils.loadHeadCC(data.getUser_avatar1(), ivOneCp2Hhead);
tvUsername2.setText(data.getNickname()); tvUsername2.setText(data.getNickname());
tvId2.setText(data.getUser_id()); tvId2.setText(data.getNickname1());
} }
} }
@@ -469,11 +469,11 @@ public class PlaceholderFragment extends BaseMvpFragment<PlaceholderPresenter, F
if (type.equals("0")) { if (type.equals("0")) {
tvUsername3.setText(data.getRoom_name()); tvUsername3.setText(data.getRoom_name());
ImageUtils.loadHeadCC(data.getRoom_cover(), imUser3); ImageUtils.loadHeadCC(data.getRoom_cover(), imUser3);
tvId3.setText(data.getRoom_id() != null ? "ID:" + data.getRoom_id() : ""); tvId3.setText(data.getRoom_number() != null ? "ID:" + data.getRoom_number() : "");
} else if (type.equals("1") || type.equals("2")) { } else if (type.equals("1") || type.equals("2")) {
tvUsername3.setText(data.getNickname()); tvUsername3.setText(data.getNickname());
ImageUtils.loadHeadCC(data.getAvatar(), imUser3); ImageUtils.loadHeadCC(data.getAvatar(), imUser3);
tvId3.setText(data.getUser_id() != null ? "ID:" + data.getUser_id() : ""); tvId3.setText(data.getUser_code() != null ? "ID:" + data.getUser_code() : "");
imUser3.setOnClickListener(new View.OnClickListener() { imUser3.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@@ -489,7 +489,7 @@ public class PlaceholderFragment extends BaseMvpFragment<PlaceholderPresenter, F
ImageUtils.loadHeadCC(data.getUser_avatar(), ivOneCp1Hhead); ImageUtils.loadHeadCC(data.getUser_avatar(), ivOneCp1Hhead);
ImageUtils.loadHeadCC(data.getUser_avatar(), ivOneCp2Hhead); ImageUtils.loadHeadCC(data.getUser_avatar(), ivOneCp2Hhead);
tvUsername3.setText(data.getNickname()); tvUsername3.setText(data.getNickname());
tvId3.setText(data.getUser_id()); tvId3.setText(data.getNickname1());
} }
} }

View File

@@ -126,7 +126,7 @@
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:rotation="-20" android:rotation="-20"
android:src="@mipmap/ic_launcher" /> />
<com.xscm.moduleutil.widget.GifAvatarOvalView <com.xscm.moduleutil.widget.GifAvatarOvalView
android:id="@+id/iv_second_cp2_head" android:id="@+id/iv_second_cp2_head"
@@ -138,7 +138,7 @@
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:layout_toEndOf="@+id/iv_second_cp1_head" android:layout_toEndOf="@+id/iv_second_cp1_head"
android:rotation="20" android:rotation="20"
android:src="@mipmap/ic_launcher" /> />
<ImageView <ImageView
android:layout_width="@dimen/dp_98" android:layout_width="@dimen/dp_98"