增加相亲模式IM相关代码

This commit is contained in:
huangjian
2021-01-20 18:57:32 +08:00
parent 143dfe8a28
commit 972f635e70
13 changed files with 413 additions and 8 deletions

View File

@@ -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<DatingNotifyInfo>) 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<Point> micViewPoint = AvRoomDataManager.get().mMicPointMap;
AnimHelper.showDatingSelectUserAnim(getContext(),
(ViewGroup) gameMainBinding.getRoot(),
micViewPoint.get(position),
micViewPoint.get(targetPosition));
}
}

View File

@@ -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<Bitmap>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> 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<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
view.post(() -> dynamicEntity.setDynamicImage(resource, forKey));
return false;
}
})
.submit();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/alpha40white" />
<corners android:radius="20dp" />
</shape>

View File

@@ -219,6 +219,59 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />
<FrameLayout
android:id="@+id/fl_svga_dating"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#66000000"
android:visibility="gone">
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/svga_dating"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:autoPlay="true"
app:loopCount="1" />
<LinearLayout
android:id="@+id/ll_dating_svga_time"
android:layout_width="70dp"
android:layout_height="25dp"
android:layout_gravity="end"
android:layout_marginTop="40dp"
android:layout_marginEnd="25dp"
android:background="@drawable/shape_dating_second_bg"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_dating_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:text="5s"
android:textColor="#fffffefe"
android:textSize="15sp" />
<View
android:layout_width="1px"
android:layout_height="13dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:background="@color/white" />
<ImageView
android:id="@+id/iv_dating_svga_close"
android:layout_width="14dp"
android:layout_height="14dp"
android:scaleType="fitXY"
android:src="@drawable/btn_close" />
</LinearLayout>
</FrameLayout>
<!-- 中奖横幅通知要在最上层 -->
<com.opensource.svgaplayer.SVGAImageView

View File

@@ -289,6 +289,7 @@ public class XChatConstants {
public static final String OPPO_APP_KEY = "631b6753a1fa481e88dd57793a04e531";
public static final String OPPO_SECRET = "c963ee7c0ba54fbfb3124b4aa7011b17";
public static int SELECT_ANIM_DURATION = 2500;
// 侧耳
// public static final String QUICK_PASS_BUSINESS_ID = BuildConfig.DEBUG ? "cadbb4ed892549dab4d1adc9d62013bb" : "ba4a642810294561b9cd17034a448b49";

View File

@@ -62,6 +62,8 @@ import com.yizhuan.xchat_android_core.im.custom.bean.ActivityTimerAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.AssistantAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.CarAttachment;
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.DatingPublishAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GameAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GameRespondAttachment;
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
@@ -184,6 +186,7 @@ import io.reactivex.SingleEmitter;
import io.reactivex.SingleOnSubscribe;
import io.reactivex.SingleSource;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.BiConsumer;
import io.reactivex.functions.Function;
import io.reactivex.functions.Predicate;
@@ -191,6 +194,7 @@ import io.reactivex.processors.PublishProcessor;
import io.reactivex.schedulers.Schedulers;
import io.reactivex.subjects.PublishSubject;
import static com.yizhuan.xchat_android_constants.XChatConstants.SELECT_ANIM_DURATION;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_CAR;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_NOBLE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MESS_HEAD_ROOM_PK;
@@ -209,6 +213,7 @@ 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_ASSISTANT_COMMON_MSG;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ASSISTANT_MSG;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_BOX;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_DATING;
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_DRAGON_BAR_CANCEL;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_DRAGON_BAR_END;
@@ -235,6 +240,10 @@ 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_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_IN_ROOM;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DATING_PUBLISH_HEART;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DATING_PUBLISH_LIKE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DATING_PUBLISH_RESULT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_DATING_SELECT;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_ADD;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_CLOSE;
import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_KTV_CONTINUE;
@@ -292,7 +301,7 @@ public final class IMNetEaseManager {
private static PublishProcessor<RoomEvent> roomProcessor;
private static PublishProcessor<RelationShipEvent> relationShipProcessor;
private static PublishSubject<ChatRoomMessage> 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;
}
}
}

View File

@@ -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;
}

View File

@@ -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() {
}

View File

@@ -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);
}
}

View File

@@ -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<DatingNotifyInfo> datingNotifyInfos;
public DatingPublishAttachment(int first, int second) {
super(first, second);
}
public List<DatingNotifyInfo> getDatingNotifyInfos() {
return datingNotifyInfos;
}
public void setDatingNotifyInfos(List<DatingNotifyInfo> datingNotifyInfos) {
this.datingNotifyInfos = datingNotifyInfos;
}
@Override
protected void parseData(JSONObject data) {
if (data.containsKey("list")) {
datingNotifyInfos = new Gson().fromJson(data.getJSONArray("list").toJSONString(), new TypeToken<List<DatingNotifyInfo>>() {
}.getType());
}
}
@Override
protected JSONObject packData() {
String jsonStr = new Gson().toJson(datingNotifyInfos);
return JSONObject.parseObject(jsonStr);
}
}

View File

@@ -189,6 +189,7 @@ public final class AvRoomDataManager {
}
public void release() {
IMNetEaseManager.get().release();
GameModel.get().clear();
RtcEngineManager.get().leaveChannel();
clear();

View File

@@ -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;