|
|
@@ -0,0 +1,1086 @@
|
|
|
+package com.xzjmyk.pm.activity.ui.message.uas;
|
|
|
+
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.content.IntentFilter;
|
|
|
+import android.graphics.Color;
|
|
|
+import android.net.ConnectivityManager;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.provider.Settings;
|
|
|
+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.BaseAdapter;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.TextView;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.android.volley.Response.ErrorListener;
|
|
|
+import com.android.volley.VolleyError;
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
|
|
|
+import com.iflytek.cloud.speech.RecognizerResult;
|
|
|
+import com.iflytek.cloud.speech.SpeechError;
|
|
|
+import com.iflytek.cloud.ui.RecognizerDialogListener;
|
|
|
+import com.roamer.slidelistview.SlideBaseAdapter;
|
|
|
+import com.roamer.slidelistview.SlideListView;
|
|
|
+import com.roamer.slidelistview.SlideListView.SlideMode;
|
|
|
+import com.xzjmyk.pm.activity.AppConfig;
|
|
|
+import com.xzjmyk.pm.activity.AppConstant;
|
|
|
+import com.xzjmyk.pm.activity.MyApplication;
|
|
|
+import com.xzjmyk.pm.activity.R;
|
|
|
+import com.xzjmyk.pm.activity.audio.voicerecognition.JsonParser;
|
|
|
+import com.xzjmyk.pm.activity.audio.voicerecognition.VoiceToWord;
|
|
|
+import com.xzjmyk.pm.activity.bean.AttentionUser;
|
|
|
+import com.xzjmyk.pm.activity.bean.Friend;
|
|
|
+import com.xzjmyk.pm.activity.bean.message.SubscriptionMessage;
|
|
|
+import com.xzjmyk.pm.activity.bean.message.XmppMessage;
|
|
|
+import com.xzjmyk.pm.activity.broadcast.MsgBroadcast;
|
|
|
+import com.xzjmyk.pm.activity.broadcast.MucgroupUpdateUtil;
|
|
|
+import com.xzjmyk.pm.activity.db.dao.ChatMessageDao;
|
|
|
+import com.xzjmyk.pm.activity.db.dao.FriendDao;
|
|
|
+import com.xzjmyk.pm.activity.db.dao.OnCompleteListener;
|
|
|
+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.EasyFragment;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.activity.NoticeMenuActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.activity.message.ProcessMsgActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.model.AllProcess;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.model.NewsEntity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.model.NoticeEntity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.FlexJsonUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.ObjectUtils;
|
|
|
+import com.xzjmyk.pm.activity.ui.message.ChatActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.message.MucChatActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.message.NewFriendActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.message.Subscription2Activity;
|
|
|
+import com.xzjmyk.pm.activity.ui.tool.ThreadPool;
|
|
|
+import com.xzjmyk.pm.activity.util.HtmlUtils;
|
|
|
+import com.xzjmyk.pm.activity.util.StringUtils;
|
|
|
+import com.xzjmyk.pm.activity.util.TimeUtils;
|
|
|
+import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
+import com.xzjmyk.pm.activity.util.ViewHolder;
|
|
|
+import com.xzjmyk.pm.activity.view.ClearEditText;
|
|
|
+import com.xzjmyk.pm.activity.view.DrawableCenterTextView;
|
|
|
+import com.xzjmyk.pm.activity.view.PullToRefreshSlideListView;
|
|
|
+import com.xzjmyk.pm.activity.volley.ArrayResult;
|
|
|
+import com.xzjmyk.pm.activity.volley.Result;
|
|
|
+import com.xzjmyk.pm.activity.volley.StringJsonArrayRequest;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by FANGlh on 2017/2/23.
|
|
|
+ * function:
|
|
|
+ */
|
|
|
+public class NewMessageFragment extends EasyFragment implements RecognizerDialogListener {
|
|
|
+ private boolean mNeedUpdate = true;
|
|
|
+ private ClearEditText mClearEditText;
|
|
|
+ private PullToRefreshSlideListView mPullToRefreshListView;
|
|
|
+ private List<BaseSortModel<Friend>> mFriendList;// 筛选后的朋友数据
|
|
|
+ private List<BaseSortModel<Friend>> mOriginalFriendList;// 原始的朋友数据,也就是从数据库查询出来,没有筛选的
|
|
|
+ private NearlyMessageAdapter mAdapter;
|
|
|
+ private Handler mHandler = new Handler();
|
|
|
+ private boolean isRefeshed;
|
|
|
+ private MainActivity mActivity;
|
|
|
+
|
|
|
+ private DrawableCenterTextView mNetTextView;
|
|
|
+ private String mNoticeMsg = null;
|
|
|
+
|
|
|
+ public static final int REQUESTCODE = 0xa1;
|
|
|
+ //界面更新广播
|
|
|
+ private BroadcastReceiver mUpdateReceiver = new BroadcastReceiver() {
|
|
|
+ @Override
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
+ if (!AppConfig.COMPANY) return;
|
|
|
+ if (intent.getAction().equals(MsgBroadcast.ACTION_MSG_UI_UPDATE)) {
|
|
|
+ if (isResumed()) {
|
|
|
+ refreshUI();
|
|
|
+ } else {
|
|
|
+ mNeedUpdate = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ //接收修改公司广播
|
|
|
+ private BroadcastReceiver receiver = new BroadcastReceiver() {
|
|
|
+ @Override
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
+ if ("home".equals(intent.getStringExtra("falg"))) {
|
|
|
+ refreshUI();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ public OnRefreshUIListener refreshRedUIListener = null;
|
|
|
+ private ArrayList<SubscriptionMessage> SubscriptionMessages;
|
|
|
+ private ImageView voice_search;
|
|
|
+ private PullToRefreshSlideListView mNewMsglist;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResult(RecognizerResult recognizerResult, boolean b) {
|
|
|
+ String text = JsonParser.parseIatResult(recognizerResult.getResultString());
|
|
|
+ mClearEditText.setText(mClearEditText.getText().toString() + CommonUtil.getPlaintext(text));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(SpeechError speechError) {
|
|
|
+ Log.v("speechError",speechError.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ public interface OnRefreshUIListener {
|
|
|
+ void updata(int num);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public NewMessageFragment() {
|
|
|
+ mOriginalFriendList = new ArrayList<BaseSortModel<Friend>>();
|
|
|
+ mFriendList = new ArrayList<BaseSortModel<Friend>>();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int inflateLayoutId() {
|
|
|
+ return R.layout.fragment_message;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc:监听网络变化
|
|
|
+ * @author:Arison on 2016/11/30
|
|
|
+ */
|
|
|
+ private BroadcastReceiver mNetWorkChangeReceiver = new BroadcastReceiver() {
|
|
|
+ @Override
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
+ if (CommonUtil.isNetWorkConnected(MyApplication.getInstance())) {
|
|
|
+ setNetNoticeVisiable(false);
|
|
|
+ } else {
|
|
|
+ setNetNoticeVisiable(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ @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));
|
|
|
+ mActivity.registerReceiver(mNetWorkChangeReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
|
|
|
+ if (createView) {
|
|
|
+ initView();
|
|
|
+ initNewMsgView();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initNewMsgView() {
|
|
|
+ mNewMsglist = (PullToRefreshSlideListView) findViewById(R.id.pull_newmessages_list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ mActivity.unregisterReceiver(mUpdateReceiver);
|
|
|
+ mActivity.unregisterReceiver(receiver);
|
|
|
+ mActivity.unregisterReceiver(mNetWorkChangeReceiver);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResume() {
|
|
|
+ super.onResume();
|
|
|
+ mHandler.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+// if (mNeedUpdate) {
|
|
|
+// mNeedUpdate = false;
|
|
|
+ refreshUI();
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setOnRefreshRedUI(OnRefreshUIListener refreshRedUI) {
|
|
|
+ this.refreshRedUIListener = refreshRedUI;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setListener() {
|
|
|
+ int num = BMSGS_count + GONGGAO_count + NOTICE_count + NES_count + TASK_count + DAIBAN_count + SUBRICE_count;
|
|
|
+ if (refreshRedUIListener == null) return;
|
|
|
+ refreshRedUIListener.updata(num);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initView() {
|
|
|
+ mNetTextView = (DrawableCenterTextView) findViewById(R.id.message_net_set);
|
|
|
+ mClearEditText = (ClearEditText) findViewById(R.id.search_edit);
|
|
|
+ voice_search = (ImageView) findViewById(R.id.voice_search_iv);
|
|
|
+
|
|
|
+ final VoiceToWord voice = new VoiceToWord(ct,"534e3fe2");
|
|
|
+ voice.setRecognizerDialogListener(this); //自己调用自己
|
|
|
+ voice_search.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+// voice_search.setImageResource(R.drawable.btn_yuyin_pressed);
|
|
|
+ voice.GetWordFromVoice();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mClearEditText.addTextChangedListener(new TextWatcher() {
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+ String filter = mClearEditText.getText().toString().trim().toUpperCase();
|
|
|
+ mFriendList.clear();
|
|
|
+ if (mOriginalFriendList != null && mOriginalFriendList.size() > 0) {
|
|
|
+ for (int i = 0; i < mOriginalFriendList.size(); i++) {
|
|
|
+ BaseSortModel<Friend> mode = mOriginalFriendList.get(i);
|
|
|
+ // 获取筛选的数据
|
|
|
+ if (TextUtils.isEmpty(filter) || mode.getSimpleSpell().startsWith(filter) || mode.getWholeSpell().startsWith(filter)
|
|
|
+ || mode.getBean().getShowName().startsWith(filter)) {
|
|
|
+ mFriendList.add(mode);
|
|
|
+ }
|
|
|
+ if (i == (mOriginalFriendList.size() - 1)) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mPullToRefreshListView = (PullToRefreshSlideListView) findViewById(R.id.pull_refresh_list);
|
|
|
+ mPullToRefreshListView.setShowIndicator(false);
|
|
|
+ mPullToRefreshListView.getRefreshableView().setCacheColorHint(Color.parseColor("#000000"));
|
|
|
+ mPullToRefreshListView.getRefreshableView().setScrollingCacheEnabled(false);
|
|
|
+ mPullToRefreshListView.setMode(Mode.PULL_FROM_START);
|
|
|
+ mAdapter = new NearlyMessageAdapter(mActivity);
|
|
|
+ mPullToRefreshListView.getRefreshableView().setAdapter(mAdapter);
|
|
|
+
|
|
|
+ mPullToRefreshListView.setOnRefreshListener(new OnRefreshListener<SlideListView>() {
|
|
|
+ @Override
|
|
|
+ public void onRefresh(PullToRefreshBase<SlideListView> refreshView) {
|
|
|
+ mNoticeMsg = null;
|
|
|
+ refreshUI();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mPullToRefreshListView.getRefreshableView().addHeaderView(getHeaderView());
|
|
|
+ mPullToRefreshListView.getRefreshableView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
|
|
|
+ Friend friend = (Friend) arg0.getItemAtPosition(position);
|
|
|
+ if (friend == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (friend.getRoomFlag() == 0) {
|
|
|
+ if (friend.getUserId().equals(Friend.ID_NEW_FRIEND_MESSAGE)) {// 新朋友消息
|
|
|
+ startActivity(new Intent(mActivity, NewFriendActivity.class));
|
|
|
+ } else {
|
|
|
+ Intent intent = new Intent(mActivity, ChatActivity.class);
|
|
|
+ intent.putExtra(ChatActivity.FRIEND, friend);
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ 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);
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (friend.getUnReadNum() > 0) {
|
|
|
+ MsgBroadcast.broadcastMsgNumUpdate(mActivity, false, friend.getUnReadNum());
|
|
|
+ friend.setUnReadNum(0);
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mNetTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ startActivity(new Intent(Settings.ACTION_SETTINGS));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setNetNoticeVisiable(boolean visiable) {
|
|
|
+ if (mNetTextView != null) {
|
|
|
+ if (visiable) {
|
|
|
+ mNetTextView.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ mNetTextView.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 头视图相关 我的审批,待办工作,我的订阅,写死的
|
|
|
+ */
|
|
|
+ private TextView schedule_num_tv, schedule_content_tv, schedule_time_tv;
|
|
|
+ private TextView waitting_work_num_tv, waitting_work_content_tv, waitting_work_time_tv;
|
|
|
+ private TextView num_tv, content_tv, time_tv;
|
|
|
+
|
|
|
+ private View getHeaderView() {
|
|
|
+ View view = LayoutInflater.from(mActivity).inflate(R.layout.new_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);
|
|
|
+ //待办工作
|
|
|
+ waitting_work_num_tv = (TextView) view.findViewById(R.id.waitting_work_num_tv);
|
|
|
+ waitting_work_content_tv = (TextView) view.findViewById(R.id.waitting_work_content_tv);
|
|
|
+ waitting_work_time_tv = (TextView) view.findViewById(R.id.waitting_work_time_tv);
|
|
|
+ //我的订阅
|
|
|
+ num_tv = (TextView) view.findViewById(R.id.num_tv);
|
|
|
+ content_tv = (TextView) view.findViewById(R.id.content_tv);
|
|
|
+ time_tv = (TextView) view.findViewById(R.id.time_tv);
|
|
|
+
|
|
|
+ view.findViewById(R.id.schedule_rl).setOnClickListener(listener);
|
|
|
+ view.findViewById(R.id._rl).setOnClickListener(listener);
|
|
|
+ return view;
|
|
|
+ }
|
|
|
+
|
|
|
+ View.OnClickListener listener = new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ switch (view.getId()) {
|
|
|
+ case R.id.schedule_rl:
|
|
|
+ // startActivity(new Intent(mActivity, ScheduleActivity.class));
|
|
|
+ startActivity(new Intent(mActivity, ProcessMsgActivity.class));
|
|
|
+ break;
|
|
|
+ case R.id._rl:
|
|
|
+// startActivity(new Intent(mActivity, SubscriptionActivity.class));
|
|
|
+ startActivity(new Intent(mActivity, Subscription2Activity.class));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ //by gongpm 刷新数据提取方法
|
|
|
+ private void refreshUI() {
|
|
|
+ if (!AppConfig.COMPANY) return;
|
|
|
+ loadData();
|
|
|
+ FriendDao.getInstance().markUserMessageRead(
|
|
|
+ MyApplication.getInstance().mLoginUser.getUserId(),
|
|
|
+ Friend.ID_ERP_ZHIHUI);
|
|
|
+ loadERPMsgNum(mActivity);
|
|
|
+ loadGongGaoCount(mActivity);
|
|
|
+ loadNoticeCount(mActivity);
|
|
|
+ loadERPNewsNum(mActivity);
|
|
|
+ loadNetData(mActivity);
|
|
|
+ loadProcessToDo(1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取关注列表(需调式查看访问数据内容) 更新朋友信息
|
|
|
+ */
|
|
|
+ private void upDataFriend() {
|
|
|
+ isRefeshed = true;
|
|
|
+ HashMap<String, String> params = new HashMap<String, String>();
|
|
|
+ params.put("access_token", MyApplication.getInstance().mAccessToken);
|
|
|
+ StringJsonArrayRequest<AttentionUser> request = new StringJsonArrayRequest<AttentionUser>(
|
|
|
+ MyApplication.getInstance().getConfig().FRIENDS_ATTENTION_LIST, new ErrorListener() {
|
|
|
+ @Override
|
|
|
+ public void onErrorResponse(VolleyError arg0) {
|
|
|
+ ToastUtil.showErrorNet(mActivity);
|
|
|
+ }
|
|
|
+ }, new StringJsonArrayRequest.Listener<AttentionUser>() {
|
|
|
+ @Override
|
|
|
+ public void onResponse(ArrayResult<AttentionUser> result) {
|
|
|
+ boolean success = Result.defaultParser(mActivity, result, false);
|
|
|
+ if (success) {
|
|
|
+ FriendDao.getInstance().addAttentionUsers(mHandler, MyApplication.getInstance().mLoginUser.getUserId(), result.getData(),
|
|
|
+ new OnCompleteListener() {
|
|
|
+ @Override
|
|
|
+ public void onCompleted() {
|
|
|
+ mPullToRefreshListView.getRefreshableView();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, AttentionUser.class, params);
|
|
|
+ mActivity.addDefaultRequest(request);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onAttach(Context context) {
|
|
|
+ super.onAttach(context);
|
|
|
+ mActivity = (MainActivity) context;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setFriendName(List<Friend> friends, String id) {
|
|
|
+ List<Friend> f = FriendDao.getInstance().getFriends(id);
|
|
|
+ if (friends == null) return;
|
|
|
+ for (int i = 0; i < friends.size(); i++) {
|
|
|
+ for (int j = 0; j < f.size(); j++) {
|
|
|
+ if (friends.get(i).get_id() == f.get(j).get_id()) {
|
|
|
+ friends.get(i).setNickName(f.get(j).getNickName());
|
|
|
+ friends.get(i).setRemarkName(f.get(j).getRemarkName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 请求加载新的筛选条件的数据
|
|
|
+ * <p/>
|
|
|
+ * 是下拉刷新,还是上拉加载
|
|
|
+ */
|
|
|
+ private void loadData() {
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ String mLoginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ final List<Friend> friends = FriendDao.getInstance().getNearlyFriendMsg(mLoginUserId);
|
|
|
+ setFriendName(friends, mLoginUserId);
|
|
|
+ long delayTime = 200 - (startTime - System.currentTimeMillis());// 保证至少200ms的刷新过程
|
|
|
+ if (delayTime < 0) {
|
|
|
+ delayTime = 0;
|
|
|
+ }
|
|
|
+ mHandler.postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ mOriginalFriendList.clear();
|
|
|
+ mFriendList.clear();
|
|
|
+ String filter = mClearEditText.getText().toString().trim().toUpperCase();
|
|
|
+ if (friends != null && friends.size() > 0) {
|
|
|
+ for (int i = 0; i < friends.size(); i++) {
|
|
|
+ BaseSortModel<Friend> mode = new BaseSortModel<Friend>();
|
|
|
+ mode.setBean(friends.get(i));
|
|
|
+ setSortCondition(mode);
|
|
|
+ mOriginalFriendList.add(mode);
|
|
|
+ // 获取筛选的数据
|
|
|
+ if (TextUtils.isEmpty(filter) || mode.getSimpleSpell().startsWith(filter) || mode.getWholeSpell().startsWith(filter)
|
|
|
+ || mode.getBean().getShowName().startsWith(filter)) {
|
|
|
+ mFriendList.add(mode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ mPullToRefreshListView.onRefreshComplete();
|
|
|
+ }
|
|
|
+ }, delayTime);
|
|
|
+ }
|
|
|
+ }).start();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+ if (requestCode == NewMessageFragment.REQUESTCODE) {
|
|
|
+ if (data != null) {
|
|
|
+ GONGGAO_count = data.getIntExtra(NoticeMenuActivity.GONGGAO, -1);
|
|
|
+ NES_count = data.getIntExtra(NoticeMenuActivity.NES, -1);
|
|
|
+ NOTICE_count = data.getIntExtra(NoticeMenuActivity.NOTICE, -1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private final void setSortCondition(BaseSortModel<Friend> mode) {
|
|
|
+ Friend friend = mode.getBean();
|
|
|
+ if (friend == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String name = friend.getShowName();
|
|
|
+ String wholeSpell = PingYinUtil.getPingYin(name);
|
|
|
+ if (!TextUtils.isEmpty(wholeSpell)) {
|
|
|
+ String firstLetter = Character.toString(wholeSpell.charAt(0));
|
|
|
+ mode.setWholeSpell(wholeSpell);
|
|
|
+ mode.setFirstLetter(firstLetter);
|
|
|
+ mode.setSimpleSpell(PingYinUtil.converterToFirstSpell(name));
|
|
|
+ } else {// 如果全拼为空,理论上是一种错误情况,因为这代表着昵称为空
|
|
|
+ mode.setWholeSpell("#");
|
|
|
+ mode.setFirstLetter("#");
|
|
|
+ mode.setSimpleSpell("#");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void deleteFriend(final String loginUserId, final BaseSortModel<Friend> sortFriend) {
|
|
|
+ Friend friend = sortFriend.getBean();
|
|
|
+ if (friend.getUnReadNum() > 0) {
|
|
|
+ MsgBroadcast.broadcastMsgNumUpdate(mActivity, false, friend.getUnReadNum());
|
|
|
+ }
|
|
|
+ mFriendList.remove(sortFriend);
|
|
|
+ mOriginalFriendList.remove(sortFriend);
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+
|
|
|
+ // 删除这个房间
|
|
|
+ FriendDao.getInstance().deleteFriend(loginUserId, friend.getUserId());
|
|
|
+ // 消息表中删除
|
|
|
+ ChatMessageDao.getInstance().deleteMessageTable(loginUserId, friend.getUserId());
|
|
|
+ mActivity.exitMucChat(friend.getUserId());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //先忽略
|
|
|
+ public void sendBroadcast() {
|
|
|
+ Intent mIntent = new Intent(MucgroupUpdateUtil.ACTION_UPDATE);
|
|
|
+ mActivity.sendBroadcast(mIntent);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public class NearlyMessageAdapter extends SlideBaseAdapter {
|
|
|
+
|
|
|
+ public NearlyMessageAdapter(Context context) {
|
|
|
+ super(context);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getCount() {
|
|
|
+ return mFriendList.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getItem(int position) {
|
|
|
+ return mFriendList.get(position).getBean();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getItemId(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(final int position, View convertView, ViewGroup parent) {
|
|
|
+ if (convertView == null) {
|
|
|
+ convertView = createConvertView(position);
|
|
|
+ }
|
|
|
+ /* if (rl_b2b != null && rl_b2b.getVisibility() == View.VISIBLE) {//商务显示
|
|
|
+ if (position % 2 == 0) {
|
|
|
+ convertView.setBackgroundColor(mActivity.getResources().getColor(R.color.item_color2));
|
|
|
+ } else {
|
|
|
+ convertView.setBackgroundColor(mActivity.getResources().getColor(R.color.item_color1));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (position % 2 == 0) {
|
|
|
+ convertView.setBackgroundColor(mActivity.getResources().getColor(R.color.item_color1));
|
|
|
+ } else {
|
|
|
+ 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);
|
|
|
+ TextView nick_name_tv = ViewHolder.get(convertView, R.id.nick_name_tv);
|
|
|
+ TextView content_tv = ViewHolder.get(convertView, R.id.content_tv);
|
|
|
+ TextView time_tv = ViewHolder.get(convertView, R.id.time_tv);
|
|
|
+
|
|
|
+ TextView delete_tv = ViewHolder.get(convertView, R.id.delete_tv);
|
|
|
+
|
|
|
+ final Friend friend = mFriendList.get(position).getBean();
|
|
|
+ avatar_img.setBackgroundResource(R.color.transparent);
|
|
|
+ if (friend.getRoomFlag() == 0) {// 这是单个人
|
|
|
+
|
|
|
+ if (isRefeshed) {
|
|
|
+ AvatarHelper.getInstance().display(friend.getUserId(), avatar_img, false, true);//每次刷新都会去删除此人缓存
|
|
|
+ isRefeshed = false;
|
|
|
+ } else {
|
|
|
+ AvatarHelper.getInstance().displayAvatar(friend.getUserId(), avatar_img, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (TextUtils.isEmpty(friend.getRoomCreateUserId())) {
|
|
|
+ avatar_img.setImageResource(R.drawable.qunliao);
|
|
|
+ } else {
|
|
|
+ AvatarHelper.getInstance().displayAvatarPng(friend.getRoomCreateUserId(), avatar_img, true);// 目前在备注名放房间的创建者Id
|
|
|
+ }
|
|
|
+ }
|
|
|
+ nick_name_tv.setText(friend.getRemarkName() != null ? friend.getRemarkName() : friend.getNickName());
|
|
|
+ time_tv.setText(TimeUtils.getFriendlyTimeDesc(mActivity, friend.getTimeSend()));
|
|
|
+
|
|
|
+ CharSequence content = "";
|
|
|
+ Log.i("gongpengming", "getStatus" + friend.getStatus());
|
|
|
+ if (friend.getType() == XmppMessage.TYPE_TEXT) {
|
|
|
+ String s = StringUtils.replaceSpecialChar(friend.getContent());
|
|
|
+ content = HtmlUtils.transform200SpanString(s.replaceAll("\n", "\r\n"), true);
|
|
|
+ } else {
|
|
|
+ content = friend.getContent();
|
|
|
+ }
|
|
|
+ content_tv.setText(content);
|
|
|
+ if (friend.getUnReadNum() > 0) {
|
|
|
+ String numStr = friend.getUnReadNum() >= 99 ? "99+" : friend.getUnReadNum() + "";
|
|
|
+ num_tv.setText(numStr);
|
|
|
+ num_tv.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ num_tv.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+
|
|
|
+ delete_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ String mLoginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
+ if (friend.getRoomFlag() == 0) {
|
|
|
+ if (friend.getUnReadNum() > 0) {
|
|
|
+ MsgBroadcast.broadcastMsgNumUpdate(mActivity, false, friend.getUnReadNum());
|
|
|
+ }
|
|
|
+ BaseSortModel<Friend> mode = mFriendList.get(position);
|
|
|
+
|
|
|
+ mFriendList.remove(mode);
|
|
|
+ mOriginalFriendList.remove(mode);
|
|
|
+
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ // 如果是普通的人,从好友表中删除最后一条消息的记录,这样就不会查出来了
|
|
|
+ FriendDao.getInstance().resetFriendMessage(mLoginUserId, friend.getUserId());
|
|
|
+
|
|
|
+ // 消息表中删除
|
|
|
+ ChatMessageDao.getInstance().deleteMessageTable(mLoginUserId, friend.getUserId());
|
|
|
+ } else {
|
|
|
+ deleteFriend(mLoginUserId, mFriendList.get(position));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return convertView;
|
|
|
+ }
|
|
|
+
|
|
|
+ //控制侧滑删除
|
|
|
+ @Override
|
|
|
+ public SlideMode getSlideModeInPosition(int position) {
|
|
|
+ Friend friend = mFriendList.get(position).getBean();
|
|
|
+ if (friend != null && (friend.getUserId().equals(Friend.ID_SYSTEM_MESSAGE) || friend.getUserId().equals(Friend.ID_NEW_FRIEND_MESSAGE)
|
|
|
+ || friend.getUserId().equals(Friend.ID_ERP_PROCESS) || friend.getUserId().equals(Friend.ID_ERP_TASK) || friend.getUserId().equals(Friend.ID_ERP_ZHIHUI)
|
|
|
+ )) {
|
|
|
+ return SlideMode.NONE;
|
|
|
+ }
|
|
|
+ return super.getSlideModeInPosition(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getFrontViewId(int position) {
|
|
|
+
|
|
|
+ return R.layout.row_nearly_message;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getLeftBackViewId(int position) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getRightBackViewId(int position) {
|
|
|
+ return R.layout.row_item_delete;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void loadNoticeCount(Context ct) {
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/note/inform.action";
|
|
|
+ final Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("count", "1000");
|
|
|
+ param.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, param, handler, headers, Constants.LOAD_SUCCESS, null, null, "get");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取任务
|
|
|
+ public void loadTaskByNet(int handlerWhat) {
|
|
|
+ String url = Constants.getAppBaseUrl(getActivity()) + "common/datalist/data.action";
|
|
|
+ Map<String, Object> mparams = new HashMap<String, Object>();
|
|
|
+ mparams.put("sessionId", CommonUtil.getSharedPreferences(mActivity, "sessionId"));
|
|
|
+ mparams.put("caller", "ResourceAssignment");
|
|
|
+ mparams.put("page", "1");
|
|
|
+ mparams.put("pageSize", "100");
|
|
|
+ mparams.put("_noc", "1");
|
|
|
+ String em_code = CommonUtil.getSharedPreferences(mActivity, "erp_username");
|
|
|
+ mparams.put("condition", "ra_resourcecode='" + em_code + "' and ra_statuscode='" + "START" + "'");
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(mActivity, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(mActivity, url, mparams, handler, headers, handlerWhat, null, null, "get");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void loadGongGaoCount(Context ct) {
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/note/notice.action";
|
|
|
+ final Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("count", "1000");
|
|
|
+ param.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, param, handler, headers, Constants.SUCCESS_LOGIN, null, null, "get");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void loadERPMsgNum(Context ct) {
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "mobile/getallprocess.action";
|
|
|
+ Map<String, Object> param = new HashMap<String, Object>();
|
|
|
+ param.put("employeeCode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
+ param.put("currentMaster", CommonUtil.getSharedPreferences(ct, "erp_master"));
|
|
|
+ param.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, param, handler, headers, load_success_erpMsgNum, null, null, "get");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void loadERPNewsNum(Context ct) {
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/news/getNews.action";
|
|
|
+ final Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("count", "1000");
|
|
|
+ param.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, param, handler, headers, Constants.SUCCESS_INITDATA, null, null, "get");
|
|
|
+ }
|
|
|
+
|
|
|
+ public void loadNetData(Context ct) {
|
|
|
+ //获取网络数据
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/subs/getSubs.action";
|
|
|
+ final Map<String, Object> param = new HashMap<>();
|
|
|
+ param.put("count", 100);
|
|
|
+ param.put("condition", "where to_char(createdate_,'yyyymmdd')='" + TimeUtils.int_long_2_str(System.currentTimeMillis()) + "'");
|
|
|
+ param.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, param, handler, headers, 0x16, null, null, "get");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc:审批流接口
|
|
|
+ * @author:Arison on 2016/11/15
|
|
|
+ */
|
|
|
+ private void loadProcessToDo(int page) {
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "common/desktop/process/toDo.action";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ // count=10&page=1&limit=25
|
|
|
+ params.put("count", "1000");
|
|
|
+
|
|
|
+ params.put("page", page);
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, handler, headers, 0x17, null, null, "get");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private final int load_success_erpMsgNum = 5;
|
|
|
+ private Handler handler = new Handler() {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(final Message msg) {
|
|
|
+ switch (msg.what) {
|
|
|
+ case Constants.SUCCESS_LOGIN://公告
|
|
|
+ updateGongGao(msg);
|
|
|
+ break;
|
|
|
+ case 0x16:
|
|
|
+ String message = (String) msg.getData().get("result");
|
|
|
+ List<SubscriptionMessage> messages = null;
|
|
|
+ int num = 0;
|
|
|
+ if (JSON.parseObject(message).containsKey("data")) {
|
|
|
+ messages = JSON.parseArray(JSON.parseObject(message).getJSONArray("data").toJSONString(), SubscriptionMessage.class);
|
|
|
+ for (SubscriptionMessage e : messages) {
|
|
|
+ if (e.getSTATUS_() == 0)
|
|
|
+ num += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SUBRICE_count = num;
|
|
|
+ setListener();
|
|
|
+ if (num > 0) {
|
|
|
+ num_tv.setText(num + "");
|
|
|
+ num_tv.setVisibility(View.VISIBLE);
|
|
|
+// content_tv.setText("您有新的订阅消息!");
|
|
|
+ content_tv.setText(messages.get(0).getTITLE_());
|
|
|
+ time_tv.setText("刚刚");
|
|
|
+ } else {
|
|
|
+ num_tv.setVisibility(View.GONE);
|
|
|
+// content_tv.setText("暂无新的订阅消息!");
|
|
|
+ content_tv.setText("");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 0x17:
|
|
|
+ try {
|
|
|
+ JSONArray itemArray = JSON.parseObject(msg.getData().getString("result")).getJSONArray("data");
|
|
|
+ itemArray = CommonUtil.sortJsonArray(itemArray);
|
|
|
+ LogUtil.d("item:" + itemArray.size());
|
|
|
+ if (!ListUtils.isEmpty(itemArray)) {
|
|
|
+ DAIBAN_count = itemArray.size();
|
|
|
+ Message DaibanMsg = Message.obtain();
|
|
|
+ DaibanMsg.what = DAIBAN_MSG;
|
|
|
+ if (itemArray.size() != 0) {
|
|
|
+ DaibanMsg.obj = itemArray.getJSONObject(0).getString("JP_LAUNCHERNAME") + "的"
|
|
|
+ + itemArray.getJSONObject(0).getString("JP_NAME");
|
|
|
+ }
|
|
|
+ handler.sendMessage(DaibanMsg);
|
|
|
+ // handler.sendEmptyMessage(DAIBAN_MSG);
|
|
|
+ } else {
|
|
|
+ DAIBAN_count = 0;
|
|
|
+ handler.sendEmptyMessage(DAIBAN_MSG);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case DAIBAN_MSG:
|
|
|
+ setListener();
|
|
|
+ if (DAIBAN_count > 0) {
|
|
|
+ String daiban = (String) msg.obj;
|
|
|
+ schedule_num_tv.setText(DAIBAN_count + "");
|
|
|
+ schedule_num_tv.setVisibility(View.VISIBLE);
|
|
|
+// schedule_content_tv.setText("您有新的待审批流程!");
|
|
|
+ if (daiban != null) {
|
|
|
+ schedule_content_tv.setText(daiban);
|
|
|
+ }
|
|
|
+ schedule_time_tv.setText("刚刚");
|
|
|
+ } else {
|
|
|
+ schedule_num_tv.setVisibility(View.GONE);
|
|
|
+ schedule_content_tv.setText("");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ public static final int GONGGAO_MSG = 0X00a, NOTICE_MSG = 0X00b, NES_MSG = 0X00c, TASK_MSG = 0X00d, DAIBAN_MSG = 0X00e;
|
|
|
+ private int GONGGAO_count = 0, NOTICE_count = 0, NES_count = 0, TASK_count = 0, DAIBAN_count = 0, SUBRICE_count = 0, BMSGS_count = 0;
|
|
|
+
|
|
|
+ private void updateGongGao(Message msg) {
|
|
|
+ final String result = msg.getData().getString("result");
|
|
|
+ ThreadPool.getThreadPool().addTask(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ NoticeEntity newsEntity =
|
|
|
+ JSON.parseObject(result, NoticeEntity.class);
|
|
|
+ int size = 0;
|
|
|
+ if (newsEntity != null) {
|
|
|
+ size = newsEntity.getData().size();
|
|
|
+ }
|
|
|
+ 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)) {
|
|
|
+ if (((int) newsEntity.getData().get(i).getSTATUS()) != -1) {
|
|
|
+ if ((!StringUtils.isEmpty(em_id) && newsEntity.getData().get(i).getNO_RECIPIENTID() != null)) {
|
|
|
+ if (newsEntity.getData().get(i).getNO_RECIPIENTID().toString().contains(em_id)) {
|
|
|
+ if (mNoticeMsg == null) {
|
|
|
+ mNoticeMsg = newsEntity.getData().get(0).getNO_TITLE().replace(" ", "");
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ((!StringUtils.isEmpty(em_id) && newsEntity.getData().get(i).getNO_RECIPIENTID() != null)) {
|
|
|
+ if (newsEntity.getData().get(i).getNO_RECIPIENTID().toString().contains(em_id)) {
|
|
|
+ if (mNoticeMsg == null) {
|
|
|
+ mNoticeMsg = newsEntity.getData().get(0).getNO_TITLE().replace(" ", "");
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (mNoticeMsg == null) {
|
|
|
+ mNoticeMsg = newsEntity.getData().get(0).getNO_TITLE().replace(" ", "");
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GONGGAO_count = count;
|
|
|
+ handler.sendEmptyMessage(GONGGAO_MSG);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateNotice(Message msg) {
|
|
|
+ final String result = msg.getData().getString("result");
|
|
|
+ ThreadPool.getThreadPool().addTask(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ NoticeEntity newsEntity;
|
|
|
+ int size;
|
|
|
+ int count;
|
|
|
+ String em_id;
|
|
|
+ newsEntity = JSON.parseObject(result, NoticeEntity.class);
|
|
|
+ size = 0;
|
|
|
+ if (newsEntity != null) {
|
|
|
+ size = newsEntity.getData().size();
|
|
|
+ }
|
|
|
+ count = 0;
|
|
|
+ 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) {
|
|
|
+ if ((!StringUtils.isEmpty(em_id) && newsEntity.getData().get(i).getNO_RECIPIENTID() != null)) {
|
|
|
+ if (newsEntity.getData().get(i).getNO_RECIPIENTID().toString().contains(em_id)) {
|
|
|
+ if (mNoticeMsg == null) {
|
|
|
+ mNoticeMsg = newsEntity.getData().get(0).getNO_TITLE().replace(" ", "");
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if ((!StringUtils.isEmpty(em_id) && newsEntity.getData().get(i).getNO_RECIPIENTID() != null)) {
|
|
|
+ if (newsEntity.getData().get(i).getNO_RECIPIENTID().toString().contains(em_id)) {
|
|
|
+ if (mNoticeMsg == null) {
|
|
|
+ mNoticeMsg = newsEntity.getData().get(0).getNO_TITLE().replace(" ", "");
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (mNoticeMsg == null) {
|
|
|
+ mNoticeMsg = newsEntity.getData().get(0).getNO_TITLE().replace(" ", "");
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ NOTICE_count = count;
|
|
|
+ handler.sendEmptyMessage(NOTICE_MSG);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateNews(Message msg) {
|
|
|
+ final String result = msg.getData().getString("result");
|
|
|
+ ThreadPool.getThreadPool().addTask(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ int size;
|
|
|
+ int count;
|
|
|
+ NewsEntity news = JSON.parseObject(result, NewsEntity.class);
|
|
|
+ size = 0;
|
|
|
+ if (news != null) {
|
|
|
+ size = news.getData().size();
|
|
|
+ }
|
|
|
+ count = 0;
|
|
|
+ for (int i = 0; i < size; i++) {
|
|
|
+ if (!ObjectUtils.isEquals(news.getData().get(i).getSTATUS(), null)) {
|
|
|
+ if (((int) news.getData().get(i).getSTATUS()) != -1) {
|
|
|
+ if (mNoticeMsg == null) {
|
|
|
+ mNoticeMsg = news.getData().get(0).getNE_THEME().replace(" ", "");
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (mNoticeMsg == null) {
|
|
|
+ mNoticeMsg = news.getData().get(0).getNE_THEME().replace(" ", "");
|
|
|
+ }
|
|
|
+ count++;//数据为空,算是未读
|
|
|
+ }
|
|
|
+ }
|
|
|
+ NES_count = count;
|
|
|
+ handler.sendEmptyMessage(NES_MSG);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getErpMsgNums(Message msg) {
|
|
|
+ String reString = msg.getData().getString("result");
|
|
|
+ Log.i("Arison", "" + reString);
|
|
|
+ if (reString != null && !reString.equals("500")) {
|
|
|
+ Map<String, Object> results = FlexJsonUtil.fromJson(reString);
|
|
|
+ if (results.get("allProcess") != null) {
|
|
|
+ List<AllProcess> allProcesses = new ArrayList<AllProcess>();
|
|
|
+ try {
|
|
|
+ allProcesses = FlexJsonUtil.fromJsonArray(
|
|
|
+ FlexJsonUtil.toJson(results.get("allProcess")),
|
|
|
+ AllProcess.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ int task_num = 0, daiban_num = 0;
|
|
|
+ for (int i = 0; i < allProcesses.size(); i++) {
|
|
|
+ if (allProcesses.get(i).getTypecode().contains("task")) {//我的任务
|
|
|
+ if (!allProcesses.get(i).getTypecode().equals("projecttask") && !allProcesses.get(i).getTypecode().equals("worktask"))
|
|
|
+ task_num++;
|
|
|
+ } else if (allProcesses.get(i).getTypecode().contains("dingyue")) {//订阅
|
|
|
+ if ("0".equals(allProcesses.get(i).getStatus().trim())) {
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ daiban_num++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ TASK_count = task_num;
|
|
|
+ Message TaskMsg = Message.obtain();
|
|
|
+ TaskMsg.what = TASK_MSG;
|
|
|
+ if (allProcesses.size() != 0) {
|
|
|
+ TaskMsg.obj = allProcesses.get(0).getTaskname();
|
|
|
+ }
|
|
|
+ handler.sendMessage(TaskMsg);
|
|
|
+// handler.sendEmptyMessage(TASK_MSG);
|
|
|
+// DAIBAN_count = daiban_num;
|
|
|
+// handler.sendEmptyMessage(DAIBAN_MSG);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //下面的消息列表适配器
|
|
|
+ public class NewMsgAdapter extends BaseAdapter{
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getCount() {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getItem(int position) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getItemId(int position) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ ViewHolder viewHolder;
|
|
|
+ if (convertView == num_tv){
|
|
|
+ convertView = View.inflate(mActivity,R.layout.item_newmsgs,null);
|
|
|
+ viewHolder = new ViewHolder();
|
|
|
+ viewHolder.msgs_img = (ImageView) convertView.findViewById(R.id.msgs_img);
|
|
|
+ viewHolder.msgs_nums_tv = (TextView) convertView.findViewById(R.id.msgs_nums_tv);
|
|
|
+ viewHolder.msgs_title_tv = (TextView) convertView.findViewById(R.id.msgs_time_tv);
|
|
|
+ viewHolder.msgs_content_tv = (TextView) convertView.findViewById(R.id.msgs_content_tv);
|
|
|
+ viewHolder.msgs_time_tv = (TextView) convertView.findViewById(R.id.msgs_time_tv);
|
|
|
+ convertView.setTag(viewHolder);
|
|
|
+ }else {
|
|
|
+ viewHolder = (ViewHolder) convertView.getTag();
|
|
|
+ }
|
|
|
+ return convertView;
|
|
|
+ }
|
|
|
+
|
|
|
+ class ViewHolder {
|
|
|
+ ImageView msgs_img;
|
|
|
+ TextView msgs_nums_tv;
|
|
|
+ TextView msgs_title_tv;
|
|
|
+ TextView msgs_content_tv;
|
|
|
+ TextView msgs_time_tv;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|