修复 [在直播间中,点击推送弹窗,进入聊天详情界面,点击聊天记录中的直播间【站内分享】,无法进入直播间]

This commit is contained in:
zlzw 2024-04-03 15:23:08 +08:00
parent b285512914
commit d06f4599fa
2 changed files with 36 additions and 7 deletions

View File

@ -1,5 +1,6 @@
package com.yunbao.common.provider; package com.yunbao.common.provider;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.text.Spannable; import android.text.Spannable;
@ -10,11 +11,13 @@ import com.yunbao.common.Constants;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.bean.ActiveBean; import com.yunbao.common.bean.ActiveBean;
import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.event.LiveRoomChangeEvent;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.message.content.MessageChatCardContent; import com.yunbao.common.message.content.MessageChatCardContent;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter; import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.RouteUtil;
@ -61,9 +64,9 @@ public class MessageChatCardItemProvider extends BaseMessageItemProvider<Message
protected boolean onItemClick(ViewHolder holder, MessageChatCardContent content, UiMessage uiMessage, int position, List<UiMessage> list, IViewProviderListener<UiMessage> listener) { protected boolean onItemClick(ViewHolder holder, MessageChatCardContent content, UiMessage uiMessage, int position, List<UiMessage> list, IViewProviderListener<UiMessage> listener) {
if ("1".equals(content.getType())) { if ("1".equals(content.getType())) {
gotoLive(content.getExtraData()); gotoLive(content.getExtraData());
}else if("0".equals(content.getType())){ } else if ("0".equals(content.getType())) {
RouteUtil.forwardCommunity(content.getExtraData()); RouteUtil.forwardCommunity(content.getExtraData());
}else if("2".equals(content.getType())){ } else if ("2".equals(content.getType())) {
LiveNetManager.get(mContext).getDynamicInfo(content.getExtraData(), new com.yunbao.common.http.base.HttpCallback<ActiveBean>() { LiveNetManager.get(mContext).getDynamicInfo(content.getExtraData(), new com.yunbao.common.http.base.HttpCallback<ActiveBean>() {
@Override @Override
public void onSuccess(ActiveBean data) { public void onSuccess(ActiveBean data) {
@ -105,8 +108,16 @@ public class MessageChatCardItemProvider extends BaseMessageItemProvider<Message
MicStatusManager.getInstance().showDownMicDialog(mContext); MicStatusManager.getInstance().showDownMicDialog(mContext);
return; return;
} }
if (AppManager.getInstance().getLiveActivity() != null) {
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)).setLiveEnd(true));
Activity activity = AppManager.getActivity("PDLiveConversationActivity");
if (activity != null) {
activity.finish();
}
} else {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk)); RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
} }
}
@Override @Override
public void onCheckError(String contextError) { public void onCheckError(String contextError) {

View File

@ -20,15 +20,33 @@ public class AppManager {
return SingleApp.INSTANCE; return SingleApp.INSTANCE;
} }
public static Activity getActivity(String activityName) {
for (Activity activity : activityStack) {
if (activity.getClass().getSimpleName().contains(activityName)) {
return activity;
}
}
return null;
}
public Activity getMainActivity() { public Activity getMainActivity() {
for (Activity activity : activityStack) { for (Activity activity : activityStack) {
if(activity.getClass().getSimpleName().contains("MainActivity")){ if (activity.getClass().getSimpleName().contains("MainActivity")) {
return activity; return activity;
} }
} }
return getLastActivity(); return getLastActivity();
} }
public Activity getLiveActivity() {
for (Activity activity : activityStack) {
if (activity.getClass().getSimpleName().contains("LiveAudienceActivity")) {
return activity;
}
}
return null;
}
public static class SingleApp { public static class SingleApp {
public static AppManager INSTANCE = new AppManager(); public static AppManager INSTANCE = new AppManager();
} }
@ -67,11 +85,11 @@ public class AppManager {
* 获取当前显示Activity堆栈中最后一个传入的activity * 获取当前显示Activity堆栈中最后一个传入的activity
*/ */
public Activity getLastActivity() { public Activity getLastActivity() {
if(activityStack.isEmpty()){ if (activityStack.isEmpty()) {
return null; return null;
} }
Activity activity = activityStack.lastElement(); Activity activity = activityStack.lastElement();
if(activity==null||activity.isFinishing()){ if (activity == null || activity.isFinishing()) {
activityStack.remove(activity); activityStack.remove(activity);
return getLastActivity(); return getLastActivity();
} }
@ -133,7 +151,7 @@ public class AppManager {
} }
/** /**
*仅在debug下运行的代码 * 仅在debug下运行的代码
*/ */
public static void runDebugCode(Runnable runnable) { public static void runDebugCode(Runnable runnable) {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {