|
@@ -6,21 +6,25 @@ import android.support.annotation.Nullable;
|
|
|
import android.view.View;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
import android.widget.ListView;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
+import com.common.library.cache.Cache;
|
|
|
import com.common.library.okhttp.callback.Callback;
|
|
|
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.MineCollectItemAdapter;
|
|
|
-import com.ynstkz.shitu.android.adapter.MineCommentItemAdapter;
|
|
|
+import com.ynstkz.shitu.android.adapter.OrgFilterListAdapter;
|
|
|
+import com.ynstkz.shitu.android.adapter.OrgNavigationGridAdapter;
|
|
|
import com.ynstkz.shitu.android.application.STSign;
|
|
|
import com.ynstkz.shitu.android.base.TitleBarActivity;
|
|
|
import com.ynstkz.shitu.android.bean.MyCollectBean;
|
|
|
import com.ynstkz.shitu.android.bean.OrgItemBean;
|
|
|
+import com.ynstkz.shitu.android.bean.OrgNavigationBean;
|
|
|
import com.ynstkz.shitu.android.data.RequestGroup;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -35,7 +39,7 @@ import okhttp3.Response;
|
|
|
* 作者:fuchangle on 2018/2/11 15:36
|
|
|
*/
|
|
|
|
|
|
-public class MineCollectActivity extends TitleBarActivity implements PullToRefreshBase.OnRefreshListener2<ListView>{
|
|
|
+public class MineCollectActivity extends TitleBarActivity implements PullToRefreshBase.OnRefreshListener2<ListView> {
|
|
|
|
|
|
@Bind(R.id.tv_all)
|
|
|
TextView tvAll;
|
|
@@ -49,10 +53,20 @@ public class MineCollectActivity extends TitleBarActivity implements PullToRefre
|
|
|
RelativeLayout rlNodata;
|
|
|
@Bind(R.id.tv_title)
|
|
|
TextView tvTitle;
|
|
|
+ @Bind(R.id.view_title)
|
|
|
+ RelativeLayout viewTitle;
|
|
|
+ @Bind(R.id.lv_filter_content)
|
|
|
+ ListView lvFilterContent;
|
|
|
+ @Bind(R.id.ll_filter_content)
|
|
|
+ LinearLayout llFilterContent;
|
|
|
+ @Bind(R.id.ll_filter_all)
|
|
|
+ LinearLayout llFilterAll;
|
|
|
|
|
|
private int pageNumber;
|
|
|
private List<OrgItemBean> listCollentOrg;
|
|
|
private MineCollectItemAdapter mineCollectItemAdapter;
|
|
|
+ private OrgNavigationBean orgNavigationBean;
|
|
|
+ private String agencyTypeId;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
@@ -75,19 +89,19 @@ public class MineCollectActivity extends TitleBarActivity implements PullToRefre
|
|
|
|
|
|
private void initData() {
|
|
|
pageNumber = 1;
|
|
|
- getMyCollectList();
|
|
|
+ getMyCollectList("");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
pageNumber = 1;
|
|
|
- getMyCollectList();
|
|
|
+ getMyCollectList(agencyTypeId);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
|
|
|
- pageNumber ++;
|
|
|
- getMyCollectList();
|
|
|
+ pageNumber++;
|
|
|
+ getMyCollectList(agencyTypeId);
|
|
|
}
|
|
|
|
|
|
private void setListener() {
|
|
@@ -95,22 +109,87 @@ public class MineCollectActivity extends TitleBarActivity implements PullToRefre
|
|
|
pullToRefresh.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
@Override
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
- OrgItemBean orgItemBean = (OrgItemBean)adapterView.getAdapter().getItem(i);
|
|
|
- if(orgItemBean != null){
|
|
|
+ OrgItemBean orgItemBean = (OrgItemBean) adapterView.getAdapter().getItem(i);
|
|
|
+ if (orgItemBean != null) {
|
|
|
Intent intent = new Intent(MineCollectActivity.this, OrgDetailActivity.class);
|
|
|
intent.putExtra("memberId", orgItemBean.getMemberId());
|
|
|
startActivity(intent);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 筛选
|
|
|
+ */
|
|
|
+ llFilterAll.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ if(llFilterContent.getVisibility() == View.GONE) {
|
|
|
+ llFilterContent.setVisibility(View.VISIBLE);
|
|
|
+
|
|
|
+ //获取机构导航数据
|
|
|
+ Cache<OrgNavigationBean> cacheNavigation = new Cache<>();
|
|
|
+ orgNavigationBean = cacheNavigation.get("OrgNavigationBean");
|
|
|
+ if (orgNavigationBean != null) {
|
|
|
+ if ("200".equals(orgNavigationBean.getCode())) {
|
|
|
+ if (orgNavigationBean.getData() != null && orgNavigationBean.getData().size() > 0) {
|
|
|
+ List<String> listFilter = new ArrayList<>();
|
|
|
+ listFilter.add("全部");
|
|
|
+ for(int i=0; i<orgNavigationBean.getData().size(); i++) {
|
|
|
+ listFilter.add(orgNavigationBean.getData().get(i).getTitle());
|
|
|
+ }
|
|
|
+ showFilterContent(listFilter);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ showToast(orgNavigationBean.getMsg());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 筛选
|
|
|
+ */
|
|
|
+ lvFilterContent.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
+ try {
|
|
|
+ if(orgNavigationBean != null) {
|
|
|
+ if(i != 0) {
|
|
|
+ agencyTypeId = orgNavigationBean.getData().get(i - 1).getTypeId();
|
|
|
+ getMyCollectList(agencyTypeId);
|
|
|
+ } else {
|
|
|
+ getMyCollectList("");
|
|
|
+ }
|
|
|
+ llFilterContent.setVisibility(View.GONE);
|
|
|
+ tvAll.setText(orgNavigationBean.getData().get(i).getTitle());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 筛选控件
|
|
|
+ */
|
|
|
+ llFilterContent.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ if(llFilterContent != null) {
|
|
|
+ llFilterContent.setVisibility(View.GONE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取我的收藏列表
|
|
|
*/
|
|
|
- private void getMyCollectList() {
|
|
|
+ private void getMyCollectList(String agencyTypeId) {
|
|
|
|
|
|
- RequestGroup.getMyCollectList(pageNumber+"", new Callback() {
|
|
|
+ RequestGroup.getMyCollectList(agencyTypeId,pageNumber + "", new Callback() {
|
|
|
@Override
|
|
|
public Object parseNetworkResponse(Response response, int id) throws Exception {
|
|
|
return new Gson().fromJson(response.body().string(), MyCollectBean.class);
|
|
@@ -123,13 +202,13 @@ public class MineCollectActivity extends TitleBarActivity implements PullToRefre
|
|
|
|
|
|
@Override
|
|
|
public void onResponse(Object response, int id) {
|
|
|
- MyCollectBean myCollectBean = (MyCollectBean)response;
|
|
|
- if(myCollectBean != null){
|
|
|
- if("200".equals(myCollectBean.getCode())){
|
|
|
- if(myCollectBean.getData() != null){
|
|
|
- if(myCollectBean.getData().getRecords() != null && myCollectBean.getData().getRecords().size() > 0){
|
|
|
- if(pageNumber == 1){
|
|
|
- if(listCollentOrg == null){
|
|
|
+ MyCollectBean myCollectBean = (MyCollectBean) response;
|
|
|
+ if (myCollectBean != null) {
|
|
|
+ if ("200".equals(myCollectBean.getCode())) {
|
|
|
+ if (myCollectBean.getData() != null) {
|
|
|
+ if (myCollectBean.getData().getRecords() != null && myCollectBean.getData().getRecords().size() > 0) {
|
|
|
+ if (pageNumber == 1) {
|
|
|
+ if (listCollentOrg == null) {
|
|
|
listCollentOrg = new ArrayList<>();
|
|
|
}
|
|
|
listCollentOrg.clear();
|
|
@@ -141,8 +220,13 @@ public class MineCollectActivity extends TitleBarActivity implements PullToRefre
|
|
|
listCollentOrg.addAll(myCollectBean.getData().getRecords());
|
|
|
mineCollectItemAdapter.notifyDataSetChanged();
|
|
|
}
|
|
|
+ pullToRefresh.setMode(PullToRefreshBase.Mode.BOTH);
|
|
|
} else {
|
|
|
- showNoData();
|
|
|
+ if(mineCollectItemAdapter != null || mineCollectItemAdapter.getCount() > 0) {
|
|
|
+ showToast("已经加载全部");
|
|
|
+ } else {
|
|
|
+ showNoData();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -160,6 +244,20 @@ public class MineCollectActivity extends TitleBarActivity implements PullToRefre
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 筛选内容
|
|
|
+ *
|
|
|
+ * @param listContent
|
|
|
+ */
|
|
|
+ private void showFilterContent(List<String> listContent) {
|
|
|
+ if (listContent == null || listContent.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ OrgFilterListAdapter orgFilterListAdapter = new OrgFilterListAdapter(MineCollectActivity.this, listContent);
|
|
|
+ lvFilterContent.setAdapter(orgFilterListAdapter);
|
|
|
+ orgFilterListAdapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 显示无数据
|
|
|
*/
|
|
|
private void showNoData() {
|