1:修改页面,更换room变成kotlin,

2:在所有的跳转到WEBview的时候,使用Intent的方式
3:优化网络请求
This commit is contained in:
2025-09-26 14:32:35 +08:00
parent 2f06d60fec
commit a4caa9b078
51 changed files with 3692 additions and 2902 deletions

View File

@@ -2,7 +2,7 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
}
//apply plugin: 'kotlin-kapt' // 关键Kotlin 注解处理器
android {
namespace 'com.xscm.moduleutil'
compileSdk 35
@@ -35,14 +35,14 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
dataBinding {
enabled = true
}
kotlinOptions {
jvmTarget = '17'
jvmTarget = '11'
}
packagingOptions {
@@ -50,6 +50,13 @@ android {
}
}
// Kotlin 注解处理器参数(针对 Kotlin 代码)
//kapt {
// arguments {
// arg("AROUTER_MODULE_NAME", project.getName())
// }
//}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
@@ -139,8 +146,9 @@ dependencies {
api(libs.alipay.alipaysdk.android)
api(libs.arouter.api.v150)
annotationProcessor libs.arouter.annotation
annotationProcessor libs.arouter.compiler
// implementation 'com.alibaba:arouter-api:1.5.2'
// kapt 'com.alibaba:arouter-compiler:1.5.2'/**/
api(libs.easypermissions)
api(libs.xbanner)
@@ -219,4 +227,4 @@ dependencies {
//aar的名称例如WbCloudNormal-v5.1.10-123456789.aar填入 'WbCloudNormal-v5.1.10-123456789.aar'
}
apply plugin: 'com.alibaba.arouter' //
//apply plugin: 'com.alibaba.arouter' //

View File

@@ -766,7 +766,10 @@ public abstract class BaseAppCompatActivity<VDB extends ViewDataBinding> extends
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(ChatInfo event) {
String id = event.getId().replace("g", "");
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id).navigation();
Intent intent = new Intent(this, WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id);
startActivity( intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/union/setGroup?id=" + SpUtil.getToken() + "&guildId=" + id).navigation();
}

View File

@@ -3,6 +3,7 @@ package com.xscm.moduleutil.activity.news;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import android.content.Intent;
import android.text.Html;
import android.view.View;
@@ -14,6 +15,7 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.activity.BaseMvpActivity;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.base.RoomManager;
import com.xscm.moduleutil.bean.NewsMessageList;
import com.xscm.moduleutil.databinding.ActivityOfficialNoticeBinding;
@@ -79,7 +81,10 @@ public class OfficialNoticeActivity extends BaseMvpActivity<NewsPresenter, Activ
RoomManager.getInstance().fetchRoomDataAndEnter(getApplicationContext(), item.getRoom_id()+"","");
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("roomId", item.getRoom_id() + "").navigation();
}else if (item.getRoom_id() == 0 && item.getUrl() != null && !item.getUrl().isEmpty()){
ARouter.getInstance().build(ARouteConstants.H5).withString("url", item.getUrl()).navigation();
Intent intent = new Intent(OfficialNoticeActivity.this, WebViewActivity.class);
intent.putExtra("url", item.getUrl());
startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", item.getUrl()).navigation();
}
}
});

View File

@@ -1,11 +1,14 @@
package com.xscm.moduleutil.base;
import static android.app.PendingIntent.getActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.bean.room.RoomInfoResp;
@@ -124,6 +127,9 @@ public class RoomManager {
if (!CommonAppContext.getInstance().playId.equals(roomId)) {
MessageListenerSingleton.getInstance().joinGroup(roomId);
exitRoom(CommonAppContext.getInstance().playId);
CommonAppContext.getInstance().isShow = false;
CommonAppContext.getInstance().isPlaying = false;
EventBus.getDefault().post(new RoomOutEvent());
} else if (CommonAppContext.getInstance().lable_id.equals("6")) {
upInfo(context, roomId, password, true, null, true);
return;
@@ -334,7 +340,6 @@ public class RoomManager {
ARouter.getInstance()
.build(ARouteConstants.ROOM_DETAILS)
.with(bundle)
.withFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
.navigation(context);
} catch (Exception e) {

View File

@@ -1,7 +1,10 @@
package com.xscm.moduleutil.dialog;
import static com.blankj.utilcode.util.ActivityUtils.startActivity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.text.TextPaint;
@@ -16,6 +19,7 @@ import androidx.databinding.DataBindingUtil;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.SpanUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.databinding.DialogPolicBinding;
import com.xscm.moduleutil.utils.ARouteConstants;
@@ -42,7 +46,12 @@ public class PolicyDialog extends Dialog {
ClickableSpan clickSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6" ).withString("title", "用户协议").navigation();
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6");
intent.putExtra("title", "用户协议");
startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6" ).withString("title", "用户协议").navigation();
}
@Override
@@ -54,7 +63,12 @@ public class PolicyDialog extends Dialog {
ClickableSpan ysClickSpan = new ClickableSpan() {
@Override
public void onClick(@NonNull View widget) {
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4");
intent.putExtra("title", "隐私协议");
startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
}
@Override

View File

@@ -1,6 +1,7 @@
package com.xscm.moduleutil.dialog;
import android.content.Context;
import android.content.Intent;
import android.view.Window;
import android.view.WindowManager;
@@ -9,6 +10,7 @@ import androidx.annotation.NonNull;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.ScreenUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.activity.WebViewActivity;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.bean.TeenagerInfo;
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
@@ -55,7 +57,11 @@ public class YouthModelDialog extends BaseDialog<IndexDialogYouthModelBinding> {
// } else {
// ARouter.getInstance().build(ARouteConstants.SET_YOUTH_PWD_ACTIVITY).withInt("type", SetYouthPasswordActivity.SET_TYPE).navigation();
// }
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken()).navigation();
Intent intent = new Intent(getContext(), WebViewActivity.class);
intent.putExtra("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken());
getContext().startActivity(intent);
// ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url() + "/web/index.html#/pages/feedback/teenage?id=" + SpUtil.getToken()).navigation();
dismiss();
});

View File

@@ -122,6 +122,9 @@ public class GiftLotteryPresenter extends BasePresenter<GiftLotteryContacts.View
@Override
public void onNext(WalletBean walletBean) {
if (MvpRef == null) {
MvpRef = new WeakReference<>(mView);
}
MvpRef.get().wallet(walletBean);
}
});

View File

@@ -0,0 +1,134 @@
package com.xscm.moduleutil.http;
import android.content.Context;
import android.widget.Toast;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.base.CommonAppContext;
import org.greenrobot.eventbus.EventBus;
import java.io.IOException;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* 通用的API响应处理回调类
* 统一处理所有接口的响应和错误情况
*/
public abstract class ApiResponseCallback<T> implements Callback<BaseModel<T>> {
private Context mContext;
// 构造方法,传入上下文用于显示提示
public ApiResponseCallback(Context context) {
this.mContext = context;
}
@Override
public void onResponse(Call<BaseModel<T>> call, Response<BaseModel<T>> response) {
// 统一处理HTTP响应
if (response.isSuccessful()) {
// 处理200-299范围内的HTTP状态码
BaseModel<T> body = response.body();
if (body != null) {
// 根据code值进行不同处理
switch (body.getCode()) {
case 1: // 接口返回成功
// 业务成功,回调给具体实现
// 即使data为null也调用onSuccess由具体实现决定如何处理null值
onSuccess(body.getData());
break;
case 0: // 接口请求成功但数据错误
// 显示错误信息
// String errorMsg = body.getMsg() != null ? body.getMsg() : "操作失败,请重试";
// showToast(errorMsg);
onFailure(new Exception(body.getMsg()));
break;
case 301: // 登录失效
// 显示错误信息并退出应用
// String loginErrorMsg = body.getMsg() != null ? body.getMsg() : "登录已失效,请重新登录";
showToast(body.getMsg());
try {
// 发送退出登录事件
// EventBus.getDefault().post(new com.xscm.moduleutil.event.LogOutEvent());
// 清除登录信息
CommonAppContext.getInstance().clearLoginInfo();
// 跳转到登录页面
// android.content.Intent intent = new android.content.Intent(CommonAppContext.getInstance(), Class.forName("com.xscm.midi.LaunchPageActivity"));
// intent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK | android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK);
// CommonAppContext.getInstance().startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
onFailure(new Exception(body.getMsg()));
break;
default:
// 其他错误情况
String defaultErrorMsg = body.getMsg() != null ? body.getMsg() : "未知错误";
showToast(defaultErrorMsg);
onFailure(new Exception(defaultErrorMsg));
break;
}
} else {
// 响应体为空的情况
String errorMsg = "获取数据失败,请重试";
showToast(errorMsg);
onFailure(new Exception(errorMsg));
}
} else {
// 处理HTTP错误状态码
String errorInfo;
try {
if (response.errorBody() != null) {
errorInfo = response.errorBody().string();
// 可以在这里统一解析错误响应体
} else {
errorInfo = "请求失败,状态码:" + response.code();
}
} catch (IOException e) {
errorInfo = "请求失败,状态码:" + response.code();
e.printStackTrace();
}
showToast("");
onFailure(new Exception(errorInfo));
}
}
@Override
public void onFailure(Call<BaseModel<T>> call, Throwable t) {
// 统一处理网络异常
String errorMsg;
if (t instanceof IOException) {
// errorMsg = "网络异常,请检查网络连接";
} else {
// errorMsg = "请求处理失败,请重试";
}
showToast("");
// 回调给具体实现处理
onFailure(t);
}
// 显示提示信息
private void showToast(String message) {
if (mContext != null) {
Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
}
}
// 业务成功时的回调,由具体接口实现
public abstract void onSuccess(T data);
// 错误时的回调,可选实现
public void onFailure(Throwable t) {
// 可以留空,由子类选择性实现
LogUtils.e("接口错误:",t);
}
}

View File

@@ -0,0 +1,74 @@
package com.xscm.moduleutil.http;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.base.CommonAppContext;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class BusinessAwareConverterFactory extends Converter.Factory {
private final GsonConverterFactory originalFactory;
private final Context context;
public BusinessAwareConverterFactory(Context context) {
this.context = context;
this.originalFactory = GsonConverterFactory.create();
}
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type,
Annotation[] annotations,
Retrofit retrofit) {
final Converter<ResponseBody, ?> delegate =
originalFactory.responseBodyConverter(type, annotations, retrofit);
return new Converter<ResponseBody, Object>() {
@Override
public Object convert(ResponseBody value) throws IOException {
// 先读取响应字符串检查业务状态码
String responseString = value.string();
try {
JSONObject jsonObject = new JSONObject(responseString);
int code = jsonObject.getInt("code");
String msg = jsonObject.getString("msg");
if (code == 301) {
handleForceLogout();
ToastUtils.showShort(msg);
}
// 重新构建 ResponseBody 供原始转换器使用
ResponseBody newValue = ResponseBody.create(value.contentType(), responseString);
return delegate.convert(newValue);
} catch (JSONException e) {
throw new IOException("");
}
}
private void handleForceLogout() {
new Handler(Looper.getMainLooper()).post(() -> {
try {
CommonAppContext.getInstance().clearLoginInfo();
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
});
}
};
}
}

View File

@@ -193,6 +193,7 @@ public class RetrofitClient {
private Retrofit provideRetrofit(OkHttpClient client) {
return new Retrofit.Builder()
.addConverterFactory(new BusinessAwareConverterFactory(CommonAppContext.getInstance()))
.addConverterFactory(MyConverterFactory.create())/**/
// .addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
@@ -234,7 +235,29 @@ public class RetrofitClient {
}
return INSTANCE;
}
/**
* 检查网络连接状态
* @return true表示网络可用false表示网络不可用
*/
private boolean isNetworkAvailable() {
ConnectivityManager connectivityManager = (ConnectivityManager) CommonAppContext.getInstance()
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager != null) {
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}
return false;
}
/**
* 网络不可用时的统一处理方法
* @param observer BaseObserver对象
* @param <T> 泛型类型
*/
private <T> void handleNetworkUnavailable(BaseObserver<T> observer) {
ToastUtils.showShort("网络不可用,请检查网络设置");
observer.onError(new Throwable("网络不可用,请检查网络设置"));
}
public <T> T createApiClient(Class<T> apiClientClass) {
return mRetrofit.create(apiClientClass);
}
@@ -258,6 +281,7 @@ public class RetrofitClient {
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
if (response.code() == 200) {
BaseModel<String> body = response.body();
observer.onNext(body.getMsg());
}
@@ -367,6 +391,7 @@ public class RetrofitClient {
sApiServer.exchangeCoin(earnings_num).enqueue(new Callback<BaseModel<String>>() {
@Override
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
onNextRetu(response, observer);
}
@@ -400,7 +425,7 @@ public class RetrofitClient {
public void onResponse(Call<BaseModel<FirstChargeBean>> call, Response<BaseModel<FirstChargeBean>> response) {
if (response.code() == 200) {
BaseModel<FirstChargeBean> baseModel = response.body();
if (baseModel != null) {
if (baseModel.getCode()==1){
observer.onNext(baseModel.getData());
} else {
ToastUtils.showShort("获取数据失败");
@@ -1301,7 +1326,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<List<MyRoomBean>>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("获取房间列表失败", t);
}
});
}
@@ -1345,7 +1371,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<List<TopRoom>>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("getTopRooms", t);
}
});
}
@@ -1748,6 +1775,11 @@ public class RetrofitClient {
}
public void roomGetIn(String roomId, String password, BaseObserver<RoomInfoResp> observer) {
if (!isNetworkAvailable()) {
handleNetworkUnavailable(observer);
CommonAppContext.getInstance().isRoomJoininj=false;
return;
}
sApiServer.roomGetIn(roomId, password).enqueue(new Callback<BaseModel<RoomInfoResp>>() {
@Override
@@ -1827,7 +1859,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<List<MyCpRoom>>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("myCpRoom", t);
}
});
}
@@ -2026,8 +2059,7 @@ public class RetrofitClient {
}
// TODO: 2025/3/15 获取主持人列表
public void getHostList(String roomId, String
type, BaseObserver<List<HostBean>> observer) {
public void getHostList(String roomId, String type, BaseObserver<List<HostBean>> observer) {
sApiServer.getHostList(roomId, type).enqueue(new Callback<BaseModel<List<HostBean>>>() {
@Override
public void onResponse(Call<BaseModel<List<HostBean>>> call, Response<BaseModel<List<HostBean>>> response) {
@@ -2046,8 +2078,7 @@ public class RetrofitClient {
});
}
public void getSearch(String keyWord, String
type, BaseObserver<List<RoomSearchResp>> observer) {
public void getSearch(String keyWord, String type, BaseObserver<List<RoomSearchResp>> observer) {
sApiServer.getSearch(keyWord, type).enqueue(new Callback<BaseModel<List<RoomSearchResp>>>() {
@Override
public void onResponse(Call<BaseModel<List<RoomSearchResp>>> call, Response<BaseModel<List<RoomSearchResp>>> response) {
@@ -2086,8 +2117,7 @@ public class RetrofitClient {
});
}
public void getCharmList(String roomId, String stime, String etime, String
p, BaseObserver<RoomDetails> observer) {
public void getCharmList(String roomId, String stime, String etime, String p, BaseObserver<RoomDetails> observer) {
sApiServer.getCharmList(roomId, stime, etime, p).enqueue(new Callback<BaseModel<RoomDetails>>() {
@Override
public void onResponse(Call<BaseModel<RoomDetails>> call, Response<BaseModel<RoomDetails>> response) {
@@ -2146,26 +2176,22 @@ public class RetrofitClient {
});
}
public void roomAuctionJoin(String auctionId, String userId, String giftId, String
num, String type, BaseObserver<RoomAuction.AuctionListBean> observer) {
sApiServer.roomAuctionJoin(auctionId, userId, giftId, num, type).enqueue(new Callback<BaseModel<RoomAuction.AuctionListBean>>() {
@Override
public void onResponse(Call<BaseModel<RoomAuction.AuctionListBean>> call, Response<BaseModel<RoomAuction.AuctionListBean>> response) {
if (response.code() == 200) {
BaseModel<RoomAuction.AuctionListBean> baseModel = response.body();
if (baseModel.getCode() == 1) {
observer.onNext(baseModel.getData());
} else {
ToastUtils.showShort(baseModel.getMsg());
public void roomAuctionJoin(String auctionId, String userId, String giftId, String num, String type, BaseObserver<RoomAuction.AuctionListBean> observer) {
sApiServer.roomAuctionJoin(auctionId, userId, giftId, num, type).enqueue(new ApiResponseCallback<RoomAuction.AuctionListBean>(CommonAppContext.getInstance()) {
@Override
public void onSuccess(RoomAuction.AuctionListBean data) {
// 确保即使data为null也能够正确传递给observer
if (data == null){
data = new RoomAuction.AuctionListBean();
}
observer.onNext(data);
}
}
}
@Override
public void onFailure(Call<BaseModel<RoomAuction.AuctionListBean>> call, Throwable t) {
t.printStackTrace();
public void onFailure(Throwable t) {
super.onFailure(t);
RoomAuction.AuctionListBean yy=new RoomAuction.AuctionListBean();
observer.onNext(yy);
}
});
}
@@ -2180,6 +2206,7 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
LogUtils.e("auction",t);
}
});
}
@@ -2197,7 +2224,7 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
}
});
}
@@ -2211,7 +2238,7 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
}
});
}
@@ -2225,7 +2252,7 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
}
});
}
@@ -2241,7 +2268,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("editRoom",t);
}
});
}
@@ -2256,7 +2284,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("setPresidedRatio",t);
}
});
}
@@ -2272,7 +2301,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("postHostAdd",t);
}
});
}
@@ -2287,7 +2317,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("reward_zone",t);
}
});
}
@@ -2301,7 +2332,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("upSong",t);
}
});
}
@@ -2315,7 +2347,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("clearApply",t);
}
});
}
@@ -2356,7 +2389,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("helpApply",t);
}
});
}
@@ -2371,7 +2405,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("setRoomApply",t);
}
});
}
@@ -2386,13 +2421,13 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("giveGift",t);
}
});
}
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String
type, String pit_number, String heart_id, BaseObserver<String> observer) {
public void roomGift(String room_id, String gift_id, String gift_num, String to_uid, String type, String pit_number, String heart_id, BaseObserver<String> observer) {
sApiServer.roomGift(room_id, gift_id, gift_num, to_uid, type, pit_number, heart_id).enqueue(new Callback<BaseModel<String>>() {
@Override
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
@@ -2401,7 +2436,9 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("解析失败:roomGift", t.toString());
observer.onNext( "");
}
});
}
@@ -2579,8 +2616,7 @@ public class RetrofitClient {
});
}
public void setMutePit(String roomId, String user_id, String
isMute, BaseObserver<String> observer) {
public void setMutePit(String roomId, String user_id, String isMute, BaseObserver<String> observer) {
sApiServer.setMutePit(roomId, user_id, isMute).enqueue(new Callback<BaseModel<String>>() {
@Override
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
@@ -2589,7 +2625,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("setMutePit", t.toString());
}
});
}
@@ -2604,7 +2641,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("setLockPit", t.toString());
}
});
}
@@ -2618,7 +2656,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("downPit", t.toString());
}
});
}
@@ -2632,7 +2671,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("kickOutRoom", t.toString());
}
});
}
@@ -2646,7 +2686,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("applySong", t.toString());
}
});
}
@@ -2660,7 +2701,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("agreeSong", t.toString());
}
});
}
@@ -2674,7 +2716,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("endSong", t.toString());
}
});
}
@@ -2769,6 +2812,7 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
LogUtils.e("changeSong", t.toString());
}
});
}
@@ -2783,7 +2827,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("hostUserPit", t.toString());
}
});
}
@@ -2836,7 +2881,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("topRelationCard", t.toString());
}
});
}
@@ -2850,7 +2896,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("deleteRelationCard", t.toString());
}
});
}
@@ -2906,7 +2953,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("setUserDecorate", t.toString());
}
});
}
@@ -2938,7 +2986,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("publishZone", t.toString());
}
});
}
@@ -2952,7 +3001,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("likeZone", t.toString());
}
});
}
@@ -2966,7 +3016,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("deleteComment", t.toString());
}
});
@@ -2982,7 +3033,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("deleteZone", t.toString());
}
});
}
@@ -2997,7 +3049,9 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("commentZone", t.toString());
}
});
}
@@ -3012,7 +3066,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("clearLoginInfo", t.toString());
}
});
}
@@ -3027,13 +3082,13 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("cancel", t.toString());
}
});
}
public void getPostData(String new_password, String mobile, String code, String
userId, BaseObserver<String> observer) {
public void getPostData(String new_password, String mobile, String code, String userId, BaseObserver<String> observer) {
sApiServer.getPostData(new_password, mobile, code, userId).enqueue(new Callback<BaseModel<String>>() {
@Override
public void onResponse(Call<BaseModel<String>> call, Response<BaseModel<String>> response) {
@@ -3066,7 +3121,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("forgotPassword", t.toString());
}
});
}
@@ -3081,7 +3137,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("createAlbum", t.toString());
}
});
}
@@ -3096,7 +3153,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("editAlbum", t.toString());
}
});
}
@@ -3113,7 +3171,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("editUserInfo", t.toString());
}
});
} else {
@@ -3126,7 +3185,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("editUserBg", t.toString());
}
});
}
@@ -3141,7 +3201,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("userGuanz", t.toString());
}
});
}
@@ -3155,7 +3216,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
t.printStackTrace();
}
});
}
@@ -3170,7 +3232,7 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
t.printStackTrace();
}
});
@@ -3220,7 +3282,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("removeBlackList", t.toString());
}
});
}
@@ -3235,7 +3298,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("upAddAlbum", t.toString());
}
});
}
@@ -3249,7 +3313,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("moveAlbum", t.toString());
}
});
}
@@ -3278,7 +3343,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("deleteAlbum", t.toString());
}
});
} else {
@@ -3290,7 +3356,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("deleteAlbum", t.toString());
}
});
}
@@ -3306,7 +3373,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("likeAlbum", t.toString());
}
});
}
@@ -3320,7 +3388,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("getRealNameResult", t.toString());
}
});
}
@@ -3334,7 +3403,8 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("changeRoom", t.toString());
}
});
}
@@ -3348,13 +3418,13 @@ public class RetrofitClient {
@Override
public void onFailure(Call<BaseModel<String>> call, Throwable t) {
ToastUtils.showShort(t.toString());
// ToastUtils.showShort(t.toString());
LogUtils.e("changeRoomType", t.toString());
}
});
}
public void onNextRetu
(Response<BaseModel<String>> response, BaseObserver<String> observer) {
public void onNextRetu(Response<BaseModel<String>> response, BaseObserver<String> observer) {
if (response.code() == 200) {
BaseModel<String> string = response.body();
if (string != null) {
@@ -3380,8 +3450,7 @@ public class RetrofitClient {
}
/// 获取活动礼物列表
public void getBoxGiftList(String giftBagId, String
roomId, BaseObserver<BlindBoxBean> observer) {
public void getBoxGiftList(String giftBagId, String roomId, BaseObserver<BlindBoxBean> observer) {
sApiServer.getBoxGiftList(giftBagId, roomId).enqueue(new Callback<BaseModel<BlindBoxBean>>() {
@Override
public void onResponse(Call<BaseModel<BlindBoxBean>> call, Response<BaseModel<BlindBoxBean>> response) {
@@ -3512,8 +3581,7 @@ public class RetrofitClient {
});
}
public void xlhMyRecord(String roomId, String page, String
pageSize, BaseObserver<List<GiftBean>> observer) {
public void xlhMyRecord(String roomId, String page, String pageSize, BaseObserver<List<GiftBean>> observer) {
sApiServer.xlhMyRecord(roomId, page, pageSize).enqueue(new Callback<BaseModel<List<GiftBean>>>() {
@Override
public void onResponse(Call<BaseModel<List<GiftBean>>> call, Response<BaseModel<List<GiftBean>>> response) {
@@ -3532,8 +3600,7 @@ public class RetrofitClient {
});
}
public void getAllRecord(String giftBagId, String page, String
pageSize, BaseObserver<List<GiftBean>> observer) {
public void getAllRecord(String giftBagId, String page, String pageSize, BaseObserver<List<GiftBean>> observer) {
sApiServer.getAllRecord(giftBagId, page, pageSize).enqueue(new Callback<BaseModel<List<GiftBean>>>() {
@Override
public void onResponse(Call<BaseModel<List<GiftBean>>> call, Response<BaseModel<List<GiftBean>>> response) {

View File

@@ -21,9 +21,9 @@ public class ARouteConstants {
public static final String CREATED_ROOM = "/modulevocal/CreatedRoomActivity"; //创建房间
public static final String WITHDRAWAL_ACTIVITY = "/modulevocal/WithdrawalActivity"; //提现
public static final String REAL_NAME_ACTIVITY ="/modulevocal/RealNameActivity"; //实名认证
public static final String REAL_NAME_ACTIVITY2 ="/app/RealNameActivity"; //实名认证
public static final String H5 ="/moduleutil/WebViewActivity"; //网页
public static final String GIFT_WALL ="/moduleroom/UserGiftWallFragment"; //实名认证
public static final String REAL_NAME_ACTIVITY2 ="/modulevocal/RealNameActivity"; //实名认证
public static final String H5 ="/moduleUtil/WebViewActivity"; //网页
// public static final String GIFT_WALL ="/moduleroom/UserGiftWallFragment"; //实名认证
public static final String RECHARGE_ACTIVITY ="/modulevocal/RechargeActivity"; //实名认证

View File

@@ -0,0 +1,38 @@
package com.xscm.moduleutil.widget.room
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import com.xscm.moduleutil.bean.room.RoomInfoResp
import com.xscm.moduleutil.http.RetrofitClient
import kotlinx.coroutines.CoroutineScope
open class BaseViewModel : ViewModel(),LifecycleObserver {
val roomInfoData=MutableLiveData<RoomInfoResp>()
private val passRoom by lazy { MutableLiveData<Exception>() }
private val error by lazy { MutableLiveData<Exception>() }
private val finally by lazy { MutableLiveData<Int>() }
//加入房间
fun jiaoRoom(roomId:String, password:String){
}
/**
* 请求失败,出现异常
*/
fun getError(): LiveData<Exception> {
return error
}
/**
* 请求完成,在此处做一些关闭操作
*/
fun getFinally(): LiveData<Int> {
return finally
}
}

View File

@@ -0,0 +1,8 @@
package com.xscm.moduleutil.widget.room
import java.io.IOException
/**
* 自定义异常信息显示
*/
data class PassRoomException(var msg: String,var code: Int) : IOException()