Browse Source

修改老师端直播间主动结束直播接口逻辑

Pq 1 year ago
parent
commit
447efe8e2a

+ 3 - 0
tclive/src/main/java/com/daya/tclive/contract/TCLiveRoomContract.java

@@ -95,6 +95,9 @@ public interface TCLiveRoomContract {
         void onLiveForceKick(TCLiveForceKickMessage messageContent);
 
         void onLiveCourseTimeChange();
+
+        void closeLiveSuccess();
+
     }
 
     interface Presenter {

+ 8 - 16
tclive/src/main/java/com/daya/tclive/presenter/TCLivePresenter.java

@@ -191,13 +191,13 @@ public class TCLivePresenter extends BasePresenter<TCLiveRoomContract.TCLiveRoom
         }
     };
 
-    public void initPublishConfig(Context context,String roomId) {
+    public void initPublishConfig(Context context, String roomId) {
         //初始化直播SDK
         TRTCSdkManager.getInstance().init(context, mCloudListener);
         //初始化IM
         TCIMSdkManager.getInstance().init(context.getApplicationContext());
         this.isSendDefaultMsg = true;
-        this.roomId =roomId;
+        this.roomId = roomId;
         registerListener(roomId);
     }
 
@@ -328,7 +328,7 @@ public class TCLivePresenter extends BasePresenter<TCLiveRoomContract.TCLiveRoom
             TCChatRoomLocalMessage tips = new TCChatRoomLocalMessage();
             tips.setText("欢迎进入直播课堂,请遵守相关法规,禁止传播低俗、暴力等不良信息。为孩子创造健康绿色的学习环境。");
             sendMessage(tips, true);
-            isSendDefaultMsg =false;
+            isSendDefaultMsg = false;
         }
     }
 
@@ -798,20 +798,12 @@ public class TCLivePresenter extends BasePresenter<TCLiveRoomContract.TCLiveRoom
     }
 
     public void notifyCloseLiveRoomAction(String roomId) {
-        addSubscribe(create(TeacherAPIService.class).notifyCloseLiveRoomAction(roomId), new DisposableObserver() {
+        addSubscribe(create(TeacherAPIService.class).notifyCloseLiveRoomAction(roomId), new BaseObserver<Object>() {
             @Override
-            public void onNext(Object o) {
-                //通知服务端加入成功即可,无须关注结果
-            }
-
-            @Override
-            public void onError(Throwable e) {
-                e.printStackTrace();
-            }
-
-            @Override
-            public void onComplete() {
-
+            protected void onSuccess(Object data) {
+                if (getView() != null) {
+                    getView().closeLiveSuccess();
+                }
             }
         });
     }

+ 8 - 1
tclive/src/main/java/com/daya/tclive/ui/TCTeacherLiveRoomActivity.java

@@ -717,7 +717,6 @@ public class TCTeacherLiveRoomActivity extends BaseMVPActivity<ActivityTcTeacher
                             if (presenter != null) {
                                 presenter.notifyCloseLiveRoomAction(mRoomId);
                             }
-                            finish();
                         }
                     });
                 }
@@ -1577,6 +1576,14 @@ public class TCTeacherLiveRoomActivity extends BaseMVPActivity<ActivityTcTeacher
         }
     }
 
+    @Override
+    public void closeLiveSuccess() {
+        if (!checkActivityExist()) {
+            return;
+        }
+        finish();
+    }
+
     private void showLiveCourseStatusChangeTip(String tip) {
         if (TextUtils.isEmpty(tip)) {
             tip = "当前课程已调整,请退出直播间";