|
@@ -2,6 +2,8 @@ package com.ynstkz.shitu.android.activity;
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
import android.support.annotation.Nullable;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
@@ -11,6 +13,7 @@ import com.common.library.pulltorefresh.PullToRefreshBase;
|
|
|
import com.common.library.pulltorefresh.PullToRefreshListView;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.ynstkz.shitu.android.R;
|
|
|
+import com.ynstkz.shitu.android.adapter.OrgCommentListAdapter;
|
|
|
import com.ynstkz.shitu.android.base.TitleBarActivity;
|
|
|
import com.ynstkz.shitu.android.bean.EvaluateListBean;
|
|
|
import com.ynstkz.shitu.android.bean.OrgCommentListBean;
|
|
@@ -27,7 +30,7 @@ import okhttp3.Response;
|
|
|
* 作者:fuchangle on 2018/3/15 17:40
|
|
|
*/
|
|
|
|
|
|
-public class OrgCommentListActivity extends TitleBarActivity implements PullToRefreshBase.OnRefreshListener2<ListView>{
|
|
|
+public class OrgCommentListActivity extends TitleBarActivity implements PullToRefreshBase.OnRefreshListener2<ListView> {
|
|
|
|
|
|
@Bind(R.id.tv_title)
|
|
|
TextView tvTitle;
|
|
@@ -35,10 +38,17 @@ public class OrgCommentListActivity extends TitleBarActivity implements PullToRe
|
|
|
RelativeLayout viewTitle;
|
|
|
@Bind(R.id.pullToRefresh)
|
|
|
PullToRefreshListView pullToRefresh;
|
|
|
+ @Bind(R.id.iv_nodata_icon)
|
|
|
+ ImageView ivNodataIcon;
|
|
|
+ @Bind(R.id.tv_nodata_lab)
|
|
|
+ TextView tvNodataLab;
|
|
|
+ @Bind(R.id.rl_nodata)
|
|
|
+ RelativeLayout rlNodata;
|
|
|
|
|
|
private String memberId;
|
|
|
private int pageNumber;
|
|
|
private List<EvaluateListBean> evaluateList;
|
|
|
+ private OrgCommentListAdapter orgCommentListAdapter;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
@@ -53,12 +63,12 @@ public class OrgCommentListActivity extends TitleBarActivity implements PullToRe
|
|
|
return R.layout.activity_org_comment_list;
|
|
|
}
|
|
|
|
|
|
- private void initView(){
|
|
|
- tvTitle.setText(getIntent().getStringExtra("收到的评论"));
|
|
|
+ private void initView() {
|
|
|
+ tvTitle.setText("收到的评论");
|
|
|
pullToRefresh.setOnRefreshListener(this);
|
|
|
}
|
|
|
|
|
|
- private void initData(){
|
|
|
+ private void initData() {
|
|
|
memberId = getIntent().getStringExtra("memberId");
|
|
|
pageNumber = 1;
|
|
|
getOrgCommentList();
|
|
@@ -66,7 +76,7 @@ public class OrgCommentListActivity extends TitleBarActivity implements PullToRe
|
|
|
|
|
|
@Override
|
|
|
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
- pageNumber ++;
|
|
|
+ pageNumber++;
|
|
|
getOrgCommentList();
|
|
|
}
|
|
|
|
|
@@ -76,13 +86,13 @@ public class OrgCommentListActivity extends TitleBarActivity implements PullToRe
|
|
|
getOrgCommentList();
|
|
|
}
|
|
|
|
|
|
- private void setListener(){
|
|
|
+ private void setListener() {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void getOrgCommentList(){
|
|
|
+ private void getOrgCommentList() {
|
|
|
|
|
|
- RequestGroup.getOrgCommentList(pageNumber+"", memberId, new Callback() {
|
|
|
+ RequestGroup.getOrgCommentList(pageNumber + "", memberId, new Callback() {
|
|
|
@Override
|
|
|
public Object parseNetworkResponse(Response response, int id) throws Exception {
|
|
|
return new Gson().fromJson(response.body().string(), OrgCommentListBean.class);
|
|
@@ -95,26 +105,56 @@ public class OrgCommentListActivity extends TitleBarActivity implements PullToRe
|
|
|
|
|
|
@Override
|
|
|
public void onResponse(Object response, int id) {
|
|
|
- OrgCommentListBean orgCommentListBean = (OrgCommentListBean)response;
|
|
|
- if(orgCommentListBean != null){
|
|
|
- if("200".equals(orgCommentListBean.getCode())){
|
|
|
- if(orgCommentListBean.getData() != null){
|
|
|
- if(orgCommentListBean.getData().getEvaluateList() != null
|
|
|
- && orgCommentListBean.getData().getEvaluateList().size() > 0){
|
|
|
- if(pageNumber == 1){
|
|
|
- if(evaluateList == null){
|
|
|
+ OrgCommentListBean orgCommentListBean = (OrgCommentListBean) response;
|
|
|
+ if (orgCommentListBean != null) {
|
|
|
+ if ("200".equals(orgCommentListBean.getCode())) {
|
|
|
+ if (orgCommentListBean.getData() != null) {
|
|
|
+ if (orgCommentListBean.getData().getEvaluateList() != null
|
|
|
+ && orgCommentListBean.getData().getEvaluateList().size() > 0) {
|
|
|
+ if (pageNumber == 1) {
|
|
|
+ if (evaluateList == null) {
|
|
|
evaluateList = new ArrayList<>();
|
|
|
}
|
|
|
+ evaluateList.clear();
|
|
|
evaluateList.addAll(orgCommentListBean.getData().getEvaluateList());
|
|
|
-
|
|
|
+ orgCommentListAdapter = new OrgCommentListAdapter(OrgCommentListActivity.this, evaluateList);
|
|
|
+ pullToRefresh.setAdapter(orgCommentListAdapter);
|
|
|
+ orgCommentListAdapter.notifyDataSetChanged();
|
|
|
+ } else {
|
|
|
+ evaluateList.addAll(orgCommentListBean.getData().getEvaluateList());
|
|
|
+ orgCommentListAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ pullToRefresh.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
+ } else {
|
|
|
+ if(orgCommentListAdapter != null && orgCommentListAdapter.getCount() > 0){
|
|
|
+ showToast("已加载完毕!");
|
|
|
+ } else {
|
|
|
+ showNoData();
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ if(orgCommentListAdapter != null && orgCommentListAdapter.getCount() > 0){
|
|
|
+ showToast("已加载完毕!");
|
|
|
+ } else {
|
|
|
+ showNoData();
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
showToast(orgCommentListBean.getMsg());
|
|
|
}
|
|
|
}
|
|
|
+ pullToRefresh.onRefreshComplete();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示无数据
|
|
|
+ */
|
|
|
+ private void showNoData() {
|
|
|
+ pullToRefresh.setVisibility(View.GONE);
|
|
|
+ rlNodata.setVisibility(View.VISIBLE);
|
|
|
+ ivNodataIcon.setImageResource(R.drawable.nodata_common);
|
|
|
+ tvNodataLab.setText(getString(R.string.nodata_org_comment));
|
|
|
+ }
|
|
|
}
|