|
|
@@ -1,1226 +1,375 @@
|
|
|
package com.xzjmyk.pm.activity.ui.message;
|
|
|
|
|
|
-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.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
import android.widget.AdapterView;
|
|
|
-import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.PopupWindow;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-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.lidroid.xutils.ViewUtils;
|
|
|
+import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
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.TaskActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.activity.message.ProcessMsgActivity;
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.activity.oa.MsgsSecondCommonActivity;
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.db.DBManager;
|
|
|
-import com.xzjmyk.pm.activity.ui.erp.entity.B2BMsg;
|
|
|
-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.adapter.MessageAdapter;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.entity.EditChangeListener;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.presenter.MessagePresenter;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.presenter.imp.IMessageView;
|
|
|
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.erp.util.auto.HttpHandler;
|
|
|
-import com.xzjmyk.pm.activity.ui.message.uas.B2bMsgActivity;
|
|
|
-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.ui.erp.util.StringUtils;
|
|
|
+import com.xzjmyk.pm.activity.util.DateFormatUtil;
|
|
|
+import com.xzjmyk.pm.activity.util.DisplayUtil;
|
|
|
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.util.WorkHandlerUtil;
|
|
|
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 com.xzjmyk.pm.activity.wxapi.ApiPlatform;
|
|
|
+import com.xzjmyk.pm.activity.wxapi.ApiUtils;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
- * @desc:消息列表
|
|
|
- * @author:Administrator on 2016/2/17 17:33
|
|
|
+ * Created by Bitliker on 2017/3/1.
|
|
|
*/
|
|
|
-public class MessageFragment 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 class MessageFragment extends EasyFragment implements IMessageView, RecognizerDialogListener, View.OnClickListener {
|
|
|
+
|
|
|
+ @ViewInject(R.id.search_edit)
|
|
|
+ private ClearEditText search_edit;
|
|
|
+
|
|
|
+ @ViewInject(R.id.message_net_set)
|
|
|
+ private DrawableCenterTextView message_net_set;
|
|
|
+ @ViewInject(R.id.pull_refresh_list)
|
|
|
+ private PullToRefreshSlideListView listView;
|
|
|
+
|
|
|
+ private MainActivity mContext;
|
|
|
+ private MessagePresenter presenter;
|
|
|
+ private MessageAdapter mAdapter = null;
|
|
|
+ private VoiceToWord mVoice;//语音工具
|
|
|
+ private PopupWindow setWindow;
|
|
|
+ private int clickPosition = 0;
|
|
|
+ private Boolean platform;
|
|
|
+ private RelativeLayout news_notice_rl;
|
|
|
+ private RelativeLayout subscribe_rl;
|
|
|
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 ImageView voice_search;
|
|
|
+ private Comparator<BaseSortModel<Friend>> comparator;
|
|
|
|
|
|
@Override
|
|
|
- public void onResult(RecognizerResult recognizerResult, boolean b) {
|
|
|
- String text = JsonParser.parseIatResult(recognizerResult.getResultString());
|
|
|
- mClearEditText.setText(mClearEditText.getText().toString() + CommonUtil.getPlaintext(text));
|
|
|
+ public void onAttach(Context context) {
|
|
|
+ super.onAttach(context);
|
|
|
+ if (context instanceof MainActivity)
|
|
|
+ mContext = (MainActivity) context;
|
|
|
+ else new ClassCastException("该碎片必须由MainActivity生成");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onError(SpeechError speechError) {
|
|
|
- Log.v("speechError", speechError.toString());
|
|
|
- }
|
|
|
-
|
|
|
- public interface OnRefreshUIListener {
|
|
|
- void updata(int num);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public MessageFragment() {
|
|
|
- mOriginalFriendList = new ArrayList<BaseSortModel<Friend>>();
|
|
|
- mFriendList = new ArrayList<BaseSortModel<Friend>>();
|
|
|
+ public void onDestroy() {
|
|
|
+ super.onDestroyView();
|
|
|
+ presenter.onDestroyView(mContext);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected int inflateLayoutId() {
|
|
|
- return R.layout.fragment_message;
|
|
|
+ return R.layout.fragment_new_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));
|
|
|
+ LogUtil.d("onCreateView:" + DateFormatUtil.getDateTimeStr());
|
|
|
if (createView) {
|
|
|
+ ViewUtils.inject(getmRootView());
|
|
|
+ platform = ApiUtils.getApiModel() instanceof ApiPlatform;
|
|
|
initView();
|
|
|
+ initEvent();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @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;
|
|
|
+ presenter.loadData();
|
|
|
}
|
|
|
|
|
|
- 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) {
|
|
|
- }
|
|
|
-
|
|
|
+ private void initEvent() {
|
|
|
+ mVoice.setRecognizerDialogListener(this);
|
|
|
+ findViewById(R.id.voice_search_iv).setOnClickListener(this);
|
|
|
+ message_net_set.setOnClickListener(this);
|
|
|
+ search_edit.addTextChangedListener(new EditChangeListener() {
|
|
|
@Override
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
+ //TODO 输入后搜索
|
|
|
+ presenter.search(s.toString());
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- 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.getRefreshableView().addHeaderView(getHeaderView());
|
|
|
- mPullToRefreshListView.setOnRefreshListener(new OnRefreshListener<SlideListView>() {
|
|
|
+ //下拉刷新
|
|
|
+ listView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<SlideListView>() {
|
|
|
@Override
|
|
|
public void onRefresh(PullToRefreshBase<SlideListView> refreshView) {
|
|
|
- mNoticeMsg = null;
|
|
|
- refreshUI();
|
|
|
+ presenter.loadData();
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- mPullToRefreshListView.getRefreshableView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ listView.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) {
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ if (mAdapter == null || ListUtils.isEmpty(mAdapter.getmFriendList()) || mAdapter.getCount() <= id)
|
|
|
return;
|
|
|
- }
|
|
|
- if (friend.getType() == XmppMessage.TYPE_ERP) {
|
|
|
- //消息
|
|
|
- //TODO 调转到制定界面
|
|
|
- turn2ERp(friend);
|
|
|
- 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();
|
|
|
- }
|
|
|
+ presenter.turn2NextAct(mContext, (int) id);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- mNetTextView.setOnClickListener(new View.OnClickListener() {
|
|
|
+ listView.getRefreshableView().setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
|
|
@Override
|
|
|
- public void onClick(View v) {
|
|
|
- startActivity(new Intent(Settings.ACTION_SETTINGS));
|
|
|
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ if (mAdapter == null || ListUtils.isEmpty(mAdapter.getmFriendList()) || mAdapter.getCount() <= id)
|
|
|
+ return true;
|
|
|
+ clickPosition = (int) id;
|
|
|
+ showPopupWindow();
|
|
|
+ return true;
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 调转到对应ERP相关知会里面去
|
|
|
- *
|
|
|
- * @param friend
|
|
|
- */
|
|
|
- private void turn2ERp(Friend friend) {
|
|
|
- String description = friend.getDescription();
|
|
|
|
|
|
- if (StringUtils.isEmpty(description)) return;
|
|
|
- Intent intent = new Intent(ct, MsgsSecondCommonActivity.class);
|
|
|
- intent.putExtra("type", description);
|
|
|
- intent.putExtra("title", friend.getNickName());
|
|
|
- intent.putExtra("emcode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
- startActivity(intent);
|
|
|
}
|
|
|
|
|
|
- public void setNetNoticeVisiable(boolean visiable) {
|
|
|
- if (mNetTextView != null) {
|
|
|
- if (visiable) {
|
|
|
- mNetTextView.setVisibility(View.VISIBLE);
|
|
|
- } else {
|
|
|
- mNetTextView.setVisibility(View.GONE);
|
|
|
- }
|
|
|
+ private void initView() {
|
|
|
+ mVoice = new VoiceToWord(mContext, "534e3fe2");
|
|
|
+ listView.getRefreshableView().addHeaderView(initHeaderView());
|
|
|
+// listView.setShowIndicator(false);
|
|
|
+// listView.getRefreshableView().setCacheColorHint(Color.parseColor("#000000"));
|
|
|
+// listView.getRefreshableView().setScrollingCacheEnabled(false);
|
|
|
+ listView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
|
|
|
+ mAdapter = new MessageAdapter(null, mContext);
|
|
|
+ listView.getRefreshableView().setAdapter(mAdapter);
|
|
|
+ presenter = new MessagePresenter(mContext, this);
|
|
|
+ }
|
|
|
+
|
|
|
+ private View initHeaderView() {
|
|
|
+ View view = LayoutInflater.from(mContext).inflate(R.layout.new_message_header, null);
|
|
|
+ news_notice_rl = (RelativeLayout) view.findViewById(R.id.notice_rl);
|
|
|
+ subscribe_rl = (RelativeLayout) view.findViewById(R.id.subscribe_rl);
|
|
|
+ schedule_num_tv = (TextView) view.findViewById(R.id.schedule_num_tv);//审批流
|
|
|
+ waitting_work_num_tv = (TextView) view.findViewById(R.id.waitting_work_num_tv);//待办工作
|
|
|
+ subscribe_num_tv = (TextView) view.findViewById(R.id.subscribe_num_tv);//我的订阅
|
|
|
+
|
|
|
+ schedule_content_tv = (TextView) view.findViewById(R.id.schedule_content_tv);//审批流
|
|
|
+ waitting_work_content_tv = (TextView) view.findViewById(R.id.waitting_work_content_tv);//待办工作
|
|
|
+ subscribe_content_tv = (TextView) view.findViewById(R.id.subscribe_content_tv);//我的订阅
|
|
|
+
|
|
|
+ schedule_time_tv = (TextView) view.findViewById(R.id.schedule_time_tv);//审批流
|
|
|
+ waitting_work_time_tv = (TextView) view.findViewById(R.id.waitting_work_time_tv);//待办工作
|
|
|
+ subscribe_time_tv = (TextView) view.findViewById(R.id.subscribe_time_tv);//我的订阅
|
|
|
+ view.findViewById(R.id.schedule_rl).setOnClickListener(this);//审批流
|
|
|
+ view.findViewById(R.id.waitting_work_rl).setOnClickListener(this);//待办工作
|
|
|
+ view.findViewById(R.id.subscribe_rl).setOnClickListener(this);//我的订阅
|
|
|
+ view.findViewById(R.id.notice_rl).setOnClickListener(this); //新闻通知
|
|
|
+ if (platform) {
|
|
|
+ subscribe_rl.setVisibility(View.GONE);
|
|
|
+ news_notice_rl.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ subscribe_rl.setVisibility(View.VISIBLE);
|
|
|
+ news_notice_rl.setVisibility(View.GONE);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 头视图相关
|
|
|
- * by gongpm 2016/06/15
|
|
|
- */
|
|
|
- private TextView schedule_num_tv, schedule_content_tv, schedule_time_tv;
|
|
|
- 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 TextView b2b_num_tv, b2b_content_tv, b2b_time_tv;
|
|
|
- private RelativeLayout rl_b2b;
|
|
|
-
|
|
|
- private View getHeaderView() {
|
|
|
- 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);
|
|
|
-
|
|
|
- task_num_tv = (TextView) view.findViewById(R.id.task_num_tv);
|
|
|
- task_content_tv = (TextView) view.findViewById(R.id.task_content_tv);
|
|
|
- task_time_tv = (TextView) view.findViewById(R.id.task_time_tv);
|
|
|
-
|
|
|
- notice_num_tv = (TextView) view.findViewById(R.id.notice_num_tv);
|
|
|
- notice_content_tv = (TextView) view.findViewById(R.id.notice_content_tv);
|
|
|
- notice_time_tv = (TextView) view.findViewById(R.id.notice_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);
|
|
|
- b2b_num_tv = (TextView) view.findViewById(R.id.b2b_num_tv);
|
|
|
- b2b_content_tv = (TextView) view.findViewById(R.id.b2b_content_tv);
|
|
|
- b2b_time_tv = (TextView) view.findViewById(R.id.b2b_time_tv);
|
|
|
- rl_b2b = (RelativeLayout) view.findViewById(R.id.rl_b2b_business);
|
|
|
- view.findViewById(R.id.schedule_rl).setOnClickListener(listener);
|
|
|
- view.findViewById(R.id.task_rl).setOnClickListener(listener);
|
|
|
- view.findViewById(R.id.notice_rl).setOnClickListener(listener);
|
|
|
- view.findViewById(R.id._rl).setOnClickListener(listener);
|
|
|
- view.findViewById(R.id.rl_b2b_business).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.task_rl:
|
|
|
- startActivity(new Intent(mActivity, TaskActivity.class));
|
|
|
- break;
|
|
|
- case R.id.notice_rl:
|
|
|
- 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);
|
|
|
- startActivityForResult(intent, REQUESTCODE);
|
|
|
- break;
|
|
|
- case R.id._rl:
|
|
|
-// startActivity(new Intent(mActivity, SubscriptionActivity.class));
|
|
|
- startActivity(new Intent(mActivity, Subscription2Activity.class));
|
|
|
- break;
|
|
|
- case R.id.rl_b2b_business:
|
|
|
- startActivity(new Intent(mActivity, B2bMsgActivity.class));
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- private void refreshUI() {
|
|
|
- if (!AppConfig.COMPANY) return;
|
|
|
- loadDataByIm();
|
|
|
- FriendDao.getInstance().markUserMessageRead(
|
|
|
- MyApplication.getInstance().mLoginUser.getUserId(),
|
|
|
- Friend.ID_ERP_ZHIHUI);
|
|
|
-
|
|
|
- loadGongGaoCount(mActivity);//公告
|
|
|
- loadNoticeCount(mActivity);//通知
|
|
|
- loadERPNewsNum(mActivity);//新闻
|
|
|
- loadNetData(mActivity);//订阅好
|
|
|
-
|
|
|
-
|
|
|
- loadERPMsgNum(mActivity);//getallprocess
|
|
|
- loadB2bMessageNum();//商务消息
|
|
|
- loadProcessToDo(1);//common/desktop/process/toDo.action
|
|
|
+ private void showPopupWindow() {
|
|
|
+ if (setWindow == null) initPopupWindow();
|
|
|
+ setWindow.showAtLocation(mContext.getWindow().getDecorView().
|
|
|
+ findViewById(android.R.id.content), Gravity.CENTER, 0, 0);
|
|
|
+ DisplayUtil.backgroundAlpha(mContext, 0.4f);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取关注列表(需调式查看访问数据内容) 更新朋友信息
|
|
|
- */
|
|
|
- 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() {
|
|
|
+ private void initPopupWindow() {
|
|
|
+ View viewContext = LayoutInflater.from(ct).inflate(R.layout.msgs_long_click, null);
|
|
|
+ viewContext.findViewById(R.id.msg_delete_tv).setOnClickListener(new View.OnClickListener() {
|
|
|
@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;
|
|
|
- }
|
|
|
+ public void onClick(View v) {
|
|
|
+ presenter.deleteListByType(clickPosition);
|
|
|
+ closePopupWindow();
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void loadDataByErp() {
|
|
|
-
|
|
|
- Map<String, Object> param = new HashMap<>();
|
|
|
- param.put("emcode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
- HttpHandler.getInstance().loadERPByNet(0x11, "mobile/queryEmNews.action", param, null, new HttpHandler.OnResultListener() {
|
|
|
+ });
|
|
|
+ viewContext.findViewById(R.id.msg_markread_tv).setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
- public void result(int what, boolean isJSON, String message, Bundle bundle) {
|
|
|
- if (!isJSON) return;
|
|
|
- JSONObject object = JSON.parseObject(message);
|
|
|
- //TODO 获取到消息的总数
|
|
|
- int allCount = WorkHandlerUtil.getIntByJson(object, "allCount");
|
|
|
- if (!object.containsKey("listdata")) return;
|
|
|
- JSONArray array = object.getJSONArray("listdata");
|
|
|
- handlerNewsFormErp(array);
|
|
|
- loadDataByIm();
|
|
|
+ public void onClick(View v) {
|
|
|
+ presenter.readerAllByType(clickPosition);
|
|
|
+ closePopupWindow();
|
|
|
}
|
|
|
-
|
|
|
+ });
|
|
|
+ setWindow = new PopupWindow(viewContext,
|
|
|
+ LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
+ LinearLayout.LayoutParams.WRAP_CONTENT, true);
|
|
|
+ setWindow.setAnimationStyle(R.style.MenuAnimationFade);
|
|
|
+ setWindow.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.bg_popuwin));
|
|
|
+ setWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
@Override
|
|
|
- public void error(int what, int statuCode, String message, Bundle bundle) {
|
|
|
-
|
|
|
+ public void onDismiss() {
|
|
|
+ closePopupWindow();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private Comparator<BaseSortModel<Friend>> erpComparator = null;
|
|
|
-
|
|
|
- private void handlerNewsFormErp(JSONArray array) {
|
|
|
- if (ListUtils.isEmpty(array)) {
|
|
|
- //TODO 为空数据情况下
|
|
|
- return;
|
|
|
- }
|
|
|
- List<BaseSortModel<Friend>> erpFriend = new ArrayList<>();
|
|
|
- JSONObject object = null;
|
|
|
- Friend friend = null;
|
|
|
- for (int i = 0; i < array.size(); i++) {
|
|
|
- object = array.getJSONObject(i);
|
|
|
- friend = new Friend();
|
|
|
- friend.setNickName(object.getString("title"));
|
|
|
- friend.setContent(object.getString("lastMessage"));
|
|
|
- friend.setTimeSend(getErpTime(object, "lastTime"));
|
|
|
- friend.setType(XmppMessage.TYPE_ERP);
|
|
|
- friend.setDescription(object.getString("type"));
|
|
|
-
|
|
|
- BaseSortModel<Friend> mode = new BaseSortModel<>();
|
|
|
- mode.setBean(friend);
|
|
|
- setSortCondition(mode);
|
|
|
- erpFriend.add(mode);
|
|
|
- }
|
|
|
- if (erpComparator == null) {
|
|
|
- erpComparator = new Comparator<BaseSortModel<Friend>>() {
|
|
|
- public int compare(BaseSortModel<Friend> s1, BaseSortModel<Friend> s2) {
|
|
|
- return (s1.getBean().getTimeSend() - s2.getBean().getTimeSend());
|
|
|
- }
|
|
|
- };
|
|
|
- }
|
|
|
- Collections.sort(erpFriend, erpComparator);
|
|
|
- mFriendList.addAll(0, erpFriend);
|
|
|
- mOriginalFriendList.addAll(0, erpFriend);
|
|
|
- mAdapter.notifyDataSetChanged();
|
|
|
+ private void closePopupWindow() {
|
|
|
+ if (setWindow != null)
|
|
|
+ setWindow.dismiss();
|
|
|
+ DisplayUtil.backgroundAlpha(mContext, 1f);
|
|
|
}
|
|
|
|
|
|
|
|
|
- private int getErpTime(JSONObject object, String lastTime) {
|
|
|
- String time = object.getString(lastTime);
|
|
|
- if (StringUtils.isEmpty(time)) {
|
|
|
- return (int) (System.currentTimeMillis() / 1000);
|
|
|
- } else {
|
|
|
- return (int) (TimeUtils.f_str_2_long(time) / 1000);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 请求加载新的筛选条件的数据
|
|
|
- * <p/>
|
|
|
- * 是下拉刷新,还是上拉加载
|
|
|
- */
|
|
|
- private void loadDataByIm() {
|
|
|
- //TODO im部分
|
|
|
- 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<>();
|
|
|
- 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 onResult(RecognizerResult recognizerResult, boolean b) {
|
|
|
+ String text = JsonParser.parseIatResult(recognizerResult.getResultString());
|
|
|
+ search_edit.setText(search_edit.getText().toString() + CommonUtil.getPlaintext(text));
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- if (requestCode == MessageFragment.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);
|
|
|
- setNOTICE_count(GONGGAO_count + NES_count + NOTICE_count);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ public void onError(SpeechError speechError) {
|
|
|
|
|
|
- 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());
|
|
|
+ //点击时间回调
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ switch (v.getId()) {
|
|
|
+ case R.id.voice_search_iv://点击语音
|
|
|
+ mVoice.GetWordFromVoice();
|
|
|
+ break;
|
|
|
+ case R.id.message_net_set://点击无网络情况
|
|
|
+ startActivity(new Intent(Settings.ACTION_SETTINGS));
|
|
|
+ break;
|
|
|
+ case R.id.schedule_rl://审批流
|
|
|
+ startActivity(new Intent(mContext, ProcessMsgActivity.class));
|
|
|
+ break;
|
|
|
+ case R.id.waitting_work_rl://待办工作
|
|
|
+ startActivity(new Intent(mContext, TaskActivity.class));
|
|
|
+ break;
|
|
|
+ case R.id.subscribe_rl://我的订阅
|
|
|
+ presenter.setSubReadTime(TimeUtils.s_long_2_str(System.currentTimeMillis()));
|
|
|
+ startActivity(new Intent(mContext, Subscription2Activity.class));
|
|
|
+ break;
|
|
|
+ case R.id.msg_delete_tv://删除
|
|
|
+ break;
|
|
|
+ case R.id.msg_markread_tv://标为已读
|
|
|
+ break;
|
|
|
+ case R.id.notice_rl: //新闻通知
|
|
|
+ Intent intent = new Intent(mContext, NoticeMenuActivity.class);
|
|
|
+// intent.putExtra(NoticeMenuActivity.GONGGAO, GONGGAO_count);
|
|
|
+// intent.putExtra(NoticeMenuActivity.NOTICE, NOTICE_count);
|
|
|
+// intent.putExtra(NoticeMenuActivity.NES, NES_count);
|
|
|
+ startActivityForResult(intent, REQUESTCODE);
|
|
|
+ break;
|
|
|
}
|
|
|
- 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 void showModel(List<BaseSortModel<Friend>> models) {
|
|
|
+ sortModels(models);
|
|
|
+ if (listView.isRefreshing())
|
|
|
+ listView.onRefreshComplete();
|
|
|
+ if (mAdapter == null) {
|
|
|
+ mAdapter = new MessageAdapter(models, mContext);
|
|
|
+ listView.getRefreshableView().setAdapter(mAdapter);
|
|
|
+ } else {
|
|
|
+ mAdapter.setmFriendList(models);
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public View getView(final int position, View convertView, ViewGroup parent) {
|
|
|
- if (convertView == null) {
|
|
|
- convertView = createConvertView(position);
|
|
|
- }
|
|
|
- //头像
|
|
|
- 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 = "";
|
|
|
- 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() {
|
|
|
+ private void sortModels(List<BaseSortModel<Friend>> models) {
|
|
|
+ if (ListUtils.isEmpty(models)) return;
|
|
|
+ if (comparator == null)
|
|
|
+ comparator = new Comparator<BaseSortModel<Friend>>() {
|
|
|
@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));
|
|
|
- }
|
|
|
-
|
|
|
+ public int compare(BaseSortModel<Friend> lhs, BaseSortModel<Friend> rhs) {
|
|
|
+ return rhs.getBean().getTimeSend() - lhs.getBean().getTimeSend();
|
|
|
}
|
|
|
- });
|
|
|
- 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");
|
|
|
+ };
|
|
|
+ Collections.sort(models, comparator);
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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");
|
|
|
+ @Override
|
|
|
+ public void clearSearch() {
|
|
|
+ search_edit.setText("");
|
|
|
}
|
|
|
|
|
|
|
|
|
- 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");
|
|
|
- }
|
|
|
+ //头文件处理
|
|
|
+ private TextView schedule_num_tv;//审批流
|
|
|
+ private TextView waitting_work_num_tv;//待办工作
|
|
|
+ private TextView subscribe_num_tv;//我的订阅
|
|
|
|
|
|
- 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");
|
|
|
- }
|
|
|
+ private TextView schedule_content_tv;//审批流
|
|
|
+ private TextView waitting_work_content_tv;//待办工作
|
|
|
+ private TextView subscribe_content_tv;//我的订阅
|
|
|
|
|
|
- /**
|
|
|
- * @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");
|
|
|
+ private TextView schedule_time_tv;//审批流
|
|
|
+ private TextView waitting_work_time_tv;//待办工作
|
|
|
+ private TextView subscribe_time_tv;//我的订阅
|
|
|
|
|
|
- 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");
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @功能:加载商务信息-本地数据库
|
|
|
- * @author:Arisono
|
|
|
- * @param:
|
|
|
- * @return:
|
|
|
- */
|
|
|
- public void loadB2bMessageNum() {
|
|
|
- DBManager db = new DBManager(getActivity());
|
|
|
- String master = CommonUtil.getSharedPreferences(getActivity(), "erp_master");
|
|
|
- Log.i("Arison", "" + master);
|
|
|
- if (StringUtils.isEmpty(master)) return;
|
|
|
- List<B2BMsg> bMsgs = db.queryB2bList(new String[]{"0", master}, " b2b_hasRead=? and b2b_master=? ");
|
|
|
- Log.i("B2B", "" + JSON.toJSONString(bMsgs));
|
|
|
- if (!ListUtils.isEmpty(bMsgs)) {
|
|
|
- if (b2b_num_tv == null) return;
|
|
|
- b2b_num_tv.setText(bMsgs.size() + "");
|
|
|
- b2b_num_tv.setVisibility(View.VISIBLE);
|
|
|
- b2b_content_tv.setText("您有" + bMsgs.size() + "条商务消息未读");
|
|
|
- rl_b2b.setVisibility(View.VISIBLE);
|
|
|
- BMSGS_count = bMsgs.size();
|
|
|
- setListener();
|
|
|
- } else {
|
|
|
- rl_b2b.setVisibility(View.GONE);
|
|
|
+ @Override
|
|
|
+ public void updateHeaderView(int postion, int num, String subTitle) {
|
|
|
+ switch (postion) {
|
|
|
+ case 0:
|
|
|
+ updateHeaderView(schedule_num_tv, schedule_content_tv, schedule_time_tv, num, subTitle);
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ updateHeaderView(waitting_work_num_tv, waitting_work_content_tv, waitting_work_time_tv, num, subTitle);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ updateHeaderView(subscribe_num_tv, subscribe_content_tv, subscribe_time_tv, num, subTitle);
|
|
|
+ break;
|
|
|
}
|
|
|
- db.closeDB();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- private final int load_success_erpMsgNum = 5;
|
|
|
- private Handler handler = new Handler() {
|
|
|
- @Override
|
|
|
- public void handleMessage(final Message msg) {
|
|
|
- switch (msg.what) {
|
|
|
- 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 Constants.SUCCESS_LOGIN://公告
|
|
|
- updateGongGao(msg);
|
|
|
- break;
|
|
|
- case load_success_erpMsgNum://待办(任务、代办、订阅)
|
|
|
- getErpMsgNums(msg);
|
|
|
- break;
|
|
|
- case Constants.LOAD_SUCCESS://通知
|
|
|
- updateNotice(msg);
|
|
|
- break;
|
|
|
- case Constants.SUCCESS_INITDATA://新闻
|
|
|
- updateNews(msg);
|
|
|
- break;
|
|
|
- //以下为更新页面
|
|
|
- case GONGGAO_MSG:
|
|
|
- setNOTICE_count(GONGGAO_count + NOTICE_count + NES_count);
|
|
|
- break;
|
|
|
- case NOTICE_MSG:
|
|
|
- setNOTICE_count(GONGGAO_count + NOTICE_count + NES_count);
|
|
|
- break;
|
|
|
- case NES_MSG:
|
|
|
- setNOTICE_count(GONGGAO_count + NOTICE_count + NES_count);
|
|
|
- break;
|
|
|
- case TASK_MSG:
|
|
|
- setListener();
|
|
|
- if (TASK_count > 0) {
|
|
|
- task_num_tv.setText(TASK_count + "");
|
|
|
- task_num_tv.setVisibility(View.VISIBLE);
|
|
|
-// task_content_tv.setText("您有新的任务!");
|
|
|
- if (msg.obj != null) {
|
|
|
- task_content_tv.setText((String) msg.obj);
|
|
|
- }
|
|
|
- task_time_tv.setText("刚刚");
|
|
|
- } else {
|
|
|
- task_num_tv.setVisibility(View.GONE);
|
|
|
- task_content_tv.setText("");
|
|
|
- }
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- private void setNOTICE_count(int count) {
|
|
|
- setListener();
|
|
|
- if (count > 0) {
|
|
|
- notice_num_tv.setText(count + "");
|
|
|
- notice_num_tv.setVisibility(View.VISIBLE);
|
|
|
- if (mNoticeMsg != null) {
|
|
|
- notice_content_tv.setText(mNoticeMsg);
|
|
|
+ @Override
|
|
|
+ public void changeNet(boolean workConnected) {
|
|
|
+ if (message_net_set != null) {
|
|
|
+ if (!workConnected) {
|
|
|
+ message_net_set.setVisibility(View.VISIBLE);
|
|
|
+ } else {
|
|
|
+ message_net_set.setVisibility(View.GONE);
|
|
|
}
|
|
|
-// notice_content_tv.setText("您有新的通知公告!");
|
|
|
- notice_time_tv.setText("刚刚");
|
|
|
- } else {
|
|
|
- notice_num_tv.setVisibility(View.GONE);
|
|
|
- notice_content_tv.setText("");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
+ private void updateHeaderView(TextView num_tv, TextView content_tv, TextView time_tv, int num, String subTitle) {
|
|
|
+ if (num_tv != null) {
|
|
|
+ num_tv.setVisibility(num == 0 ? View.GONE : View.VISIBLE);
|
|
|
+ num_tv.setText("" + num);
|
|
|
}
|
|
|
+ if (content_tv != null)
|
|
|
+ content_tv.setText(StringUtils.isEmpty(subTitle) ? "" : subTitle);
|
|
|
+ if (time_tv != null)
|
|
|
+ time_tv.setText(num == 0 ? "" : "刚刚");
|
|
|
}
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
|
|
|
+}
|