From 972f635e70b4b362badfaf0dc36dbf9c6734610a Mon Sep 17 00:00:00 2001 From: huangjian Date: Wed, 20 Jan 2021 18:57:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E4=BA=B2=E6=A8=A1?= =?UTF-8?q?=E5=BC=8FIM=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../avroom/fragment/HomePartyFragment.java | 83 +++++++++++++ .../erban/avroom/helper/AnimHelper.java | 110 ++++++++++++++++++ .../res/drawable-xhdpi/ic_dating_like.png | Bin 0 -> 4866 bytes .../res/drawable/shape_dating_second_bg.xml | 6 + .../layout/fragment_chatroom_game_main.xml | 53 +++++++++ .../XChatConstants.java | 1 + .../manager/IMNetEaseManager.java | 58 ++++++++- .../im/custom/bean/CustomAttachParser.java | 18 ++- .../im/custom/bean/CustomAttachment.java | 8 ++ .../im/custom/bean/DatingAttachment.java | 38 ++++++ .../custom/bean/DatingPublishAttachment.java | 43 +++++++ .../manager/AvRoomDataManager.java | 1 + .../xchat_android_core/manager/RoomEvent.java | 2 + 13 files changed, 413 insertions(+), 8 deletions(-) create mode 100644 app/src/main/java/com/yizhuan/erban/avroom/helper/AnimHelper.java create mode 100644 app/src/main/res/drawable-xhdpi/ic_dating_like.png create mode 100644 app/src/main/res/drawable/shape_dating_second_bg.xml create mode 100644 core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/DatingAttachment.java create mode 100644 core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/DatingPublishAttachment.java diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java index 887f64785..ae54f84c0 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/HomePartyFragment.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.content.res.AssetFileDescriptor; import android.graphics.Color; +import android.graphics.Point; import android.media.MediaPlayer; import android.os.Bundle; import android.os.SystemClock; @@ -13,9 +14,11 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; import android.text.style.ForegroundColorSpan; +import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; import android.view.ViewConfiguration; +import android.view.ViewGroup; import android.view.ViewStub; import android.view.animation.Animation; import android.view.animation.AnimationUtils; @@ -29,6 +32,7 @@ import androidx.databinding.DataBindingUtil; import com.coorchice.library.SuperTextView; import com.netease.nim.uikit.common.util.string.StringUtil; +import com.netease.nim.uikit.common.util.sys.ScreenUtil; import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder; import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage; import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment; @@ -44,6 +48,7 @@ import com.yizhuan.erban.R; import com.yizhuan.erban.UIHelper; import com.yizhuan.erban.avroom.activity.AVRoomActivity; import com.yizhuan.erban.avroom.activity.RoomOnlineUserActivity; +import com.yizhuan.erban.avroom.helper.AnimHelper; import com.yizhuan.erban.avroom.presenter.HomePartyPresenter; import com.yizhuan.erban.avroom.widget.GiftV2View; import com.yizhuan.erban.avroom.widget.MessageView; @@ -70,6 +75,7 @@ import com.yizhuan.xchat_android_core.home.bean.BannerInfo; import com.yizhuan.xchat_android_core.home.event.FollowRoomEvent; import com.yizhuan.xchat_android_core.home.model.CollectionRoomModel; import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.DatingAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.LevelUpNoticeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomInfoAttachment; @@ -81,6 +87,7 @@ import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; import com.yizhuan.xchat_android_core.manager.RoomEvent; import com.yizhuan.xchat_android_core.monsterhunting.SimpleAnimationListener; import com.yizhuan.xchat_android_core.praise.PraiseModel; +import com.yizhuan.xchat_android_core.room.bean.DatingNotifyInfo; import com.yizhuan.xchat_android_core.room.bean.RoomInfo; import com.yizhuan.xchat_android_core.room.game.GameEvent; import com.yizhuan.xchat_android_core.room.game.GameResultInfo; @@ -91,6 +98,7 @@ import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol; import com.yizhuan.xchat_android_core.super_admin.util.SuperAdminUtil; import com.yizhuan.xchat_android_core.user.UserModel; import com.yizhuan.xchat_android_core.user.bean.UserInfo; +import com.yizhuan.xchat_android_core.utils.StringExtensionKt; import com.yizhuan.xchat_android_library.rxbus.RxBus; import com.yizhuan.xchat_android_library.utils.ListUtils; import com.yizhuan.xchat_android_library.utils.LogUtil; @@ -99,6 +107,7 @@ import com.yizhuan.xchat_android_library.utils.SingleToastUtil; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.lang.reflect.Field; @@ -112,6 +121,8 @@ import java.util.concurrent.TimeUnit; import cn.sharesdk.framework.Platform; import io.reactivex.Observable; +import io.reactivex.ObservableOnSubscribe; +import io.reactivex.Single; import io.reactivex.SingleObserver; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.Disposable; @@ -119,6 +130,8 @@ import io.reactivex.functions.Action; import nl.dionsegijn.konfetti.models.Shape; import nl.dionsegijn.konfetti.models.Size; +import static com.yizhuan.xchat_android_constants.XChatConstants.SELECT_ANIM_DURATION; + /** * 轰趴房 * Created by 2016/9/22. @@ -156,6 +169,8 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi private ShareDialog shareDialog; + private Disposable datingDisposable; + //收藏房间 private String FOLLOW_ROOM_TYPE = ""; //取消收藏房间 @@ -405,6 +420,9 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi //厅内福袋 addLuckyBagNotify(roomEvent.getChatRoomMessage()); break; + case RoomEvent.DATING_PUBLISH_RESULT: + showHandAnim(((DatingAttachment) roomEvent.getChatRoomMessage().getAttachment()).getDatingNotifyInfo()); + break; default: break; } @@ -841,6 +859,7 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi if (disposableLuckyGift != null) disposableLuckyGift.dispose(); if (disposableMemberIn != null) disposableMemberIn.dispose(); if (disposableLevelUp != null) disposableLevelUp.dispose(); + if (datingDisposable != null) datingDisposable.dispose(); } @@ -1341,4 +1360,68 @@ public class HomePartyFragment extends AbsRoomFragment implements View.OnClickLi } gameMainBinding.roomNums.setText("在线" + onlineNumber); } + + @SuppressLint({"SetTextI18n"}) + private void showHandAnim(final DatingNotifyInfo datingNotifyInfo) { + if (datingDisposable != null) datingDisposable.dispose(); + gameMainBinding.flSvgaDating.post(() -> gameMainBinding.flSvgaDating.setVisibility(View.GONE)); + datingDisposable = Single.just(datingNotifyInfo) + .compose(bindToLifecycle()) + .observeOn(AndroidSchedulers.mainThread()) + .flatMap(info -> { + if (datingNotifyInfo.getHasSelectUser() && !datingNotifyInfo.getHasHeart()) { + showHeartAnim(datingNotifyInfo.getPosition(), datingNotifyInfo.getTargetPosition()); + return Single.timer(SELECT_ANIM_DURATION, TimeUnit.MILLISECONDS).map(aLong -> info); + } + return Single.just(info); + }) + .observeOn(AndroidSchedulers.mainThread()) + .filter(info -> datingNotifyInfo.getHasHeart()) + .toObservable() + .flatMap(info -> Observable.create((ObservableOnSubscribe) emitter -> + SVGAParser.Companion.shareParser().decodeFromURL(new URL(datingNotifyInfo.getSvgaUrl()), new SVGAParser.ParseCompletion() { + + @Override + public void onComplete(@NotNull SVGAVideoEntity svgaVideoEntity) { + gameMainBinding.flSvgaDating.setVisibility(View.VISIBLE); + gameMainBinding.llDatingSvgaTime.setVisibility(View.GONE); + SVGADynamicEntity dynamicEntity = new SVGADynamicEntity(); + TextPaint textPaint = new TextPaint(); + textPaint.setColor(Color.WHITE); + textPaint.setTextSize(ScreenUtil.sp2px(10)); + AnimHelper.addDynamicImage(gameMainBinding.svgaDating, dynamicEntity, datingNotifyInfo.getAvatar(), "z_tx"); + AnimHelper.addDynamicImage(gameMainBinding.svgaDating, dynamicEntity, datingNotifyInfo.getTargetAvatar(), "y_tx"); + dynamicEntity.setDynamicText(StringExtensionKt.subAndReplaceDot(datingNotifyInfo.getNickname(), 5), textPaint, "z_yhname"); + dynamicEntity.setDynamicText(StringExtensionKt.subAndReplaceDot(datingNotifyInfo.getTargetNickname(), 5), textPaint, "y_yhname"); + SVGADrawable drawable = new SVGADrawable(svgaVideoEntity, dynamicEntity); + gameMainBinding.svgaDating.setImageDrawable(drawable); + gameMainBinding.svgaDating.startAnimation(); + emitter.onNext(info); + emitter.onComplete(); + } + + @Override + public void onError() { + emitter.onError(new Throwable("svga解析失败")); + } + }))) + .flatMap(info -> Observable.intervalRange(1, info.getSvgaSecond(), 1, 1, TimeUnit.SECONDS)) + .observeOn(AndroidSchedulers.mainThread()) + .doAfterTerminate(() -> gameMainBinding.flSvgaDating.setVisibility(View.GONE)) + .subscribe(aLong -> { + long residueTime = datingNotifyInfo.getSvgaSecond() - aLong; + gameMainBinding.tvDatingSecond.setText(residueTime + "S"); + if (residueTime == 5) {//剩余5秒开始显示倒计时 + gameMainBinding.llDatingSvgaTime.setVisibility(View.VISIBLE); + } + }); + } + + public void showHeartAnim(int position, int targetPosition) { + SparseArray micViewPoint = AvRoomDataManager.get().mMicPointMap; + AnimHelper.showDatingSelectUserAnim(getContext(), + (ViewGroup) gameMainBinding.getRoot(), + micViewPoint.get(position), + micViewPoint.get(targetPosition)); + } } \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/helper/AnimHelper.java b/app/src/main/java/com/yizhuan/erban/avroom/helper/AnimHelper.java new file mode 100644 index 000000000..fbbd20944 --- /dev/null +++ b/app/src/main/java/com/yizhuan/erban/avroom/helper/AnimHelper.java @@ -0,0 +1,110 @@ +package com.yizhuan.erban.avroom.helper; + +import android.animation.Animator; +import android.animation.AnimatorListenerAdapter; +import android.animation.Keyframe; +import android.animation.ObjectAnimator; +import android.animation.PropertyValuesHolder; +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Point; +import android.text.TextUtils; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.RelativeLayout; + +import androidx.annotation.Nullable; + +import com.bumptech.glide.load.DataSource; +import com.bumptech.glide.load.engine.GlideException; +import com.bumptech.glide.request.RequestListener; +import com.bumptech.glide.request.target.Target; +import com.coorchice.library.utils.LogUtils; +import com.netease.nim.uikit.common.util.sys.ScreenUtil; +import com.netease.nim.uikit.support.glide.GlideApp; +import com.opensource.svgaplayer.SVGADynamicEntity; +import com.yizhuan.erban.R; + +import static com.yizhuan.xchat_android_constants.XChatConstants.SELECT_ANIM_DURATION; + +public class AnimHelper { + + public static void showDatingSelectUserAnim(Context context, ViewGroup viewGroup, Point senderPoint, Point receivePoint) { + if (viewGroup == null || context == null || senderPoint == null || receivePoint == null) + return; + + final int width = ScreenUtil.dip2px(80); + final int height = ScreenUtil.dip2px(80); + final ImageView imageView = new ImageView(context); + RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, height); + layoutParams.leftMargin = senderPoint.x; + layoutParams.topMargin = senderPoint.y; + imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); + imageView.setImageResource(R.drawable.ic_dating_like); + viewGroup.addView(imageView,layoutParams); + Keyframe kx0 = Keyframe.ofFloat(0f, 0f); + Keyframe kx1 = Keyframe.ofFloat(0.2f, 0f); + Keyframe kx2 = Keyframe.ofFloat(0.8f, receivePoint.x - senderPoint.x); + Keyframe kx3 = Keyframe.ofFloat(1f, receivePoint.x - senderPoint.x); + + Keyframe ky0 = Keyframe.ofFloat(0f, 0); + Keyframe ky1 = Keyframe.ofFloat(0.2f, 0); + Keyframe ky2 = Keyframe.ofFloat(0.8f, receivePoint.y - senderPoint.y); + Keyframe ky3 = Keyframe.ofFloat(1f, receivePoint.y - senderPoint.y); + + Keyframe ks0 = Keyframe.ofFloat(0f, 0f); + Keyframe ks1 = Keyframe.ofFloat(0.2f, 1f); + Keyframe ks2 = Keyframe.ofFloat(0.8f, 1f); + Keyframe ks3 = Keyframe.ofFloat(1f, 1.6f); + + Keyframe ka0 = Keyframe.ofFloat(0f, 0f); + Keyframe ka1 = Keyframe.ofFloat(0.2f, 1f); + Keyframe ka2 = Keyframe.ofFloat(0.8f, 1f); + Keyframe ka3 = Keyframe.ofFloat(1f, 0f); + + PropertyValuesHolder p0 = PropertyValuesHolder.ofKeyframe("translationX", kx0, kx1, kx2, kx3); + PropertyValuesHolder p1 = PropertyValuesHolder.ofKeyframe("translationY", ky0, ky1, ky2, ky3); + PropertyValuesHolder p2 = PropertyValuesHolder.ofKeyframe("scaleX", ks0, ks1, ks2, ks3); + PropertyValuesHolder p3 = PropertyValuesHolder.ofKeyframe("scaleY", ks0, ks1, ks2, ks3); + PropertyValuesHolder p4 = PropertyValuesHolder.ofKeyframe("alpha", ka0, ka1, ka2, ka3); + ObjectAnimator objectAnimator = ObjectAnimator.ofPropertyValuesHolder(imageView, p0, p1, p2, p3, p4); + objectAnimator.setDuration(SELECT_ANIM_DURATION); + objectAnimator.start(); + objectAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + super.onAnimationEnd(animation); + ViewGroup viewGroup = (ViewGroup) imageView.getParent(); + viewGroup.removeView(imageView); + } + }); + } + + public static void addDynamicImage(View view, SVGADynamicEntity dynamicEntity, String url, String forKey) { + if (TextUtils.isEmpty(url) || TextUtils.isEmpty(forKey)) { + LogUtils.e("addDynamicImage: url or forKey is null or empty"); + return; + } + GlideApp.with(view) + .asBitmap() + .circleCrop() + .load(url) + .addListener(new RequestListener() { + @Override + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { + view.post(() -> dynamicEntity.setDynamicImage(BitmapFactory.decodeResource(view.getResources(), R.drawable.default_avatar), forKey)); + return false; + } + + @Override + public boolean onResourceReady(Bitmap resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { + view.post(() -> dynamicEntity.setDynamicImage(resource, forKey)); + return false; + } + }) + .submit(); + } + +} diff --git a/app/src/main/res/drawable-xhdpi/ic_dating_like.png b/app/src/main/res/drawable-xhdpi/ic_dating_like.png new file mode 100644 index 0000000000000000000000000000000000000000..fccb6833a07eaa7999019a5748daf154a5af4dba GIT binary patch literal 4866 zcmV+d6aDOoP)Cz z`hBteE{puUviq>S{EMml%DeTVq3nv8@vW`*u(kjI0Q}|M{<6*ftI7F5g8fRA``Y&X z*U0t$GRjU8S$NyfL{Qv*`<@Ns6`Tf$w{bYIl`2YUE?Ebjr{=>oktKI(M z{r|Dw{-(wLKbZeuu>Y&O{%o}WRhIu)p#IF{{qg_(il_d{!v31j{%45(Xn+4&k^W$H z{!gR+s-pj1gZ_q||74i{U!?x%|NfoT|1^{TVTb=(cK(yV|D41AG>QM1xc(`K{!oto zz}^1Q=KihL{;|C*xzeU<-%vi^CX{&}1JUXK2LuKsSC{%oE9nxFr5 zp8kZA|8SlDX`udrp#E=={*kKxgqi+ytNx3X{*RgeiKPFit^a|T|7ni?gQotevj1a~ zpH)G20000xbW%=J{p zpVob}ZYT;f)7ILK`&PA8t5L)SMZGAMMG@RU8&C;|1VnaZ5rnXWeKSC0OF)8QP1uu| zKnNi$AqmX)J;91=we`98{=x4-T7BSr^8LN-is=KObT?=TGO)@8AC|solGG?|dQeM`TFx>55oF%9{iIDYDUFb4d)C=_*oa~rH+stR***J~T3Vhy{m4&0ihP_)j-Q{; zlRMjpM4}UZncw_#_xE3aeemF49tmSUUmcMxDe^ol7R4-He!*^Q;7PG_1YHq5a_`v8 znQuM=nUtT~pHB!6vEAZDi`Jev5sNV2e-Grlxet9jv)@T`vWqMDdA$Dqez~*gbNr#w?K^0bIm1)OL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~)vlL20kjs>LFZ}R%)~QYYDLGt49<#HP$z7pS;c`u0k!t9a2;$niYnADU~uQ$BiT4Na;#$5;CedDZcAoH~Sec1m2s1 zFvXlOrz8b4N|6-C<#MrilaY-m2;^ha5o5{ZpZC_meD-#iIAJmFV4?_vIHWK(DhNy_ zov#^QH)Y<>ezjrx+f&2dqdmhc!}lmfCjpoWl{CfMW&33Fm+=0?Z1#4F2}=T!mq%tZ znbQhfI{aPM%~KTff#uz@eeYV+4f2UBf&c&j literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable/shape_dating_second_bg.xml b/app/src/main/res/drawable/shape_dating_second_bg.xml new file mode 100644 index 000000000..8a3917023 --- /dev/null +++ b/app/src/main/res/drawable/shape_dating_second_bg.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_chatroom_game_main.xml b/app/src/main/res/layout/fragment_chatroom_game_main.xml index 7d8a75e82..879a0aae3 100644 --- a/app/src/main/res/layout/fragment_chatroom_game_main.xml +++ b/app/src/main/res/layout/fragment_chatroom_game_main.xml @@ -219,6 +219,59 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + + + + + + + + + + + + + + + + + roomProcessor; private static PublishProcessor relationShipProcessor; private static PublishSubject msgProcessor; - + private Disposable datingDisposable; private static final class Helper { private static final IMNetEaseManager INSTANCE = new IMNetEaseManager(); @@ -1268,14 +1277,46 @@ public final class IMNetEaseManager { break; } break; - case CustomAttachment.CUSTOM_MSG_LEVEL_UP: + if (second == CUSTOM_MSG_EXPER_LEVEL_UP_NOTICE) { + noticeExperLevelUpNotice(msg); + } + break; + case CUSTOM_MSG_DATING: switch (second) { - case CUSTOM_MSG_EXPER_LEVEL_UP_NOTICE: - noticeExperLevelUpNotice(msg); + case CUSTOM_MSG_SUB_DATING_SELECT: + if (((DatingAttachment) msg.getAttachment()).getDatingNotifyInfo().getUid() == AuthModel.get().getCurrentUid()) { + addMessages(msg); + } + break; + case CUSTOM_MSG_SUB_DATING_PUBLISH_LIKE: + case CUSTOM_MSG_SUB_DATING_PUBLISH_HEART: + addMessages(msg); + break; + case CUSTOM_MSG_SUB_DATING_PUBLISH_RESULT: + DatingPublishAttachment dpAttachment = (DatingPublishAttachment) msg.getAttachment(); + if (datingDisposable != null) datingDisposable.dispose(); + datingDisposable = Observable.fromIterable(dpAttachment.getDatingNotifyInfos()) + .concatMap(datingNotifyInfo -> { + DatingAttachment datingAttachment = new DatingAttachment(datingNotifyInfo.getHasHeart() ? + CUSTOM_MSG_SUB_DATING_PUBLISH_HEART : CUSTOM_MSG_SUB_DATING_PUBLISH_LIKE); + datingAttachment.setDatingNotifyInfo(datingNotifyInfo); + ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( + String.valueOf(AvRoomDataManager.get().getRoomId()), + datingAttachment); + addMessages(message); + noticeRoomEvent(message, RoomEvent.DATING_PUBLISH_RESULT); + //延迟发送消息,是心动则在Svga时长上加一秒,避免过早结束,选人则是SELECT_ANIM_DURATION时长,没选择就是0了 + return Observable.timer(datingNotifyInfo.getHasHeart() ? (datingNotifyInfo.getSvgaSecond() * 1000 + 1000) : + (datingNotifyInfo.getHasSelectUser() ? SELECT_ANIM_DURATION : 0), TimeUnit.MILLISECONDS); + }) + .subscribe(aLong -> { + }, Throwable::printStackTrace); break; } + break; default: + break; } } else if (msg.getMsgType() == MsgTypeEnum.text) { addMessages(msg); @@ -3474,4 +3515,13 @@ public final class IMNetEaseManager { getChatRoomEventObservable().onNext(new RoomEvent().setEvent(RoomEvent.LEAVE_MODE)); } + + //释放退出房间云信需要释放的资源 + public void release() { + mCacheRoomQueueInfo = null; + if (datingDisposable != null) { + datingDisposable.dispose(); + datingDisposable = null; + } + } } 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..87895f86d 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 @@ -6,8 +6,8 @@ import com.netease.nimlib.sdk.msg.attachment.MsgAttachment; import com.netease.nimlib.sdk.msg.attachment.MsgAttachmentParser; import com.yizhuan.xchat_android_core.bean.attachmsg.RoomQueueMsgAttachment; import com.yizhuan.xchat_android_core.community.attachment.DynamicSysAttachment; -import com.yizhuan.xchat_android_core.community.im.WorldDynamicAttachment; import com.yizhuan.xchat_android_core.community.attachment.UnReadCountAttachment; +import com.yizhuan.xchat_android_core.community.im.WorldDynamicAttachment; import com.yizhuan.xchat_android_core.im.custom.AttachManager; import com.yizhuan.xchat_android_core.mentoring_relationship.attachment.MentoringApprenticeMissionFourAttachment; import com.yizhuan.xchat_android_core.mentoring_relationship.attachment.MentoringApprenticeMissionOneAttachment; @@ -44,11 +44,11 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CHATTER_BOX_ASK; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CHATTER_BOX_DROP; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_CHATTER_BOX_INIT; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_DRAGON_BAR; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_LEVEL_UP; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_LEVEL_UP_NOTICE; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GAME_RESPOND; -import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_DRAGON_BAR; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GAME; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GAME_RESPOND; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_MEMBER_COUNT; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_ROOM_NOTIFY; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_TOPIC; @@ -533,7 +533,17 @@ public class CustomAttachParser implements MsgAttachmentParser { attachment = new NewbieHelloAttachment(second); } break; - + case CustomAttachment.CUSTOM_MSG_DATING: + switch (second) { + case CustomAttachment.CUSTOM_MSG_SUB_DATING_SELECT: + case CustomAttachment.CUSTOM_MSG_SUB_DATING_PUBLISH_LIKE: + case CustomAttachment.CUSTOM_MSG_SUB_DATING_PUBLISH_HEART: + attachment = new DatingAttachment(second); + break; + case CustomAttachment.CUSTOM_MSG_SUB_DATING_PUBLISH_RESULT: + attachment = new DatingPublishAttachment(first, second); + 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..0b3db94c6 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 @@ -369,6 +369,14 @@ public class CustomAttachment implements MsgAttachment { // 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_MSG_DATING = 71; + public static final int CUSTOM_MSG_SUB_DATING_SELECT = 711; + public static final int CUSTOM_MSG_SUB_DATING_PUBLISH_RESULT = 712; + public static final int CUSTOM_MSG_SUB_DATING_PUBLISH_LIKE = 713; + public static final int CUSTOM_MSG_SUB_DATING_PUBLISH_HEART = 714; + public CustomAttachment() { } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/DatingAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/DatingAttachment.java new file mode 100644 index 000000000..e95b4fcf7 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/DatingAttachment.java @@ -0,0 +1,38 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import com.yizhuan.xchat_android_core.room.bean.DatingNotifyInfo; + +/** + * @author xiaoyu + */ + +public class DatingAttachment extends CustomAttachment { + + private DatingNotifyInfo datingNotifyInfo; + + + public DatingAttachment(int second) { + super(CUSTOM_MSG_DATING, second); + } + + public DatingNotifyInfo getDatingNotifyInfo() { + return datingNotifyInfo; + } + + public void setDatingNotifyInfo(DatingNotifyInfo datingNotifyInfo) { + this.datingNotifyInfo = datingNotifyInfo; + } + + @Override + protected void parseData(JSONObject data) { + datingNotifyInfo = new Gson().fromJson(data.toJSONString(), DatingNotifyInfo.class); + } + + @Override + protected JSONObject packData() { + String jsonStr = new Gson().toJson(datingNotifyInfo); + return JSONObject.parseObject(jsonStr); + } +} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/DatingPublishAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/DatingPublishAttachment.java new file mode 100644 index 000000000..411109164 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/DatingPublishAttachment.java @@ -0,0 +1,43 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.yizhuan.xchat_android_core.room.bean.DatingNotifyInfo; + +import java.util.List; + +/** + * @author xiaoyu + */ + +public class DatingPublishAttachment extends CustomAttachment { + private List datingNotifyInfos; + + public DatingPublishAttachment(int first, int second) { + super(first, second); + } + + public List getDatingNotifyInfos() { + return datingNotifyInfos; + } + + public void setDatingNotifyInfos(List datingNotifyInfos) { + this.datingNotifyInfos = datingNotifyInfos; + } + + @Override + protected void parseData(JSONObject data) { + if (data.containsKey("list")) { + datingNotifyInfos = new Gson().fromJson(data.getJSONArray("list").toJSONString(), new TypeToken>() { + }.getType()); + } + + } + + @Override + protected JSONObject packData() { + String jsonStr = new Gson().toJson(datingNotifyInfos); + return JSONObject.parseObject(jsonStr); + } +} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java b/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java index d0e5ce63f..04c5a5b6d 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/manager/AvRoomDataManager.java @@ -189,6 +189,7 @@ public final class AvRoomDataManager { } public void release() { + IMNetEaseManager.get().release(); GameModel.get().clear(); RtcEngineManager.get().leaveChannel(); clear(); diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java b/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java index 060cc1285..c9abc643f 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java @@ -206,6 +206,8 @@ public class RoomEvent { //开宝箱横幅,SVGA背景的 public static final int BOX_NOTIFY_SVGA = 69; + public static final int DATING_PUBLISH_RESULT = 70; + private int event = NONE; private int micPosition = Integer.MIN_VALUE; private int posState = -1;