|
|
@@ -10,12 +10,12 @@ import android.os.Message;
|
|
|
import android.text.Editable;
|
|
|
import android.text.TextUtils;
|
|
|
import android.text.TextWatcher;
|
|
|
+import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ImageView;
|
|
|
-import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -42,7 +42,6 @@ import com.xzjmyk.pm.activity.helper.AvatarHelper;
|
|
|
import com.xzjmyk.pm.activity.sortlist.BaseSortModel;
|
|
|
import com.xzjmyk.pm.activity.sortlist.PingYinUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.MainActivity;
|
|
|
-import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.base.EasyFragment;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.NoticeMenuActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.ScheduleActivity;
|
|
|
@@ -86,6 +85,8 @@ public class MessageFragment extends EasyFragment {
|
|
|
private NearlyMessageAdapter mAdapter;
|
|
|
private Handler mHandler = new Handler();
|
|
|
private boolean isRefeshed;
|
|
|
+ private MainActivity mActivity;
|
|
|
+
|
|
|
//界面更新广播
|
|
|
private BroadcastReceiver mUpdateReceiver = new BroadcastReceiver() {
|
|
|
@Override
|
|
|
@@ -100,7 +101,6 @@ public class MessageFragment extends EasyFragment {
|
|
|
}
|
|
|
};
|
|
|
//接收修改公司广播
|
|
|
- private IntentFilter inputFilter;
|
|
|
private BroadcastReceiver receiver = new BroadcastReceiver() {
|
|
|
@Override
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
@@ -109,7 +109,13 @@ public class MessageFragment extends EasyFragment {
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
- private BaseActivity mActivity;
|
|
|
+
|
|
|
+ public OnRefreshUIListener refreshRedUIListener = null;
|
|
|
+
|
|
|
+ public interface OnRefreshUIListener {
|
|
|
+ void updata(int num);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public MessageFragment() {
|
|
|
mOriginalFriendList = new ArrayList<BaseSortModel<Friend>>();
|
|
|
@@ -123,25 +129,18 @@ public class MessageFragment extends EasyFragment {
|
|
|
|
|
|
@Override
|
|
|
protected void onCreateView(Bundle savedInstanceState, boolean createView) {
|
|
|
+ mActivity.registerReceiver(mUpdateReceiver, new IntentFilter(MsgBroadcast.ACTION_MSG_UI_UPDATE));
|
|
|
+ mActivity.registerReceiver(receiver, new IntentFilter(MsgBroadcast.ACTION_MSG_COMPANY_UPDATE));
|
|
|
if (createView) {
|
|
|
initView();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- inputFilter = new IntentFilter();
|
|
|
- inputFilter.addAction("com.app.home.update");
|
|
|
- getActivity().registerReceiver(mUpdateReceiver, new IntentFilter(MsgBroadcast.ACTION_MSG_UI_UPDATE));
|
|
|
- getActivity().registerReceiver(receiver, inputFilter);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void onDestroy() {
|
|
|
super.onDestroy();
|
|
|
- getActivity().unregisterReceiver(mUpdateReceiver);
|
|
|
- getActivity().unregisterReceiver(receiver);
|
|
|
+ mActivity.unregisterReceiver(mUpdateReceiver);
|
|
|
+ mActivity.unregisterReceiver(receiver);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -158,6 +157,15 @@ public class MessageFragment extends EasyFragment {
|
|
|
}, 100);
|
|
|
}
|
|
|
|
|
|
+ public void setOnRefreshRedUI(OnRefreshUIListener refreshRedUI) {
|
|
|
+ this.refreshRedUIListener = refreshRedUI;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setListener(int num) {
|
|
|
+ if (refreshRedUIListener == null) return;
|
|
|
+ refreshRedUIListener.updata(num);
|
|
|
+ }
|
|
|
+
|
|
|
private void initView() {
|
|
|
|
|
|
mClearEditText = (ClearEditText) findViewById(R.id.search_edit);
|
|
|
@@ -193,7 +201,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
mPullToRefreshListView = (PullToRefreshSlideListView) findViewById(R.id.pull_refresh_list);
|
|
|
mPullToRefreshListView.setShowIndicator(false);
|
|
|
mPullToRefreshListView.setMode(Mode.PULL_FROM_START);
|
|
|
- mAdapter = new NearlyMessageAdapter(getActivity());
|
|
|
+ mAdapter = new NearlyMessageAdapter(mActivity);
|
|
|
mPullToRefreshListView.getRefreshableView().setAdapter(mAdapter);
|
|
|
|
|
|
mPullToRefreshListView.setOnRefreshListener(new OnRefreshListener<SlideListView>() {
|
|
|
@@ -209,14 +217,14 @@ public class MessageFragment extends EasyFragment {
|
|
|
Friend friend = (Friend) arg0.getItemAtPosition(position);
|
|
|
if (friend.getRoomFlag() == 0) {
|
|
|
if (friend.getUserId().equals(Friend.ID_NEW_FRIEND_MESSAGE)) {// 新朋友消息
|
|
|
- startActivity(new Intent(getActivity(), NewFriendActivity.class));
|
|
|
+ startActivity(new Intent(mActivity, NewFriendActivity.class));
|
|
|
} else {
|
|
|
- Intent intent = new Intent(getActivity(), ChatActivity.class);
|
|
|
+ Intent intent = new Intent(mActivity, ChatActivity.class);
|
|
|
intent.putExtra(ChatActivity.FRIEND, friend);
|
|
|
startActivity(intent);
|
|
|
}
|
|
|
} else {
|
|
|
- Intent intent = new Intent(getActivity(), MucChatActivity.class);
|
|
|
+ Intent intent = new Intent(mActivity, MucChatActivity.class);
|
|
|
intent.putExtra(AppConstant.EXTRA_USER_ID, friend.getUserId());
|
|
|
intent.putExtra(AppConstant.EXTRA_NICK_NAME, friend.getNickName());
|
|
|
intent.putExtra(AppConstant.EXTRA_IS_GROUP_CHAT, true);
|
|
|
@@ -224,7 +232,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
}
|
|
|
|
|
|
if (friend.getUnReadNum() > 0) {
|
|
|
- MsgBroadcast.broadcastMsgNumUpdate(getActivity(), false, friend.getUnReadNum());
|
|
|
+ MsgBroadcast.broadcastMsgNumUpdate(mActivity, false, friend.getUnReadNum());
|
|
|
friend.setUnReadNum(0);
|
|
|
mAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
@@ -242,10 +250,9 @@ public class MessageFragment extends EasyFragment {
|
|
|
private TextView task_num_tv, task_content_tv, task_time_tv;
|
|
|
private TextView notice_num_tv, notice_content_tv, notice_time_tv;
|
|
|
private TextView num_tv, content_tv, time_tv;
|
|
|
- private RelativeLayout schedule_rl, task_rl, _rl, notice_rl;
|
|
|
|
|
|
private View getHeaderView() {
|
|
|
- View view = LayoutInflater.from(getActivity()).inflate(R.layout.message_header, null);
|
|
|
+ View view = LayoutInflater.from(mActivity).inflate(R.layout.message_header, null);
|
|
|
schedule_num_tv = (TextView) view.findViewById(R.id.schedule_num_tv);
|
|
|
schedule_content_tv = (TextView) view.findViewById(R.id.schedule_content_tv);
|
|
|
schedule_time_tv = (TextView) view.findViewById(R.id.schedule_time_tv);
|
|
|
@@ -274,20 +281,20 @@ public class MessageFragment extends EasyFragment {
|
|
|
public void onClick(View view) {
|
|
|
switch (view.getId()) {
|
|
|
case R.id.schedule_rl:
|
|
|
- startActivity(new Intent(getActivity(), ScheduleActivity.class));
|
|
|
+ startActivity(new Intent(mActivity, ScheduleActivity.class));
|
|
|
break;
|
|
|
case R.id.task_rl:
|
|
|
- startActivity(new Intent(getActivity(), TaskActivity.class));
|
|
|
+ startActivity(new Intent(mActivity, TaskActivity.class));
|
|
|
break;
|
|
|
case R.id.notice_rl:
|
|
|
- Intent intent = new Intent(getActivity(), NoticeMenuActivity.class);
|
|
|
+ Intent intent = new Intent(mActivity, NoticeMenuActivity.class);
|
|
|
intent.putExtra(NoticeMenuActivity.GONGGAO, GONGGAO_count);
|
|
|
intent.putExtra(NoticeMenuActivity.NOTICE, NOTICE_count);
|
|
|
intent.putExtra(NoticeMenuActivity.NES, NES_count);
|
|
|
startActivity(intent);
|
|
|
break;
|
|
|
case R.id._rl:
|
|
|
- startActivity(new Intent(getActivity(), SubscriptionActivity.class));
|
|
|
+ startActivity(new Intent(mActivity, SubscriptionActivity.class));
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -300,10 +307,10 @@ public class MessageFragment extends EasyFragment {
|
|
|
FriendDao.getInstance().markUserMessageRead(
|
|
|
MyApplication.getInstance().mLoginUser.getUserId(),
|
|
|
Friend.ID_ERP_ZHIHUI);
|
|
|
- loadERPMsgNum(getActivity());
|
|
|
- loadGongGaoCount(getActivity());
|
|
|
- loadNoticeCount(getActivity());
|
|
|
- loadERPNewsNum(getActivity());
|
|
|
+ loadERPMsgNum(mActivity);
|
|
|
+ loadGongGaoCount(mActivity);
|
|
|
+ loadNoticeCount(mActivity);
|
|
|
+ loadERPNewsNum(mActivity);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -338,10 +345,11 @@ public class MessageFragment extends EasyFragment {
|
|
|
mActivity.addDefaultRequest(request);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
- public void onActivityCreated(Bundle savedInstanceState) {
|
|
|
- super.onActivityCreated(savedInstanceState);
|
|
|
- mActivity = (BaseActivity) getActivity();
|
|
|
+ public void onAttach(Context context) {
|
|
|
+ super.onAttach(context);
|
|
|
+ mActivity = (MainActivity) context;
|
|
|
}
|
|
|
|
|
|
public void setFriendName(List<Friend> friends, String id) {
|
|
|
@@ -426,7 +434,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
private void deleteFriend(final String loginUserId, final BaseSortModel<Friend> sortFriend) {
|
|
|
Friend friend = sortFriend.getBean();
|
|
|
if (friend.getUnReadNum() > 0) {
|
|
|
- MsgBroadcast.broadcastMsgNumUpdate(getActivity(), false, friend.getUnReadNum());
|
|
|
+ MsgBroadcast.broadcastMsgNumUpdate(mActivity, false, friend.getUnReadNum());
|
|
|
}
|
|
|
mFriendList.remove(sortFriend);
|
|
|
mOriginalFriendList.remove(sortFriend);
|
|
|
@@ -436,15 +444,14 @@ public class MessageFragment extends EasyFragment {
|
|
|
FriendDao.getInstance().deleteFriend(loginUserId, friend.getUserId());
|
|
|
// 消息表中删除
|
|
|
ChatMessageDao.getInstance().deleteMessageTable(loginUserId, friend.getUserId());
|
|
|
-
|
|
|
- MainActivity activity = (MainActivity) getActivity();
|
|
|
- activity.exitMucChat(friend.getUserId());
|
|
|
+ mActivity.exitMucChat(friend.getUserId());
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //先忽略
|
|
|
public void sendBroadcast() {
|
|
|
Intent mIntent = new Intent(MucgroupUpdateUtil.ACTION_UPDATE);
|
|
|
- getActivity().sendBroadcast(mIntent);
|
|
|
+ mActivity.sendBroadcast(mIntent);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -475,9 +482,9 @@ public class MessageFragment extends EasyFragment {
|
|
|
convertView = createConvertView(position);
|
|
|
}
|
|
|
if (position % 2 == 0) {
|
|
|
- convertView.setBackgroundColor(getActivity().getResources().getColor(R.color.item_color1));
|
|
|
+ convertView.setBackgroundColor(mActivity.getResources().getColor(R.color.item_color1));
|
|
|
} else {
|
|
|
- convertView.setBackgroundColor(getActivity().getResources().getColor(R.color.item_color2));
|
|
|
+ convertView.setBackgroundColor(mActivity.getResources().getColor(R.color.item_color2));
|
|
|
}
|
|
|
ImageView avatar_img = ViewHolder.get(convertView, R.id.avatar_img);
|
|
|
TextView num_tv = ViewHolder.get(convertView, R.id.num_tv);
|
|
|
@@ -504,12 +511,11 @@ public class MessageFragment extends EasyFragment {
|
|
|
if (TextUtils.isEmpty(friend.getRoomCreateUserId())) {
|
|
|
avatar_img.setImageResource(R.drawable.qunliao);
|
|
|
} else {
|
|
|
- if (position >= 3)
|
|
|
AvatarHelper.getInstance().displayAvatarPng(friend.getRoomCreateUserId(), avatar_img, false);// 目前在备注名放房间的创建者Id
|
|
|
}
|
|
|
}
|
|
|
nick_name_tv.setText(friend.getRemarkName() != null ? friend.getRemarkName() : friend.getNickName());
|
|
|
- time_tv.setText(TimeUtils.getFriendlyTimeDesc(getActivity(), friend.getTimeSend()));
|
|
|
+ time_tv.setText(TimeUtils.getFriendlyTimeDesc(mActivity, friend.getTimeSend()));
|
|
|
|
|
|
CharSequence content = "";
|
|
|
if (friend.getType() == XmppMessage.TYPE_TEXT) {
|
|
|
@@ -534,7 +540,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
String mLoginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
if (friend.getRoomFlag() == 0) {
|
|
|
if (friend.getUnReadNum() > 0) {
|
|
|
- MsgBroadcast.broadcastMsgNumUpdate(getActivity(), false, friend.getUnReadNum());
|
|
|
+ MsgBroadcast.broadcastMsgNumUpdate(mActivity, false, friend.getUnReadNum());
|
|
|
}
|
|
|
BaseSortModel<Friend> mode = mFriendList.get(position);
|
|
|
|
|
|
@@ -650,6 +656,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
updateNews(msg);
|
|
|
break;
|
|
|
|
|
|
+ //以下为更新页面
|
|
|
case GONGGAO_MSG:
|
|
|
setNOTICE_count(GONGGAO_count + NOTICE_count + NES_count);
|
|
|
break;
|
|
|
@@ -660,6 +667,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
setNOTICE_count(GONGGAO_count + NOTICE_count + NES_count);
|
|
|
break;
|
|
|
case TASK_MSG:
|
|
|
+ setListener(GONGGAO_count + NOTICE_count + NES_count + TASK_count + DAIBAN_count + SUBRICE_count);
|
|
|
if (TASK_count > 0) {
|
|
|
task_num_tv.setText(TASK_count + "");
|
|
|
task_num_tv.setVisibility(View.VISIBLE);
|
|
|
@@ -671,6 +679,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
}
|
|
|
break;
|
|
|
case DAIBAN_MSG:
|
|
|
+ setListener(GONGGAO_count + NOTICE_count + NES_count + TASK_count + DAIBAN_count + SUBRICE_count);
|
|
|
if (DAIBAN_count > 0) {
|
|
|
schedule_num_tv.setText(DAIBAN_count + "");
|
|
|
schedule_num_tv.setVisibility(View.VISIBLE);
|
|
|
@@ -682,6 +691,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
}
|
|
|
break;
|
|
|
case SUBRICE_MSG:
|
|
|
+ setListener(GONGGAO_count + NOTICE_count + NES_count + TASK_count + DAIBAN_count + SUBRICE_count);
|
|
|
if (SUBRICE_count > 0) {
|
|
|
num_tv.setText(SUBRICE_count + "");
|
|
|
num_tv.setVisibility(View.VISIBLE);
|
|
|
@@ -698,6 +708,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
};
|
|
|
|
|
|
private void setNOTICE_count(int count) {
|
|
|
+ setListener(GONGGAO_count + NOTICE_count + NES_count + TASK_count + DAIBAN_count + SUBRICE_count);
|
|
|
if (count > 0) {
|
|
|
notice_num_tv.setText(count + "");
|
|
|
notice_num_tv.setVisibility(View.VISIBLE);
|
|
|
@@ -709,7 +720,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private final int GONGGAO_MSG = 0X00a, NOTICE_MSG = 0X00b, NES_MSG = 0X00c, TASK_MSG = 0X00d, DAIBAN_MSG = 0X00e, SUBRICE_MSG = 0xf;
|
|
|
+ public static final int GONGGAO_MSG = 0X00a, NOTICE_MSG = 0X00b, NES_MSG = 0X00c, TASK_MSG = 0X00d, DAIBAN_MSG = 0X00e, SUBRICE_MSG = 0xf;
|
|
|
private int GONGGAO_count = 0, NOTICE_count = 0, NES_count = 0, TASK_count = 0, DAIBAN_count = 0, SUBRICE_count = 0;
|
|
|
|
|
|
private void updateGongGao(Message msg) {
|
|
|
@@ -723,7 +734,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
if (newsEntity != null) {
|
|
|
size = newsEntity.getData().size();
|
|
|
}
|
|
|
- String em_id = CommonUtil.getSharedPreferences(getActivity(), "erp_emid");
|
|
|
+ String em_id = CommonUtil.getSharedPreferences(mActivity, "erp_emid");
|
|
|
int count = 0;
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
if (!ObjectUtils.isEquals(newsEntity.getData().get(i).getSTATUS(), null)) {
|
|
|
@@ -765,7 +776,7 @@ public class MessageFragment extends EasyFragment {
|
|
|
size = newsEntity.getData().size();
|
|
|
}
|
|
|
count = 0;
|
|
|
- em_id = CommonUtil.getSharedPreferences(getActivity(), "erp_emid");
|
|
|
+ em_id = CommonUtil.getSharedPreferences(mActivity, "erp_emid");
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
if (!ObjectUtils.isEquals(newsEntity.getData().get(i).getSTATUS(), null)) {
|
|
|
if (((int) newsEntity.getData().get(i).getSTATUS()) != -1) {
|