导游信息轮播图与照片流一起滑动

chengzhenyu 8 ans auparavant
Parent
Commettre
d60743e616

+ 8 - 4
app/src/main/java/ai/pai/client/fragments/TabRecentPhotoFragment.java

@@ -58,7 +58,7 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
58 58
     private HeaderAndFooterRecyclerViewAdapter photoAdapter;
59 59
     private EndlessRecyclerOnScrollListener scrollListener;
60 60
     private View loadMoreView;
61
-
61
+    private View headerView;
62 62
     private HttpPostTask fetchPhotosTask;
63 63
     private HttpPostTask fetchTourInfoTask;
64 64
     private ArrayList<GroupPhotoItem> photoList;
@@ -81,7 +81,7 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
81 81
     @Override
82 82
     public View onCreateView(LayoutInflater inflater,  ViewGroup container,  Bundle savedInstanceState) {
83 83
         View rootView = inflater.inflate(R.layout.fragment_recent_photo, container, false);
84
-        banner = (ConvenientBanner)rootView.findViewById(R.id.banner_tour);
84
+
85 85
         swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_layout);
86 86
         swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary);
87 87
         recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view);
@@ -98,6 +98,10 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
98 98
         recyclerView.setAdapter(photoAdapter);
99 99
         loadMoreView = LayoutInflater .from(getActivity()).inflate(R.layout.view_load_more, recyclerView, false);
100 100
         RecyclerViewUtils.setFooterView(recyclerView,loadMoreView);
101
+        headerView = LayoutInflater .from(getActivity()).inflate(R.layout.recyclerview_header_view, recyclerView, false);
102
+        RecyclerViewUtils.setHeaderView(recyclerView,headerView);
103
+        headerView.setVisibility(View.GONE);
104
+        banner = (ConvenientBanner)headerView.findViewById(R.id.banner_tour);
101 105
         swipeRefreshLayout.setOnRefreshListener(this);
102 106
         scrollListener = new EndlessRecyclerOnScrollListener() {
103 107
             @Override
@@ -221,7 +225,7 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
221 225
 
222 226
     private void initBanner(){
223 227
         if(TextUtils.isEmpty(images[0]) && TextUtils.isEmpty(images[1])){
224
-            banner.setVisibility(View.GONE);
228
+            headerView.setVisibility(View.GONE);
225 229
             return;
226 230
         }
227 231
         String[] imageCopy = new String[2];
@@ -236,7 +240,7 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh
236 240
                 images[0] =imageCopy[1];
237 241
             }
238 242
         }
239
-        banner.setVisibility(View.VISIBLE);
243
+        headerView.setVisibility(View.VISIBLE);
240 244
 
241 245
         banner.setPages(new CBViewHolderCreator<NetworkImageHolderView>() {
242 246
             @Override

+ 12 - 24
app/src/main/res/layout/fragment_recent_photo.xml

@@ -3,34 +3,22 @@
3 3
     android:layout_width="match_parent"
4 4
     android:layout_height="match_parent"
5 5
     android:background="@color/background_light_grey_color">
6
-<LinearLayout
7
-    android:layout_width="match_parent"
8
-    android:layout_height="match_parent"
9
-    android:orientation="vertical">
10
-
11
-    <com.android.views.banner.ConvenientBanner
12
-        android:id="@+id/banner_tour"
13
-        android:layout_width="match_parent"
14
-        android:layout_height="160dp"
15
-        android:visibility="gone"/>
16 6
 
17 7
     <android.support.v4.widget.SwipeRefreshLayout
18 8
         android:id="@+id/swipe_refresh_layout"
19 9
         android:layout_width="match_parent"
20 10
         android:layout_height="match_parent"
21
-        android:paddingTop="4dp"
22
-        >
11
+        android:paddingTop="4dp">
23 12
 
24 13
         <android.support.v7.widget.RecyclerView
25 14
             android:id="@+id/recycler_view"
26 15
             android:layout_width="match_parent"
27 16
             android:layout_height="match_parent"
28 17
             android:paddingLeft="3dp"
29
-            android:paddingRight="3dp"/>
18
+            android:paddingRight="3dp" />
30 19
 
31
-    </android.support.v4.widget.SwipeRefreshLayout>
32 20
 
33
-</LinearLayout>
21
+    </android.support.v4.widget.SwipeRefreshLayout>
34 22
 
35 23
 
36 24
     <LinearLayout
@@ -38,22 +26,22 @@
38 26
         android:layout_width="match_parent"
39 27
         android:layout_height="match_parent"
40 28
         android:gravity="center_horizontal"
41
-        android:visibility="invisible"
42
-        android:orientation="vertical">
43
-        
29
+        android:orientation="vertical"
30
+        android:visibility="invisible">
31
+
44 32
         <ImageView
45
-            android:layout_marginTop="100dp"
46 33
             android:layout_width="160dp"
47 34
             android:layout_height="120dp"
48
-            android:src="@drawable/no_content_tip"/>
49
-        
35
+            android:layout_marginTop="100dp"
36
+            android:src="@drawable/no_content_tip" />
37
+
50 38
         <TextView
51
-            android:layout_marginTop="4dp"
52 39
             android:layout_width="wrap_content"
53 40
             android:layout_height="wrap_content"
54
-            android:textSize="16sp"
41
+            android:layout_marginTop="4dp"
55 42
             android:text="@string/fetch_group_photo_zero"
56
-            android:textColor="@color/dark_grey"/>
43
+            android:textColor="@color/dark_grey"
44
+            android:textSize="16sp" />
57 45
     </LinearLayout>
58 46
 
59 47
 </RelativeLayout>

+ 13 - 0
app/src/main/res/layout/recyclerview_header_view.xml

@@ -0,0 +1,13 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
+    android:id="@+id/header_layout"
4
+    android:layout_width="match_parent"
5
+    android:layout_height="160dp"
6
+    android:gravity="center">
7
+
8
+    <com.android.views.banner.ConvenientBanner
9
+        android:id="@+id/banner_tour"
10
+        android:layout_width="match_parent"
11
+        android:layout_height="match_parent"/>
12
+
13
+</FrameLayout>