@@ -37,7 +37,7 @@ |
||
| 37 | 37 |
<ConfirmationsSetting value="0" id="Add" /> |
| 38 | 38 |
<ConfirmationsSetting value="0" id="Remove" /> |
| 39 | 39 |
</component> |
| 40 |
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> |
|
| 40 |
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> |
|
| 41 | 41 |
<output url="file://$PROJECT_DIR$/build/classes" /> |
| 42 | 42 |
</component> |
| 43 | 43 |
<component name="ProjectType"> |
@@ -10,17 +10,23 @@ import android.support.v7.widget.StaggeredGridLayoutManager; |
||
| 10 | 10 |
import android.view.LayoutInflater; |
| 11 | 11 |
import android.view.View; |
| 12 | 12 |
import android.view.ViewGroup; |
| 13 |
+import android.widget.ImageView; |
|
| 13 | 14 |
import android.widget.Toast; |
| 14 | 15 |
|
| 15 | 16 |
import com.android.common.executors.ThreadExecutor; |
| 16 | 17 |
import com.android.common.utils.LogHelper; |
| 18 |
+import com.android.views.banner.CBViewHolderCreator; |
|
| 19 |
+import com.android.views.banner.ConvenientBanner; |
|
| 20 |
+import com.android.views.banner.Holder; |
|
| 17 | 21 |
import com.android.views.swiperefreshrecyclerview.EndlessRecyclerOnScrollListener; |
| 18 | 22 |
import com.android.views.swiperefreshrecyclerview.HeaderAndFooterRecyclerViewAdapter; |
| 23 |
+import com.nostra13.universalimageloader.core.ImageLoader; |
|
| 19 | 24 |
|
| 20 | 25 |
import org.json.JSONArray; |
| 21 | 26 |
import org.json.JSONObject; |
| 22 | 27 |
|
| 23 | 28 |
import java.util.ArrayList; |
| 29 |
+import java.util.Arrays; |
|
| 24 | 30 |
import java.util.HashMap; |
| 25 | 31 |
|
| 26 | 32 |
import ai.pai.client.BuildConfig; |
@@ -48,6 +54,17 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh |
||
| 48 | 54 |
private int left; |
| 49 | 55 |
private static final int num = 10; |
| 50 | 56 |
|
| 57 |
+ private ConvenientBanner banner; |
|
| 58 |
+ |
|
| 59 |
+ private String[] images = {"http://img2.imgtn.bdimg.com/it/u=3093785514,1341050958&fm=21&gp=0.jpg",
|
|
| 60 |
+ "http://img2.3lian.com/2014/f2/37/d/40.jpg", |
|
| 61 |
+ "http://d.3987.com/sqmy_131219/001.jpg", |
|
| 62 |
+ "http://img2.3lian.com/2014/f2/37/d/39.jpg", |
|
| 63 |
+ "http://www.8kmm.com/UploadFiles/2012/8/201208140920132659.jpg", |
|
| 64 |
+ "http://f.hiphotos.baidu.com/image/h%3D200/sign=1478eb74d5a20cf45990f9df460b4b0c/d058ccbf6c81800a5422e5fdb43533fa838b4779.jpg", |
|
| 65 |
+ "http://f.hiphotos.baidu.com/image/pic/item/09fa513d269759ee50f1971ab6fb43166c22dfba.jpg" |
|
| 66 |
+ }; |
|
| 67 |
+ |
|
| 51 | 68 |
@Override |
| 52 | 69 |
public void onCreate( Bundle savedInstanceState) {
|
| 53 | 70 |
super.onCreate(savedInstanceState); |
@@ -59,6 +76,7 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh |
||
| 59 | 76 |
@Override |
| 60 | 77 |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
| 61 | 78 |
View rootView = inflater.inflate(R.layout.fragment_recent_photo, container, false); |
| 79 |
+ banner = (ConvenientBanner)rootView.findViewById(R.id.banner_tour); |
|
| 62 | 80 |
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe_refresh_layout); |
| 63 | 81 |
swipeRefreshLayout.setColorSchemeResources(R.color.colorPrimary); |
| 64 | 82 |
recyclerView = (RecyclerView) rootView.findViewById(R.id.recycler_view); |
@@ -91,6 +109,7 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh |
||
| 91 | 109 |
}; |
| 92 | 110 |
recyclerView.addOnScrollListener(scrollListener); |
| 93 | 111 |
doFetchPhotoTask(); |
| 112 |
+ initBanner(); |
|
| 94 | 113 |
return rootView; |
| 95 | 114 |
} |
| 96 | 115 |
|
@@ -142,12 +161,24 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh |
||
| 142 | 161 |
@Override |
| 143 | 162 |
protected void onPostSuccess(Context context) {
|
| 144 | 163 |
super.onPostSuccess(context); |
| 164 |
+ |
|
| 145 | 165 |
} |
| 146 | 166 |
}; |
| 147 | 167 |
fetchTourInfoTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), UrlContainer.TOUR_INFO_URL); |
| 148 | 168 |
|
| 149 | 169 |
} |
| 150 | 170 |
|
| 171 |
+ private void initBanner(){
|
|
| 172 |
+ banner.setVisibility(View.VISIBLE); |
|
| 173 |
+ banner.setPages(new CBViewHolderCreator<NetworkImageHolderView>() {
|
|
| 174 |
+ @Override |
|
| 175 |
+ public NetworkImageHolderView createHolder() {
|
|
| 176 |
+ return new NetworkImageHolderView(); |
|
| 177 |
+ } |
|
| 178 |
+ },Arrays.asList(images)).setPageIndicator(new int[]{R.drawable.ic_page_indicator, R.drawable.ic_page_indicator_focused});
|
|
| 179 |
+ banner.startTurning(3000); |
|
| 180 |
+ } |
|
| 181 |
+ |
|
| 151 | 182 |
private synchronized void doFetchPhotoTask(){
|
| 152 | 183 |
if(!isAdded()){
|
| 153 | 184 |
return; |
@@ -248,4 +279,21 @@ public class TabRecentPhotoFragment extends BaseFragment implements SwipeRefresh |
||
| 248 | 279 |
doFetchPhotoTask(); |
| 249 | 280 |
} |
| 250 | 281 |
|
| 282 |
+ public class NetworkImageHolderView implements Holder<String> {
|
|
| 283 |
+ private ImageView imageView; |
|
| 284 |
+ @Override |
|
| 285 |
+ public View createView(Context context) {
|
|
| 286 |
+ //你可以通过layout文件来创建,也可以像我一样用代码创建,不一定是Image,任何控件都可以进行翻页 |
|
| 287 |
+ imageView = new ImageView(context); |
|
| 288 |
+ imageView.setScaleType(ImageView.ScaleType.FIT_XY); |
|
| 289 |
+ return imageView; |
|
| 290 |
+ } |
|
| 291 |
+ |
|
| 292 |
+ @Override |
|
| 293 |
+ public void UpdateUI(Context context,int position, String data) {
|
|
| 294 |
+ imageView.setImageResource(R.drawable.default_img); |
|
| 295 |
+ ImageLoader.getInstance().displayImage(data,imageView); |
|
| 296 |
+ } |
|
| 297 |
+ } |
|
| 298 |
+ |
|
| 251 | 299 |
} |
@@ -8,17 +8,17 @@ |
||
| 8 | 8 |
android:layout_height="match_parent" |
| 9 | 9 |
android:orientation="vertical"> |
| 10 | 10 |
|
| 11 |
- <include |
|
| 11 |
+ <com.android.views.banner.ConvenientBanner |
|
| 12 | 12 |
android:id="@+id/banner_tour" |
| 13 |
- layout="@layout/include_viewpager" |
|
| 14 | 13 |
android:layout_width="match_parent" |
| 15 |
- android:layout_height="120dp" |
|
| 14 |
+ android:layout_height="160dp" |
|
| 16 | 15 |
android:visibility="gone"/> |
| 17 | 16 |
|
| 18 | 17 |
<android.support.v4.widget.SwipeRefreshLayout |
| 19 | 18 |
android:id="@+id/swipe_refresh_layout" |
| 20 | 19 |
android:layout_width="match_parent" |
| 21 | 20 |
android:layout_height="match_parent" |
| 21 |
+ android:paddingTop="4dp" |
|
| 22 | 22 |
> |
| 23 | 23 |
|
| 24 | 24 |
<android.support.v7.widget.RecyclerView |