|
|
@@ -6,6 +6,7 @@ import android.content.Intent;
|
|
|
import android.content.IntentFilter;
|
|
|
import android.net.ConnectivityManager;
|
|
|
import android.os.Bundle;
|
|
|
+import android.support.v4.content.LocalBroadcastManager;
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -63,7 +64,6 @@ public class MessagePresenter implements OnHttpResultListener {
|
|
|
private final int LOAD_TASK = 0x14;
|
|
|
private final int LOAD_EMNEWS_DETAILS = 0x15;
|
|
|
private final int LOAD_B2B_COUNT = 0x16;//获取b2b的审批和任务数量
|
|
|
- private final int READ_EMNEWS = 0x17;
|
|
|
public static final String AUTO_SIGIN_ALART = "AUTO_SIGIN_ALART";
|
|
|
|
|
|
private String SUB_READ_TIME;//订阅好点击阅读时间
|
|
|
@@ -77,22 +77,18 @@ public class MessagePresenter implements OnHttpResultListener {
|
|
|
|
|
|
private String filter;//搜索数据
|
|
|
private int emnewsNum, subsNum, processNum, taskNum;//红点消息分类数量
|
|
|
-
|
|
|
-
|
|
|
- private String[] RECEIVER_LIST = {ConnectivityManager.CONNECTIVITY_ACTION, AUTO_SIGIN_ALART};
|
|
|
- /**
|
|
|
- * @desc:监听网络变化
|
|
|
- * @author:Arison on 2016/11/30
|
|
|
- */
|
|
|
+ private String[] RECEIVER_LIST = {ConnectivityManager.CONNECTIVITY_ACTION, AUTO_SIGIN_ALART, MsgBroadcast.ACTION_MSG_COMPANY_UPDATE, "com.app.home.update"};
|
|
|
private BroadcastReceiver dataChangeReceiver = new BroadcastReceiver() {
|
|
|
@Override
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
- if (StringUtils.isEmpty(intent.getAction())) return;
|
|
|
String action = intent.getAction();
|
|
|
+ if (StringUtils.isEmpty(action)) return;
|
|
|
if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
|
|
|
iMessageView.changeNet(CommonUtil.isNetWorkConnected(MyApplication.getInstance()));
|
|
|
} else if (AUTO_SIGIN_ALART.equals(action)) {
|
|
|
loadNews(isB2b);//获取消息
|
|
|
+ } else if (action.equals("com.app.home.update") || action.equals(MsgBroadcast.ACTION_MSG_COMPANY_UPDATE)) {
|
|
|
+ loadData();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
@@ -109,7 +105,7 @@ public class MessagePresenter implements OnHttpResultListener {
|
|
|
IntentFilter dateFilter = new IntentFilter();
|
|
|
for (String f : RECEIVER_LIST)
|
|
|
dateFilter.addAction(f);
|
|
|
- ct.registerReceiver(dataChangeReceiver, dateFilter);
|
|
|
+ LocalBroadcastManager.getInstance(ct).registerReceiver(dataChangeReceiver, dateFilter);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -860,6 +856,10 @@ public class MessagePresenter implements OnHttpResultListener {
|
|
|
}
|
|
|
|
|
|
public void onDestroyView(MainActivity mContext) {
|
|
|
- ct.unregisterReceiver(dataChangeReceiver);
|
|
|
+ try {
|
|
|
+ mContext.unregisterReceiver(dataChangeReceiver);
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
}
|