33
This commit is contained in:
@@ -0,0 +1,753 @@
|
||||
package cn.shangyu.gdxzExpert.activity;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.RadioGroup.OnCheckedChangeListener;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.lidroid.xutils.exception.HttpException;
|
||||
import com.lidroid.xutils.http.HttpHandler;
|
||||
import com.lidroid.xutils.http.RequestParams;
|
||||
import com.lidroid.xutils.http.ResponseInfo;
|
||||
import com.lidroid.xutils.http.callback.RequestCallBack;
|
||||
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
|
||||
import com.netease.nim.uikit.api.model.main.LoginSyncDataStatusObserver;
|
||||
import com.netease.nim.uikit.common.ToastHelper;
|
||||
import com.netease.nim.uikit.common.ui.dialog.DialogMaker;
|
||||
import com.netease.nim.uikit.common.ui.drop.DropManager;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.Observer;
|
||||
import com.netease.nimlib.sdk.StatusCode;
|
||||
import com.netease.nimlib.sdk.auth.AuthService;
|
||||
import com.netease.nimlib.sdk.auth.OnlineClient;
|
||||
import com.netease.nimlib.sdk.msg.MsgService;
|
||||
import com.netease.nimlib.sdk.msg.SystemMessageObserver;
|
||||
import com.netease.nimlib.sdk.msg.SystemMessageService;
|
||||
import com.netease.nimlib.sdk.msg.model.CustomNotification;
|
||||
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import cn.shangyu.gdxzExpert.R;
|
||||
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
||||
import cn.shangyu.gdxzExpert.bean.PatientListBean;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.storage.IMessageSqlManager;
|
||||
import cn.shangyu.gdxzExpert.ecdemo.ui.ConversationListFragment.OnUpdateMsgUnreadCountsListener;
|
||||
import cn.shangyu.gdxzExpert.fragment.PatientListFragment;
|
||||
import cn.shangyu.gdxzExpert.fragment.VisitPlanFragment;
|
||||
import cn.shangyu.gdxzExpert.http.HttpHelper;
|
||||
import cn.shangyu.gdxzExpert.netease.config.LogoutHelper;
|
||||
import cn.shangyu.gdxzExpert.netease.main.CustomNotificationCache;
|
||||
import cn.shangyu.gdxzExpert.netease.main.ReminderItem;
|
||||
import cn.shangyu.gdxzExpert.netease.main.ReminderManager;
|
||||
import cn.shangyu.gdxzExpert.netease.main.SystemMessageUnreadManager;
|
||||
import cn.shangyu.gdxzExpert.netease.main.fragment.SessionListFragmentNew;
|
||||
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.Constant;
|
||||
import cn.shangyu.gdxzExpert.utils.GsonTools;
|
||||
import cn.shangyu.gdxzExpert.utils.LogUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.SharePrefUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.ToastUtil;
|
||||
import cn.shangyu.gdxzExpert.utils.Url;
|
||||
import cn.shangyu.gdxzExpert.view.viewbadger.BadgeView;
|
||||
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
|
||||
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
||||
|
||||
import static cn.shangyu.gdxzExpert.ecdemo.common.utils.CommomUtil.simpleDateFormat;
|
||||
import static cn.shangyu.gdxzExpert.fragment.PatientListFragment.PatientUrl;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* MainActivity.java
|
||||
*
|
||||
* @author ssy
|
||||
* @date 2015-8-31 下午3:52:22 Copyright (C) 2015 河南商宇科技有限公司
|
||||
*
|
||||
* 功能说明:我的患者页面
|
||||
*/
|
||||
|
||||
public class MyPatientActivity extends BaseActivity implements
|
||||
OnCheckedChangeListener, OnUpdateMsgUnreadCountsListener, ReminderManager.UnreadNumChangedCallback {
|
||||
|
||||
private RadioGroup main_radiogroup;
|
||||
private FragmentManager fm;
|
||||
// private ConversationListFragment myPatientMsgFragment;
|
||||
// private MessageFragment messageFragment;
|
||||
private SessionListFragmentNew sessionListFragment;
|
||||
private static MyPatientActivity instance;
|
||||
private PatientListFragment myPatientListFragment;
|
||||
private VisitPlanFragment mVisitPlanFragment;
|
||||
private BadgeView badgePublicServiceMsg;
|
||||
private Button bt_paintlist;
|
||||
private int consultCount;
|
||||
Boolean isSuccessView = false;
|
||||
private long count = 0;
|
||||
private String applyListUrl = Url.getapplyList;
|
||||
/**
|
||||
* 云信
|
||||
*/
|
||||
private Observer<Integer> sysMsgUnreadCountChangedObserver = (Observer<Integer>) unreadCount -> {
|
||||
SystemMessageUnreadManager.getInstance().setSysMsgUnreadCount(unreadCount);
|
||||
ReminderManager.getInstance().updateContactUnreadNum(unreadCount);
|
||||
};
|
||||
public static MyPatientActivity getInstance() {
|
||||
return instance;
|
||||
}
|
||||
// sample
|
||||
Observer<CustomNotification> customNotificationObserver = (Observer<CustomNotification>) notification -> {
|
||||
// 处理自定义通知消息
|
||||
// com.netease.nim.uikit.common.util.log.LogUtil.i("demo", "receive custom notification: " + notification.getContent() + " from :" +
|
||||
// notification.getSessionId() + "/" + notification.getSessionType() +
|
||||
// "unread=" + (notification.getConfig() == null ? "" : notification.getConfig().enableUnreadCount + " " + "push=" +
|
||||
// notification.getConfig().enablePush + " nick=" +
|
||||
// notification.getConfig().enablePushNick));
|
||||
try {
|
||||
JSONObject obj = JSONObject.parseObject(notification.getContent());
|
||||
if (obj != null && obj.getIntValue("id") == 2) {
|
||||
// 加入缓存中
|
||||
CustomNotificationCache.getInstance().addCustomNotification(notification);
|
||||
// Toast
|
||||
String content = obj.getString("content");
|
||||
String tip = String.format("自定义消息[%s]:%s", notification.getFromAccount(), content);
|
||||
ToastHelper.showToast(MyPatientActivity.this, tip);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
com.netease.nim.uikit.common.util.log.LogUtil.e("demo", e.getMessage());
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void setTitle() {
|
||||
// TODO Auto-generated method stub
|
||||
top_back_layout.setVisibility(View.VISIBLE);
|
||||
top_back_layout.setOnClickListener(this);
|
||||
top_right.setVisibility(View.VISIBLE);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
top_title.setTextSize(23);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateSuccessedView() {
|
||||
// TODO Auto-generated method stub
|
||||
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
||||
View view;
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
view = View.inflate(ct, R.layout.activity_my_patient_big, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
view = View.inflate(ct, R.layout.activity_my_patient, null);
|
||||
}
|
||||
|
||||
main_radiogroup = (RadioGroup) view.findViewById(R.id.main_radiogroup_patient);
|
||||
main_radiogroup.setOnCheckedChangeListener(this);
|
||||
instance = this;
|
||||
fm = getSupportFragmentManager();
|
||||
changeMessage();
|
||||
isSuccessView = true;
|
||||
// 患者列表申请提醒
|
||||
bt_paintlist = (Button) view.findViewById(R.id.bt_paintlist);
|
||||
badgePublicServiceMsg = new BadgeView(ct, bt_paintlist);
|
||||
// badgePublicServiceMsg.setTargetView(bt_paintlist);
|
||||
badgePublicServiceMsg.setBackgroundResource(R.drawable.unread_count_bg);
|
||||
badgePublicServiceMsg.setBadgePosition(BadgeView.POSITION_TOP_RIGHT);
|
||||
registerDeletPatient();
|
||||
getNewPatientList(applyListUrl);
|
||||
yuninit();
|
||||
return view;
|
||||
}
|
||||
private LocalBroadcastManager localBroadcastManager;
|
||||
private IntentFilter intentFilter;
|
||||
LocalReceiver localReceiver;
|
||||
private void registerDeletPatient()
|
||||
{
|
||||
localBroadcastManager = LocalBroadcastManager.getInstance(this);
|
||||
intentFilter = new IntentFilter();
|
||||
intentFilter.addAction("DELET_PATION_ACTION");
|
||||
localReceiver = new LocalReceiver();
|
||||
//注册本地接收器
|
||||
localBroadcastManager.registerReceiver(localReceiver,intentFilter);
|
||||
}
|
||||
private class LocalReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
getPatientList(PatientUrl);
|
||||
}
|
||||
}
|
||||
private void getPatientList(final String loadUrl) {
|
||||
RequestParams params = new RequestParams();// 封装参数
|
||||
params.addBodyParameter("expertUuid", SharePrefUtil.getString(MyPatientActivity.this,
|
||||
Constant.uuid, ""));
|
||||
HttpHandler<String> httpHandler = HttpHelper.loadData(HttpMethod.POST, loadUrl, params,
|
||||
new RequestCallBack<String>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<String> info) {
|
||||
SharePrefUtil.saveString(MyPatientActivity.this, PatientUrl,
|
||||
info.result);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException arg0, String arg1) {
|
||||
|
||||
ToastUtil.showToast("请求失败,请重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
long count = SharePrefUtil.getLong(MyPatientActivity.this,"new_patient_count", 0);
|
||||
showNewPatientRed(count);
|
||||
if (isSuccessView) {
|
||||
badgePublicServiceMsg.setText(count + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
isSuccessView = true;
|
||||
registerMsgUnreadInfoObserver(false);
|
||||
registerSystemMessageObservers(false);
|
||||
registerCustomMessageObservers(false);
|
||||
localBroadcastManager.unregisterReceiver(localReceiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultState onLoad() {
|
||||
return ResultState.STATE_SUCCESSED;
|
||||
}
|
||||
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
|
||||
switch (checkedId) {
|
||||
case R.id.tab_rbn_message:
|
||||
changeMessage();
|
||||
break;
|
||||
case R.id.tab_rbn_patlist:
|
||||
changePatlist();
|
||||
break;
|
||||
case R.id.tab_rbn_visit:
|
||||
changevisit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void changevisit() {
|
||||
top_title.setText("随访计划");
|
||||
// top_right_text.setText("邀请\n患者");
|
||||
top_right_search.setVisibility(View.GONE);
|
||||
top_right.setVisibility(View.GONE);
|
||||
top_right_text.setVisibility(View.VISIBLE);
|
||||
top_right_text.setText("添加");
|
||||
|
||||
top_right_text.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
showPopupWindow(v);
|
||||
}
|
||||
});
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
top_right_text.setTextSize(18);
|
||||
}
|
||||
else
|
||||
{
|
||||
// top_right.setImageResource(R.drawable.invite);
|
||||
// top_right_search.setVisibility(View.GONE);
|
||||
// top_right.setOnClickListener(new OnClickListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// // TODO Auto-generated method stub
|
||||
// showPopupWindow(v);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
mVisitPlanFragment = new VisitPlanFragment();
|
||||
fm.beginTransaction().replace(R.id.frame_container, mVisitPlanFragment,
|
||||
"mVisitPlanFragment").commit();
|
||||
|
||||
|
||||
}
|
||||
|
||||
LinearLayout mLv_addTime, mLv_addVisit;
|
||||
|
||||
private void showPopupWindow(View view) {
|
||||
|
||||
// 一个自定义的布局,作为显示的内容
|
||||
View contentView;
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
contentView = LayoutInflater.from(instance).inflate(
|
||||
R.layout.pop_window_big, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
contentView = LayoutInflater.from(instance).inflate(
|
||||
R.layout.pop_window, null);
|
||||
}
|
||||
|
||||
// 设置按钮的点击事件
|
||||
mLv_addTime = (LinearLayout) contentView.findViewById(R.id.ll_addTime);
|
||||
mLv_addVisit = (LinearLayout) contentView
|
||||
.findViewById(R.id.ll_addVisit);
|
||||
|
||||
final PopupWindow popupWindow = new PopupWindow(contentView,
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
|
||||
mLv_addTime.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
Intent intent = new Intent(instance, AddVisitDateActivity.class);
|
||||
intent.setType("main");
|
||||
startActivityForResult(intent, 201);
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
});
|
||||
mLv_addVisit.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
Intent intent = new Intent(instance, AddVisitPlanActivity.class);
|
||||
intent.setType("main");
|
||||
startActivityForResult(intent, 201);
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
});
|
||||
popupWindow.setTouchable(true);
|
||||
|
||||
popupWindow.setTouchInterceptor(new OnTouchListener() {
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
|
||||
Log.i("mengdd", "onTouch : ");
|
||||
|
||||
return false;
|
||||
// 这里如果返回true的话,touch事件将被拦截
|
||||
// 拦截后 PopupWindow的onTouchEvent不被调用,这样点击外部区域无法dismiss
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
|
||||
// 我觉得这里是API的一个bug
|
||||
popupWindow.setBackgroundDrawable(getResources().getDrawable(
|
||||
R.drawable.popwrite));
|
||||
|
||||
// 设置好参数之后再show
|
||||
popupWindow.showAsDropDown(view);
|
||||
|
||||
}
|
||||
|
||||
private void changePatlist() {
|
||||
top_right_text.setVisibility(View.GONE);
|
||||
top_right.setVisibility(View.VISIBLE);
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
|
||||
|
||||
top_right.setImageResource(R.drawable.invite_big);
|
||||
}
|
||||
else
|
||||
{
|
||||
top_right.setImageResource(R.drawable.invite);
|
||||
}
|
||||
top_title.setText("我的患者");
|
||||
// top_right_text.setText("邀请\n患者");
|
||||
|
||||
top_right_search.setVisibility(View.VISIBLE);
|
||||
top_right.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
LogUtil.i("邀请患者");
|
||||
startActivity(new Intent(MyPatientActivity.this, MyQrCodeActivity.class));
|
||||
/*ClientUser user = new ClientUser(SharePrefUtil.getString(ct,
|
||||
"USERID", ""));
|
||||
CCPAppManager.setClientUser(user);
|
||||
LogUtil.i("UserId==" + user.getUserId());
|
||||
if (!ContactSqlManager.hasContact(user.getUserId())) {
|
||||
ECContacts contacts = new ECContacts();
|
||||
contacts.setClientUser(user);
|
||||
ContactSqlManager.insertContact(contacts);
|
||||
LogUtil.i("加载联系人==");
|
||||
}
|
||||
startActivity(new Intent(ct, InvitePatientActivity.class));*/
|
||||
}
|
||||
});
|
||||
myPatientListFragment = new PatientListFragment();
|
||||
fm.beginTransaction().replace(R.id.frame_container, myPatientListFragment,
|
||||
"PatientListFragment").commit();
|
||||
// Bundle args = new Bundle();
|
||||
// args.putInt("type", 0);
|
||||
// myPatientListFragment.setArguments(args);
|
||||
|
||||
}
|
||||
|
||||
private void changeMessage() {
|
||||
if(CommonUtil.BigModule())
|
||||
{
|
||||
|
||||
top_right_search.setImageResource(R.drawable.big_search);
|
||||
|
||||
}
|
||||
top_right_text.setVisibility(View.GONE);
|
||||
top_right.setVisibility(View.VISIBLE);
|
||||
top_title.setText("患者消息");
|
||||
|
||||
top_right.setImageResource(R.drawable.icon_group_send);
|
||||
// top_right_text.setText("群发\n消息");
|
||||
top_right_search.setVisibility(View.VISIBLE);
|
||||
top_right.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
LogUtil.i("群发消息");
|
||||
// startActivity(new Intent(ct, GroupChatPatientActivity.class));
|
||||
startActivity(new Intent(ct, SendGroupMsgListActivity.class));
|
||||
}
|
||||
});
|
||||
sessionListFragment=new SessionListFragmentNew();
|
||||
fm.beginTransaction().replace(R.id.frame_container, sessionListFragment,
|
||||
"ConversationListFragment").commit();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processClick(View v) {
|
||||
// TODO Auto-generated method stub
|
||||
switch (v.getId()) {
|
||||
case R.id.top_right_text:
|
||||
ToastUtil.showToast(top_right_text.getText().toString());
|
||||
break;
|
||||
case R.id.top_right_search:
|
||||
startActivity(new Intent(ct, SearchPatientActivity.class));
|
||||
break;
|
||||
case R.id.top_back_layout:
|
||||
finish();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK ){
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求网络,获取患者申请的列表 getNewPatientList ssy
|
||||
*
|
||||
* @param loadUrl
|
||||
* 请求地址 void
|
||||
*/
|
||||
private void getNewPatientList(final String loadUrl) {
|
||||
String uuid = SharePrefUtil.getString(MyPatientActivity.this,
|
||||
Constant.uuid, "");
|
||||
RequestParams params = new RequestParams();
|
||||
params.addBodyParameter("expertUuid", uuid);
|
||||
HttpHandler<String> httpHandlerNewPatient = HttpHelper.loadData(
|
||||
HttpMethod.POST, loadUrl, params,
|
||||
new RequestCallBack<String>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResponseInfo<String> info) {
|
||||
// SharePrefUtil.saveString(MyPatientActivity.this,
|
||||
// loadUrl,info.result);
|
||||
processData(info.result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(HttpException arg0, String arg1) {
|
||||
LogUtil.i("数据请求失败了: " + arg1);
|
||||
// SharePrefUtil.saveString(mActivity, loadUrl,"");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析并处理数据
|
||||
*
|
||||
* @param result
|
||||
*/
|
||||
private void processData(String result) {
|
||||
PatientListBean bean = GsonTools.fromGsonToBean(result,
|
||||
PatientListBean.class);
|
||||
// 数据为空
|
||||
count = 0;
|
||||
for (int i = 0; i < bean.data.size(); i++) {
|
||||
// 判断状态是否是待审核,加入待审核到list,其他的不显示
|
||||
if (1 == bean.data.get(i).status) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
showNewPatientRed(count);
|
||||
badgePublicServiceMsg.setText(count + "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 网络注册状态改变
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
public void onNetWorkNotify( ) {
|
||||
// if (myPatientMsgFragment instanceof ConversationListFragment&& myPatientMsgFragment.isResumed()) {
|
||||
// ((ConversationListFragment) myPatientMsgFragment)
|
||||
// .updateConnectState();
|
||||
// }m
|
||||
}
|
||||
|
||||
/**
|
||||
* shuaxin notifyChange
|
||||
*
|
||||
* void
|
||||
*/
|
||||
public void notifyChange() {
|
||||
// if (myPatientMsgFragment instanceof ConversationListFragment
|
||||
// && myPatientMsgFragment.isResumed()) {
|
||||
// ((ConversationListFragment) myPatientMsgFragment).notifyChange();
|
||||
// }
|
||||
if (myPatientListFragment instanceof PatientListFragment
|
||||
&& myPatientListFragment.isResumed()) {
|
||||
((PatientListFragment) myPatientListFragment).notifyChange();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示是否有新的患者申请红点提示
|
||||
*/
|
||||
public void showNewPatientRed(long count) {
|
||||
if (badgePublicServiceMsg != null) {
|
||||
if (count != 0) {
|
||||
badgePublicServiceMsg.show();
|
||||
} else {
|
||||
badgePublicServiceMsg.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计未读数量
|
||||
*/
|
||||
@Override
|
||||
public void OnUpdateMsgUnreadCounts() {
|
||||
// TODO Auto-generated method stub
|
||||
int unreadCount = IMessageSqlManager.qureyAllSessionUnreadCount();
|
||||
int notifyUnreadCount = IMessageSqlManager.getUnNotifyUnreadCount();
|
||||
int count = unreadCount;
|
||||
if (unreadCount >= notifyUnreadCount) {
|
||||
count = unreadCount - notifyUnreadCount;
|
||||
}
|
||||
/*
|
||||
* if(unreadCount > 0) { if(unreadCount > 99) {
|
||||
* tv_new_pt_count.setText(getResources
|
||||
* ().getString(R.string.unread_count_overt_100)); return; }
|
||||
* tv_new_pt_count.setText(String.valueOf(unreadCount)); return; }
|
||||
* tv_new_pt_count.setText(null);
|
||||
*/
|
||||
/*
|
||||
* <TextView android:id="@+id/tv_new_pt_count"
|
||||
* android:layout_width="wrap_content"
|
||||
* android:layout_height="wrap_content"
|
||||
* android:layout_alignParentRight="true"
|
||||
* android:layout_centerVertical="true"
|
||||
* android:background="@drawable/unread_count_bg"
|
||||
* android:gravity="center" android:singleLine="true"
|
||||
* android:textColor="@android:color/white" android:textSize="12sp" />
|
||||
*/
|
||||
}
|
||||
private void yuninit()
|
||||
{
|
||||
observerSyncDataComplete();
|
||||
// findViews();
|
||||
// setupPager();
|
||||
// setupTabs();
|
||||
registerMsgUnreadInfoObserver(true);
|
||||
registerSystemMessageObservers(true);
|
||||
registerCustomMessageObservers(true);
|
||||
|
||||
requestSystemMessageUnreadCount();
|
||||
// initUnreadCover();
|
||||
}
|
||||
Observer<List<OnlineClient>> clientsObserver = new Observer<List<OnlineClient>>() {
|
||||
@Override
|
||||
public void onEvent(List<OnlineClient> onlineClients) {
|
||||
if (onlineClients == null || onlineClients.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户状态变化
|
||||
*/
|
||||
Observer<StatusCode> userStatusObserver = new Observer<StatusCode>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(StatusCode code) {
|
||||
if (code.wontAutoLogin()) {
|
||||
|
||||
LogoutHelper.logout();
|
||||
showlogout();
|
||||
// startActivity(new Intent(MyPatientActivity.this, LoginActivity.class));
|
||||
// finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
private void showlogout()
|
||||
{
|
||||
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
String phone="ios";
|
||||
switch(NIMClient.getService(AuthService.class).getKickedClientType())
|
||||
{
|
||||
case 1:
|
||||
phone="android";
|
||||
break;
|
||||
case 2:
|
||||
phone="ios";
|
||||
break;
|
||||
case 16:
|
||||
phone="web";
|
||||
break;
|
||||
default:
|
||||
phone="unknow";
|
||||
break;
|
||||
|
||||
}
|
||||
ECAlertDialog buildAlert = ECAlertDialog.buildAlert(this,
|
||||
getString(R.string.nim_kick_out)+
|
||||
simpleDateFormat.format(date)+getString(R.string.nim_kick_out1)+
|
||||
phone+getString(R.string.nim_kick_out2)
|
||||
, getString(R.string.dialog_btn_confim),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
startActivity(new Intent(MyPatientActivity.this, LoginNewActivity.class));
|
||||
finish();
|
||||
}
|
||||
});
|
||||
buildAlert.setTitle("异地登陆");
|
||||
buildAlert.setCanceledOnTouchOutside(false);
|
||||
buildAlert.setCancelable(false);
|
||||
buildAlert.show();
|
||||
}
|
||||
private void observerSyncDataComplete() {
|
||||
boolean syncCompleted = LoginSyncDataStatusObserver.getInstance()
|
||||
.observeSyncDataCompletedEvent(
|
||||
(Observer<Void>) v -> DialogMaker
|
||||
.dismissProgressDialog());
|
||||
//如果数据没有同步完成,弹个进度Dialog
|
||||
if (!syncCompleted) {
|
||||
DialogMaker.showProgressDialog(MyPatientActivity.this, getString(com.netease.nim.uikit.R.string.prepare_data))
|
||||
.setCanceledOnTouchOutside(false);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 注册未读消息数量观察者
|
||||
*/
|
||||
private void registerMsgUnreadInfoObserver(boolean register) {
|
||||
if (register) {
|
||||
ReminderManager.getInstance().registerUnreadNumChangedCallback(this);
|
||||
} else {
|
||||
ReminderManager.getInstance().unregisterUnreadNumChangedCallback(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnreadNumChanged(ReminderItem item) {
|
||||
|
||||
}
|
||||
/**
|
||||
* 注册/注销系统消息未读数变化
|
||||
*/
|
||||
private void registerSystemMessageObservers(boolean register) {
|
||||
// NIMClient.getService(AuthServiceObserver.class).observeOtherClients(clientsObserver, register);
|
||||
NIMClient.getService(SystemMessageObserver.class).observeUnreadCountChange(
|
||||
sysMsgUnreadCountChangedObserver, register);
|
||||
// NIMClient.getService(AuthServiceObserver.class).observeOnlineStatus(userStatusObserver, register);
|
||||
}
|
||||
private void registerCustomMessageObservers(boolean register) {
|
||||
// NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(
|
||||
// customNotificationObserver, register);
|
||||
}
|
||||
/**
|
||||
* 查询系统消息未读数
|
||||
*/
|
||||
private void requestSystemMessageUnreadCount() {
|
||||
int unread = NIMClient.getService(SystemMessageService.class)
|
||||
.querySystemMessageUnreadCountBlock();
|
||||
SystemMessageUnreadManager.getInstance().setSysMsgUnreadCount(unread);
|
||||
ReminderManager.getInstance().updateContactUnreadNum(unread);
|
||||
}
|
||||
//初始化未读红点动画
|
||||
private void initUnreadCover() {
|
||||
DropManager.getInstance().init(this, findViewById(R.id.unread_cover), (id, explosive) -> {
|
||||
if (id == null || !explosive) {
|
||||
return;
|
||||
}
|
||||
if (id instanceof RecentContact) {
|
||||
RecentContact r = (RecentContact) id;
|
||||
NIMClient.getService(MsgService.class).clearUnreadCount(r.getContactId(),
|
||||
r.getSessionType());
|
||||
return;
|
||||
}
|
||||
if (id instanceof String) {
|
||||
if (((String) id).contentEquals("0")) {
|
||||
NIMClient.getService(MsgService.class).clearAllUnreadCount();
|
||||
} else if (((String) id).contentEquals("1")) {
|
||||
NIMClient.getService(SystemMessageService.class)
|
||||
.resetSystemMessageUnreadCount();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user