From 3d80ccd003e9003c23a84bf95793e3e39d26b868 Mon Sep 17 00:00:00 2001 From: huangjian Date: Thu, 21 Jan 2021 15:32:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A1=94=E7=BD=97=E7=89=8C=E5=85=AC=E5=B1=8F?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erban/avroom/widget/MessageView.java | 23 ++++++++++++ .../ui/webview/CommonWebViewActivity.java | 18 +++------ .../yizhuan/erban/ui/webview/JSInterface.java | 11 +++--- .../ui/webview/event/CloseWebViewEvent.java | 8 ---- .../XChatConstants.java | 2 +- .../manager/IMNetEaseManager.java | 3 +- .../im/custom/bean/CustomAttachParser.java | 4 ++ .../im/custom/bean/CustomAttachment.java | 5 ++- .../im/custom/bean/TarotAttachment.java | 37 +++++++++++++++++++ .../im/custom/bean/TarotMsgBean.java | 31 ++++++++++++++++ gradle.properties | 4 +- 11 files changed, 114 insertions(+), 32 deletions(-) delete mode 100644 app/src/main/java/com/yizhuan/erban/ui/webview/event/CloseWebViewEvent.java create mode 100644 core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/TarotAttachment.java create mode 100644 core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/TarotMsgBean.java diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java index b93f4a0f4..d8404fc46 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java @@ -98,6 +98,8 @@ import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment2; import com.yizhuan.xchat_android_core.im.custom.bean.RoomNoticeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomTipAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.TarotAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean; import com.yizhuan.xchat_android_core.im.custom.bean.WelcomeAttachment; import com.yizhuan.xchat_android_core.im.game.ImGameInfo; import com.yizhuan.xchat_android_core.im.game.ImGameMode; @@ -793,6 +795,9 @@ public class MessageView extends FrameLayout { if (second == CustomAttachment.CUSTOM_MSG_SUB_RED_PACKAGE_RECEIVE_ROOM_MSG) { setRedPackageMsg(chatRoomMessage, tvContent); } + } else if (first == CustomAttachment.CUSTOM_MESS_TAROT) { + clearBackground(tvContent); + setTarotMsg(chatRoomMessage, tvContent); } else { tvContent.setTextColor(Color.WHITE); tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip)); @@ -805,6 +810,20 @@ public class MessageView extends FrameLayout { } } + private void setTarotMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) { + TarotAttachment attachment = (TarotAttachment) chatRoomMessage.getAttachment(); + if (attachment.getSecond() == CustomAttachment.CUSTOM_MESS_TAROT_SUCCESS) { + TarotMsgBean tarotMsgBean = attachment.getTarotMsgBean(); + String nickName = RegexUtil.getPrintableString(tarotMsgBean.getNick()); + SpannableBuilder text = new SpannableBuilder(tvContent) + .append("恭喜 ", new ForegroundColorSpan(textColor)) + .append(nickName, new ForegroundColorSpan(roomTipNickColor)) + .append(" 在塔罗占卜中运气爆发,收获", new ForegroundColorSpan(textColor)) + .append(tarotMsgBean.getDrawGoldNum() + "金币", new ForegroundColorSpan(roomTipColor)); + tvContent.setText(text.build()); + } + } + /** * 提示已经加入的话题的通知 * @@ -2595,6 +2614,10 @@ public class MessageView extends FrameLayout { EventBus.getDefault().post(new FollowRoomEvent()); PraiseModel.get().setFollowRoomSuccessRoomTip(JavaUtil.str2long(chatRoomMessage.getFromAccount())); }); + } else if (attachment.getFirst() == CustomAttachment.CUSTOM_MESS_TAROT) { + if (attachment instanceof TarotAttachment) { + account = ((TarotAttachment) attachment).getTarotMsgBean().getUid() + ""; + } } } if (TextUtils.isEmpty(account)) return; diff --git a/app/src/main/java/com/yizhuan/erban/ui/webview/CommonWebViewActivity.java b/app/src/main/java/com/yizhuan/erban/ui/webview/CommonWebViewActivity.java index fb6aab901..fdf2ddef8 100644 --- a/app/src/main/java/com/yizhuan/erban/ui/webview/CommonWebViewActivity.java +++ b/app/src/main/java/com/yizhuan/erban/ui/webview/CommonWebViewActivity.java @@ -37,7 +37,6 @@ import com.yizhuan.erban.R; import com.yizhuan.erban.application.XChatApplication; import com.yizhuan.erban.base.BaseActivity; import com.yizhuan.erban.ui.im.RouterHandler; -import com.yizhuan.erban.ui.webview.event.CloseWebViewEvent; import com.yizhuan.erban.ui.webview.event.ShowNavEvent; import com.yizhuan.erban.ui.webview.event.TaroPayResultEvent; import com.yizhuan.erban.ui.widget.ShareDialog; @@ -158,7 +157,7 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O initView(); initData(); setListener(); - ShowWebView(url); + showWebView(url); RxBus.get().toFlowable(ShareH5Event.class) .compose(bindUntilEvent(ActivityEvent.DESTROY)) .subscribeOn(Schedulers.newThread()) @@ -390,7 +389,7 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O } } - public void ShowWebView(String url) { + public void showWebView(String url) { Logger.d("ShowWebView--------" + url); if (!TextUtils.isEmpty(url)) { Map map = new HashMap<>(); @@ -442,7 +441,7 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O @Subscribe(threadMode = ThreadMode.MAIN) public void onRecieveNeedRefreshWebView(WebViewRefreshEvent event) { if (!StringUtil.isEmpty(url)) { - ShowWebView(url); + showWebView(url); } } @@ -451,13 +450,6 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O webView.evaluateJavascript("renderByStatus(" + event.getStatus() + ")", null); } - @Subscribe(threadMode = ThreadMode.MAIN) - public void closeWebViewEvent(CloseWebViewEvent event) { - if (event != null) { - finish(); - } - } - @Subscribe(threadMode = ThreadMode.MAIN) public void showNavEvent(ShowNavEvent event) { if (event != null) { @@ -507,6 +499,8 @@ public class CommonWebViewActivity extends BaseActivity implements ShareDialog.O @Subscribe(threadMode = ThreadMode.MAIN) public void onTaroPayResultEvent(TaroPayResultEvent event) { - finish(); + if (webView != null) { + webView.evaluateJavascript("taroPayResultCallback(" + event.getResult() + ")", null); + } } } diff --git a/app/src/main/java/com/yizhuan/erban/ui/webview/JSInterface.java b/app/src/main/java/com/yizhuan/erban/ui/webview/JSInterface.java index 2cbac5cf9..2909f069e 100644 --- a/app/src/main/java/com/yizhuan/erban/ui/webview/JSInterface.java +++ b/app/src/main/java/com/yizhuan/erban/ui/webview/JSInterface.java @@ -26,8 +26,6 @@ import com.yizhuan.erban.public_chat_hall.activity.PublicChatHallHomeActivity; import com.yizhuan.erban.ui.im.RouterHandler; import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity; import com.yizhuan.erban.ui.pay.ChargeActivity; -import com.yizhuan.erban.ui.webview.event.CloseDialogWebViewEvent; -import com.yizhuan.erban.ui.webview.event.CloseWebViewEvent; import com.yizhuan.erban.ui.webview.event.H5NotifyClientEvent; import com.yizhuan.erban.ui.webview.event.ShowNavEvent; import com.yizhuan.erban.ui.webview.event.TaroPayResultEvent; @@ -114,7 +112,7 @@ public class JSInterface { @JavascriptInterface public void openChargePage() { if (context != null) { - ChargeActivity.start(context,true); + ChargeActivity.start(context, true); } } @@ -272,7 +270,7 @@ public class JSInterface { */ @JavascriptInterface public void closeWebView() { - EventBus.getDefault().post(new CloseWebViewEvent()); + if (mActivity != null) mActivity.finish(); } /** @@ -454,7 +452,7 @@ public class JSInterface { } else if (audit == RPSDK.AUDIT.AUDIT_FAIL) { // 认证不通过 result = 1; - } else if (audit == RPSDK.AUDIT.AUDIT_NOT) { + } else if (audit == RPSDK.AUDIT.AUDIT_NOT) { // 未认证,用户取消 result = -1; } else if (audit == RPSDK.AUDIT.AUDIT_EXCEPTION) { @@ -502,7 +500,7 @@ public class JSInterface { @JavascriptInterface public void closeDialogWebView() { - if (mActivity!=null) mActivity.finish(); + if (mActivity instanceof DialogWebViewActivity) mActivity.finish(); } /** @@ -516,6 +514,7 @@ public class JSInterface { @JavascriptInterface public void checkResultFinish(int result) { EventBus.getDefault().post(new TaroPayResultEvent().setResult(result)); + if (mActivity instanceof DialogWebViewActivity) mActivity.finish(); } } diff --git a/app/src/main/java/com/yizhuan/erban/ui/webview/event/CloseWebViewEvent.java b/app/src/main/java/com/yizhuan/erban/ui/webview/event/CloseWebViewEvent.java deleted file mode 100644 index b65432089..000000000 --- a/app/src/main/java/com/yizhuan/erban/ui/webview/event/CloseWebViewEvent.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.yizhuan.erban.ui.webview.event; - -import lombok.Data; - -@Data -public class CloseWebViewEvent { - -} diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_constants/XChatConstants.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_constants/XChatConstants.java index d4c2394b8..43d4d0e02 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_constants/XChatConstants.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_constants/XChatConstants.java @@ -292,7 +292,7 @@ public class XChatConstants { /** * Referer (DEBUG) */ - public static final String KEY_REFERER_DEBUG = "http://120.79.211.243/"; + public static final String KEY_REFERER_DEBUG = "http://api.uat.zhongjialx.com/"; /** * Referer (RELEASE) diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java index 22eb6d37a..e34982e99 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java @@ -726,7 +726,8 @@ public final class IMNetEaseManager { || customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_FOLLOW_ROOM || customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_SEND_MAGIC || customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_MULTI_GIFT - || customAttachment.getFirst() == CUSTOM_MSG_HEADER_TYPE_KICK_MIC + || customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_KICK_MIC + || customAttachment.getFirst() == CustomAttachment.CUSTOM_MESS_TAROT || customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_MONSTER_HUNTING || customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_MINI_WORLD) { addMessages(msg); diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java index d507fe4ed..f19edcaf0 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java @@ -534,6 +534,10 @@ public class CustomAttachParser implements MsgAttachmentParser { } break; + case CustomAttachment.CUSTOM_MESS_TAROT: + attachment = new TarotAttachment(CustomAttachment.CUSTOM_MESS_TAROT, CustomAttachment.CUSTOM_MESS_TAROT_SUCCESS); + break; + default: break; } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java index 888f8e403..bf38a4dc4 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java @@ -366,8 +366,9 @@ public class CustomAttachment implements MsgAttachment { //推送消息 public static final int CUSTOM_MSG_PUSH_NOTIFIFICATION = 70; public static final int CUSTOM_MSG_SUB_PUSH_NOTIFICATION_IN_ROOM = 701;// 推送进入房间 -// public static final int CUSTOM_MSG_SUB_PUSH_NOTIFICATION_IN_CHAT_ROOM = 702;// 推送进入聊天页 -// public static final int CUSTOM_MSG_SUB_PUSH_NOTIFICATION_IN_DYNAMIC_MSG = 703;// 推送进入动态消息 + + public static final int CUSTOM_MESS_TAROT = 71; //塔罗牌充值消息 + public static final int CUSTOM_MESS_TAROT_SUCCESS = 711; //塔罗牌充值中奖消息 public CustomAttachment() { diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/TarotAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/TarotAttachment.java new file mode 100644 index 000000000..8a55a431d --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/TarotAttachment.java @@ -0,0 +1,37 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; + +public class TarotAttachment extends CustomAttachment { + private TarotMsgBean tarotMsgBean; + + public TarotAttachment(int first, int second) { + super(first, second); + } + + public TarotMsgBean getTarotMsgBean() { + return tarotMsgBean; + } + + public void setTarotMsgBean(TarotMsgBean tarotMsgBean) { + this.tarotMsgBean = tarotMsgBean; + } + + @Override + protected void parseData(JSONObject data) { + tarotMsgBean = new Gson().fromJson(data.toJSONString(), TarotMsgBean.class); + } + + @Override + protected JSONObject packData() { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("chargeProdId", tarotMsgBean.getChargeProdId()); + jsonObject.put("chargeProdName", tarotMsgBean.getChargeProdName()); + jsonObject.put("drawGoldNum", tarotMsgBean.getDrawGoldNum()); + jsonObject.put("nick", tarotMsgBean.getNick()); + jsonObject.put("roomUid", tarotMsgBean.getRoomUid()); + jsonObject.put("uid", tarotMsgBean.getUid()); + return jsonObject; + } +} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/TarotMsgBean.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/TarotMsgBean.java new file mode 100644 index 000000000..c5e1c6871 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/TarotMsgBean.java @@ -0,0 +1,31 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import lombok.Data; + +@Data +public class TarotMsgBean { + /** + * 中奖用户uid + **/ + private long uid; + /** + * 中奖用户昵称 + **/ + private String nick; + /** + * 中奖的房间uid + **/ + private long roomUid; + /** + * 中奖的产品ID + **/ + private String chargeProdId; + /** + * 中奖的产品名称 + **/ + private String chargeProdName; + /** + * 中奖的金币数量 + **/ + private long drawGoldNum; +} diff --git a/gradle.properties b/gradle.properties index 09a17100a..a0754c18e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,5 +20,5 @@ with_jenkins=false #\u6253\u652F\u6301x86\u7684\u6A21\u62DF\u5668\u5305\u4F7F\u7528 ndk_abi_filters=arm -version_name=2.1.1 -version_code=211 \ No newline at end of file +version_name=5.1.1 +version_code=511 \ No newline at end of file