1.添加巡乐会房间展示

This commit is contained in:
2025-09-25 16:13:51 +08:00
parent a0ecafbbd7
commit 59eeb1415b
37 changed files with 896 additions and 211 deletions

View File

@@ -47,6 +47,7 @@ import com.xscm.moduleutil.listener.MessageListenerSingleton;
import com.xscm.moduleutil.rtc.AgoraManager;
import com.xscm.moduleutil.service.MqttConnect;
import com.xscm.moduleutil.utils.ARouteConstants;
import com.xscm.moduleutil.utils.CrashHandler;
import com.xscm.moduleutil.utils.SpUtil;
import com.xscm.moduleutil.utils.UtilConfig;
import com.xscm.moduleutil.utils.config.EnvironmentEnum;
@@ -99,6 +100,8 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
public boolean isShowAg;
public boolean isRoomJoininj=false;
public String playCover;
public boolean showSelf;//盲盒是否能送自己
public String playName;
@@ -143,6 +146,8 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
startListeningUnreadMessageCount();
// 全局设置字体不缩放
adjustFontScale(getResources().getConfiguration());
CrashHandler.init(this);
}
@@ -216,6 +221,67 @@ public class CommonAppContext extends MultiDexApplication implements Applicatio
CommonAppContext.getInstance().setUnreadCountEvent(event);
EventBus.getDefault().post(event);
}
/**
* 检查网络是否可用
* @return true表示网络可用false表示网络不可用
*/
public boolean isNetworkAvailable() {
try {
// 获取网络连接管理器
android.net.ConnectivityManager connectivityManager =
(android.net.ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// Android 6.0及以上版本
android.net.Network network = connectivityManager.getActiveNetwork();
if (network != null) {
android.net.NetworkCapabilities capabilities =
connectivityManager.getNetworkCapabilities(network);
if (capabilities != null) {
// 检查是否有网络连接并且可以访问互联网
return capabilities.hasCapability(android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
capabilities.hasCapability(android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED);
}
}
} else {
// Android 6.0以下版本
android.net.NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
}
} catch (Exception e) {
LogUtils.e("Network availability check failed: " + e.getMessage());
}
return false;
}
/**
* 检查网络是否可用(简化版本)
* @return true表示网络可用false表示网络不可用
*/
public boolean isNetworkConnected() {
try {
android.net.ConnectivityManager connectivityManager =
(android.net.ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
android.net.Network network = connectivityManager.getActiveNetwork();
return network != null;
} else {
android.net.NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
}
} catch (Exception e) {
LogUtils.e("Network connection check failed: " + e.getMessage());
}
return false;
}
/**
* 优化内存设置
*/

View File

@@ -110,7 +110,10 @@ public class RoomManager {
public void fetchRoomDataAndEnter(Context context, String roomId, String password) {
// 显示加载提示
// 这里可以根据需要添加加载对话框
if (CommonAppContext.getInstance().isRoomJoininj){
return;
}
CommonAppContext.getInstance().isRoomJoininj=true;
// 检查是否有有效的缓存数据
// RoomInfoResp roomInfo = getCachedRoomData(roomId);
// 检查是否是当前房间且用户在线
@@ -119,6 +122,7 @@ public class RoomManager {
fetchAndJoinRoom(context, roomId, password);
} else {
if (!CommonAppContext.getInstance().playId.equals(roomId)) {
MessageListenerSingleton.getInstance().joinGroup(roomId);
exitRoom(CommonAppContext.getInstance().playId);
} else if (CommonAppContext.getInstance().lable_id.equals("6")) {
upInfo(context, roomId, password, true, null, true);
@@ -241,7 +245,7 @@ public class RoomManager {
*/
private void fetchAndJoinRoom(Context context, String roomId, String password) {
// 获取房间数据
MessageListenerSingleton.getInstance().joinGroup(roomId);
// 等待一段时间确保退出完成
try {
Thread.sleep(300);
@@ -394,11 +398,11 @@ public class RoomManager {
// 可以通过检查Agora是否还在房间中或者通过服务端接口查询用户状态等方式实现
// 目前返回false需要根据实际需求实现具体逻辑
// boolean isCurrentRoom=isCurrentRoom(roomId);
try {
Thread.sleep(300);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
// try {
// Thread.sleep(300);
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// }
final boolean[] isOnline = {false};
RetrofitClient.getInstance().getRoomOnline(roomId, "1", "50", new BaseObserver<RoomOnline>() {
@Override

View File

@@ -0,0 +1,22 @@
package com.xscm.moduleutil.bean;
import lombok.Data;
/**
*@author qx
*@data 2025/9/25
*@description: 绑定详情
*/
@Data
public class BindDetail {
private String id;
private String alipay_name;//支付宝姓名
private String alipay_account;//支付宝账户
private String bank_card_number;//银行卡号
private String bank_user_name;//姓名
private String bank_card;//所属行
private String open_bank;//开户行
}

View File

@@ -26,6 +26,7 @@ public class BlindBoxBean {
private int is_xlh; ///是否开启巡乐会 0 关闭 1 开启
private Object xlh_data;
private List<GiftBean> gift_list;
private String end_time;//巡乐会结束时间
private GiveGift give_homeowner_gift;//房主礼物
private GiveGift locking_gift;//锁定礼物
@@ -95,6 +96,14 @@ public class BlindBoxBean {
}
}
}
Object endTime = map.get("end_time");
if (endTime != null) {
if (endTime instanceof String){
xlhData.setEnd_time(endTime.toString());
}else {
xlhData.setEnd_time(endTime.toString());
}
}
return xlhData;
}
@@ -118,6 +127,9 @@ public class BlindBoxBean {
if (jsonObject.has("status")) {
xlhData.setStatus(jsonObject.get("status").getAsInt());
}
if (jsonObject.has("end_time")){
xlhData.setEnd_time(jsonObject.get("end_time").getAsString());
}
return xlhData;
}
@@ -130,6 +142,7 @@ public class BlindBoxBean {
private String start_num;//巡乐会开启需要达到的次数
private int current_num;//当前已抽奖次数
private int status;
private String end_time;
}
@Data
public static class GiveGift {

View File

@@ -29,6 +29,7 @@ public class RoomInfoResp implements Serializable {
private PkRoomInfo pk_info;
private List<RoomPitBean> song_pit_list;
private FriendInfo friend_info;
private GiftXlh gift_cycle;
//弹出麦位操作弹出
@@ -114,4 +115,18 @@ public class RoomInfoResp implements Serializable {
public boolean isFreedomMode() {
return "1".equals(room_info.getWheat());
}
@Data
public class GiftXlh implements Serializable{
private XlhInfo xlh_info ;
}
@Data
public class XlhInfo implements Serializable{
private String activities_name;
private String icon;
private String xlh_status;
private String end_time;
}
}

View File

@@ -453,17 +453,17 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
if (icon > 0 && box_price > 0) {
if (type == 10) {
updateBackground(mBinding.mirroeSky.llOne, icon > box_price, drawableX, drawableW);
updateBackground(mBinding.mirroeSky.llTen, icon > box_price * 6, drawableX, drawableW);
updateBackground(mBinding.mirroeSky.llHundred, icon > box_price * 9, drawableX, drawableW);
updateBackground(mBinding.mirroeSky.llOne, icon >= box_price, drawableX, drawableW);
updateBackground(mBinding.mirroeSky.llTen, icon >= box_price * 6, drawableX, drawableW);
updateBackground(mBinding.mirroeSky.llHundred, icon >= box_price * 9, drawableX, drawableW);
} else if (type == 11) {
updateBackground(mBinding.cityTime.llOne, icon > box_price, drawableX, drawableW);
updateBackground(mBinding.cityTime.llTen, icon > box_price * 6, drawableX, drawableW);
updateBackground(mBinding.cityTime.llOne, icon >= box_price, drawableX, drawableW);
updateBackground(mBinding.cityTime.llTen, icon >= box_price * 6, drawableX, drawableW);
updateBackground(mBinding.cityTime.llHundred, icon > box_price * 9, drawableX, drawableW);
} else if (type == 12) {
updateBackground(mBinding.pinnacleTime.llOne, icon > box_price, drawableX, drawableW);
updateBackground(mBinding.pinnacleTime.llTen, icon > box_price * 6, drawableX, drawableW);
updateBackground(mBinding.pinnacleTime.llHundred, icon > box_price * 9, drawableX, drawableW);
updateBackground(mBinding.pinnacleTime.llOne, icon >= box_price, drawableX, drawableW);
updateBackground(mBinding.pinnacleTime.llTen, icon >= box_price * 6, drawableX, drawableW);
updateBackground(mBinding.pinnacleTime.llHundred, icon >= box_price * 9, drawableX, drawableW);
} else {
// 兜底处理:未知 type 时全部设为不可点击 + 默认背景
setAllBackgroundToDefault(drawableW);

View File

@@ -5,6 +5,7 @@ import com.xscm.moduleutil.bean.AlbumBean;
import com.xscm.moduleutil.bean.AppPay;
import com.xscm.moduleutil.bean.AppUpdateModel;
import com.xscm.moduleutil.bean.BannerModel;
import com.xscm.moduleutil.bean.BindDetail;
import com.xscm.moduleutil.bean.BindType;
import com.xscm.moduleutil.bean.BlackUserBean;
import com.xscm.moduleutil.bean.CharmRankingResp;
@@ -165,9 +166,13 @@ public interface ApiServer {
@GET(Constants.GET_WITHDRAWAL_LIST)
Observable<BaseModel<List<WithdrawalBean>>> withdrawalList(@Query("page") String page, @Query("page_limit") String page_limit, @Query("search_stime") String search_stime, @Query("search_etime") String search_etime);
@FormUrlEncoded
@POST(Constants.POST_BIND_DETAIL)
Call<BaseModel<BindDetail>> bindDetai(@Field("user_id") String user_id, @Field("type") String type);
@FormUrlEncoded
@POST(Constants.POST_MESSAGE_LIST)
Observable<BaseModel<List<NewsMessageList>>> getMessagetitle(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<List<NewsMessageList>>> getMessagetitle(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.POST_ROOM_RANK)

View File

@@ -19,6 +19,7 @@ import com.xscm.moduleutil.bean.AlbumBean;
import com.xscm.moduleutil.bean.AppPay;
import com.xscm.moduleutil.bean.AppUpdateModel;
import com.xscm.moduleutil.bean.BannerModel;
import com.xscm.moduleutil.bean.BindDetail;
import com.xscm.moduleutil.bean.BindType;
import com.xscm.moduleutil.bean.BlackUserBean;
import com.xscm.moduleutil.bean.CharmRankingResp;
@@ -450,13 +451,51 @@ public class RetrofitClient {
}
public void getMessagetitle(String type, String page, String page_limit, BaseObserver<List<NewsMessageList>> observer) {
sApiServer.getMessagetitle(type, page, page_limit).compose(new DefaultTransformer<>()).subscribe(observer);
sApiServer.getMessagetitle(type, page, page_limit).enqueue(new Callback<BaseModel<List<NewsMessageList>>>() {
@Override
public void onResponse(Call<BaseModel<List<NewsMessageList>>> call, Response<BaseModel<List<NewsMessageList>>> response) {
if (response.code() == 200){
BaseModel<List<NewsMessageList>> baseModel = response.body();
if (baseModel.getCode()==1){
observer.onNext(baseModel.getData());
}else {
ToastUtils.showShort(baseModel.getMsg());
}
}
}
@Override
public void onFailure(Call<BaseModel<List<NewsMessageList>>> call, Throwable t) {
}
});
}
public void withdrawalList(String page, String page_limit, String search_stime, String search_etime, BaseObserver<List<WithdrawalBean>> observer) {
sApiServer.withdrawalList(page, page_limit, search_stime, search_etime).compose(new DefaultTransformer<>()).subscribe(observer);
}
public void bindDetai(String userId, String type,BaseObserver<BindDetail> observer){
sApiServer.bindDetai(userId, type).enqueue(new Callback<BaseModel<BindDetail>>() {
@Override
public void onResponse(Call<BaseModel<BindDetail>> call, Response<BaseModel<BindDetail>> response) {
if (response.code() == 200){
BaseModel<BindDetail> baseModel = response.body();
if (baseModel.getCode()==1){
observer.onNext(baseModel.getData());
}else {
observer.onNext(null);
}
}
}
@Override
public void onFailure(Call<BaseModel<BindDetail>> call, Throwable t) {
t.printStackTrace();
}
});
}
public void getRoomRank(String roomId, String type, String time_type, String page, String page_limit, BaseObserver<List<CharmRankingResp>> observer) {
// sApiServer.getRoomRank(roomId, type, time_type, page, page_limit).compose(new DefaultTransformer<>()).subscribe(observer);
sApiServer.getRoomRank(roomId, type, time_type, page, page_limit).enqueue(new Callback<BaseModel<List<CharmRankingResp>>>() {
@@ -1067,6 +1106,8 @@ public class RetrofitClient {
BaseModel<List<BlackUserBean>> baseModel = response.body();
if (baseModel.getCode() == 1) {
observer.onNext(baseModel.getData());
}else {
ToastUtils.showShort(baseModel.getMsg());
}
}
}
@@ -1086,6 +1127,8 @@ public class RetrofitClient {
BaseModel<List<BlackUserBean>> baseModel = response.body();
if (baseModel.getCode() == 1) {
observer.onNext(baseModel.getData());
}else {
ToastUtils.showShort(baseModel.getMsg());
}
}
}
@@ -1105,6 +1148,8 @@ public class RetrofitClient {
BaseModel<List<BlackUserBean>> baseModel = response.body();
if (baseModel.getCode() == 1) {
observer.onNext(baseModel.getData());
}else {
ToastUtils.showShort(baseModel.getMsg());
}
}
}
@@ -1124,6 +1169,8 @@ public class RetrofitClient {
BaseModel<List<BlackUserBean>> baseModel = response.body();
if (baseModel.getCode() == 1) {
observer.onNext(baseModel.getData());
}else {
ToastUtils.showShort(baseModel.getMsg());
}
}
}
@@ -1700,12 +1747,12 @@ public class RetrofitClient {
});
}
public void roomGetIn(String roomId, String
password, BaseObserver<RoomInfoResp> observer) {
public void roomGetIn(String roomId, String password, BaseObserver<RoomInfoResp> observer) {
sApiServer.roomGetIn(roomId, password).enqueue(new Callback<BaseModel<RoomInfoResp>>() {
@Override
public void onResponse(Call<BaseModel<RoomInfoResp>> call, Response<BaseModel<RoomInfoResp>> response) {
CommonAppContext.getInstance().isRoomJoininj=false;
if (response.code() == 200) {
BaseModel<RoomInfoResp> roomInfoRespBaseModel = response.body();
if (roomInfoRespBaseModel.getCode() == 1) {
@@ -1718,7 +1765,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<RoomInfoResp>> call, Throwable t) {
MessageListenerSingleton.getInstance().quitGroup(roomId);
CommonAppContext.getInstance().isRoomJoininj=false;
}
});
}
@@ -1846,8 +1894,7 @@ public class RetrofitClient {
});
}
public void appPay(String user_id, String money, String coin, String
type, BaseObserver<AppPay> observer) {
public void appPay(String user_id, String money, String coin, String type, BaseObserver<AppPay> observer) {
sApiServer.appPay(user_id, money, coin, type).enqueue(new Callback<BaseModel<AppPay>>() {
@Override
public void onResponse(Call<BaseModel<AppPay>> call, Response<BaseModel<AppPay>> response) {
@@ -1855,6 +1902,8 @@ public class RetrofitClient {
BaseModel<AppPay> appPayBaseModel = response.body();
if (appPayBaseModel.getCode() == 1) {
observer.onNext(appPayBaseModel.getData());
}else {
ToastUtils.showShort(appPayBaseModel.getMsg());
}
}
}
@@ -1904,8 +1953,7 @@ public class RetrofitClient {
});
}
public void bind(String userId, String type, String alipayAccount, String
bank_card_number, String bank_card, String open_bank, BaseObserver<String> observer) {
public void bind(String userId, String type, String alipayAccount, String bank_card_number, String bank_card, String open_bank, BaseObserver<String> observer) {
sApiServer.bind(userId, type, alipayAccount, bank_card_number, bank_card, open_bank).enqueue(new Callback<BaseModel<String>>() {
@Override
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
@@ -3128,8 +3176,7 @@ public class RetrofitClient {
});
}
public void userOnlineStatus(String user_id, String
roomId, BaseObserver<List<UserOnlineStatusBean>> observer) {
public void userOnlineStatus(String user_id, String roomId, BaseObserver<List<UserOnlineStatusBean>> observer) {
sApiServer.userOnlineStatus(user_id, roomId).enqueue(new Callback<BaseModel<List<UserOnlineStatusBean>>>() {
@Override
public void onResponse(Call<BaseModel<List<UserOnlineStatusBean>>> call, Response<BaseModel<List<UserOnlineStatusBean>>> response) {

View File

@@ -0,0 +1,41 @@
package com.xscm.moduleutil.utils;
import android.content.Context;
import android.util.Log;
import com.alibaba.android.arouter.launcher.ARouter;
public class CrashHandler implements Thread.UncaughtExceptionHandler {
private static CrashHandler instance;
private Thread.UncaughtExceptionHandler defaultHandler;
private CrashHandler(Context context) {
defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
}
public static void init(Context context) {
if (instance == null) {
instance = new CrashHandler(context);
Thread.setDefaultUncaughtExceptionHandler(instance);
}
}
@Override
public void uncaughtException(Thread t, Throwable e) {
// 记录崩溃日志
Log.e("CrashHandler", "未捕获异常: " + e.getMessage());
// 简单处理空指针
if (e instanceof NullPointerException) {
// 重启应用或跳转错误页
restartApp();
} else {
// 交给系统默认处理
defaultHandler.uncaughtException(t, e);
}
}
private void restartApp() {
// 实现应用重启逻辑
ARouter.getInstance().build(ARouteConstants.ME).navigation();
}
}

View File

@@ -15,20 +15,20 @@ public enum EnvironmentEnum {
"tcp://81.70.45.221",
"https://md.xscmmidi.site/h5"),
TEST(//测试环境
"http://md.qxmier.com/",
"http://tmd.xscmmidi.site/",
"6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=",
"https://oss-cn-hangzhou.aliyuncs.com/",
"LTAI5tJ2UYfFNF7K3F4e1siv",
"DhpCS82gaigZljYqsWsUWUAZ20dREz",
"qx-yusheng",
"https://qx-yusheng.oss-cn-hangzhou.aliyuncs.com/",
"https://oss-cn-beijing.aliyuncs.com/",
"LTAI5tKgrfcFQxH46ZwWYgFW",
"ZOjTqAJmUL563EKFKySrUwAHtx4hKt",
"midi01",
"https://midi01.oss-cn-beijing.aliyuncs.com/",
"wxc7681513be9f926b",
1600101474,
1600106397,
"05b406b4541e413887d8d2bf9be8642c",
"tcp://47.120.21.132",
"tcp://1.13.181.248",
"https://chatvespa.qxmier.com");
private final String serverUrl;
private final String serverUrl;//服务器地址
private final String ALI_AUTH_KEY;//阿里云授权key
private final String ossEndPoint;
@@ -37,15 +37,15 @@ public enum EnvironmentEnum {
private final String ossBucketName;
private final String ossBaseUrl;
private final String wxAppId;
private final String wxAppId;//微信appId
private final int sdkAppId;//腾讯云sdkAppId im
private final String swSdkAppId;
private final String swSdkAppId;//声网sdkAppId
private final String mqttUrl;
private final String mqttUrl;//MQTT服务器地址
private final String H5Url;
private final String H5Url;//h5地址
EnvironmentEnum(String serverUrl, String ALI_AUTH_KEY, String ossEndPoint, String ossaAcessKeyId,
String ossAccessKeySecret, String ossBucketName, String ossBaseUrl, String wxAppId,

View File

@@ -27,11 +27,11 @@ public class EnvironmentPrefs {
// 获取当前选择的环境,默认为 PRODUCTION
public EnvironmentEnum getSelectedEnvironment() {
String envName = sharedPreferences.getString(KEY_ENV, EnvironmentEnum.PRODUCTION.name());
String envName = sharedPreferences.getString(KEY_ENV, EnvironmentEnum.TEST.name());
try {
return EnvironmentEnum.valueOf(envName);
} catch (IllegalArgumentException e) {
return EnvironmentEnum.PRODUCTION; // 出错时默认返回生产环境
return EnvironmentEnum.TEST; // 出错时默认返回生产环境
}
}
}

View File

@@ -45,7 +45,7 @@ public class ClearEditText extends AppCompatEditText implements View.OnFocusChan
//获取EditText的DrawableRight,假如没有设置我们就使用默认的图片
mClearDrawable = getCompoundDrawables()[2];
if (mClearDrawable == null) {
mClearDrawable = getResources().getDrawable(R.mipmap.common_et_clear_icon);
mClearDrawable = getResources().getDrawable(R.mipmap.index_icon_close);
}
mClearDrawable.setBounds(0, 0, mClearDrawable.getIntrinsicWidth(),
mClearDrawable.getIntrinsicHeight());

View File

@@ -356,6 +356,7 @@ public class Constants {
public static final String GET_APP_UPDATE = "/api/Version/get_app_version";//版本更新
public static final String POST_CLEAR_USER_CHARM = "/api/Room/clear_user_charm";//清除魅力值
public static final String POST_MESSAGE_LIST = "/api/UserMessage/get_user_message_list";//消息列表
public static final String POST_BIND_DETAIL = "/api/Bind/bind_detail";//绑定详情
public static final String POST_USER_WALL = "/api/User/user_gift_wall";//礼物墙
public static final String POST_USER_OLINE_STATUS = "/api/Room/user_online_status";//用户在线状态
public static final String DELETE_ROOM_HISTORY = "/api/Room/delete_room_history";//删除历史足迹

View File

@@ -0,0 +1,184 @@
package com.xscm.moduleutil.widget;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.widget.LinearLayout;
import com.blankj.utilcode.util.ScreenUtils;
public class DropViewRoom extends LinearLayout {
private int rightMargin = 0;
private float lastX, lastY;
private int screenWidth;
public DropViewRoom(Context context) {
super(context);
init();
}
public DropViewRoom(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public DropViewRoom(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
void init() {
post(new Runnable() {
@Override
public void run() {
//设置初始位置
int sh = ScreenUtils.getScreenHeight();
int sw = ScreenUtils.getScreenWidth()-100;
// setBackgroundResource(R.drawable.bg_home_drop_view);
int y = (int) (0.5f * sh) - getHeight();
int x = sw - getWidth();
setTranslationX(x);
setTranslationY(y);
}
});
}
boolean starDrap = false;
float X1;
float X2;
float Y1;
float Y2;
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (starDrap) return true;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
X1 = event.getX();
Y1 = event.getY();
break;
case MotionEvent.ACTION_MOVE:
X2 = event.getX();//当手指抬起时再次获取屏幕位置的X值
Y2 = event.getY();//同理
Action(X1, X2, Y1, Y2);
break;
}
return starDrap;
}
String TAG = "DropView";
public boolean Action(float X1, float X2, float Y1, float Y2) {
float ComparedX = X2 - X1;//第二次的X坐标的位置减去第一次X坐标的位置代表X坐标上的变化情况
float ComparedY = Y2 - Y1;//同理
//当X坐标的变化量的绝对值大于Y坐标的变化量的绝对值以X坐标的变化情况作为判断依据
//上下左右的判断,都在一条直线上,但手指的操作不可能划直线,所有选择变化量大的方向上的量
//作为判断依据
if (Math.abs(ComparedX) > 30 || Math.abs(ComparedY) > 30) {
Log.i(TAG, "Action: 拖动");
starDrap = true;
// setBackgroundResource(R.drawable.bg_home_drop_view);
return true;
} else {
starDrap = false;
return false;
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
// setBackgroundResource(R.drawable.bg_home_drop_view);
setTranslationX(getX() + (event.getX() - X1));
setTranslationY(getY() + (event.getY() - Y1));
X2 = event.getX();
break;
case MotionEvent.ACTION_UP:
starDrap = false;
int sw = ScreenUtils.getScreenWidth();
Log.i(TAG, "onTouchEvent: " + sw + "," + X2);
boolean isR = getTranslationX() + getWidth() / 2 >= sw / 2;//贴边方向
ObjectAnimator anim = ObjectAnimator.ofFloat(this, "translationX", isR ? sw - getWidth()+10 : 0f).setDuration(200);
anim.start();
break;
}
return true;
}
public void doRevealAnimation(View mPuppet, boolean flag) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int[] vLocation = new int[2];
getLocationInWindow(vLocation);
int centerX = vLocation[0] + getMeasuredWidth() / 2;
int centerY = vLocation[1] + getMeasuredHeight() / 2;
int height = ScreenUtils.getScreenHeight();
int width = ScreenUtils.getScreenWidth();
int maxRradius = (int) Math.hypot(height, width);
Log.e("hei", maxRradius + "");
if (flag) {
mPuppet.setVisibility(VISIBLE);
Animator animator = ViewAnimationUtils.createCircularReveal(mPuppet, centerX, centerY, maxRradius, 0);
animator.setDuration(600);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mPuppet.setVisibility(View.GONE);
}
});
animator.start();
flag = false;
} else {
Animator animator = ViewAnimationUtils.createCircularReveal(mPuppet, centerX, centerY, 0, maxRradius);
animator.setDuration(1000);
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
mPuppet.setVisibility(View.VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
animator.start();
flag = true;
}
}
}
}

View File

@@ -59,7 +59,7 @@ public class RoomMessageInputMenu extends ConstraintLayout {
}
String text = etContent.getText().toString();
if (TextUtils.isEmpty(text)) {
ToastUtils.show("请输入评论内容");
ToastUtils.show("请输入内容");
return;
}
// ApiClient.getInstance().sendTxtFilter(text,new BaseObserver<String>() {