|
|
@@ -1,10 +1,18 @@
|
|
|
package com.sk.weichat.ui.erp.activity;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.LayoutInflater;
|
|
|
+import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.AdapterView.OnItemClickListener;
|
|
|
+import android.widget.BaseAdapter;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
@@ -19,209 +27,215 @@ import com.sk.weichat.ui.erp.model.NoticeEntity;
|
|
|
import com.sk.weichat.ui.erp.net.ViewUtil;
|
|
|
import com.sk.weichat.ui.erp.util.CommonUtil;
|
|
|
import com.sk.weichat.ui.erp.util.Constants;
|
|
|
-import com.sk.weichat.ui.erp.util.ObjectUtils;
|
|
|
import com.sk.weichat.ui.erp.util.StringUtils;
|
|
|
import com.sk.weichat.ui.erp.view.EmptyLayout;
|
|
|
|
|
|
-import android.content.Context;
|
|
|
-import android.content.Intent;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.os.Handler;
|
|
|
-import android.os.PersistableBundle;
|
|
|
-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.TextView;
|
|
|
-import android.widget.AdapterView.OnItemClickListener;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
/**
|
|
|
- * @author Administrator
|
|
|
- * @功能:通知
|
|
|
- */
|
|
|
-public class NoticesActivity extends BaseActivity{
|
|
|
-
|
|
|
- @ViewInject(R.id.list_notice)
|
|
|
- private PullToRefreshListView mlist;
|
|
|
- private EmptyLayout mEmptyLayout;
|
|
|
- private CardItemAdapter adapter;
|
|
|
- private int type;
|
|
|
- private Context ct;
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- initView();
|
|
|
- initData();
|
|
|
- }
|
|
|
-
|
|
|
- public void initView() {
|
|
|
- setContentView(R.layout.act_notice_list);
|
|
|
+ * @author Administrator
|
|
|
+ * @功能:通知
|
|
|
+ */
|
|
|
+public class NoticesActivity extends BaseActivity {
|
|
|
+
|
|
|
+ @ViewInject(R.id.list_notice)
|
|
|
+ private PullToRefreshListView mlist;
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
+ private CardItemAdapter adapter;
|
|
|
+ private int type;
|
|
|
+ private Context ct;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ initView();
|
|
|
+ initData();
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initView() {
|
|
|
+ setContentView(R.layout.act_notice_list);
|
|
|
ViewUtils.inject(this);
|
|
|
- TAG="NoticesActivity";
|
|
|
- ct=this;
|
|
|
+ TAG = "NoticesActivity";
|
|
|
+ ct = this;
|
|
|
getSupportActionBar().setTitle("通知");
|
|
|
mEmptyLayout = new EmptyLayout(this, mlist.getRefreshableView());
|
|
|
- mEmptyLayout.setShowEmptyButton(false);
|
|
|
- mEmptyLayout.setShowErrorButton(false);
|
|
|
- mEmptyLayout.setShowLoadingButton(false);
|
|
|
-
|
|
|
- type= getIntent().getIntExtra("type", 0);
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+
|
|
|
+ type = getIntent().getIntExtra("type", 0);
|
|
|
mlist.getRefreshableView().setOnItemClickListener(new OnItemClickListener() {
|
|
|
|
|
|
- @Override
|
|
|
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
- CardItemAdapter.ItemModel model=(CardItemAdapter.ItemModel) view.getTag();
|
|
|
- Intent intent=new Intent(NoticesActivity.this, NewsDetailActivity.class);
|
|
|
- intent.putExtra("id", model.id);
|
|
|
- intent.putExtra("type", type);
|
|
|
- startActivity(intent);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- public void initData() {
|
|
|
- String url= Constants.getAppBaseUrl(ct)+"common/desktop/note/notice.action";
|
|
|
- final Map<String,Object> param=new HashMap<>();
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ CardItemAdapter.ItemModel model = (CardItemAdapter.ItemModel) view.getTag();
|
|
|
+ Intent intent = new Intent(NoticesActivity.this, NewsDetailActivity.class);
|
|
|
+ intent.putExtra("id", model.id);
|
|
|
+ intent.putExtra("type", type);
|
|
|
+ startActivity(intent);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ public void initData() {
|
|
|
+ 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"));
|
|
|
- if (getIntent().getIntExtra("type", 0)==1) {
|
|
|
- url= Constants.getAppBaseUrl(ct)+"common/desktop/note/inform.action";
|
|
|
- getSupportActionBar().setTitle("通知");
|
|
|
- String mLoginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
- // 表示已读
|
|
|
- FriendDao.getInstance().markUserMessageRead(mLoginUserId, Friend.ID_ERP_NOTICE);
|
|
|
- }else{
|
|
|
- url= Constants.getAppBaseUrl(ct)+"common/desktop/note/notice.action";
|
|
|
- getSupportActionBar().setTitle("公告");
|
|
|
- String mLoginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
- // 表示已读
|
|
|
- FriendDao.getInstance().markUserMessageRead(mLoginUserId, Friend.ID_ERP_GONGGAO);
|
|
|
- }
|
|
|
- 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");
|
|
|
- }
|
|
|
-
|
|
|
- private Handler handler=new Handler(){
|
|
|
- public void handleMessage(android.os.Message msg) {
|
|
|
- switch (msg.what) {
|
|
|
- case Constants.LOAD_SUCCESS:
|
|
|
- String result=msg.getData().getString("result");
|
|
|
- NoticeEntity newsEntity=JSON.parseObject(result, NoticeEntity.class);
|
|
|
- if (adapter==null) {
|
|
|
- String em_id=CommonUtil.getSharedPreferences(ct, "erp_emid");
|
|
|
- Log.i("User", "em_id="+em_id);
|
|
|
- List<NoticeEntity.Data> fiterdata=new ArrayList<NoticeEntity.Data>();
|
|
|
- for (int i = 0; i < newsEntity.getData().size(); i++) {
|
|
|
- if (newsEntity.getData().get(i).getNO_ISPUBLIC()==0) {
|
|
|
- if ((!StringUtils.isEmpty(em_id)&&newsEntity.getData().get(i).getNO_RECIPIENTID()!=null)){
|
|
|
- if (newsEntity.getData().get(i).getNO_RECIPIENTID().toString().contains(em_id)) {
|
|
|
- fiterdata.add(newsEntity.getData().get(i));
|
|
|
- }
|
|
|
- }
|
|
|
- }else{
|
|
|
- fiterdata.add(newsEntity.getData().get(i));
|
|
|
- }
|
|
|
- }
|
|
|
- newsEntity.setData(fiterdata);
|
|
|
- adapter=new CardItemAdapter(ct, newsEntity);
|
|
|
- mlist.getRefreshableView().setAdapter(adapter);
|
|
|
- }else{
|
|
|
- adapter.notifyDataSetChanged();
|
|
|
- }
|
|
|
- Log.i(TAG, result);
|
|
|
- break;
|
|
|
- case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
- result=msg.getData().getString("result");
|
|
|
- Log.i(TAG, result);
|
|
|
- mEmptyLayout.setErrorMessage(result+",请刷新重试!");
|
|
|
- mEmptyLayout.showError();
|
|
|
- ViewUtil.AutoLoginErp(NoticesActivity.this, handler);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
- }
|
|
|
- };
|
|
|
- };
|
|
|
-
|
|
|
- public class CardItemAdapter extends BaseAdapter{
|
|
|
-
|
|
|
- private NoticeEntity newsEntities;
|
|
|
- private LayoutInflater inflater;
|
|
|
-
|
|
|
- public CardItemAdapter(Context ct,NoticeEntity list) {
|
|
|
- this.newsEntities=list;
|
|
|
- this.inflater=LayoutInflater.from(ct);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getCount() {
|
|
|
- return newsEntities==null?0:newsEntities.getData().size();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Object getItem(int position) {
|
|
|
- return newsEntities.getData().get(position);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public long getItemId(int position) {
|
|
|
- return position;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
- ItemModel model=null;
|
|
|
- if (convertView==null) {
|
|
|
- convertView=inflater.inflate(R.layout.item_card_notice, parent,false);
|
|
|
- model=new ItemModel();
|
|
|
- model.tv_title=(TextView) convertView.findViewById(R.id.tv_title);
|
|
|
- model.tv_time=(TextView) convertView.findViewById(R.id.tv_time);
|
|
|
- model.tv_count=(TextView) convertView.findViewById(R.id.tv_count);
|
|
|
- model.tv_theme=(TextView) convertView.findViewById(R.id.tv_theme);
|
|
|
- model.tv_author=(TextView) convertView.findViewById(R.id.tv_author);
|
|
|
- model.tv_hasRead=(TextView)convertView.findViewById(R.id.tv_hasRead);
|
|
|
- convertView.setTag(model);
|
|
|
- }else{
|
|
|
- model=(ItemModel) convertView.getTag();
|
|
|
- }
|
|
|
- List<NoticeEntity.Data> datas= newsEntities.getData();
|
|
|
- model.tv_title.setText(datas.get(position).getNO_TITLE());
|
|
|
- model.tv_time.setText(CommonUtil.transferLongToDate("yyyy-MM-dd HH:mm:ss",
|
|
|
- datas.get(position).getNO_APPTIME()));
|
|
|
- model.tv_theme.setText((CharSequence) datas.get(position).getNO_KEYWORD());
|
|
|
- model.tv_author.setText("作者:"+datas.get(position).getNO_APPROVER());
|
|
|
- model.id=datas.get(position).getNO_ID();
|
|
|
- if(!ObjectUtils.isEquals(datas.get(position).getSTATUS(),null)){
|
|
|
- if (((int)datas.get(position).getSTATUS())!=-1)
|
|
|
- {
|
|
|
- model.tv_hasRead.setText("未读");}
|
|
|
- else{
|
|
|
- if (((int)datas.get(position).getSTATUS())==-1)
|
|
|
- {
|
|
|
- model.tv_hasRead.setText("已读");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- model.tv_hasRead.setText("未读");
|
|
|
- }
|
|
|
- model.tv_count.setVisibility(View.GONE);
|
|
|
- return convertView;
|
|
|
- }
|
|
|
- class ItemModel{
|
|
|
- private int id;
|
|
|
- private TextView tv_title;
|
|
|
- private TextView tv_time;
|
|
|
- private TextView tv_count;
|
|
|
- private TextView tv_theme;
|
|
|
- private TextView tv_author;
|
|
|
- private TextView tv_hasRead;//已读,未读
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ if (getIntent().getIntExtra("type", 0) == 1) {
|
|
|
+ url = Constants.getAppBaseUrl(ct) + "common/desktop/note/inform.action";
|
|
|
+ getSupportActionBar().setTitle("通知");
|
|
|
+ String mLoginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
+ // 表示已读
|
|
|
+ FriendDao.getInstance().markUserMessageRead(mLoginUserId, Friend.ID_ERP_NOTICE);
|
|
|
+ } else {
|
|
|
+ url = Constants.getAppBaseUrl(ct) + "common/desktop/note/notice.action";
|
|
|
+ getSupportActionBar().setTitle("公告");
|
|
|
+ String mLoginUserId = MyApplication.getInstance().mLoginUser.getUserId();
|
|
|
+ // 表示已读
|
|
|
+ FriendDao.getInstance().markUserMessageRead(mLoginUserId, Friend.ID_ERP_GONGGAO);
|
|
|
+ }
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+
|
|
|
+ private Handler handler = new Handler() {
|
|
|
+ public void handleMessage(android.os.Message msg) {
|
|
|
+ switch (msg.what) {
|
|
|
+ case Constants.LOAD_SUCCESS:
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ NoticeEntity newsEntity = JSON.parseObject(result, NoticeEntity.class);
|
|
|
+ if (adapter == null) {
|
|
|
+ String em_id = CommonUtil.getSharedPreferences(ct, "erp_emid");
|
|
|
+ Log.i("User", "em_id=" + em_id);
|
|
|
+ List<NoticeEntity.Data> fiterdata = new ArrayList<NoticeEntity.Data>();
|
|
|
+ for (int i = 0; i < newsEntity.getData().size(); i++) {
|
|
|
+ if (newsEntity.getData().get(i).getNO_ISPUBLIC() == 0) {
|
|
|
+ if ((!StringUtils.isEmpty(em_id) && newsEntity.getData().get(i).getNO_RECIPIENTID() != null)) {
|
|
|
+ if (newsEntity.getData().get(i).getNO_RECIPIENTID().toString().contains(em_id)) {
|
|
|
+ fiterdata.add(newsEntity.getData().get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ fiterdata.add(newsEntity.getData().get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newsEntity.setData(fiterdata);
|
|
|
+ adapter = new CardItemAdapter(ct, newsEntity);
|
|
|
+ mlist.getRefreshableView().setAdapter(adapter);
|
|
|
+ } else {
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ Log.i(TAG, result);
|
|
|
+ break;
|
|
|
+ case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
+ result = msg.getData().getString("result");
|
|
|
+ Log.i(TAG, result);
|
|
|
+ mEmptyLayout.setErrorMessage(result + ",请刷新重试!");
|
|
|
+ mEmptyLayout.showError();
|
|
|
+ ViewUtil.AutoLoginErp(NoticesActivity.this, handler);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ;
|
|
|
+ };
|
|
|
+
|
|
|
+ public class CardItemAdapter extends BaseAdapter {
|
|
|
+
|
|
|
+ private NoticeEntity newsEntities;
|
|
|
+ private LayoutInflater inflater;
|
|
|
+
|
|
|
+ public CardItemAdapter(Context ct, NoticeEntity list) {
|
|
|
+ this.newsEntities = list;
|
|
|
+ this.inflater = LayoutInflater.from(ct);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int getCount() {
|
|
|
+ return newsEntities == null ? 0 : newsEntities.getData().size();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object getItem(int position) {
|
|
|
+ return newsEntities.getData().get(position);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long getItemId(int position) {
|
|
|
+ return position;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public View getView(int position, View convertView, ViewGroup parent) {
|
|
|
+ ItemModel model = null;
|
|
|
+ if (convertView == null) {
|
|
|
+ convertView = inflater.inflate(R.layout.item_card_notice, parent, false);
|
|
|
+ model = new ItemModel();
|
|
|
+ model.img= (ImageView) convertView.findViewById(R.id.img);
|
|
|
+// model.tv_title=(TextView) convertView.findViewById(R.id.tv_title);
|
|
|
+ model.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
|
|
|
+// model.tv_count=(TextView) convertView.findViewById(R.id.tv_count);
|
|
|
+ model.tv_theme = (TextView) convertView.findViewById(R.id.tv_theme);
|
|
|
+ model.tv_author = (TextView) convertView.findViewById(R.id.tv_author);
|
|
|
+// model.tv_hasRead=(TextView)convertView.findViewById(R.id.tv_hasRead);
|
|
|
+ convertView.setTag(model);
|
|
|
+ } else {
|
|
|
+ model = (ItemModel) convertView.getTag();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (position%2==0){
|
|
|
+ convertView.setBackgroundColor(getResources().getColor(R.color.item_color1));
|
|
|
+ model.img.setImageResource( R.drawable.notice_img_1);
|
|
|
+ }else{
|
|
|
+ convertView.setBackgroundColor(getResources().getColor(R.color.item_color2));
|
|
|
+ model.img.setImageResource(R.drawable.notice_img_2);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<NoticeEntity.Data> datas = newsEntities.getData();
|
|
|
+// model.tv_title.setText(datas.get(position).getNO_TITLE());
|
|
|
+ model.tv_time.setText(CommonUtil.transferLongToDate("yyyy-MM-dd HH:mm:ss",
|
|
|
+ datas.get(position).getNO_APPTIME()));
|
|
|
+ model.tv_theme.setText( datas.get(position).getNO_TITLE());
|
|
|
+ model.tv_author.setText(datas.get(position).getNO_APPROVER());
|
|
|
+ model.id = datas.get(position).getNO_ID();
|
|
|
+// if(!ObjectUtils.isEquals(datas.get(position).getSTATUS(),null)){
|
|
|
+// if (((int)datas.get(position).getSTATUS())!=-1)
|
|
|
+// {
|
|
|
+// model.tv_hasRead.setText("未读");}
|
|
|
+// else{
|
|
|
+// if (((int)datas.get(position).getSTATUS())==-1)
|
|
|
+// {
|
|
|
+// model.tv_hasRead.setText("已读");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// else{
|
|
|
+// model.tv_hasRead.setText("未读");
|
|
|
+// }
|
|
|
+// model.tv_count.setVisibility(View.GONE);
|
|
|
+ return convertView;
|
|
|
+ }
|
|
|
+
|
|
|
+ class ItemModel {
|
|
|
+ private int id;
|
|
|
+ // private TextView tv_title;
|
|
|
+ private TextView tv_time;
|
|
|
+ private ImageView img;
|
|
|
+ // private TextView tv_count;
|
|
|
+ private TextView tv_theme;
|
|
|
+ private TextView tv_author;
|
|
|
+// private TextView tv_hasRead;//已读,未读
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|