|
|
@@ -1,12 +1,14 @@
|
|
|
package com.xzjmyk.pm.activity.ui.message;
|
|
|
|
|
|
-import android.app.Activity;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.provider.Settings;
|
|
|
import android.support.v7.widget.AppCompatTextView;
|
|
|
-import android.text.Editable;
|
|
|
+import android.support.v7.widget.DividerItemDecoration;
|
|
|
+import android.support.v7.widget.LinearLayoutManager;
|
|
|
+import android.support.v7.widget.RecyclerView;
|
|
|
+import android.support.v7.widget.Toolbar;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
@@ -15,7 +17,6 @@ import android.view.MenuInflater;
|
|
|
import android.view.MenuItem;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
-import android.widget.AdapterView;
|
|
|
import android.widget.BaseAdapter;
|
|
|
import android.widget.ImageButton;
|
|
|
import android.widget.ImageView;
|
|
|
@@ -38,15 +39,13 @@ import com.core.model.WorkModel;
|
|
|
import com.core.utils.ToastUtil;
|
|
|
import com.core.utils.sortlist.BaseSortModel;
|
|
|
import com.core.widget.DrawableCenterTextView;
|
|
|
-import com.core.widget.MyListView;
|
|
|
import com.core.widget.RedView;
|
|
|
-import com.core.widget.VoiceSearchView;
|
|
|
-import com.core.widget.listener.EditChangeListener;
|
|
|
import com.modular.appmessages.activity.ProcessB2BActivity;
|
|
|
import com.modular.appmessages.activity.ProcessMsgActivity;
|
|
|
import com.modular.appmessages.activity.Subscription2Activity;
|
|
|
-import com.modular.appmessages.adapter.MessageAdapter;
|
|
|
+import com.modular.appmessages.adapter.MessageNewAdapter;
|
|
|
import com.modular.appmessages.model.MessageHeader;
|
|
|
+import com.modular.appmessages.model.MessageNew;
|
|
|
import com.modular.appmessages.presenter.MessagePresenter;
|
|
|
import com.modular.appmessages.presenter.imp.IMessageView;
|
|
|
import com.modular.appmessages.widget.SignRefreshLayout;
|
|
|
@@ -55,6 +54,7 @@ import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.ui.platform.task.TaskActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.platform.task.TaskB2BActivity;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
@@ -64,28 +64,24 @@ import java.util.List;
|
|
|
*/
|
|
|
public class MessageFragment extends SupportToolBarFragment implements IMessageView, View.OnClickListener {
|
|
|
|
|
|
- private VoiceSearchView voiceSearchView;
|
|
|
private DrawableCenterTextView message_net_set;
|
|
|
private SignRefreshLayout mSignRefreshLayout;
|
|
|
- private MyListView headerLV;
|
|
|
- private MyListView contentLV;
|
|
|
- private View handerAndContentLine;
|
|
|
+ private RecyclerView mRecyclerView;
|
|
|
|
|
|
+ //打卡界面
|
|
|
private View signView;
|
|
|
private ImageButton itemSignImage;
|
|
|
private AppCompatTextView itemWorkTv;
|
|
|
private AppCompatTextView itemOffkTv;
|
|
|
|
|
|
+ private MessageNewAdapter mAdapter;
|
|
|
private BaseActivity mContext;
|
|
|
private MessagePresenter presenter;
|
|
|
- private MessageAdapter mAdapter;
|
|
|
private PopupWindow setWindow;
|
|
|
private int clickPosition = 0;
|
|
|
private Boolean platform;
|
|
|
|
|
|
private Comparator<BaseSortModel<Friend>> comparator;
|
|
|
-
|
|
|
- private HeadAdapter headAdapter;
|
|
|
private MessagePresenter.UnReaderListener unReaderListener;
|
|
|
|
|
|
@Override
|
|
|
@@ -122,7 +118,7 @@ public class MessageFragment extends SupportToolBarFragment implements IMessageV
|
|
|
|
|
|
@Override
|
|
|
protected int inflateLayoutId() {
|
|
|
- return R.layout.fragment_new_message;
|
|
|
+ return R.layout.fragment_message;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -145,15 +141,38 @@ public class MessageFragment extends SupportToolBarFragment implements IMessageV
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private MessageNewAdapter.ItemTouchListener mItemTouchListener = new MessageNewAdapter.ItemTouchListener() {
|
|
|
+ @Override
|
|
|
+ public void longClick(int id) {
|
|
|
+
|
|
|
+
|
|
|
+ clickPosition = id - mAdapter.getHeaderSize();
|
|
|
+ if (clickPosition < 0) clickPosition = 0;
|
|
|
+ showPopupWindow();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void click(int id, MessageNew messageNew) {
|
|
|
+ if (messageNew != null && messageNew.getT() != null) {
|
|
|
+ if (messageNew.getT() instanceof MessageHeader) {
|
|
|
+ MessageHeader model = (MessageHeader) messageNew.getT();
|
|
|
+ if (model != null) {
|
|
|
+ if (!model.isHideRed()) {//如果没有被隐藏,需要更新
|
|
|
+ model.hideRed();
|
|
|
+ mAdapter.notifyItemChanged(id);
|
|
|
+ }
|
|
|
+ presenter.turn2ActByHeader(ct, model);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ presenter.turn2NextAct(mContext, id - mAdapter.getHeaderSize());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
|
|
|
private void initEvent() {
|
|
|
message_net_set.setOnClickListener(this);
|
|
|
- voiceSearchView.addTextChangedListener(new EditChangeListener() {
|
|
|
- @Override
|
|
|
- public void afterTextChanged(Editable s) {
|
|
|
- presenter.search(s.toString());
|
|
|
- }
|
|
|
- });
|
|
|
mSignRefreshLayout.setOnRefreshListener(new SignRefreshLayout.onRefreshListener() {
|
|
|
@Override
|
|
|
public void onRefresh() {
|
|
|
@@ -161,47 +180,20 @@ public class MessageFragment extends SupportToolBarFragment implements IMessageV
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- contentLV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
- @Override
|
|
|
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- if (mAdapter == null || ListUtils.isEmpty(mAdapter.getmFriendList()) || mAdapter.getCount() <= id || id < 0)
|
|
|
- return;
|
|
|
- try {
|
|
|
- presenter.turn2NextAct(mContext, (int) id);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- contentLV.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
|
|
- @Override
|
|
|
- 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;
|
|
|
- if (clickPosition < 0) clickPosition = 0;
|
|
|
- showPopupWindow();
|
|
|
- return true;
|
|
|
- }
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
|
|
|
private void initView() {
|
|
|
- android.support.v7.widget.Toolbar toolbar = getCommonToolBar();
|
|
|
+ Toolbar toolbar = getCommonToolBar();
|
|
|
if (toolbar != null) {
|
|
|
toolbar.setBackgroundResource(R.drawable.common_toolbar_message_bg);
|
|
|
}
|
|
|
setTitle(R.string.contact_title);
|
|
|
- voiceSearchView = findViewById(R.id.voiceSearchView);
|
|
|
message_net_set = findViewById(R.id.message_net_set);
|
|
|
mSignRefreshLayout = findViewById(R.id.mSignRefreshLayout);
|
|
|
- headerLV = findViewById(R.id.headerLV);
|
|
|
- contentLV = findViewById(R.id.contentLV);
|
|
|
- handerAndContentLine = findViewById(R.id.handerAndContentLine);
|
|
|
-
|
|
|
- mAdapter = new MessageAdapter(null, mContext);
|
|
|
- contentLV.setAdapter(mAdapter);
|
|
|
+ mRecyclerView = findViewById(R.id.mRecyclerView);
|
|
|
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(ct));
|
|
|
+ mRecyclerView.addItemDecoration(new DividerItemDecoration(ct, LinearLayout.VERTICAL));
|
|
|
presenter = new MessagePresenter(mContext, this, unReaderListener);
|
|
|
signView = mSignRefreshLayout.getSignView();
|
|
|
if (signView != null) {
|
|
|
@@ -348,15 +340,24 @@ public class MessageFragment extends SupportToolBarFragment implements IMessageV
|
|
|
if (mSignRefreshLayout.isEnablePullDown() && mSignRefreshLayout.isRefreshing()) {
|
|
|
mSignRefreshLayout.stopRefresh();
|
|
|
}
|
|
|
+ List<MessageNew> messageNews = new ArrayList<>();
|
|
|
+ if (!ListUtils.isEmpty(models)) {
|
|
|
+ for (BaseSortModel<Friend> e : models) {
|
|
|
+ MessageNew<BaseSortModel<Friend>> t = new MessageNew<>();
|
|
|
+ t.setT(e);
|
|
|
+ t.setType(1);
|
|
|
+ messageNews.add(t);
|
|
|
+ }
|
|
|
+ }
|
|
|
if (mAdapter == null) {
|
|
|
- mAdapter = new MessageAdapter(models, mContext);
|
|
|
- contentLV.setAdapter(mAdapter);
|
|
|
+ mAdapter = new MessageNewAdapter(ct);
|
|
|
+ mAdapter.setContentModels(messageNews);
|
|
|
+ mAdapter.setItemTouchListener(mItemTouchListener);
|
|
|
+ mRecyclerView.setAdapter(mAdapter);
|
|
|
} else {
|
|
|
- mAdapter.setmFriendList(models);
|
|
|
+ mAdapter.setContentModels(messageNews);
|
|
|
mAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
- headerLV.setSelection(0);
|
|
|
- handerAndContentLine.setVisibility(ListUtils.isEmpty(models) ? View.GONE : View.VISIBLE);
|
|
|
}
|
|
|
|
|
|
private void sortModels(List<BaseSortModel<Friend>> models) {
|
|
|
@@ -374,49 +375,53 @@ public class MessageFragment extends SupportToolBarFragment implements IMessageV
|
|
|
|
|
|
@Override
|
|
|
public void clearSearch() {
|
|
|
- voiceSearchView.setText("");
|
|
|
}
|
|
|
|
|
|
|
|
|
@Override
|
|
|
public void updateHeaderView(int type, int num, String subTitle, String time) {
|
|
|
- if (headAdapter != null && !ListUtils.isEmpty(headAdapter.getModels())) {
|
|
|
+ if (mAdapter != null && !ListUtils.isEmpty(mAdapter.getModels())) {
|
|
|
boolean isUpdated = false;
|
|
|
if (type != MessagePresenter.REAL_TIME_FORM && type != MessagePresenter.BUSINESS_STATISTICS) {
|
|
|
- for (MessageHeader e : headAdapter.getModels()) {
|
|
|
- if (e.getType() == type) {
|
|
|
- isUpdated = true;
|
|
|
- e.setSubDoc(subTitle);
|
|
|
- e.setRedNum(num);
|
|
|
- e.setTime(time);
|
|
|
+ for (int i = 0; i < mAdapter.getModels().size(); i++) {
|
|
|
+ MessageNew e = mAdapter.getModels().get(i);
|
|
|
+ if (e != null && e.getT() != null && e.getT() instanceof MessageHeader) {
|
|
|
+ MessageHeader h = (MessageHeader) e.getT();
|
|
|
+ if (h.getType() == type) {
|
|
|
+ isUpdated = true;
|
|
|
+ h.setSubDoc(subTitle);
|
|
|
+ h.setRedNum(num);
|
|
|
+ h.setTime(time);
|
|
|
+ mAdapter.notifyItemChanged(i, e);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (type == MessagePresenter.REAL_TIME_FORM || type == MessagePresenter.BUSINESS_STATISTICS) {
|
|
|
- isUpdated = updateHideOrDisplay(num, isUpdated, type);
|
|
|
- }
|
|
|
-
|
|
|
- if (isUpdated) {
|
|
|
- headAdapter.notifyDataSetChanged();
|
|
|
+ updateHideOrDisplay(num, isUpdated, type);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
if (mSignRefreshLayout.isEnablePullDown() && mSignRefreshLayout.isRefreshing()) {
|
|
|
mSignRefreshLayout.stopRefresh();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //更新是否显示红点
|
|
|
private boolean updateHideOrDisplay(int num, boolean isUpdated, int type) {
|
|
|
boolean isExist = false;
|
|
|
int position = -1;
|
|
|
- for (int i = 0; i < headAdapter.getModels().size(); i++) {
|
|
|
- MessageHeader messageHeader = headAdapter.getModels().get(i);
|
|
|
- if (messageHeader.getType() == type) {
|
|
|
- position = i;
|
|
|
- isExist = true;
|
|
|
- break;
|
|
|
+ for (int i = 0; i < mAdapter.getModels().size(); i++) {
|
|
|
+ MessageNew model = mAdapter.getModels().get(i);
|
|
|
+ if (model != null && model.getT() != null && model.getT() instanceof MessageHeader) {
|
|
|
+ MessageHeader messageHeader = (MessageHeader) model.getT();
|
|
|
+ if (messageHeader.getType() == type) {
|
|
|
+ position = i;
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
if (num > 0) {
|
|
|
if (!isExist) {
|
|
|
@@ -426,21 +431,28 @@ public class MessageFragment extends SupportToolBarFragment implements IMessageV
|
|
|
model.setIcon(R.drawable.ic_real_time_form);
|
|
|
model.setRedKey(Constants.MESSAGE_REAL_TIME);
|
|
|
model.setType(MessagePresenter.REAL_TIME_FORM);
|
|
|
- headAdapter.getModels().add(2, model);
|
|
|
+ MessageNew news = new MessageNew();
|
|
|
+ news.setT(model);
|
|
|
+ mAdapter.addHeadModel(2, news);
|
|
|
} else if (type == MessagePresenter.BUSINESS_STATISTICS) {
|
|
|
MessageHeader model = new MessageHeader(StringUtil.getMessage(R.string.business_statistics));
|
|
|
model.setIcon(R.drawable.ic_business_statistics);
|
|
|
model.setRedKey(Constants.MESSAGE_BUSINESS_STATISTICS);
|
|
|
model.setType(MessagePresenter.BUSINESS_STATISTICS);
|
|
|
- headAdapter.getModels().add(headAdapter.getModels().size() - 1, model);
|
|
|
+ MessageNew news = new MessageNew();
|
|
|
+ news.setT(model);
|
|
|
+ mAdapter.getModels().add(1000, news);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
isUpdated = true;
|
|
|
- if (position >= 0 && position <= headAdapter.getModels().size()) {
|
|
|
- headAdapter.getModels().remove(position);
|
|
|
+ if (position >= 0 && position <= mAdapter.getModels().size()) {
|
|
|
+ mAdapter.getModels().remove(position);
|
|
|
}
|
|
|
}
|
|
|
+ if (isUpdated) {
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
return isUpdated;
|
|
|
}
|
|
|
|
|
|
@@ -456,25 +468,14 @@ public class MessageFragment extends SupportToolBarFragment implements IMessageV
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateHeader(List<MessageHeader> models) {
|
|
|
- if (headAdapter == null) {
|
|
|
- headAdapter = new HeadAdapter(models);
|
|
|
- headerLV.setAdapter(headAdapter);
|
|
|
- headerLV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
- @Override
|
|
|
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- MessageHeader model = headAdapter.getItemModel(position);
|
|
|
- if (model != null) {
|
|
|
- if (!model.isHideRed()) {//如果没有被隐藏,需要更新
|
|
|
- model.hideRed();
|
|
|
- headAdapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- presenter.turn2ActByHeader((Activity) ct, model);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ public void updateHeader(List<MessageNew> models) {
|
|
|
+ if (mAdapter == null) {
|
|
|
+ mAdapter = new MessageNewAdapter(ct);
|
|
|
+ mAdapter.setItemTouchListener(mItemTouchListener);
|
|
|
+ mAdapter.setHeaderModels(models);
|
|
|
+ mRecyclerView.setAdapter(mAdapter);
|
|
|
} else {
|
|
|
- headAdapter.setModels(models);
|
|
|
+ mAdapter.setHeaderModels(models);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -586,7 +587,6 @@ public class MessageFragment extends SupportToolBarFragment implements IMessageV
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|