zengjiebin преди 7 години
родител
ревизия
e85ea852cb

+ 26 - 8
app/src/main/java/com/kfzs/duanduan/fragment/FgtFindChild.java

@@ -20,14 +20,12 @@ import com.kfzs.duanduan.BaseCompatFragment;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.FindItem;
 import com.sheep.gamegroup.model.entity.FindTag;
-import com.sheep.gamegroup.model.entity.UserLabel;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.ListUtil;
 import com.sheep.gamegroup.util.LogUtil;
 import com.sheep.gamegroup.util.SysAppUtil;
 import com.sheep.gamegroup.util.ViewHolder;
 import com.sheep.gamegroup.util.ViewUtil;
-import com.sheep.gamegroup.view.activity.ActUserLabelList;
 import com.sheep.gamegroup.view.adapter.AdbCommonRecycler;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
@@ -78,6 +76,8 @@ public class FgtFindChild extends BaseCompatFragment {
 
     @BindView(R.id.find_refresh)
     SwipeRefreshLayout refresh;
+    @BindView(R.id.empty_view)
+    View empty_view;
     @BindView(R.id.check_net_ll)
     View check_net_ll;
     @BindView(R.id.find_list)
@@ -91,17 +91,26 @@ public class FgtFindChild extends BaseCompatFragment {
             }
         });
 
-
         view_list.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
         view_list.setAdapter(new AdbCommonRecycler<FindItem>(SheepApp.getInstance(), list){
 
             @Override
-            public int getViewIdByType(int type) {
+            public int getItemViewType(int position) {
+                return position;
+            }
+            @Override
+            public int getViewIdByType(int type) {//type来源于 getItemViewType 返回的值
+                if(type == -1 + list.size()){
+                   return R.layout.find_item_bottom;
+                }
                 return R.layout.find_item;
             }
 
             @Override
             public void convert(ViewHolder holder, final FindItem item) {
+                if(item == null){
+                    return;
+                }
                 View rootConvertView = holder.itemView;
                 TextView find_item_name = (TextView)rootConvertView.findViewById(R.id.find_item_name);
                 TextView find_item_time = (TextView)rootConvertView.findViewById(R.id.find_item_time);
@@ -135,7 +144,7 @@ public class FgtFindChild extends BaseCompatFragment {
                     TagAdapter adapter = new TagAdapter<FindTag>(item.getTages()) {
                         @Override
                         public View getView(FlowLayout parent, int position, FindTag item) {
-                            TextView tv = (TextView) LayoutInflater.from(activity).inflate(R.layout.user_label, parent, false);
+                            TextView tv = (TextView) LayoutInflater.from(activity).inflate(R.layout.find_item_tag, parent, false);
                             ViewUtil.setText(tv, item.getName());
                             return tv;
                         }
@@ -154,6 +163,7 @@ public class FgtFindChild extends BaseCompatFragment {
     }
 
     private void initData(){
+        empty_view.setVisibility(View.INVISIBLE);
         SysAppUtil.checkNet(new Action1<Integer>() {
             @Override
             public void call(Integer result) {
@@ -163,7 +173,6 @@ public class FgtFindChild extends BaseCompatFragment {
                 } else {
                     if(check_net_ll != null)
                         check_net_ll.setVisibility(View.GONE);
-
                 }
             }
         });
@@ -178,16 +187,25 @@ public class FgtFindChild extends BaseCompatFragment {
                                 if(!ListUtil.isEmpty(newList)){
                                     list.clear();
                                     ListUtil.addAll(list, newList);
-                                    view_list.getAdapter().notifyDataSetChanged();
+                                    notifyDataSetChanged();
                                 }
                             }
 
                             @Override
                             public void onError(BaseMessage baseMessage) {
                                 LogUtil.println("baseMessage onError "+JSON.toJSONString(baseMessage));
-                                G.showToast(baseMessage);
+                                notifyDataSetChanged();
                             }
                         });
     }
+
+    private void notifyDataSetChanged(){
+        if(list.isEmpty())
+            empty_view.setVisibility(View.VISIBLE);
+        else
+            list.add(null);//底部部分----我是有底线的
+        refresh.setRefreshing(false);
+        view_list.getAdapter().notifyDataSetChanged();
+    }
     private List<FindItem> list = ListUtil.emptyList();
 }

+ 13 - 7
app/src/main/res/layout/fgt_find_child.xml

@@ -1,22 +1,28 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="@color/bg_gray"
-    android:orientation="vertical">
+    android:background="@color/bg_gray">
 
     <include
+        android:id="@+id/check_net_ll"
         layout="@layout/check_net_view"/>
 
+    <include
+        android:id="@+id/empty_view"
+        layout="@layout/empty_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:layout_below="@+id/check_net_ll" />
     <com.sheep.gamegroup.util.SheepSwipeRefreshLayout
         android:id="@+id/find_refresh"
         android:layout_width="match_parent"
-        android:layout_height="match_parent">
+        android:layout_height="match_parent"
+        android:layout_below="@+id/check_net_ll" >
         <android.support.v7.widget.RecyclerView
             android:id="@+id/find_list"
             android:layout_width="match_parent"
-            android:layout_height="0dp"
-            android:layout_weight="1"
+            android:layout_height="match_parent"
             android:layout_margin="@dimen/content_padding_10"/>
     </com.sheep.gamegroup.util.SheepSwipeRefreshLayout>
-</LinearLayout>
+</RelativeLayout>

+ 23 - 0
app/src/main/res/layout/find_item_bottom.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    android:gravity="center"
+    android:layout_margin="@dimen/content_padding_20"
+    android:orientation="horizontal">
+
+    <ImageView
+        android:layout_width="30dp"
+        android:layout_height="wrap_content"
+        android:adjustViewBounds="true"
+        android:scaleType="fitXY"
+        android:src="@mipmap/bottom_icon"/>
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginStart="@dimen/content_padding"
+        android:text="我是有底线的"
+        android:textColor="#C0C0C0"
+        android:textSize="14sp" />
+</LinearLayout>

+ 16 - 0
app/src/main/res/layout/find_item_tag.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/find_tag_tv"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:paddingTop="5dp"
+    android:paddingBottom="5dp"
+    android:paddingStart="20dp"
+    android:paddingEnd="20dp"
+    android:gravity="center"
+    android:textAlignment="center"
+    android:textColor="@color/main_tab_activated"
+    android:background="@drawable/layer_list_check_rectgangle"
+    android:layout_marginStart="@dimen/dp_10"
+    android:textSize="@dimen/text_size_13"
+    android:text="小标签" />

BIN
app/src/main/res/mipmap-xxhdpi/bottom_icon.webp