|
|
@@ -13,16 +13,19 @@ import android.widget.AdapterView;
|
|
|
import android.widget.AdapterView.OnItemClickListener;
|
|
|
import android.widget.BaseAdapter;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.ListView;
|
|
|
import android.widget.ProgressBar;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.handmark.pulltorefresh.library.PullToRefreshBase;
|
|
|
import com.handmark.pulltorefresh.library.PullToRefreshListView;
|
|
|
import com.xzjmyk.pm.activity.MyApplication;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.bean.Friend;
|
|
|
import com.xzjmyk.pm.activity.db.dao.FriendDao;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.model.NoticeData;
|
|
|
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;
|
|
|
@@ -30,6 +33,11 @@ import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.ObjectUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.view.EmptyLayout;
|
|
|
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONException;
|
|
|
+import org.json.JSONObject;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
@@ -37,7 +45,7 @@ import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author Administrator
|
|
|
- * @功能:通知
|
|
|
+ * @功能:通知公告
|
|
|
*/
|
|
|
public class NoticesActivity extends BaseActivity {
|
|
|
|
|
|
@@ -48,6 +56,8 @@ public class NoticesActivity extends BaseActivity {
|
|
|
private int type;
|
|
|
private Context ct;
|
|
|
private int gnum = 0, nnum = 0;
|
|
|
+ private int currentpage = 1;
|
|
|
+ private List<NoticeData> mNoticeData;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -62,13 +72,18 @@ public class NoticesActivity extends BaseActivity {
|
|
|
public void initView() {
|
|
|
TAG = "NoticesActivity";
|
|
|
ct = this;
|
|
|
-
|
|
|
getSupportActionBar().setTitle("通知");
|
|
|
+
|
|
|
+ mNoticeData = new ArrayList<>();
|
|
|
+ adapter = new CardItemAdapter(this,mNoticeData);
|
|
|
+ mlist.getRefreshableView().setAdapter(adapter);
|
|
|
+
|
|
|
mEmptyLayout = new EmptyLayout(this, mlist.getRefreshableView());
|
|
|
mEmptyLayout.setShowEmptyButton(false);
|
|
|
mEmptyLayout.setShowErrorButton(false);
|
|
|
mEmptyLayout.setShowLoadingButton(false);
|
|
|
type = getIntent().getIntExtra("type", 0);
|
|
|
+ mlist.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
mlist.getRefreshableView().setOnItemClickListener(new OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
@@ -88,6 +103,20 @@ public class NoticesActivity extends BaseActivity {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ mlist.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
|
|
|
+ @Override
|
|
|
+ public void onPullDownToRefresh(PullToRefreshBase refreshView) {
|
|
|
+ currentpage = 1;
|
|
|
+ initData();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPullUpToRefresh(PullToRefreshBase refreshView) {
|
|
|
+ currentpage++;
|
|
|
+ initData();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -111,7 +140,7 @@ public class NoticesActivity extends BaseActivity {
|
|
|
Intent intent = new Intent();
|
|
|
if (type == 1) {//通知
|
|
|
intent.putExtra(NoticeMenuActivity.NOTICE, nnum);
|
|
|
- } else {
|
|
|
+ } else { //公告
|
|
|
intent.putExtra(NoticeMenuActivity.GONGGAO, gnum);
|
|
|
|
|
|
}
|
|
|
@@ -124,7 +153,9 @@ public class NoticesActivity extends BaseActivity {
|
|
|
progress_bar.setVisibility(View.VISIBLE);
|
|
|
String url =null;
|
|
|
final Map<String, Object> param = new HashMap<>();
|
|
|
- param.put("count", "1000");
|
|
|
+ // param.put("count", "1000");
|
|
|
+ param.put("page",currentpage);
|
|
|
+ param.put("pageSize",10);
|
|
|
param.put("sessionId", CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
if (getIntent().getIntExtra("type", 0) == 1) {
|
|
|
url = Constants.getAppBaseUrl(ct) + "common/desktop/note/inform.action";
|
|
|
@@ -148,35 +179,33 @@ public class NoticesActivity extends BaseActivity {
|
|
|
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");
|
|
|
-// 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);
|
|
|
- mlist.setVisibility(View.VISIBLE);
|
|
|
- progress_bar.setVisibility(View.GONE);
|
|
|
-
|
|
|
- } else {
|
|
|
- adapter.notifyDataSetChanged();
|
|
|
+ if (currentpage == 1){
|
|
|
+ mNoticeData.clear();
|
|
|
+ ToastMessage("刷新成功");
|
|
|
+ }else {
|
|
|
+ ToastMessage("加载完毕");
|
|
|
}
|
|
|
- if(adapter.getCount()==0){
|
|
|
- mEmptyLayout.showEmpty();
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ Log.i("handleMessage: ",result);
|
|
|
+ progress_bar.setVisibility(View.GONE);
|
|
|
+ mlist.setVisibility(View.VISIBLE);
|
|
|
+ mlist.onRefreshComplete();
|
|
|
+ try {
|
|
|
+ JSONObject resultJsonObject = new JSONObject(result);
|
|
|
+ JSONArray dataArray = resultJsonObject.getJSONArray("data");
|
|
|
+ if (currentpage == 1 && dataArray.length() == 0){
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }else {
|
|
|
+ for (int i = 0; i < dataArray.length(); i++) {
|
|
|
+ JSONObject currentObject = dataArray.getJSONObject(i);
|
|
|
+ NoticeData noticeData = JSON.parseObject(currentObject.toString(), NoticeData.class);
|
|
|
+ mNoticeData.add(noticeData);
|
|
|
+ }
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- Log.i(TAG, result);
|
|
|
break;
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
result = msg.getData().getString("result");
|
|
|
@@ -195,23 +224,24 @@ public class NoticesActivity extends BaseActivity {
|
|
|
|
|
|
public class CardItemAdapter extends BaseAdapter {
|
|
|
|
|
|
- private NoticeEntity newsEntities;
|
|
|
+ // private NoticeEntity newsEntities;
|
|
|
+ private List<NoticeData> noticeDataList;
|
|
|
private LayoutInflater inflater;
|
|
|
|
|
|
- public CardItemAdapter(Context ct, NoticeEntity list) {
|
|
|
- this.newsEntities = list;
|
|
|
+ public CardItemAdapter(Context ct, List<NoticeData> noticeDataList) {
|
|
|
+ this.noticeDataList = noticeDataList;
|
|
|
this.inflater = LayoutInflater.from(ct);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int getCount() {
|
|
|
- return newsEntities == null ? 0 : newsEntities.getData().size();
|
|
|
+ return noticeDataList == null ? 0 : noticeDataList.size();
|
|
|
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object getItem(int position) {
|
|
|
- return newsEntities.getData().get(position);
|
|
|
+ return noticeDataList.get(position);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -243,26 +273,26 @@ public class NoticesActivity extends BaseActivity {
|
|
|
convertView.setBackgroundColor(getResources().getColor(R.color.item_color2));
|
|
|
}
|
|
|
|
|
|
- List<NoticeEntity.Data> datas = newsEntities.getData();
|
|
|
+ // List<NoticeData> noticeDataList = noticeDataList;
|
|
|
// 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().replace(" ",""));
|
|
|
- model.tv_author.setText(datas.get(position).getNO_APPROVER());
|
|
|
- model.id = datas.get(position).getNO_ID();
|
|
|
- model.hasRead = datas.get(position).getSTATUS() == null ? -1 : (int) datas.get(position).getSTATUS();
|
|
|
- if (!ObjectUtils.isEquals(datas.get(position).getSTATUS(), null)) {
|
|
|
- if (((int) datas.get(position).getSTATUS()) != -1) {
|
|
|
+ noticeDataList.get(position).getNO_APPTIME()));
|
|
|
+ model.tv_theme.setText(noticeDataList.get(position).getNO_TITLE().replace(" ",""));
|
|
|
+ model.tv_author.setText(noticeDataList.get(position).getNO_APPROVER());
|
|
|
+ model.id = noticeDataList.get(position).getNO_ID();
|
|
|
+ model.hasRead = noticeDataList.get(position).getSTATUS() == null ? -1 : (int) noticeDataList.get(position).getSTATUS();
|
|
|
+ if (!ObjectUtils.isEquals(noticeDataList.get(position).getSTATUS(), null)) {
|
|
|
+ if (((int) noticeDataList.get(position).getSTATUS()) != -1) {
|
|
|
model.img.setImageResource(R.drawable.notice_img_1);
|
|
|
} else {
|
|
|
- if (((int) datas.get(position).getSTATUS()) == -1) {
|
|
|
+ if (((int) noticeDataList.get(position).getSTATUS()) == -1) {
|
|
|
model.img.setImageResource(R.drawable.notice_img_2);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
model.img.setImageResource(R.drawable.notice_img_1);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// model.tv_count.setVisibility(View.GONE);
|
|
|
return convertView;
|
|
|
}
|