1:修改获取网络数据的解析方式

2:修改拍卖房的规则
This commit is contained in:
2025-09-24 15:59:41 +08:00
parent 5f573e607d
commit 407b21c33f
23 changed files with 1790 additions and 344 deletions

View File

@@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
import com.blankj.utilcode.util.ScreenUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
import com.xscm.moduleutil.databinding.DialogRealNameBinding;
import com.xscm.moduleutil.databinding.IndexDialogYouthModelBinding;
@@ -20,6 +21,18 @@ import com.xscm.moduleutil.widget.dialog.BaseDialog;
*/
public class RealNameDialog extends BaseDialog<DialogRealNameBinding> {
public interface OnFirstChargeListener {
void onFirstChargeConfirmed(String giftBean, int type);
void onFirstChargeCancelled();
}
private OnFirstChargeListener listener;
// 设置监听器的方法
public void setOnFirstChargeListener(OnFirstChargeListener listener) {
this.listener = listener;
}
public RealNameDialog(@NonNull Context context) {
super(context);
}
@@ -36,8 +49,19 @@ public class RealNameDialog extends BaseDialog<DialogRealNameBinding> {
Window window = getWindow();
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
mBinding.tvIKnow.setOnClickListener(v -> dismiss());
mBinding.ivClose.setOnClickListener(v -> dismiss());
// mBinding.tvIKnow.setOnClickListener(v -> dismiss());
// mBinding.ivClose.setOnClickListener(v -> dismiss());
mBinding.tvIKnow.setOnClickListener(v -> {
if (listener != null) {
listener.onFirstChargeConfirmed(null, 0);
}
});
mBinding.ivClose.setOnClickListener(v -> {
if (listener != null) {
listener.onFirstChargeCancelled();
}
});
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvIKnow, ColorManager.getInstance().getPrimaryColorInt(), 53);
mBinding.tvIKnow.setTextColor(ColorManager.getInstance().getButtonColorInt());

View File

@@ -0,0 +1,228 @@
package com.xscm.moduleutil.dialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.webkit.JavascriptInterface;
import android.webkit.WebSettings;
import android.webkit.WebViewClient;
import android.widget.Toast;
import androidx.annotation.NonNull;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.tencent.imsdk.v2.V2TIMConversation;
import com.tencent.mm.opensdk.modelbiz.WXOpenCustomerServiceChat;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.tencent.qcloud.tuicore.TUIConstants;
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIC2CChatActivity;
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.base.RoomManager;
import com.xscm.moduleutil.databinding.DialogRoomAuctionWebviewBinding;
import com.xscm.moduleutil.databinding.WebViewDialogBinding;
import com.xscm.moduleutil.utils.ARouteConstants;
import com.xscm.moduleutil.widget.dialog.BaseDialog;
/**
*@author qx
*@data 2025/9/24
*@description: 这是拍卖房的规则界面
*/
public class RoomAuctionWebViewDialog extends BaseDialog<DialogRoomAuctionWebviewBinding> {
String mUrl;
int type;//10天空之境 11岁月之城 12时空之巅
public RoomAuctionWebViewDialog(@NonNull Context context, Bundle args) {
super(context, R.style.BaseDialogStyleH);
this.mUrl = args.getString("url");
this.type = args.getInt("type");
initData1();
}
@Override
public void onStart() {
super.onStart();
if (getWindow() != null) {
// 获取屏幕尺寸
android.util.DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
// 设置高度为屏幕高度的80%
android.view.WindowManager.LayoutParams params = getWindow().getAttributes();
params.height = (int) (displayMetrics.heightPixels * 0.9);
params.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
getWindow().setAttributes(params);
}
}
@Override
public int getLayoutId() {
return R.layout.dialog_room_auction_webview;
}
@Override
public void initView() {
setCancelable(true);
setCanceledOnTouchOutside(true);
Window window = getWindow();
assert window != null;
window.setGravity(Gravity.BOTTOM);
window.setLayout((int) (ScreenUtils.getScreenWidth() * 320.f / 375), WindowManager.LayoutParams.MATCH_PARENT);
mBinding.topBar.setTitle("规则");
mBinding.topBar.getIvBack().setOnClickListener(v -> dismiss());
}
@Override
public void initData() {
}
public void initData1() {
// WebSettings webSettings = mBinding.webView.getSettings();
// webSettings.setUseWideViewPort(true);
// webSettings.setLoadWithOverviewMode(true);
// webSettings.setJavaScriptEnabled(true);
// webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
// //增加JSBridge
// mBinding.webView.addJavascriptInterface(new WebAppInterface(getContext()), "Android");
//// mBinding.webView.addJavascriptInterface(new WebViewBridgeConfig(title), WebViewBridgeConfig.NAME);
// webSettings.setBuiltInZoomControls(false);
// webSettings.setSupportZoom(false);
// webSettings.setDomStorageEnabled(true);
// webSettings.setBlockNetworkImage(false);//解决图片不显示
// // 启用 WebView 内容的滚动
// mBinding.webView.setVerticalScrollBarEnabled(true);
// mBinding.webView.setScrollbarFadingEnabled(true);
// webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
// mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
// mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示
// mBinding.webView.setWebViewClient(new WebViewClient());
// mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
// mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
//
// mBinding.webView.requestFocus();
// mBinding.webView.loadUrl(mUrl);
WebSettings webSettings = mBinding.webView.getSettings();
webSettings.setUseWideViewPort(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setJavaScriptEnabled(true);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
//增加JSBridge
mBinding.webView.addJavascriptInterface(new WebAppInterface(getContext()), "Android");
// mBinding.webView.addJavascriptInterface(new WebViewBridgeConfig(title), WebViewBridgeConfig.NAME);
webSettings.setBuiltInZoomControls(false);
webSettings.setSupportZoom(false);
webSettings.setDomStorageEnabled(true);
webSettings.setBlockNetworkImage(false);//解决图片不显示
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
// 启用 WebView 内容的滚动,但隐藏滚动条
mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示滚动条
mBinding.webView.setWebViewClient(new WebViewClient());
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
// 确保内容可以滚动
webSettings.setDomStorageEnabled(true);
mBinding.webView.requestFocus();
mBinding.webView.loadUrl(mUrl);
}
private Resources getResources() {
return getContext().getResources();
}
public class WebAppInterface {
Context mContext;
WebAppInterface(Context c) {
mContext = c;
}
// 被 H5 调用的方法
@JavascriptInterface
public void showToast(String toast) {
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
}
@JavascriptInterface
public void closeWeb() {
LogUtils.e("value: ");
dismiss();
}
@JavascriptInterface
public void customerService() {
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(); // 填移动应用(App)的 AppId
IWXAPI api = WXAPIFactory.createWXAPI(mContext, appId);
// 判断当前版本是否支持拉起客服会话
WXOpenCustomerServiceChat.Req req = new WXOpenCustomerServiceChat.Req();
req.corpId = "ww1de4300858c0b461"; // 企业ID
req.url = "https://work.weixin.qq.com/kfid/kfcb3d23a59c188a0e7"; // 客服URL
api.sendReq(req);
}
@JavascriptInterface
public void jumpRoomPage(String room_id) {
RoomManager.getInstance().fetchRoomDataAndEnter(getContext(), room_id,"");
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
}
@JavascriptInterface
public void jumpWebPage(String objects) {
// ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).navigation();
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", objects).navigation();
}
@JavascriptInterface
public void enterGroupChat(String group_id,String cover,String guild_name) {
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, group_id);
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP);
mContext.startActivity(intent);
}
@JavascriptInterface
public void chatWithUser(String user_id,String nickname) {
Intent intent = new Intent(mContext, TUIC2CChatActivity.class);
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, user_id);
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
mContext.startActivity(intent);
}
@JavascriptInterface
public void exchange(){
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
}
@JavascriptInterface
public void Withdrawal() {
ARouter.getInstance().build(ARouteConstants.WITHDRAWAL_ACTIVITY).navigation();
}
@JavascriptInterface
public void enterAuthent() {//实名认证
ARouter.getInstance().build(ARouteConstants.REAL_NAME_ACTIVITY2).navigation();
}
@JavascriptInterface
public void Recharge(){
ARouter.getInstance().build(ARouteConstants.RECHARGE_ACTIVITY).navigation();
}
}
}

View File

@@ -171,7 +171,7 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.POST_ROOM_RANK)
Observable<BaseModel<List<CharmRankingResp>>> getRoomRank(@Field("room_id") String room_id, @Field("type") String type, @Field("time_type") String time_type, @Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<List<CharmRankingResp>>> getRoomRank(@Field("room_id") String room_id, @Field("type") String type, @Field("time_type") String time_type, @Field("page") String page, @Field("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.POST_ROOM_RANKING)
@@ -182,16 +182,16 @@ public interface ApiServer {
Observable<BaseModel<PlaceholderBean>> loveRanking(@Field("type") String type);
@GET(Constants.GET_REAL_NAME)
Observable<BaseModel<RealNameBean>> realNameInfo();
Call<BaseModel<RealNameBean>> realNameInfo();
@GET(Constants.GET_DAILY_TASK_BOX)
Observable<BaseModel<List<GiftBoxRecordBean>>> dailyTasksBoxRecord();
Call<BaseModel<List<GiftBoxRecordBean>>> dailyTasksBoxRecord();
@GET(Constants.GET_MY_BAG_DATA)
Observable<BaseModel<List<MyBagDataBean>>> packIncome(@Query("page") String page, @Query("page_limit") String page_size);
Call<BaseModel<List<MyBagDataBean>>> packIncome(@Query("page") String page, @Query("page_limit") String page_size);
@GET(Constants.GET_MY_BAG_OUTCOME)
Observable<BaseModel<List<MyBagDataBean>>> packOutcome(@Query("page") String page, @Query("page_limit") String page_size);
Call<BaseModel<List<MyBagDataBean>>> packOutcome(@Query("page") String page, @Query("page_limit") String page_size);
@GET(Constants.GET_GIFT_PACK)
Call<BaseModel<List<GiftPackBean>>> giftPack();
@@ -213,7 +213,7 @@ public interface ApiServer {
Call<ResponseBody> endPk(@Field("pk_id") String is_pk, @Field("type") String type, @Field("user_id") String user_id);
@GET(Constants.GET_RECHARGE)
Observable<BaseModel<List<RechargeBean>>> recharge();
Call<BaseModel<List<RechargeBean>>> recharge();
@FormUrlEncoded
@POST(Constants.POST_START_PK)
@@ -225,7 +225,7 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.SWITCH_ACCOUNTS)
Observable<BaseModel<List<UserBean>>> switchAccounts(@Field("user_login") String user_id);
Call<BaseModel<List<UserBean>>> switchAccounts(@Field("user_login") String user_id);
@FormUrlEncoded
@POST(Constants.FORGOT_PASSWORD)
@@ -233,7 +233,7 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.USER_UPDATE)
Observable<BaseModel<UserBean>> userUpdate(@Field("nickname") String nickname, @Field("birthday") String birthday, @Field("sex") String sex, @Field("avatar") String avatar, @Field("init_code") String init_code, @Field("user_id") String user_id);
Call<BaseModel<UserBean>> userUpdate(@Field("nickname") String nickname, @Field("birthday") String birthday, @Field("sex") String sex, @Field("avatar") String avatar, @Field("init_code") String init_code, @Field("user_id") String user_id);
@GET(Constants.AUTHORIZATION)
Call<ResponseBody> authorization();
@@ -263,18 +263,18 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.REAL_NAME)
Observable<BaseModel<RealNameBean>> realName(@Field("real_name") String real_name, @Field("card_number") String card_number);
Call<BaseModel<RealNameBean>> realName(@Field("real_name") String real_name, @Field("card_number") String card_number);
@FormUrlEncoded
@POST(Constants.GET_EXPAND_COLUMN)
Observable<BaseModel<List<ExpandColumnBean>>> getExpandColumn(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<List<ExpandColumnBean>>> getExpandColumn(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit);
@GET(Constants.GET_OFFICIAL_NOTICE)
Observable<BaseModel<NewsDataBean>> getOfficialNotice();
Call<BaseModel<NewsDataBean>> getOfficialNotice();
@FormUrlEncoded
@POST(Constants.GET_ALBUM_LIST)
Observable<BaseModel<List<AlbumBean>>> getAlbumList(@Field("page") String page, @Field("page_limit") String page_limit, @Field("user_id") String user_id);
Call<BaseModel<List<AlbumBean>>> getAlbumList(@Field("page") String page, @Field("page_limit") String page_limit, @Field("user_id") String user_id);
@FormUrlEncoded
@POST(Constants.CREATE_ALBUM)
@@ -289,19 +289,19 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.POST_FOLLOW_LIST)
Observable<BaseModel<List<BlackUserBean>>> getUserFollowList(@Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<List<BlackUserBean>>> getUserFollowList(@Field("page") String page, @Field("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.POST_FANS_LIST)
Observable<BaseModel<List<BlackUserBean>>> getUserFansList(@Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<List<BlackUserBean>>> getUserFansList(@Field("page") String page, @Field("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.POST_BLACK_LIST)
Observable<BaseModel<List<BlackUserBean>>> getBlacklist(@Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<List<BlackUserBean>>> getBlacklist(@Field("page") String page, @Field("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.POST_LOCK_MI_LIST)
Observable<BaseModel<List<BlackUserBean>>> getLockMiniList(@Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<List<BlackUserBean>>> getLockMiniList(@Field("page") String page, @Field("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.GET_MY_ROOM)
@@ -316,7 +316,7 @@ public interface ApiServer {
Call<BaseModel<List<TopRoom>>> getTopRooms(@Field("page") String page, @Field("page_limit") String page_limit, @Field("is_top") String is_top, @Field("label_id") String label_id);
@GET(Constants.GET_ROOM_TYPE)
Observable<BaseModel<List<RoomTypeModel>>> getRoomCategories();
Call<BaseModel<List<RoomTypeModel>>> getRoomCategories();
@FormUrlEncoded
@POST(Constants.CHECK_TXT)
@@ -324,35 +324,35 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.GET_REWARD_LIST)
Observable<BaseModel<List<RewardUserBean>>> getRewardList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<List<RewardUserBean>>> getRewardList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
@GET(Constants.GET_GIFT_LABEL)
Observable<BaseModel<List<GiftLabelBean>>> getGiftLabel(@Query("have_hot") String have_hot);
Call<BaseModel<List<GiftLabelBean>>> getGiftLabel(@Query("have_hot") String have_hot);
@GET(Constants.GIFT_LIST)
//获取礼物列表
Observable<BaseModel<List<RoonGiftModel>>> getGiftList(@Query("label") int label,@Query("room_id")String room_id);
Call<BaseModel<List<RoonGiftModel>>> getGiftList(@Query("label") int label,@Query("room_id")String room_id);
@GET(Constants.TOPIC_LIST)
//获取话题
Observable<BaseModel<List<HeatedBean>>> topicList(@Query("page") String page, @Query("page_limit") String page_limit);
Call<BaseModel<List<HeatedBean>>> topicList(@Query("page") String page, @Query("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.PUBLISH_ZONE)
Call<BaseModel<String>> publishZone(@Field("images") String images, @Field("content") String content, @Field("topic_id") String topic_id, @Field("room_id") String room_id, @Field("ip") String ip);
@GET(Constants.GET_CATEGORIES)
Observable<BaseModel<List<HeatedBean>>> getCategories();
Call<BaseModel<List<HeatedBean>>> getCategories();
@GET(Constants.GET_CIRCLE_LIST)
Call<BaseModel<List<CircleListBean>>> getCircleList(@Query("page") String page, @Query("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.GET_USER_HOME_ZONE)
Observable<BaseModel<List<CircleListBean>>> getCircleUserList(@Field("user_id") String user_id, @Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<List<CircleListBean>>> getCircleUserList(@Field("user_id") String user_id, @Field("page") String page, @Field("page_limit") String page_limit);
@GET(Constants.GET_MY_FOOT)
Observable<BaseModel<List<MyFootResp>>> getMyFoot(@Query("page") String page, @Query("page_limit") String page_limit);
Call<BaseModel<List<MyFootResp>>> getMyFoot(@Query("page") String page, @Query("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.LIKE_ZONE)
@@ -360,15 +360,15 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.TOPIC_ID)
Observable<BaseModel<List<CircleListBean>>> topicId(@Field("topic_id") String topic_id);
Call<BaseModel<List<CircleListBean>>> topicId(@Field("topic_id") String topic_id);
@FormUrlEncoded
@POST(Constants.ZONE_DETAIL)
Observable<BaseModel<CircleListBean>> zoneDetail(@Field("id") String topic_id);
Call<BaseModel<CircleListBean>> zoneDetail(@Field("id") String topic_id);
@FormUrlEncoded
@POST(Constants.GET_USER_HOME)
Observable<BaseModel<UserInfo>> getUserHome(@Field("user_id") String user_id);
Call<BaseModel<UserInfo>> getUserHome(@Field("user_id") String user_id);
@FormUrlEncoded
@POST(Constants.DELETE_COMMENT)
@@ -376,11 +376,11 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.GET_COMMENT_LIST)
Observable<BaseModel<CommentBean>> getCommentList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<CommentBean>> getCommentList(@Field("id") String id, @Field("page") String page, @Field("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.POST_SONG)
Observable<BaseModel<List<SongMusicBean>>> song(@Field("room_id") String roomId, @Field("user_id") String userId, @Field("song_code") String songCode, @Field("song_name") String songName, @Field("singer") String singer, @Field("poster") String poster, @Field("duration") String duration);
Call<BaseModel<List<SongMusicBean>>> song(@Field("room_id") String roomId, @Field("user_id") String userId, @Field("song_code") String songCode, @Field("song_name") String songName, @Field("singer") String singer, @Field("poster") String poster, @Field("duration") String duration);
@FormUrlEncoded
@POST(Constants.COMMENT_ZONE)
@@ -403,7 +403,7 @@ public interface ApiServer {
Call<BaseModel<String>> deleteZone(@Field("id") String id);
@GET(Constants.GET_MY_INFO)
Observable<BaseModel<UserInfo>> getMyInfo();
Call<BaseModel<UserInfo>> getMyInfo();
@FormUrlEncoded
@POST(Constants.ED_USER_INFO)
@@ -414,25 +414,25 @@ public interface ApiServer {
Call<BaseModel<String>> editUserBg(@Field("images") String images);
@GET(Constants.GET_USER_TAG_LIST)
Observable<BaseModel<List<UserTagBean>>> getUserTagList();
Call<BaseModel<List<UserTagBean>>> getUserTagList();
@FormUrlEncoded
@POST(Constants.GET_LIKE_LIST)
Observable<BaseModel<List<CircleListBean.LikeList>>> getLikeList(@Field("id") String id);
Call<BaseModel<List<CircleListBean.LikeList>>> getLikeList(@Field("id") String id);
@FormUrlEncoded
@POST(Constants.GET_ALBUM_DETAIL)
Observable<BaseModel<AlbumBean>> getAlbumDetail(@Field("album_id") String albumId, @Field("pwd") String pwd, @Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<AlbumBean>> getAlbumDetail(@Field("album_id") String albumId, @Field("pwd") String pwd, @Field("page") String page, @Field("page_limit") String page_limit);
@GET(Constants.GET_PERSONALTY)
Observable<BaseModel<List<PersonaltyBean>>> getPersonaltyList();
Call<BaseModel<List<PersonaltyBean>>> getPersonaltyList();
@FormUrlEncoded
@POST(Constants.GET_SUBSIDY)
Observable<BaseModel<RoomSubsidy>> getSubsidy(@Field("room_id") String roomId);
Call<BaseModel<RoomSubsidy>> getSubsidy(@Field("room_id") String roomId);
@GET(Constants.GET_DECORATE)
Observable<BaseModel<List<ZhuangBanShangChengBean>>> getDecorateList(@Query("type") String type);
Call<BaseModel<List<ZhuangBanShangChengBean>>> getDecorateList(@Query("type") String type);
@FormUrlEncoded
@POST(Constants.POST_GZ)
@@ -497,11 +497,11 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.UPDATEPASSWORD)
Observable<BaseModel<String>> updatePassword(@Field("room_id") String roomId, @Field("password") String password);
Call<BaseModel<String>> updatePassword(@Field("room_id") String roomId, @Field("password") String password);
@FormUrlEncoded
@POST(Constants.GET_ROOM_ONLINE)
Observable<BaseModel<RoomOnline>> getRoomOnline(@Field("room_id") String roomId, @Field("page") String page, @Field("page_limit") String page_limit);
Call<BaseModel<RoomOnline>> getRoomOnline(@Field("room_id") String roomId, @Field("page") String page, @Field("page_limit") String page_limit);
@FormUrlEncoded
@POST(Constants.GET_GIVE_GIFT)
@@ -512,29 +512,29 @@ public interface ApiServer {
Call<BaseModel<String>> roomGift(@Field("room_id") String room_id, @Field("gift_id") String gift_id, @Field("gift_num") String num, @Field("to_uid") String to_uid, @Field("type") String gift_type, @Field("pit_number") String pit_number, @Field("heart_id") String heat_id);
@GET(Constants.GET_FIRST_CHARGE_GIFT)
Observable<BaseModel<FirstChargeGiftBean>> firstChargeGift();
Call<BaseModel<FirstChargeGiftBean>> firstChargeGift();
@GET(Constants.GET_WALLET)
Observable<BaseModel<WalletBean>> wallet();
Call<BaseModel<WalletBean>> wallet();
@FormUrlEncoded
@POST(Constants.POST_APPLY_Pay)
Observable<BaseModel<AppPay>> appPay(@Field("user_id") String user_id, @Field("money") String money, @Field("coin") String coin, @Field("type") String type);
Call<BaseModel<AppPay>> appPay(@Field("user_id") String user_id, @Field("money") String money, @Field("coin") String coin, @Field("type") String type);
@FormUrlEncoded
@POST(Constants.POST_APPLY_LIST)
Observable<BaseModel<RoomApplyListBean>> roomApplyListBean(@Field("room_id") String room_id);
Call<BaseModel<RoomApplyListBean>> roomApplyListBean(@Field("room_id") String room_id);
@FormUrlEncoded
@POST(Constants.GET_ROOM_USER)
Observable<BaseModel<UserInfo>> getRoomUserInfo(@Field("room_id") String roomId, @Field("user_id") String userId);
Call<BaseModel<UserInfo>> getRoomUserInfo(@Field("room_id") String roomId, @Field("user_id") String userId);
@FormUrlEncoded
@POST(Constants.POST_BIND_TYPE)
Observable<BaseModel<BindType>> bindType(@Field("user_id") String userId);
Call<BaseModel<BindType>> bindType(@Field("user_id") String userId);
@GET(Constants.GET_WALLET_CONFIG)
Observable<BaseModel<WalletConfig>> getWalletConfig();
Call<BaseModel<WalletConfig>> getWalletConfig();
@FormUrlEncoded
@POST(Constants.POST_BIND)
@@ -542,7 +542,7 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.POST_SONG_LIST)
Observable<BaseModel<List<MusicSongBean>>> songList(@Field("room_id") String room_id);
Call<BaseModel<List<MusicSongBean>>> songList(@Field("room_id") String room_id);
@FormUrlEncoded
@POST(Constants.APPLY_PIT)
@@ -626,23 +626,23 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.POST_HOST_LIST)
Observable<BaseModel<List<HostBean>>> getHostList(@Query("room_id") String room_id, @Field("type") String type);
Call<BaseModel<List<HostBean>>> getHostList(@Query("room_id") String room_id, @Field("type") String type);
@FormUrlEncoded
@POST(Constants.GET_CHARM_RANK)
Observable<BaseModel<List<RoomCharmRankBean>>> getCharmRank(@Field("room_id") String roomId);
Call<BaseModel<List<RoomCharmRankBean>>> getCharmRank(@Field("room_id") String roomId);
@FormUrlEncoded
@POST(Constants.POST_ROOM_RELATION_LIST)
Observable<BaseModel<List<RoomRelationBean>>> roomRelationList(@Field("type") String type);
Call<BaseModel<List<RoomRelationBean>>> roomRelationList(@Field("type") String type);
@FormUrlEncoded
@POST(Constants.POST_ROOM_AUCTION_LIST)
Observable<BaseModel<List<RoomAuction.AuctionListBean>>> roomAuctionList(@Field("auction_id") String auction_id);
Call<BaseModel<List<RoomAuction.AuctionListBean>>> roomAuctionList(@Field("auction_id") String auction_id);
@FormUrlEncoded
@POST(Constants.POST_SEARCH)
Observable<BaseModel<List<RoomSearchResp>>> getSearch(@Query("search") String room_id, @Field("type") String type);
Call<BaseModel<List<RoomSearchResp>>> getSearch(@Query("search") String room_id, @Field("type") String type);
@FormUrlEncoded
@POST(Constants.SET_PRESIDED_RATIO)
@@ -670,11 +670,11 @@ public interface ApiServer {
Call<BaseModel<String>> setLockPit(@Field("room_id") String room_id, @Field("pit_number") String pit_number, @Field("is_lock") String is_lock);
@GET(Constants.GET_ROOM_BJ)
Observable<BaseModel<RoomBgBean>> getBackgroundList();
Call<BaseModel<RoomBgBean>> getBackgroundList();
@FormUrlEncoded
@POST(Constants.POST_CHARM_LIST)
Observable<BaseModel<RoomDetails>> getCharmList(@Field("room_id") String room_id, @Field("start_time") String start_time, @Field("end_time") String end_time, @Field("page") String page);
Call<BaseModel<RoomDetails>> getCharmList(@Field("room_id") String room_id, @Field("start_time") String start_time, @Field("end_time") String end_time, @Field("page") String page);
@FormUrlEncoded
@POST(Constants.POST_SET_UPLOAD_BG_IMG)
@@ -707,7 +707,7 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.POST_RELATION_CARD)
Observable<BaseModel<RelationCardBean>> relationCard(@Field("user_id") String user_id);
Call<BaseModel<RelationCardBean>> relationCard(@Field("user_id") String user_id);
@FormUrlEncoded
@POST(Constants.POST_TOP_RELATION_CARD)
@@ -720,11 +720,11 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.POST_ROOM_AUCTION)
Observable<BaseModel<AuctionBean>> roomAuction(@Field("room_id") String room_id, @Field("user_id") String user_id, @Field("gift_id") String gift_id, @Field("relation_id") String relation_id, @Field("auction_type") String auction_type, @Field("time_day") String time_day);
Call<BaseModel<AuctionBean>> roomAuction(@Field("room_id") String room_id, @Field("user_id") String user_id, @Field("gift_id") String gift_id, @Field("relation_id") String relation_id, @Field("auction_type") String auction_type, @Field("time_day") String time_day);
@FormUrlEncoded
@POST(Constants.POST_ROOM_AUCTION_TIME)
Observable<BaseModel<RoomTime>> roomAuctionTime(@Field("gift_id") String gift_id);
Call<BaseModel<RoomTime>> roomAuctionTime(@Field("gift_id") String gift_id);
@FormUrlEncoded
@POST(Constants.POST_ROOM_AUCTION_JOIN)
@@ -733,7 +733,7 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.POST_SEARCH_PK_ROOM)
Observable<BaseModel<List<RoomBean>>> searchPkRoom(@Field("room_id") String room_id, @Field("page") String page, @Field("limit") String limit);
Call<BaseModel<List<RoomBean>>> searchPkRoom(@Field("room_id") String room_id, @Field("page") String page, @Field("limit") String limit);
@GET(Constants.GET_BOX_GIFT_LIST)
Call<BaseModel<BlindBoxBean>> getBoxGiftList(@Query("gift_bag_id") String gift_bag_id, @Query("room_id") String room_id);
@@ -779,6 +779,6 @@ public interface ApiServer {
@FormUrlEncoded
@POST(Constants.ROOM_USER_RECONNECT)
Observable<BaseModel<String>> roomUserReconnect(@Field("room_id") String room_id);
Call<BaseModel<String>> roomUserReconnect(@Field("room_id") String room_id);
}

View File

@@ -46,26 +46,9 @@ public class DefaultTransformer<T> implements ObservableTransformer<BaseModel<T>
T data = response.getData();
if (data == null) {
return getDefaultValue();
// 根据类型返回默认值
// if (data instanceof String) {
// data = (T) "";
// } else if (data instanceof List) {
// data = (T) new ArrayList<>();
// } else if (data instanceof Integer) {
// data = (T) Integer.valueOf(0);
// } else if (data instanceof Long) {
// data = (T) Long.valueOf(0L);
// } else if (data instanceof Double) {
// data = (T) Double.valueOf(0.0);
// } else if (data instanceof Float) {
// data = (T) Float.valueOf(0.0f);
// } else if (data instanceof Boolean) {
// data = (T) Boolean.FALSE;
// } else {
// data= ;
// }
}
return data;
// return response.getData();
})
.onErrorResumeNext(throwable -> {
// 可以在这里统一处理异常
@@ -81,8 +64,26 @@ public class DefaultTransformer<T> implements ObservableTransformer<BaseModel<T>
@SuppressWarnings("unchecked")
private T getDefaultValue() {
try {
// 尝试返回合理类型的默认值
return (T) new Object();
// 根据类型返回合理的默认值
Class<T> type = (Class<T>) Object.class;
if (String.class.isAssignableFrom(type)) {
return (T) "";
} else if (List.class.isAssignableFrom(type)) {
return (T) new ArrayList<>();
} else if (Integer.class.isAssignableFrom(type) || int.class.isAssignableFrom(type)) {
return (T) Integer.valueOf(0);
} else if (Long.class.isAssignableFrom(type) || long.class.isAssignableFrom(type)) {
return (T) Long.valueOf(0L);
} else if (Double.class.isAssignableFrom(type) || double.class.isAssignableFrom(type)) {
return (T) Double.valueOf(0.0);
} else if (Float.class.isAssignableFrom(type) || float.class.isAssignableFrom(type)) {
return (T) Float.valueOf(0.0f);
} else if (Boolean.class.isAssignableFrom(type) || boolean.class.isAssignableFrom(type)) {
return (T) Boolean.FALSE;
} else {
// 对于其他对象类型返回一个新的Object实例
return (T) new Object();
}
} catch (Exception e) {
return null;
}

View File

@@ -2,6 +2,7 @@ package com.xscm.moduleutil.widget;
import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
@@ -47,7 +48,22 @@ public class GiftAnimView extends FrameLayout implements GiftSvgaView.OnAnimatio
private List<String> giftArray = new ArrayList<>();
public ExecutorService queue = Executors.newSingleThreadExecutor();
private Context mContext;
private boolean isOnece;
// 添加带Context参数的构造函数
// 添加带Context和AttributeSet参数的构造函数解决XML inflate问题的关键
public GiftAnimView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
this.mContext = context;
init();
}
// 添加带Context、AttributeSet和 defStyleAttr 参数的构造函数(更完整的实现)
public GiftAnimView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mContext = context;
init();
}
public void setQueue(ExecutorService queue) {
this.queue = queue;
}
@@ -85,6 +101,9 @@ public class GiftAnimView extends FrameLayout implements GiftSvgaView.OnAnimatio
post(() -> {
if (playerMp4View!=null) {
playerMp4View.setVisibility(View.GONE);
if (isOnece){
return;
}
// 通知播放完成
notifyPlaybackComplete();
loadStartSVGAPlayer();
@@ -187,6 +206,35 @@ public class GiftAnimView extends FrameLayout implements GiftSvgaView.OnAnimatio
});
}
public void previewEffectWith(String playImage){
this.isOnece=true;
if (playImage.endsWith("mp4")) {
downloadAndPlay(getContext(), playImage, new DownloadCallback() {
@Override
public void onSuccess(File file) {
post(() -> {
playerMp4View.setVisibility(View.VISIBLE);
svgaView.setVisibility(View.GONE);
playerMp4View.startPlay(file);
});
}
@Override
public void onFailure(Exception e) {
LogUtils.e("MP4下载或播放失败: " + e.getMessage());
// 处理失败情况,继续播放下一个
}
});
} else if (playImage.endsWith("svga")) {
// File file = downloadAndPlay(getContext(), playImage);
post(() -> {
playerMp4View.setVisibility(View.GONE);
svgaView.setVisibility(View.VISIBLE);
svgaView.loadSVGAPlayerWith(playImage, false);
});
}
}
public void openOrCloseEffectViewWith(boolean isShow) {
this.isShow = isShow;
removeSvgaQueueData();
@@ -420,6 +468,9 @@ public class GiftAnimView extends FrameLayout implements GiftSvgaView.OnAnimatio
if (svgaView!=null) {
svgaView.setVisibility(View.GONE);
}
if (isOnece){
return;
}
// 通知播放完成
notifyPlaybackComplete();
loadStartSVGAPlayer();

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<com.xscm.moduleutil.widget.CustomTopBar
android:id="@+id/top_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-30dp"
app:layout_constraintTop_toTopOf="parent" />
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@color/white"
app:layout_constraintTop_toBottomOf="@+id/top_bar"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>