浏览代码

修改我的收藏功能

316044749 7 年之前
父节点
当前提交
27d5d73668

+ 4 - 0
app/src/main/java/com/ynstkz/shitu/android/activity/IdAuthActivity.java

@@ -83,6 +83,9 @@ public class IdAuthActivity extends TitleBarActivity {
             }
             editUsername.setText(idAuthCacheBean.getUserName());
             editIdcard.setText(idAuthCacheBean.getIdCard());
+            if(idAuthCacheBean.isAgree()) {
+                cbAgree.setChecked(true);
+            }
         }
     }
 
@@ -153,6 +156,7 @@ public class IdAuthActivity extends TitleBarActivity {
                         idAuthCacheBean.setPatriarch(isParent);
                         idAuthCacheBean.setUserName(realName);
                         idAuthCacheBean.setIdCard(idCardNum);
+                        idAuthCacheBean.setAgree(true);
                         com.common.library.cache.Cache.put(CACHE_KEY, idAuthCacheBean);
                         finish();
                     }

+ 116 - 18
app/src/main/java/com/ynstkz/shitu/android/activity/MineCollectActivity.java

@@ -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() {

+ 15 - 0
app/src/main/java/com/ynstkz/shitu/android/activity/SettingActivity.java

@@ -7,12 +7,14 @@ import android.os.Message;
 import android.support.annotation.Nullable;
 import android.support.v7.widget.SwitchCompat;
 import android.view.View;
+import android.widget.CompoundButton;
 import android.widget.ImageView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import com.ynstkz.shitu.android.R;
 import com.ynstkz.shitu.android.base.TitleBarActivity;
+import com.ynstkz.shitu.android.data.SharedPreferencesUtils;
 import com.ynstkz.shitu.android.utils.FileUtils;
 
 import butterknife.Bind;
@@ -53,6 +55,9 @@ public class SettingActivity extends TitleBarActivity {
 
     private void initView(){
         tvTitle.setText("通用设置");
+        if(SharedPreferencesUtils.getKeyMessageSwitch()) {
+            sbPatriarch.setChecked(SharedPreferencesUtils.getKeyMessageSwitch());
+        }
     }
 
     private void initData(){
@@ -67,6 +72,16 @@ public class SettingActivity extends TitleBarActivity {
                 cleanCache();
             }
         });
+
+        /**
+         * 消息设置开关
+         */
+        sbPatriarch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+            @Override
+            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+                SharedPreferencesUtils.setKeyMessageSwitch(b);
+            }
+        });
     }
 
     /**

+ 5 - 0
app/src/main/java/com/ynstkz/shitu/android/adapter/MineCollectItemAdapter.java

@@ -46,6 +46,8 @@ public class MineCollectItemAdapter extends CCListAdapter<OrgItemBean>{
             TextView tvMemberName;
             TextView tvRegaddress;
             MaterialRatingBar materialRatingBar;
+            TextView tvCommentCount;
+            TextView tvViewCount;
 
             @Override
             public int getResource() {
@@ -58,6 +60,8 @@ public class MineCollectItemAdapter extends CCListAdapter<OrgItemBean>{
                 tvMemberName = convertView.findViewById(R.id.tv_memberName);
                 tvRegaddress = convertView.findViewById(R.id.tv_regaddress);
                 materialRatingBar = convertView.findViewById(R.id.rb_score);
+                tvCommentCount = convertView.findViewById(R.id.tv_comment_count);
+                tvViewCount = convertView.findViewById(R.id.tv_view_count);
             }
 
             @Override
@@ -74,6 +78,7 @@ public class MineCollectItemAdapter extends CCListAdapter<OrgItemBean>{
                 tvMemberName.setText(content.getMemberName());
                 tvRegaddress.setText(content.getAddress());
                 materialRatingBar.setProgress((int)content.getScore());
+                tvViewCount.setText("浏览人数" + content.getViewCount() + "人");
             }
         };
     }

+ 9 - 0
app/src/main/java/com/ynstkz/shitu/android/bean/IdAuthCacheBean.java

@@ -12,6 +12,7 @@ public class IdAuthCacheBean implements Serializable{
     private String isPatriarch;
     private String userName;
     private String idCard;
+    private boolean isAgree;
 
     public String getUserId() {
         return userId;
@@ -44,4 +45,12 @@ public class IdAuthCacheBean implements Serializable{
     public void setIdCard(String idCard) {
         this.idCard = idCard;
     }
+
+    public boolean isAgree() {
+        return isAgree;
+    }
+
+    public void setAgree(boolean agree) {
+        isAgree = agree;
+    }
 }

+ 4 - 1
app/src/main/java/com/ynstkz/shitu/android/data/RequestGroup.java

@@ -196,9 +196,12 @@ public class RequestGroup {
     /**
      * 我的收藏
      */
-    public static void getMyCollectList(String pageNumber, Callback callback){
+    public static void getMyCollectList(String agencyTypeId, String pageNumber, Callback callback){
         Map<String, String> params = getSystemParams();
         params.put("pageNumber",pageNumber);
+        if(!TextUtils.isEmpty(agencyTypeId)){
+            params.put("agencyTypeId", agencyTypeId);
+        }
         OkHttpUtils.get().url(UrlCat.URL_MY_COLLECT).addHeader(KEY_TOKEN,
                 SharedPreferencesUtils.getToken()).params(params).build().execute(callback);
     }

+ 14 - 0
app/src/main/java/com/ynstkz/shitu/android/data/SharedPreferencesUtils.java

@@ -16,6 +16,8 @@ public class SharedPreferencesUtils {
 
     public static final String KEY_USERID = "userId";
 
+    public static final String KEY_MESSAGE_SWITCH = "key_message_switch";
+
     /**
      * 是否登录
      * @return
@@ -61,4 +63,16 @@ public class SharedPreferencesUtils {
     public static String getUserId(){
         return (String)SharedPreferencesDao.get(KEY_USERID, "");
     }
+
+    /**
+     * 消息开关
+     * @param isSwitch
+     */
+    public static void setKeyMessageSwitch(boolean isSwitch){
+        SharedPreferencesDao.set(KEY_MESSAGE_SWITCH, isSwitch);
+    }
+
+    public static boolean getKeyMessageSwitch(){
+        return (Boolean)SharedPreferencesDao.get(KEY_MESSAGE_SWITCH, false);
+    }
 }

+ 36 - 16
app/src/main/res/layout/activity_minecollect.xml

@@ -1,40 +1,60 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    android:orientation="vertical">
 
-    <include layout="@layout/view_title"/>
+    <include layout="@layout/view_title" />
 
     <LinearLayout
+        android:id="@+id/ll_filter_all"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:padding="@dimen/default_content_margin"
-        android:background="@color/white">
+        android:background="@color/white"
+        android:padding="@dimen/default_content_margin">
 
         <TextView
             android:id="@+id/tv_all"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:text="全部"/>
+            android:text="全部" />
 
     </LinearLayout>
 
-    <com.common.library.pulltorefresh.PullToRefreshListView
-        android:id="@+id/pullToRefresh"
+    <RelativeLayout
         android:layout_width="match_parent"
-        android:layout_height="match_parent"/>
+        android:layout_height="match_parent">
 
+        <com.common.library.pulltorefresh.PullToRefreshListView
+            android:id="@+id/pullToRefresh"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent" />
 
-    <RelativeLayout
-        android:id="@+id/rl_nodata"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:visibility="gone">
+        <RelativeLayout
+            android:id="@+id/rl_nodata"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:visibility="gone">
 
-        <include layout="@layout/view_nodata"/>
+            <include layout="@layout/view_nodata" />
 
-    </RelativeLayout>
+        </RelativeLayout>
 
+        <LinearLayout
+            android:id="@+id/ll_filter_content"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@color/translucence"
+            android:visibility="gone">
+
+            <ListView
+                android:id="@+id/lv_filter_content"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:background="@color/white" />
+
+        </LinearLayout>
+
+    </RelativeLayout>
 
 </LinearLayout>

+ 13 - 5
app/src/main/res/layout/item_mine_collect.xml

@@ -6,6 +6,11 @@
     android:orientation="vertical"
     android:background="@color/white">
 
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="@dimen/company_5dp"
+        android:background="@color/default_bg"/>
+
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
@@ -27,6 +32,8 @@
                 android:id="@+id/tv_memberName"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
+                android:maxLines="1"
+                android:ellipsize="end"
                 android:textSize="@dimen/company_16sp"
                 android:textColor="@color/color_333"
                 android:textStyle="bold"
@@ -52,12 +59,18 @@
                     android:id="@+id/tv_comment_count"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:textSize="12sp"
+                    android:textColor="@color/color_999"
                     android:layout_toRightOf="@+id/rb_score"/>
 
                 <TextView
                     android:id="@+id/tv_view_count"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:textSize="11sp"
+                    android:textColor="@color/color_999"
                     android:layout_alignParentRight="true"/>
 
             </RelativeLayout>
@@ -91,9 +104,4 @@
 
     </LinearLayout>
 
-    <TextView
-        android:layout_width="match_parent"
-        android:layout_height="@dimen/company_5dp"
-        android:background="@color/default_bg"/>
-
 </LinearLayout>