[add] 添加1.注册消息类型 2.监听类 3.云公告模块路由PATH 4.Caller java文件
长链接未调通
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 云公告注册
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
public class MoGoNoticeManager {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mogo.eagle.core.function.notice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.notice.IMoGoNoticeProvider;
|
||||
import com.mogo.eagle.core.function.notice.receiver.NoticeMessageListener;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.cloud.socket.IMogoLifecycleListener;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_AI_NOTICE)
|
||||
public class NoticeProvider implements IMoGoNoticeProvider {
|
||||
private String TAG = "AINotice";
|
||||
private Context mContext;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Fragment createCoverage(@Nullable Context context, @Nullable Bundle data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFunctionName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
NoticeSocketManager.getInstance().unRegisterSocketMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
Log.d(TAG, "init");
|
||||
mContext = context;
|
||||
NoticeSocketManager.getInstance().registerSocketMessage(context);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mogo.eagle.core.function.notice;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.mogo.eagle.core.function.notice.receiver.NoticeMessageListener;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.IMogoServiceApis;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description 云公告注册、反注册
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
class NoticeSocketManager {
|
||||
private String TAG = "AINotice";
|
||||
private static NoticeSocketManager mNoticeSocketManager;
|
||||
private NoticeMessageListener mNoticeMessageListener;
|
||||
private static IMogoServiceApis mMoGoServiceApis;
|
||||
private Context mContext;
|
||||
|
||||
public static synchronized NoticeSocketManager getInstance() {
|
||||
synchronized (NoticeSocketManager.class) {
|
||||
if (mNoticeSocketManager == null) {
|
||||
mNoticeSocketManager = new NoticeSocketManager();
|
||||
}
|
||||
}
|
||||
return mNoticeSocketManager;
|
||||
}
|
||||
|
||||
public void registerSocketMessage(Context context) {
|
||||
Log.d(TAG, "registerSocketMessage");
|
||||
mContext = context;
|
||||
mNoticeMessageListener = new NoticeMessageListener();
|
||||
if (mMoGoServiceApis == null) {
|
||||
mMoGoServiceApis = (IMogoServiceApis) ARouter.getInstance().build(com.mogo.eagle.core.data.constants.
|
||||
MogoServicePaths.PATH_SERVICE_APIS).navigation(context);
|
||||
}
|
||||
mMoGoServiceApis.
|
||||
getSocketManagerApi(context).
|
||||
registerOnMessageListener(100, mNoticeMessageListener);
|
||||
}
|
||||
|
||||
public void unRegisterSocketMessage() {
|
||||
if (mNoticeMessageListener != null) {
|
||||
mMoGoServiceApis
|
||||
.getSocketManagerApi(mContext).
|
||||
unregisterOnMessageListener(100, mNoticeMessageListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.eagle.core.function.notice.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.service.cloud.socket.IMogoOnMessageListener;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description push云公告消息接收
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
public class NoticeMessageListener implements IMogoOnMessageListener {
|
||||
private String TAG = "AINotice";
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public Class target() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(Object obj) {
|
||||
Log.d(TAG, obj.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.mogo.eagle.core.function.notice.receiver;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
/**
|
||||
* @author Jing
|
||||
* @description push云公告消息接收
|
||||
* @since: 10/27/21
|
||||
*/
|
||||
public class NoticeReceiver extends BroadcastReceiver {
|
||||
private Context mContext;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mContext = context;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user