Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

重构优化代码

1. 完全重写代码
2. 增加背景边框
3. 列固定为两列
4. 优化滚动速度
5. 内容从网上直接获取
  • Loading branch information...
commit 1878b9f11b19f2d57b44534f1b2258d7377594ba 1 parent ce82a26
@dodola authored
Showing with 2,407 additions and 900 deletions.
  1. +11 −8 .classpath
  2. +33 −33 .project
  3. +2 −0  .settings/org.eclipse.core.resources.prefs
  4. +27 −9 AndroidManifest.xml
  5. +19 −2 README.md
  6. BIN  assets/images/00ba632630100cad1b37a5b_p.jpg
  7. BIN  assets/images/012b8593c9782d90fd8a1e3_p.jpg
  8. BIN  assets/images/0167c19bf8742139449727b_p.jpg
  9. BIN  assets/images/01a377b7944b7a272fc411f_p.jpg
  10. BIN  assets/images/01f1b3bf86bded07c66e293_p.jpg
  11. BIN  assets/images/0239156d80c801cd7298010_p.jpg
  12. BIN  assets/images/03b2f677350cc8a642121d8_p.jpg
  13. BIN  assets/images/0e08be54533cb6802369626_p.jpg
  14. BIN  assets/images/0e9c98de2b470118883ef7c_p.jpg
  15. BIN  assets/images/164c119b055fc742adcfbf3_p.jpg
  16. BIN  assets/images/16fa0260a392f1765770bf8_p.jpg
  17. BIN  assets/images/1b44bb8cf2ad931ac3bd3e7_p.jpg
  18. BIN  assets/images/1d2568918dbc326b242dfe9_p.jpg
  19. BIN  assets/images/1d9917c2b4f6de3ba8206c0_p.jpg
  20. BIN  assets/images/23b039f6348243b06fa9661_p.jpg
  21. BIN  assets/images/269d4e59e17ccf359263b27_p.jpg
  22. BIN  assets/images/28d808e5735b02ce758ce79_p.jpg
  23. BIN  assets/images/3105497cdf082e470714edc_p.jpg
  24. BIN  assets/images/33dfbe8a9fa808a68726449_p.jpg
  25. BIN  assets/images/3452b1e98faa9db22e002ce_p.jpg
  26. BIN  assets/images/3d538dc25878233920fcff6_p.jpg
  27. BIN  assets/images/41b8c413e16928948bd43be_p.jpg
  28. BIN  assets/images/4233de84603a9c0d2ef12c6_p.jpg
  29. BIN  assets/images/4523b6cd483a3b91f57e13d_p.jpg
  30. BIN  assets/images/47bf072c5f9cca1cac41fcd_p.jpg
  31. BIN  assets/images/4e7e20b528ab9586f5411c4_p.jpg
  32. BIN  assets/images/57e9247492318907cc58a35_p.jpg
  33. BIN  assets/images/58738584bdaa61c3dd72c86_p.jpg
  34. BIN  assets/images/58cdceec6236f848ec90215_p.jpg
  35. BIN  assets/images/5e03d469cc8a96c6ef7f2ab_p.jpg
  36. BIN  assets/images/60bcf7c0f836cdd2e649f86_p.jpg
  37. BIN  assets/images/634fff686d3401401ca6524_p.jpg
  38. BIN  assets/images/69cbf139a0a90244472b26f_p.jpg
  39. BIN  assets/images/6b5da1f1df09fa5c3cd1be4_p.jpg
  40. BIN  assets/images/74436ab6039af1ee48e8a7c_p.jpg
  41. BIN  assets/images/76fee67470d4507a4be4388_p.jpg
  42. BIN  assets/images/7c749525697f05e441a99bf_p.jpg
  43. BIN  assets/images/7df6abb44305495a9bbcaef_p.jpg
  44. BIN  assets/images/82109a426b114d805e75571_p.jpg
  45. BIN  assets/images/87dc22d85b16ab8560014a3_p.jpg
  46. BIN  assets/images/884843558d838422777ac43_p.jpg
  47. BIN  assets/images/88794e620af82ddc23defe2_p.jpg
  48. BIN  assets/images/88cbed8329326b79b37d714_p.jpg
  49. BIN  assets/images/921c9b1c090651260cdf12f_p.jpg
  50. BIN  assets/images/9491dd8ff3a5c3ca8701b8d_p.jpg
  51. BIN  assets/images/9a565e490fa2b0c2c61c1d9_p.jpg
  52. BIN  assets/images/9cba75ed097b6f707e16c7d_p.jpg
  53. BIN  assets/images/9cf1450de5ac3d075131a67_p.jpg
  54. BIN  assets/images/9f16c08828df6ab526ccd33_p.jpg
  55. BIN  assets/images/a019c7bcdbc214a892a27f5_p.jpg
  56. BIN  assets/images/a06006b5fafb7f3acb92b3a_p.jpg
  57. BIN  assets/images/a1fa0061e1a9ea2c69e3e2d_p.jpg
  58. BIN  assets/images/a33a656c04a16f6a1e21439_p.jpg
  59. BIN  assets/images/a71cf8346ef45340240b5b5_p.jpg
  60. BIN  assets/images/a7a0a277204d4d28329a7bc_p.jpg
  61. BIN  assets/images/a8fd684040d2474272c5f4b_p.jpg
  62. BIN  assets/images/aa077d669fb5b18105759f2_p.jpg
  63. BIN  assets/images/aaf27f6974a1c17630222f4_p.jpg
  64. BIN  assets/images/ae209076d129676924d96b3_p.jpg
  65. BIN  assets/images/aff5b457ad3204f47e0eca5_p.jpg
  66. BIN  assets/images/b02bf679fafec08fe0bfe3d_p.jpg
  67. BIN  assets/images/b0f682c127268f4cfdc6c8a_p.jpg
  68. BIN  assets/images/b1831fd8d8d55912b815234_p.jpg
  69. BIN  assets/images/b3613eea069777dc6feb877_p.jpg
  70. BIN  assets/images/b66fcb5c4802d41b41cb292_p.jpg
  71. BIN  assets/images/b77c6310da07cfd53129f52_p.jpg
  72. BIN  assets/images/b87c5b942b80d1fff74f8bf_p.jpg
  73. BIN  assets/images/b8ca651315a780d47686e2b_p.jpg
  74. BIN  assets/images/bc82d49d3399ca5ceb06b86_p.jpg
  75. BIN  assets/images/c010e289ba2345d7e74b3d5_p.jpg
  76. BIN  assets/images/c57f27a09486678c38afb6f_p.jpg
  77. BIN  assets/images/c7961157126eb7a98b2835d_p.jpg
  78. BIN  assets/images/c9410926a6b2670baeeb3db_p.jpg
  79. BIN  assets/images/ce25a98d1356cabbed0958a_p.jpg
  80. BIN  assets/images/cf758dbdad9b79bf7114fb4_p.jpg
  81. BIN  assets/images/d1e76c70c760d90029e9790_p.jpg
  82. BIN  assets/images/d3f68feeb16486b5458a162_p.jpg
  83. BIN  assets/images/d469bad1020830844d8ef22_p.jpg
  84. BIN  assets/images/d5fcb524c1e7d2082cd5460_p.jpg
  85. BIN  assets/images/d6b0ca44922d9c55611bf8b_p.jpg
  86. BIN  assets/images/da4380621a563b4f51e3a4f_p.jpg
  87. BIN  assets/images/db5a7a481a808f2410ed738_p.jpg
  88. BIN  assets/images/e00f74dbdf66fcb8c6c330b_p.jpg
  89. BIN  assets/images/e0881dc1b9e95ba6f2bd1c8_p.jpg
  90. BIN  assets/images/e3f8904bf2e586570a385a9_p.jpg
  91. BIN  assets/images/e587562aa756ccac8766c63_p.jpg
  92. BIN  assets/images/e89e2f2f78000e3d31a18b2_p.jpg
  93. BIN  assets/images/e8b23366dcbdfb63b3ab7a1_p.jpg
  94. BIN  assets/images/f0889cb471889884aaf50d3_p.jpg
  95. BIN  assets/images/f80827d3feedc8ca08e8125_p.jpg
  96. BIN  assets/images/f998546a5c1c047948bbfd8_p.jpg
  97. +37 −0 bin/AndroidManifest.xml
  98. BIN  bin/classes.dex
  99. BIN  bin/classes/com/dodola/BuildConfig.class
  100. BIN  bin/classes/com/dodola/R$anim.class
  101. BIN  bin/classes/com/dodola/R$attr.class
  102. BIN  bin/classes/com/dodola/R$drawable.class
  103. BIN  bin/classes/com/dodola/R$id.class
  104. BIN  bin/classes/com/dodola/R$layout.class
  105. BIN  bin/classes/com/dodola/R$string.class
  106. BIN  bin/classes/com/dodola/R.class
  107. BIN  bin/classes/com/dodola/activity/ContentActivity$1.class
  108. BIN  bin/classes/com/dodola/activity/ContentActivity$2.class
  109. BIN  bin/classes/com/dodola/activity/ContentActivity$3.class
  110. BIN  bin/classes/com/dodola/activity/ContentActivity$ManagerBmp.class
  111. BIN  bin/classes/com/dodola/activity/ContentActivity.class
  112. BIN  bin/classes/com/dodola/activity/MainActivity.class
  113. BIN  bin/classes/com/dodola/base/ActivityBase.class
  114. BIN  bin/classes/com/dodola/base/TaskBase.class
  115. BIN  bin/classes/com/dodola/model/DuitangInfo.class
  116. BIN  bin/classes/com/dodola/model/Infos.class
  117. BIN  bin/classes/com/dodola/task/ContentFootTask.class
  118. BIN  bin/classes/com/dodola/task/ContentTask.class
  119. BIN  bin/classes/com/dodola/tools/AsyncImageLoader$1.class
  120. BIN  bin/classes/com/dodola/tools/AsyncImageLoader$2.class
  121. BIN  bin/classes/com/dodola/tools/AsyncImageLoader$ImageCallBack.class
  122. BIN  bin/classes/com/dodola/tools/AsyncImageLoader.class
  123. BIN  bin/classes/com/dodola/tools/FileCache.class
  124. BIN  bin/classes/com/dodola/tools/ImageViewBorder.class
  125. BIN  bin/classes/com/dodola/views/InfoImageView.class
  126. BIN  bin/classes/com/dodola/views/InfosListAdapter$1.class
  127. BIN  bin/classes/com/dodola/views/InfosListAdapter$2.class
  128. BIN  bin/classes/com/dodola/views/InfosListAdapter.class
  129. BIN  bin/classes/com/dodola/views/InfosListLayout$1.class
  130. BIN  bin/classes/com/dodola/views/InfosListLayout$2.class
  131. BIN  bin/classes/com/dodola/views/InfosListLayout.class
  132. BIN  bin/classes/com/dodola/views/InfosListLayoutInterface.class
  133. BIN  bin/classes/com/dodola/views/InfosSmallBmp.class
  134. BIN  bin/dodo_waterfall.apk
  135. +3 −0  bin/jarlist.cache
  136. BIN  bin/res/drawable-hdpi/background.png
  137. BIN  bin/res/drawable-hdpi/icon.png
  138. BIN  bin/res/drawable-hdpi/news_detail_bottom.png
  139. BIN  bin/res/drawable-hdpi/news_item_bg.9.png
  140. BIN  bin/res/drawable-hdpi/news_item_bg_cover.9.png
  141. BIN  bin/res/drawable-hdpi/news_picture.png
  142. BIN  bin/resources.ap_
  143. +6 −0 gen/com/dodola/BuildConfig.java
  144. +53 −0 gen/com/dodola/R.java
  145. BIN  lib/commons-codec.jar
  146. BIN  lib/commons-httpclient-3.1.jar
  147. BIN  lib/commons-logging-1.1.jar
  148. +1 −1  project.properties
  149. +14 −0 res/anim/rotate_left.xml
  150. BIN  res/drawable-hdpi/background.png
  151. BIN  res/drawable-hdpi/ic_launcher.png
  152. BIN  res/drawable-hdpi/icon.png
  153. BIN  res/drawable-hdpi/news_detail_bottom.png
  154. BIN  res/drawable-hdpi/news_item_bg.9.png
  155. BIN  res/drawable-hdpi/news_item_bg_cover.9.png
  156. BIN  res/drawable-hdpi/news_picture.png
  157. BIN  res/drawable-ldpi/ic_launcher.png
  158. BIN  res/drawable-mdpi/ic_launcher.png
  159. +0 −16 res/drawable/shape.xml
  160. +68 −0 res/layout/infos_content.xml
  161. +68 −0 res/layout/infos_list.xml
  162. +22 −0 res/layout/list_footer.xml
  163. +9 −12 res/layout/main.xml
  164. +0 −8 res/layout/waterfallitem.xml
  165. +10 −4 res/values/strings.xml
  166. BIN  screen1.png
  167. BIN  screen2.png
  168. +371 −0 src/com/dodola/activity/ContentActivity.java
  169. +69 −0 src/com/dodola/activity/MainActivity.java
  170. +162 −0 src/com/dodola/base/ActivityBase.java
  171. +151 −0 src/com/dodola/base/TaskBase.java
  172. +33 −0 src/com/dodola/model/DuitangInfo.java
  173. +34 −0 src/com/dodola/model/Infos.java
  174. +108 −0 src/com/dodola/task/ContentFootTask.java
  175. +106 −0 src/com/dodola/task/ContentTask.java
  176. +82 −0 src/com/dodola/tools/AsyncImageLoader.java
  177. +348 −0 src/com/dodola/tools/FileCache.java
  178. +30 −0 src/com/dodola/tools/ImageViewBorder.java
  179. +45 −0 src/com/dodola/views/InfoImageView.java
  180. +227 −0 src/com/dodola/views/InfosListAdapter.java
  181. +212 −0 src/com/dodola/views/InfosListLayout.java
  182. +14 −0 src/com/dodola/views/InfosListLayoutInterface.java
  183. +32 −0 src/com/dodola/views/InfosSmallBmp.java
  184. +0 −15 src/com/dodowaterfall/Constants.java
  185. +0 −127 src/com/dodowaterfall/LazyScrollView.java
  186. +0 −308 src/com/dodowaterfall/MainActivity.java
  187. +0 −48 src/com/dodowaterfall/widget/FlowTag.java
  188. +0 −214 src/com/dodowaterfall/widget/FlowView.java
  189. +0 −95 src/com/dodowaterfall/widget/ImageLoaderTask.java
View
19 .classpath
@@ -1,8 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+ <classpathentry kind="lib" path="lib/commons-codec.jar"/>
+ <classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
+ <classpathentry kind="lib" path="lib/commons-logging-1.1.jar"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
+ <classpathentry kind="output" path="bin/classes"/>
+</classpath>
View
66 .project
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>DodoWaterFall</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>dodo_waterfall</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.android.ide.eclipse.adt.ApkBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
View
2  .settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
View
36 AndroidManifest.xml
@@ -1,19 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.dodowaterfall"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-sdk android:minSdkVersion="10" />
- <uses-permission android:name="android.permission.INTERNET"/>
+ package="com.dodola"
+ android:versionCode="1" >
- <application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
- <activity android:name="MainActivity"
- android:label="@string/app_name">
+ <uses-sdk android:minSdkVersion="7" />
+
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_LOGS" >
+ </uses-permission>
+
+ <application
+ android:icon="@drawable/icon"
+ android:label="@string/app_name" >
+ <activity
+ android:name=".activity.MainActivity"
+ android:label=""
+ android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
+
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-
+ <activity
+ android:name=".activity.ContentActivity"
+ android:label=""
+ android:screenOrientation="portrait" >
+ </activity>
</application>
+
</manifest>
View
21 README.md
@@ -1,6 +1,23 @@
-Android瀑布流实例
+Android瀑布流实例v 2.0
========
+
实现了类似于迷尚android和蘑菇街android的瀑布流布局
+**2012-11-23 更新**
+
+1. 完全重写代码
+2. 增加背景边框
+3. 列固定为两列
+4. 优化滚动速度
+5. 内容从网上直接获取
+
+感谢一些网友提供的帮助!!
+
+**联系:**> email:dinophp@gmail.com
+
+
![Screenshot](https://github.com/dodola/android_waterfall/raw/master/screen1.png)
-![Screenshot](https://github.com/dodola/android_waterfall/raw/master/screen2.png)
+![Screenshot](https://github.com/dodola/android_waterfall/raw/master/screen2.png)
+
+
+
View
BIN  assets/images/00ba632630100cad1b37a5b_p.jpg
Deleted file not rendered
View
BIN  assets/images/012b8593c9782d90fd8a1e3_p.jpg
Deleted file not rendered
View
BIN  assets/images/0167c19bf8742139449727b_p.jpg
Deleted file not rendered
View
BIN  assets/images/01a377b7944b7a272fc411f_p.jpg
Deleted file not rendered
View
BIN  assets/images/01f1b3bf86bded07c66e293_p.jpg
Deleted file not rendered
View
BIN  assets/images/0239156d80c801cd7298010_p.jpg
Deleted file not rendered
View
BIN  assets/images/03b2f677350cc8a642121d8_p.jpg
Deleted file not rendered
View
BIN  assets/images/0e08be54533cb6802369626_p.jpg
Deleted file not rendered
View
BIN  assets/images/0e9c98de2b470118883ef7c_p.jpg
Deleted file not rendered
View
BIN  assets/images/164c119b055fc742adcfbf3_p.jpg
Deleted file not rendered
View
BIN  assets/images/16fa0260a392f1765770bf8_p.jpg
Deleted file not rendered
View
BIN  assets/images/1b44bb8cf2ad931ac3bd3e7_p.jpg
Deleted file not rendered
View
BIN  assets/images/1d2568918dbc326b242dfe9_p.jpg
Deleted file not rendered
View
BIN  assets/images/1d9917c2b4f6de3ba8206c0_p.jpg
Deleted file not rendered
View
BIN  assets/images/23b039f6348243b06fa9661_p.jpg
Deleted file not rendered
View
BIN  assets/images/269d4e59e17ccf359263b27_p.jpg
Deleted file not rendered
View
BIN  assets/images/28d808e5735b02ce758ce79_p.jpg
Deleted file not rendered
View
BIN  assets/images/3105497cdf082e470714edc_p.jpg
Deleted file not rendered
View
BIN  assets/images/33dfbe8a9fa808a68726449_p.jpg
Deleted file not rendered
View
BIN  assets/images/3452b1e98faa9db22e002ce_p.jpg
Deleted file not rendered
View
BIN  assets/images/3d538dc25878233920fcff6_p.jpg
Deleted file not rendered
View
BIN  assets/images/41b8c413e16928948bd43be_p.jpg
Deleted file not rendered
View
BIN  assets/images/4233de84603a9c0d2ef12c6_p.jpg
Deleted file not rendered
View
BIN  assets/images/4523b6cd483a3b91f57e13d_p.jpg
Deleted file not rendered
View
BIN  assets/images/47bf072c5f9cca1cac41fcd_p.jpg
Deleted file not rendered
View
BIN  assets/images/4e7e20b528ab9586f5411c4_p.jpg
Diff not rendered
View
BIN  assets/images/57e9247492318907cc58a35_p.jpg
Diff not rendered
View
BIN  assets/images/58738584bdaa61c3dd72c86_p.jpg
Diff not rendered
View
BIN  assets/images/58cdceec6236f848ec90215_p.jpg
Diff not rendered
View
BIN  assets/images/5e03d469cc8a96c6ef7f2ab_p.jpg
Diff not rendered
View
BIN  assets/images/60bcf7c0f836cdd2e649f86_p.jpg
Diff not rendered
View
BIN  assets/images/634fff686d3401401ca6524_p.jpg
Diff not rendered
View
BIN  assets/images/69cbf139a0a90244472b26f_p.jpg
Diff not rendered
View
BIN  assets/images/6b5da1f1df09fa5c3cd1be4_p.jpg
Diff not rendered
View
BIN  assets/images/74436ab6039af1ee48e8a7c_p.jpg
Diff not rendered
View
BIN  assets/images/76fee67470d4507a4be4388_p.jpg
Diff not rendered
View
BIN  assets/images/7c749525697f05e441a99bf_p.jpg
Diff not rendered
View
BIN  assets/images/7df6abb44305495a9bbcaef_p.jpg
Diff not rendered
View
BIN  assets/images/82109a426b114d805e75571_p.jpg
Diff not rendered
View
BIN  assets/images/87dc22d85b16ab8560014a3_p.jpg
Diff not rendered
View
BIN  assets/images/884843558d838422777ac43_p.jpg
Diff not rendered
View
BIN  assets/images/88794e620af82ddc23defe2_p.jpg
Diff not rendered
View
BIN  assets/images/88cbed8329326b79b37d714_p.jpg
Diff not rendered
View
BIN  assets/images/921c9b1c090651260cdf12f_p.jpg
Diff not rendered
View
BIN  assets/images/9491dd8ff3a5c3ca8701b8d_p.jpg
Diff not rendered
View
BIN  assets/images/9a565e490fa2b0c2c61c1d9_p.jpg
Diff not rendered
View
BIN  assets/images/9cba75ed097b6f707e16c7d_p.jpg
Diff not rendered
View
BIN  assets/images/9cf1450de5ac3d075131a67_p.jpg
Diff not rendered
View
BIN  assets/images/9f16c08828df6ab526ccd33_p.jpg
Diff not rendered
View
BIN  assets/images/a019c7bcdbc214a892a27f5_p.jpg
Diff not rendered
View
BIN  assets/images/a06006b5fafb7f3acb92b3a_p.jpg
Diff not rendered
View
BIN  assets/images/a1fa0061e1a9ea2c69e3e2d_p.jpg
Diff not rendered
View
BIN  assets/images/a33a656c04a16f6a1e21439_p.jpg
Diff not rendered
View
BIN  assets/images/a71cf8346ef45340240b5b5_p.jpg
Diff not rendered
View
BIN  assets/images/a7a0a277204d4d28329a7bc_p.jpg
Diff not rendered
View
BIN  assets/images/a8fd684040d2474272c5f4b_p.jpg
Diff not rendered
View
BIN  assets/images/aa077d669fb5b18105759f2_p.jpg
Diff not rendered
View
BIN  assets/images/aaf27f6974a1c17630222f4_p.jpg
Diff not rendered
View
BIN  assets/images/ae209076d129676924d96b3_p.jpg
Diff not rendered
View
BIN  assets/images/aff5b457ad3204f47e0eca5_p.jpg
Diff not rendered
View
BIN  assets/images/b02bf679fafec08fe0bfe3d_p.jpg
Diff not rendered
View
BIN  assets/images/b0f682c127268f4cfdc6c8a_p.jpg
Diff not rendered
View
BIN  assets/images/b1831fd8d8d55912b815234_p.jpg
Diff not rendered
View
BIN  assets/images/b3613eea069777dc6feb877_p.jpg
Diff not rendered
View
BIN  assets/images/b66fcb5c4802d41b41cb292_p.jpg
Diff not rendered
View
BIN  assets/images/b77c6310da07cfd53129f52_p.jpg
Diff not rendered
View
BIN  assets/images/b87c5b942b80d1fff74f8bf_p.jpg
Diff not rendered
View
BIN  assets/images/b8ca651315a780d47686e2b_p.jpg
Diff not rendered
View
BIN  assets/images/bc82d49d3399ca5ceb06b86_p.jpg
Diff not rendered
View
BIN  assets/images/c010e289ba2345d7e74b3d5_p.jpg
Diff not rendered
View
BIN  assets/images/c57f27a09486678c38afb6f_p.jpg
Diff not rendered
View
BIN  assets/images/c7961157126eb7a98b2835d_p.jpg
Diff not rendered
View
BIN  assets/images/c9410926a6b2670baeeb3db_p.jpg
Diff not rendered
View
BIN  assets/images/ce25a98d1356cabbed0958a_p.jpg
Diff not rendered
View
BIN  assets/images/cf758dbdad9b79bf7114fb4_p.jpg
Diff not rendered
View
BIN  assets/images/d1e76c70c760d90029e9790_p.jpg
Diff not rendered
View
BIN  assets/images/d3f68feeb16486b5458a162_p.jpg
Diff not rendered
View
BIN  assets/images/d469bad1020830844d8ef22_p.jpg
Diff not rendered
View
BIN  assets/images/d5fcb524c1e7d2082cd5460_p.jpg
Diff not rendered
View
BIN  assets/images/d6b0ca44922d9c55611bf8b_p.jpg
Diff not rendered
View
BIN  assets/images/da4380621a563b4f51e3a4f_p.jpg
Diff not rendered
View
BIN  assets/images/db5a7a481a808f2410ed738_p.jpg
Diff not rendered
View
BIN  assets/images/e00f74dbdf66fcb8c6c330b_p.jpg
Diff not rendered
View
BIN  assets/images/e0881dc1b9e95ba6f2bd1c8_p.jpg
Diff not rendered
View
BIN  assets/images/e3f8904bf2e586570a385a9_p.jpg
Diff not rendered
View
BIN  assets/images/e587562aa756ccac8766c63_p.jpg
Diff not rendered
View
BIN  assets/images/e89e2f2f78000e3d31a18b2_p.jpg
Diff not rendered
View
BIN  assets/images/e8b23366dcbdfb63b3ab7a1_p.jpg
Diff not rendered
View
BIN  assets/images/f0889cb471889884aaf50d3_p.jpg
Diff not rendered
View
BIN  assets/images/f80827d3feedc8ca08e8125_p.jpg
Diff not rendered
View
BIN  assets/images/f998546a5c1c047948bbfd8_p.jpg
Diff not rendered
View
37 bin/AndroidManifest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.dodola"
+ android:versionCode="1" >
+
+ <uses-sdk android:minSdkVersion="7" />
+
+ <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+ <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.READ_LOGS" >
+ </uses-permission>
+
+ <application
+ android:icon="@drawable/icon"
+ android:label="@string/app_name" >
+ <activity
+ android:name=".activity.MainActivity"
+ android:label=""
+ android:screenOrientation="portrait" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".activity.ContentActivity"
+ android:label=""
+ android:screenOrientation="portrait" >
+ </activity>
+ </application>
+
+</manifest>
View
BIN  bin/classes.dex
Binary file not shown
View
BIN  bin/classes/com/dodola/BuildConfig.class
Binary file not shown
View
BIN  bin/classes/com/dodola/R$anim.class
Binary file not shown
View
BIN  bin/classes/com/dodola/R$attr.class
Binary file not shown
View
BIN  bin/classes/com/dodola/R$drawable.class
Binary file not shown
View
BIN  bin/classes/com/dodola/R$id.class
Binary file not shown
View
BIN  bin/classes/com/dodola/R$layout.class
Binary file not shown
View
BIN  bin/classes/com/dodola/R$string.class
Binary file not shown
View
BIN  bin/classes/com/dodola/R.class
Binary file not shown
View
BIN  bin/classes/com/dodola/activity/ContentActivity$1.class
Binary file not shown
View
BIN  bin/classes/com/dodola/activity/ContentActivity$2.class
Binary file not shown
View
BIN  bin/classes/com/dodola/activity/ContentActivity$3.class
Binary file not shown
View
BIN  bin/classes/com/dodola/activity/ContentActivity$ManagerBmp.class
Binary file not shown
View
BIN  bin/classes/com/dodola/activity/ContentActivity.class
Binary file not shown
View
BIN  bin/classes/com/dodola/activity/MainActivity.class
Binary file not shown
View
BIN  bin/classes/com/dodola/base/ActivityBase.class
Binary file not shown
View
BIN  bin/classes/com/dodola/base/TaskBase.class
Binary file not shown
View
BIN  bin/classes/com/dodola/model/DuitangInfo.class
Binary file not shown
View
BIN  bin/classes/com/dodola/model/Infos.class
Binary file not shown
View
BIN  bin/classes/com/dodola/task/ContentFootTask.class
Binary file not shown
View
BIN  bin/classes/com/dodola/task/ContentTask.class
Binary file not shown
View
BIN  bin/classes/com/dodola/tools/AsyncImageLoader$1.class
Binary file not shown
View
BIN  bin/classes/com/dodola/tools/AsyncImageLoader$2.class
Binary file not shown
View
BIN  bin/classes/com/dodola/tools/AsyncImageLoader$ImageCallBack.class
Binary file not shown
View
BIN  bin/classes/com/dodola/tools/AsyncImageLoader.class
Binary file not shown
View
BIN  bin/classes/com/dodola/tools/FileCache.class
Binary file not shown
View
BIN  bin/classes/com/dodola/tools/ImageViewBorder.class
Binary file not shown
View
BIN  bin/classes/com/dodola/views/InfoImageView.class
Binary file not shown
View
BIN  bin/classes/com/dodola/views/InfosListAdapter$1.class
Binary file not shown
View
BIN  bin/classes/com/dodola/views/InfosListAdapter$2.class
Binary file not shown
View
BIN  bin/classes/com/dodola/views/InfosListAdapter.class
Binary file not shown
View
BIN  bin/classes/com/dodola/views/InfosListLayout$1.class
Binary file not shown
View
BIN  bin/classes/com/dodola/views/InfosListLayout$2.class
Binary file not shown
View
BIN  bin/classes/com/dodola/views/InfosListLayout.class
Binary file not shown
View
BIN  bin/classes/com/dodola/views/InfosListLayoutInterface.class
Binary file not shown
View
BIN  bin/classes/com/dodola/views/InfosSmallBmp.class
Binary file not shown
View
BIN  bin/dodo_waterfall.apk
Binary file not shown
View
3  bin/jarlist.cache
@@ -0,0 +1,3 @@
+# cache for current jar dependecy. DO NOT EDIT.
+# format is <lastModified> <length> <SHA-1> <path>
+# Encoding is UTF-8
View
BIN  bin/res/drawable-hdpi/background.png
Diff not rendered
View
BIN  bin/res/drawable-hdpi/icon.png
Diff not rendered
View
BIN  bin/res/drawable-hdpi/news_detail_bottom.png
Diff not rendered
View
BIN  bin/res/drawable-hdpi/news_item_bg.9.png
Diff not rendered
View
BIN  bin/res/drawable-hdpi/news_item_bg_cover.9.png
Diff not rendered
View
BIN  bin/res/drawable-hdpi/news_picture.png
Diff not rendered
View
BIN  bin/resources.ap_
Binary file not shown
View
6 gen/com/dodola/BuildConfig.java
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package com.dodola;
+
+public final class BuildConfig {
+ public final static boolean DEBUG = true;
+}
View
53 gen/com/dodola/R.java
@@ -0,0 +1,53 @@
+/* AUTO-GENERATED FILE. DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found. It
+ * should not be modified by hand.
+ */
+
+package com.dodola;
+
+public final class R {
+ public static final class anim {
+ public static final int rotate_left=0x7f040000;
+ }
+ public static final class attr {
+ }
+ public static final class drawable {
+ public static final int background=0x7f020000;
+ public static final int icon=0x7f020001;
+ public static final int news_detail_bottom=0x7f020002;
+ public static final int news_item_bg=0x7f020003;
+ public static final int news_item_bg_cover=0x7f020004;
+ public static final int news_picture=0x7f020005;
+ }
+ public static final class id {
+ public static final int footerViewText=0x7f06000a;
+ public static final int newsButtonPro=0x7f060003;
+ public static final int newsLeftLayout=0x7f060001;
+ public static final int newsLoadMore=0x7f060002;
+ public static final int newsScrollview=0x7f060000;
+ public static final int news_content=0x7f06000b;
+ public static final int news_cover=0x7f060009;
+ public static final int news_list=0x7f060005;
+ public static final int news_pic=0x7f060006;
+ public static final int news_time=0x7f060008;
+ public static final int news_title=0x7f060007;
+ public static final int progressBar=0x7f060004;
+ }
+ public static final class layout {
+ public static final int infos_content=0x7f030000;
+ public static final int infos_list=0x7f030001;
+ public static final int list_footer=0x7f030002;
+ public static final int main=0x7f030003;
+ }
+ public static final class string {
+ public static final int app_name=0x7f050000;
+ public static final int loading=0x7f050004;
+ public static final int loadmore=0x7f050005;
+ public static final int menu_settings=0x7f050002;
+ public static final int refresh=0x7f050001;
+ public static final int temp_date=0x7f050006;
+ public static final int title_activity_main=0x7f050003;
+ }
+}
View
BIN  lib/commons-codec.jar
Binary file not shown
View
BIN  lib/commons-httpclient-3.1.jar
Binary file not shown
View
BIN  lib/commons-logging-1.1.jar
Binary file not shown
View
2  project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-10
+target=android-17
View
14 res/anim/rotate_left.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<set>
+
+ <rotate
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:duration="0"
+ android:fromDegrees="0"
+ android:interpolator="@android:anim/linear_interpolator"
+ android:pivotX="50%"
+ android:pivotY="50%"
+ android:repeatCount="0"
+ android:toDegrees="-90" />
+
+</set>
View
BIN  res/drawable-hdpi/background.png
Diff not rendered
View
BIN  res/drawable-hdpi/ic_launcher.png
Diff not rendered
View
BIN  res/drawable-hdpi/icon.png
Diff not rendered
View
BIN  res/drawable-hdpi/news_detail_bottom.png
Diff not rendered
View
BIN  res/drawable-hdpi/news_item_bg.9.png
Diff not rendered
View
BIN  res/drawable-hdpi/news_item_bg_cover.9.png
Diff not rendered
View
BIN  res/drawable-hdpi/news_picture.png
Diff not rendered
View
BIN  res/drawable-ldpi/ic_launcher.png
Diff not rendered
View
BIN  res/drawable-mdpi/ic_launcher.png
Diff not rendered
View
16 res/drawable/shape.xml
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<shape xmlns:android="http://schemas.android.com/apk/res/android"
- android:shape="rectangle" >
-
- <gradient
- android:angle="270"
- android:endColor="@android:color/white"
- android:startColor="@android:color/white" />
-
- <corners
- android:bottomLeftRadius="2dp"
- android:bottomRightRadius="2dp"
- android:topLeftRadius="2dp"
- android:topRightRadius="2dp" />
-
-</shape>
View
68 res/layout/infos_content.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:background="@drawable/background" >
+
+ <ScrollView
+ android:id="@+id/newsScrollview"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" >
+
+ <RelativeLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingBottom="70dip" >
+
+ <com.dodola.views.InfosListLayout
+ android:id="@+id/newsLeftLayout"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:paddingBottom="35dip"
+ android:paddingLeft="4dip" >
+ </com.dodola.views.InfosListLayout>
+
+ <TextView
+ android:id="@+id/newsLoadMore"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_marginBottom="100dip"
+ android:gravity="center_horizontal"
+ android:text="@string/loadmore"
+ android:textColor="#9f9f9f"
+ android:visibility="invisible" />
+
+ <LinearLayout
+ android:id="@+id/newsButtonPro"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_marginBottom="50dip"
+ android:gravity="center"
+ android:visibility="invisible" >
+
+ <ProgressBar
+ style="?android:attr/progressBarStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/loading"
+ android:textColor="#9f9f9f" />
+ </LinearLayout>
+ </RelativeLayout>
+ </ScrollView>
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:progressBarStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:visibility="visible" />
+
+</RelativeLayout>
View
68 res/layout/infos_list.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center_horizontal" >
+
+ <LinearLayout
+ android:id="@+id/news_list"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="5dip"
+ android:background="@drawable/news_item_bg"
+ android:orientation="vertical"
+ android:paddingBottom="10dip"
+ android:paddingLeft="7dip"
+ android:paddingRight="7dip"
+ android:paddingTop="10dip" >
+
+ <com.dodola.views.InfoImageView
+ android:id="@+id/news_pic"
+ android:layout_width="140dip"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginBottom="3dip"
+ android:adjustViewBounds="true"
+ android:focusable="false"
+ android:maxHeight="500dip"
+ android:maxWidth="500dip" />
+
+ <TextView
+ android:id="@+id/news_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:singleLine="false"
+ android:textColor="#656565" />
+
+ <TextView
+ android:id="@+id/news_time"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right|bottom"
+ android:gravity="right"
+ android:text="@string/temp_date"
+ android:textColor="#9f9f9f" />
+ </LinearLayout>
+
+ <ImageView
+ android:id="@+id/news_cover"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignBottom="@id/news_list"
+ android:layout_alignLeft="@id/news_list"
+ android:layout_alignRight="@id/news_list"
+ android:layout_alignTop="@id/news_list"
+ android:background="@drawable/news_item_bg_cover"
+ android:visibility="invisible" >
+ </ImageView>
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_marginTop="60dip"
+ android:visibility="visible" />
+
+</RelativeLayout>
View
22 res/layout/list_footer.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:orientation="horizontal" >
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:progressBarStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="10dip"
+ android:visibility="gone" />
+
+ <TextView
+ android:id="@+id/footerViewText"
+ android:layout_width="wrap_content"
+ android:layout_height="35dip"
+ android:gravity="center_vertical" />
+
+</LinearLayout>
View
21 res/layout/main.xml
@@ -1,17 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
-<com.dodowaterfall.LazyScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:id="@+id/waterfall_scroll"
- android:scrollbars="vertical"
- >
+ android:background="@drawable/background" >
- <LinearLayout
- android:id="@+id/waterfall_container"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@android:color/white"
- >
- </LinearLayout>
-</com.dodowaterfall.LazyScrollView>
+ <LinearLayout
+ android:id="@+id/news_content"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent" >
+ </LinearLayout>
+
+</RelativeLayout>
View
8 res/layout/waterfallitem.xml
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<com.dodowaterfall.widget.FlowView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/waterfall_image"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/ic_launcher" >
-
-</com.dodowaterfall.widget.FlowView>
View
14 res/values/strings.xml
@@ -1,5 +1,11 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<resources>
- <string name="hello">Hello World</string>
- <string name="app_name">瀑布流示例</string>
-</resources>
+
+ <string name="app_name">瀑布流demo</string>
+ <string name="refresh">刷新</string>
+ <string name="menu_settings">Settings</string>
+ <string name="title_activity_main">MainActivity</string>
+ <string name="loading">加载中...</string>
+ <string name="loadmore">加载更多...</string>
+ <string name="temp_date">2012-3-19 13:45</string>
+
+</resources>
View
BIN  screen1.png
Diff not rendered
View
BIN  screen2.png
Diff not rendered
View
371 src/com/dodola/activity/ContentActivity.java
@@ -0,0 +1,371 @@
+package com.dodola.activity;
+
+import java.util.List;
+
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.View.OnTouchListener;
+import android.view.Window;
+import android.view.animation.AlphaAnimation;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.RelativeLayout;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import com.dodola.R;
+import com.dodola.base.ActivityBase;
+import com.dodola.model.Infos;
+import com.dodola.task.ContentFootTask;
+import com.dodola.task.ContentTask;
+import com.dodola.tools.FileCache;
+import com.dodola.views.InfoImageView;
+import com.dodola.views.InfosListAdapter;
+import com.dodola.views.InfosListLayout;
+import com.dodola.views.InfosListLayoutInterface;
+import com.dodola.views.InfosSmallBmp;
+
+public class ContentActivity extends ActivityBase implements
+ InfosListLayoutInterface {
+ public InfosListAdapter listAdapter;
+ public InfosListLayout newsListLayout; // 列表控件
+ public LinearLayout newsButtonPro;
+ public ScrollView scrollView; // 界面中的ScrollView控件
+ public TextView newsLoadMore; // 界面中的提示“上拉或点击加载更多...”的TextView
+ public ProgressBar progressBar; // 刚进入界面加载内容时 显示的进度圈
+
+ public int flag = 0; // 用来判断此界面数据是否正在加载:0代表已经加载完成,1代表正在加载
+ public String newsLast = "";
+ public Infos newsLeft; // 控件数据模型
+
+ public View selectedView;
+ private int isFirstCreate = 1;
+ public int isDetailBcak = 0;
+
+ public InfosSmallBmp smallBmp;
+ private int iIndex;
+ private List<List<View>> all_screen_view; // 封装每屏View集合的集合
+ boolean thread_once_flag = true; // 确保线程只被开启一次
+ private ManagerBmp managerBmp;
+ private boolean initFlag = true; // 只有当本Activity中新增加了View时,其为true
+
+ public ContentActivity() {
+ newsLeft = new Infos();
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ setContentView(R.layout.infos_content);
+
+ newsListLayout = (InfosListLayout) findViewById(R.id.newsLeftLayout);
+ scrollView = (ScrollView) findViewById(R.id.newsScrollview);
+ newsLoadMore = (TextView) findViewById(R.id.newsLoadMore);
+ progressBar = (ProgressBar) findViewById(R.id.progressBar);
+ newsButtonPro = (LinearLayout) findViewById(R.id.newsButtonPro);
+
+ smallBmp = new InfosSmallBmp();
+ newsListLayout.setScrollView(scrollView);
+ newsListLayout.setEvent(this);
+
+ upDateList();
+
+ setListener();
+ }
+
+ /**
+ *
+ * 给相应的控件注册事件
+ *
+ * */
+ public void setListener() {
+ // 上拉刷新
+ scrollView.setOnTouchListener(new OnTouchListener() {
+
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ // TODO Auto-generated method stub
+ if (event.getAction() == MotionEvent.ACTION_UP && flag == 0
+ && progressBar.getVisibility() == View.INVISIBLE) { // 当手指离开ScrollView且数据已经加载完成
+ View view = ((ScrollView) v).getChildAt(0);
+ if (view.getMeasuredHeight() <= v.getScrollY()
+ + v.getHeight()) { // 当ScrollView中包含的View的高度小于已经滚动了的值+SrollView本身的高度时
+ newsLoadMore.setVisibility(android.view.View.VISIBLE);
+ if (newsListLayout != null) {
+ new ContentFootTask(ContentActivity.this)
+ .execute("http://www.duitang.com/album/369270/masn/p/4/24/");
+ } else {
+ return false;
+ }
+ }
+ }
+ return false;
+ }
+ });
+
+ // 点击刷新
+ newsLoadMore.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ new ContentFootTask(ContentActivity.this)
+ .execute("http://www.duitang.com/album/369270/masn/p/4/24/");
+ }
+ });
+ }
+
+ public String getNewsLast() {
+ return newsLast;
+ }
+
+ public void setNewsLast(String newsLast) {
+ this.newsLast = newsLast;
+ }
+
+ public int getFlag() {
+ return flag;
+ }
+
+ public void setFlag(int flag) {
+ this.flag = flag;
+ }
+
+ /**
+ *
+ * 加载数据资源
+ * */
+ public void upDateList() {
+ new ContentTask(this)
+ .execute("http://www.duitang.com/album/369270/masn/p/4/24/"); // 请求数据
+ }
+
+ @Override
+ protected void onResume() {
+ // TODO Auto-generated method stub
+ super.onResume();
+ if (isFirstCreate == 1) {
+ isFirstCreate = 0;
+ } else if (isDetailBcak == 1) {
+ isDetailBcak = 0;
+ ImageView imgCover = (ImageView) selectedView
+ .findViewById(R.id.news_cover);
+ AlphaAnimation alphaAnimation = new AlphaAnimation(1f, 0f);
+ alphaAnimation.setDuration(1500);
+ alphaAnimation.setFillAfter(true);
+ imgCover.startAnimation(alphaAnimation);
+ }
+ if (null != managerBmp) {
+ managerBmp.manaBmp_flag = true;
+ }
+ }
+
+ Handler handler = new Handler() {
+ public void handleMessage(Message msg) {
+ if (0 == msg.what) {
+ ((ProgressBar) msg.obj).setVisibility(View.INVISIBLE);
+ } else if (1 == msg.what) {
+ ((ProgressBar) msg.obj).setVisibility(View.VISIBLE);
+ }
+ }
+ };
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ if (null != managerBmp) {
+ managerBmp.manaBmp_flag = false;
+ }
+
+ if (null != this.all_screen_view) {
+ int iBeforPresentBmps = 0;
+ for (int i = 0; i < all_screen_view.size(); i++) {
+ List<View> one_screen_view = all_screen_view.get(i);
+ if (iIndex - 1 == i || iIndex + 1 == i) {
+ for (int j = 0; j < one_screen_view.size(); j++) {
+ RelativeLayout rootView = (RelativeLayout) one_screen_view
+ .get(j);
+ ProgressBar proBar = (ProgressBar) rootView
+ .findViewById(R.id.progressBar);
+ InfoImageView imageView = (InfoImageView) rootView
+ .findViewById(R.id.news_pic);
+ if (proBar.getVisibility() == View.INVISIBLE) {
+ Bitmap bmp = imageView.getBmp();
+ imageView.setMyImageBitmap(smallBmp
+ .getSmalBmpList()
+ .get(iBeforPresentBmps + j));
+ proBar.setVisibility(View.VISIBLE);
+ this.freeBmp(bmp);
+ }
+ }
+ }
+ iBeforPresentBmps += one_screen_view.size();
+ }
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (null != managerBmp) {
+ managerBmp.query_flag = false;
+ managerBmp.manaBmp_flag = false;
+ }
+
+ for (int i = 0; i < smallBmp.getSmalBmpList().size(); i++) {
+ this.freeBmp(smallBmp.getSmalBmpList().get(i));
+ }
+ smallBmp.getSmalBmpList().clear();
+
+ // 释放掉MyImageView中的所有Bitmap
+ if (null != this.all_screen_view) {
+ int iBeforPresentBmps = 0;// 当前屏以前共有多少张图片
+ for (int i = 0; i < all_screen_view.size(); i++) {
+ List<View> one_screen_view = all_screen_view.get(i);
+
+ for (int j = 0; j < one_screen_view.size(); j++) {
+ RelativeLayout rootView = (RelativeLayout) one_screen_view
+ .get(j);
+ InfoImageView imageView = (InfoImageView) rootView
+ .findViewById(R.id.news_pic);
+ Bitmap bmp = imageView.getBmp();
+ imageView.setMyImageBitmap(null);
+ this.freeBmp(bmp);
+ }
+ // }
+ // 删除SD卡上的多余的缓存(只保留第一次加载的图片缓存,不保留下拉或点击获得更多的图片)
+ if (iBeforPresentBmps >= 10) {
+ for (int j = 0; j < one_screen_view.size(); j++) {
+ RelativeLayout rootView = (RelativeLayout) one_screen_view
+ .get(j);
+ FileCache.getInstance().clearImgByImgUrl(
+ rootView.getTag().toString());
+ }
+ }
+ iBeforPresentBmps += one_screen_view.size();
+ }
+ }
+ }
+
+ // 释放Bitmap的方法
+ public void freeBmp(Bitmap bmp) {
+ if (null != bmp && !bmp.isRecycled()) {
+ bmp.recycle();
+ bmp = null;
+ }
+ }
+
+ @Override
+ public void onCurChileCtrlScreen(int index, int direct, boolean flag) {
+ // TODO Auto-generated method stub
+ int preIndex = this.iIndex;
+ this.iIndex = index;
+ this.initFlag = flag;
+ if (null == managerBmp || !managerBmp.isAlive()) {
+ managerBmp = new ManagerBmp(handler); // 注意这里必须在重新赋值;如果不重新赋值的话线程结束后,这个引用指向的是已经结束了的线程对象(已经在内存中不存在咯)
+ managerBmp.query_flag = true;
+ managerBmp.manaBmp_flag = false;
+ all_screen_view = newsListLayout.initScreenView();
+ // System.out.println("总共有多少屏---------------->"
+ // + all_screen_view.size());
+ // 取得封装每屏View集合的集合
+ managerBmp.start(); // 守护线程只开启一次
+ }
+
+ if (preIndex != index) { // 当屏幕变化时使守护线程内部循环开始执行
+ managerBmp.manaBmp_flag = true;
+ }
+ }
+
+ class ManagerBmp extends Thread {
+ public boolean manaBmp_flag = false;
+ public boolean query_flag = true;
+ public Handler handler;
+
+ public ManagerBmp(Handler handler) {
+ this.handler = handler;
+ }
+
+ public void run() {
+ while (query_flag) {
+ if (initFlag) {
+ all_screen_view = newsListLayout.initScreenView();// 重新取得封装每屏View集合的集合
+ manaBmp_flag = true;
+ }
+ int i = 0;
+ int iBeforPresentBmps = 0;// 当前屏以前共有多少张图片
+ while (manaBmp_flag && i < all_screen_view.size()) {
+ // 属于当前屏幕中心的上下三个屏幕,需要保留内存,因为随时会被上或下滑动
+ List<View> one_screen_view = all_screen_view.get(i);
+ if (iIndex - 1 == i || iIndex == i || iIndex + 1 == i) {
+ for (int j = 0; j < one_screen_view.size(); j++) {
+ RelativeLayout rootView = (RelativeLayout) one_screen_view
+ .get(j);
+ ProgressBar proBar = (ProgressBar) rootView
+ .findViewById(R.id.progressBar);
+ InfoImageView imageView = (InfoImageView) rootView
+ .findViewById(R.id.news_pic);
+
+ if (proBar.getVisibility() == View.VISIBLE) {
+ // 获得SD卡上的图片
+ Bitmap bmp = FileCache.getInstance().getBmp(
+ rootView.getTag().toString());
+ // System.out
+ // .println("从SD卡上读取图片-------------------------");
+ // System.out.println(rootView.getTag()
+ // + "------------>图片的URL地址");
+ // System.out.println("守护线程开始加载图片...");
+ if (null != bmp) {
+ imageView.setMyImageBitmap(bmp);
+ // System.out.println("开始加载第"
+ // + (iBeforPresentBmps + j) + "个View的图片");
+ Message msg3 = handler.obtainMessage();
+ msg3.what = 0; // 让ProgressBar消失
+ msg3.obj = proBar;
+ handler.sendMessage(msg3);
+ }
+ }
+ }
+ } else {
+ for (int j = 0; j < one_screen_view.size(); j++) {
+ RelativeLayout rootView = (RelativeLayout) one_screen_view
+ .get(j);
+ ProgressBar proBar = (ProgressBar) rootView
+ .findViewById(R.id.progressBar);
+ InfoImageView imageView = (InfoImageView) rootView
+ .findViewById(R.id.news_pic);
+ Bitmap bitmap = null;
+ if (proBar.getVisibility() == View.INVISIBLE) {
+ bitmap = imageView.getBmp();
+ imageView.setMyImageBitmap(smallBmp
+ .getSmalBmpList().get(
+ iBeforPresentBmps + j));// 先给它设置小内存的默认图片
+ ContentActivity.this.freeBmp(bitmap);// 释放掉
+ Message msg = handler.obtainMessage();
+ msg.what = 1; // ProgressBar出现
+ msg.obj = proBar;
+ handler.sendMessage(msg);
+ }
+ }
+ }
+ iBeforPresentBmps += one_screen_view.size();
+ i++;
+ }
+ this.manaBmp_flag = false; // 内层循环执行完后停止
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
View
69 src/com/dodola/activity/MainActivity.java
@@ -0,0 +1,69 @@
+package com.dodola.activity;
+
+import android.app.ActivityGroup;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup.LayoutParams;
+import android.view.Window;
+import android.view.animation.Animation;
+import android.view.animation.Animation.AnimationListener;
+import android.view.animation.TranslateAnimation;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+
+import com.dodola.R;
+
+public class MainActivity extends ActivityGroup {
+ public LinearLayout newsContent;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ setContentView(R.layout.main);
+
+ initView();
+ }
+
+ private void initView() {
+
+ newsContent = (LinearLayout) findViewById(R.id.news_content);
+ addView();
+
+ RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+ LayoutParams.WRAP_CONTENT);
+ rl.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
+
+ }
+
+ public void addView() {
+ newsContent.removeAllViews();
+ Intent intent = new Intent();
+
+ intent.setClass(MainActivity.this, ContentActivity.class);
+ newsContent.addView(getLocalActivityManager().startActivity("duitang", intent)
+ .getDecorView());
+ newsContent.setMinimumWidth(getWindowManager().getDefaultDisplay().getWidth());
+
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ menu.add(1, 1, 1, R.string.refresh);
+ return super.onCreateOptionsMenu(menu);
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ addView();
+ return true;
+ }
+}
View
162 src/com/dodola/base/ActivityBase.java
@@ -0,0 +1,162 @@
+package com.dodola.base;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.Map;
+
+
+import android.R;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Bundle;
+
+public class ActivityBase extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ // TODO Auto-generated method stub
+ super.onCreate(savedInstanceState);
+ }
+
+ //检测网络连接
+ public boolean checkConnection() {
+ ConnectivityManager connectivityManager = (ConnectivityManager)this.getSystemService(CONNECTIVITY_SERVICE);
+ NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
+ if (networkInfo != null) {
+ return networkInfo.isAvailable();
+ }
+ return false;
+ }
+
+ //通过URL来获得输入流,这个是通过GET方式联网
+ public InputStream getStreamByGetURL(String path) throws IOException {
+
+ URL url = new URL(path);
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.setReadTimeout(2000*10);
+
+ if (connection.getResponseCode() == 200) {
+ InputStream inputStream = connection.getInputStream();
+ return inputStream;
+ }
+
+ return null;
+ }
+
+ //通过URL来获得输入流,这个是通过POST方式联网
+ public InputStream getStreamByPostURL(String path, Map<String, String> params) throws IOException {
+
+ StringBuilder sb = new StringBuilder();
+ if(params!=null && !params.isEmpty()){
+ for(Map.Entry<String, String> entry : params.entrySet()){
+ sb.append(entry.getKey()).append('=')
+ .append(URLEncoder.encode(entry.getValue())).append('&');
+ }
+ sb.deleteCharAt(sb.length()-1);
+ }
+ byte[] entitydata = sb.toString().getBytes();
+ URL url = new URL(path);
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setRequestMethod("POST");
+ connection.setConnectTimeout(2000*10);
+ connection.setDoOutput(true);
+
+ connection.setRequestProperty("Charset", "UTF-8");
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-Length", String.valueOf(entitydata.length));
+ OutputStream outStream = connection.getOutputStream();
+ outStream.write(entitydata);
+
+ outStream.flush();
+ outStream.close();
+
+ if (connection.getResponseCode() == 200) {
+ InputStream inputStream = connection.getInputStream();
+ return inputStream;
+ }
+
+ return null;
+ }
+
+ public InputStream getStreamByURLAndCookie(String path, Map<String, String> params, String cookie) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ if(params!=null && !params.isEmpty()){
+ for(Map.Entry<String, String> entry : params.entrySet()){
+ sb.append(entry.getKey()).append('=')
+ .append(URLEncoder.encode(entry.getValue())).append('&');
+ }
+ sb.deleteCharAt(sb.length()-1);
+ }
+ byte[] entitydata = sb.toString().getBytes();
+ URL url = new URL(path);
+ HttpURLConnection connection = (HttpURLConnection)url.openConnection();
+ connection.setRequestProperty("Cookie", cookie);
+ connection.setRequestMethod("POST");
+ connection.setConnectTimeout(2000*10);
+ connection.setDoOutput(true);
+
+ connection.setRequestProperty("Charset", "UTF-8");
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-Length", String.valueOf(entitydata.length));
+ OutputStream outStream = connection.getOutputStream();
+ outStream.write(entitydata);
+
+ outStream.flush();
+ outStream.close();
+
+ if (connection.getResponseCode() == 200) {
+ InputStream inputStream = connection.getInputStream();
+ return inputStream;
+ }
+
+ return null;
+ }
+
+ public byte[] readInputStream(InputStream inputStream) throws IOException {
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int len = 0;
+
+ while ((len=inputStream.read(buffer)) != -1 ) {
+ outStream.write(buffer, 0, len);
+ }
+ outStream.close();
+ inputStream.close();
+
+ return outStream.toByteArray();
+ }
+
+ public boolean isWifi(Context mContext) {
+ ConnectivityManager connectivityManager = (ConnectivityManager) mContext
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
+ if(activeNetInfo != null && activeNetInfo.getTypeName().equals("WIFI")){
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected void onPause() {
+ // TODO Auto-generated method stub
+ super.onPause();
+ }
+
+ @Override
+ protected void onResume() {
+ // TODO Auto-generated method stub
+ super.onResume();
+ }
+
+
+}
View
151 src/com/dodola/base/TaskBase.java
@@ -0,0 +1,151 @@
+package com.dodola.base;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.List;
+import java.util.Map;
+
+import org.json.JSONObject;
+
+import android.content.Context;
+import android.content.res.AssetManager;
+import android.os.AsyncTask;
+import android.util.Log;
+
+public class TaskBase extends AsyncTask<String, Integer, List<Map<String, Object>>> {
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ }
+
+ @Override
+ protected List<Map<String, Object>> doInBackground(String... params) {
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(List<Map<String, Object>> result) {
+ super.onPostExecute(result);
+ }
+
+ public InputStream getStreamByLocalURL(Context context, String fileUrl) throws IOException {
+ AssetManager assetManager = context.getAssets();
+
+ return assetManager.open(fileUrl);
+ }
+
+ public InputStream getStreamByGetURL(String path) throws IOException {
+
+ URL url = new URL(path);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("GET");
+ connection.setReadTimeout(2000 * 10);
+ connection.setRequestProperty("Charset", "UTF-8");
+
+ if (connection.getResponseCode() == 200) {
+ InputStream inputStream = connection.getInputStream();
+ return inputStream;
+ }
+
+ return null;
+ }
+
+ public InputStream getStreamByPostURL(String path, Map<String, String> params)
+ throws IOException {
+
+ StringBuilder sb = new StringBuilder();
+ if (params != null && !params.isEmpty()) {
+ for (Map.Entry<String, String> entry : params.entrySet()) {
+ sb.append(entry.getKey())
+ .append('=')
+ .append(URLEncoder.encode(entry.getValue()))
+ .append('&');
+ }
+ sb.deleteCharAt(sb.length() - 1);
+ }
+ byte[] entitydata = sb.toString().getBytes();
+ URL url = new URL(path);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("POST");
+ connection.setConnectTimeout(2000 * 10);
+ connection.setDoOutput(true);
+
+ connection.setRequestProperty("Charset", "UTF-8");
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-Length", String.valueOf(entitydata.length));
+ OutputStream outStream = connection.getOutputStream();
+ outStream.write(entitydata);
+
+ outStream.flush();
+ outStream.close();
+
+ if (connection.getResponseCode() == 200) {
+ InputStream inputStream = connection.getInputStream();
+ return inputStream;
+ }
+
+ return null;
+ }
+
+ public InputStream getStreamByURLAndCookie(String path, Map<String, String> params,
+ String cookie) throws IOException {
+
+ StringBuilder sb = new StringBuilder();
+ if (params != null && !params.isEmpty()) {
+ for (Map.Entry<String, String> entry : params.entrySet()) {
+ sb.append(entry.getKey())
+ .append('=')
+ .append(URLEncoder.encode(entry.getValue()))
+ .append('&');
+ }
+ sb.deleteCharAt(sb.length() - 1);
+ }
+ byte[] entitydata = sb.toString().getBytes();
+ URL url = new URL(path);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestProperty("Cookie", cookie);
+ connection.setRequestMethod("POST");
+ connection.setConnectTimeout(2000 * 10);
+ connection.setDoOutput(true);
+
+ connection.setRequestProperty("Charset", "UTF-8");
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-Length", String.valueOf(entitydata.length));
+ OutputStream outStream = connection.getOutputStream();
+ outStream.write(entitydata);
+
+ outStream.flush();
+ outStream.close();
+
+ if (connection.getResponseCode() == 200) {
+ InputStream inputStream = connection.getInputStream();
+ return inputStream;
+ }
+
+ return null;
+ }
+
+ public byte[] readInputStream(InputStream inputStream) throws IOException {
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int len = 0;
+
+ while ((len = inputStream.read(buffer)) != -1) {
+ outStream.write(buffer, 0, len);
+ }
+ outStream.close();
+ inputStream.close();
+
+ return outStream.toByteArray();
+ }
+
+
+}
View
33 src/com/dodola/model/DuitangInfo.java
@@ -0,0 +1,33 @@
+package com.dodola.model;
+
+public class DuitangInfo {
+
+ private String albid = "";
+ private String msg = "";
+ private String isrc = "";
+
+ public String getAlbid() {
+ return albid;
+ }
+
+ public void setAlbid(String albid) {
+ this.albid = albid;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+
+ public void setMsg(String msg) {
+ this.msg = msg;
+ }
+
+ public String getIsrc() {
+ return isrc;
+ }
+
+ public void setIsrc(String isrc) {
+ this.isrc = isrc;
+ }
+
+}
View
34 src/com/dodola/model/Infos.java
@@ -0,0 +1,34 @@
+package com.dodola.model;
+
+import java.util.List;
+
+public class Infos {
+ private String newsLast = "0";
+ private int type = 0;
+ private List<DuitangInfo> newsInfos;
+
+ public String getNewsLast() {
+ return newsLast;
+ }
+
+ public void setNewsLast(String newsLast) {
+ this.newsLast = newsLast;
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public void setType(int type) {
+ this.type = type;
+ }
+
+ public List<DuitangInfo> getNewsInfos() {
+ return newsInfos;
+ }
+
+ public void setNewsInfos(List<DuitangInfo> newsInfos) {
+ this.newsInfos = newsInfos;
+ }
+
+}
View
108 src/com/dodola/task/ContentFootTask.java
@@ -0,0 +1,108 @@
+package com.dodola.task;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.util.Log;
+
+import com.dodola.activity.ContentActivity;
+import com.dodola.base.TaskBase;
+import com.dodola.model.DuitangInfo;
+import com.dodola.views.InfosListAdapter;
+
+public class ContentFootTask extends TaskBase {
+
+ public ContentActivity contentActivity;
+
+ public ContentFootTask(ContentActivity newsContentActivity) {
+ super();
+ this.contentActivity = newsContentActivity;
+ }
+
+ @Override
+ protected List<Map<String, Object>> doInBackground(String... params) {
+ try {
+ parseNewsJSON(params[0]);
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ protected void onPostExecute(List<Map<String, Object>> result) {
+ if (this.contentActivity.newsLeft != null
+ && this.contentActivity.newsLeft.getNewsInfos() != null) {
+ if (null == this.contentActivity.listAdapter) {
+ this.contentActivity.listAdapter = new InfosListAdapter(this.contentActivity,
+ this.contentActivity.newsLeft.getNewsInfos(), this.contentActivity.smallBmp);
+ }
+ this.contentActivity.listAdapter.setList(this.contentActivity.newsLeft.getNewsInfos());
+ this.contentActivity.listAdapter.notifyDataSetChanged();
+ this.contentActivity.newsListLayout.setAdapter(this.contentActivity.listAdapter);
+ }
+
+ this.contentActivity.newsButtonPro.setVisibility(android.view.View.INVISIBLE);
+ this.contentActivity.newsLoadMore.setVisibility(android.view.View.VISIBLE);
+ this.contentActivity.setFlag(0);
+ }
+
+ @Override
+ protected void onPreExecute() {
+ this.contentActivity.newsLoadMore.setVisibility(android.view.View.INVISIBLE);
+ this.contentActivity.newsButtonPro.setVisibility(android.view.View.VISIBLE);
+ this.contentActivity.setFlag(1);
+ }
+
+ public void parseNewsJSON(String url) throws IOException {
+ String json = "";
+ if (this.contentActivity.checkConnection()) {
+ try {
+ InputStream inputStream = getStreamByGetURL(url);
+ if (null != inputStream) {
+ json = new String(readInputStream(inputStream));
+ }
+ }
+ catch (IOException e) {
+ Log.e("IOException is : ", e.toString());
+ e.printStackTrace();
+ return;
+ }
+
+ try {
+ JSONObject newsObject = new JSONObject(json);
+ JSONObject jsonObject = newsObject.getJSONObject("data");
+ JSONArray blogsJson = jsonObject.getJSONArray("blogs");
+
+ List<DuitangInfo> newsLeftInfos = new ArrayList<DuitangInfo>();
+ for (int i = 0; i < blogsJson.length(); i++) {
+ JSONObject newsInfoLeftObject = blogsJson.getJSONObject(i);
+ DuitangInfo newsInfo1 = new DuitangInfo();
+ newsInfo1.setAlbid(newsInfoLeftObject.isNull("albid")
+ ? "" : newsInfoLeftObject.getString("albid"));
+ newsInfo1.setIsrc(newsInfoLeftObject.isNull("isrc")
+ ? "" : newsInfoLeftObject.getString("isrc"));
+ newsInfo1.setMsg(newsInfoLeftObject.isNull("msg")
+ ? "" : newsInfoLeftObject.getString("msg"));
+ newsLeftInfos.add(newsInfo1);
+ }
+ this.contentActivity.newsLeft.setNewsInfos(newsLeftInfos);
+ }
+ catch (JSONException e) {
+ e.printStackTrace();
+ }
+
+ }
+ else {
+ // 出现网络异常
+ }
+ }
+}
View
106 src/com/dodola/task/ContentTask.java
@@ -0,0 +1,106 @@
+package com.dodola.task;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.content.Intent;
+import android.util.Log;
+import android.view.View;
+
+import com.dodola.activity.ContentActivity;
+import com.dodola.base.TaskBase;
+import com.dodola.model.DuitangInfo;
+import com.dodola.tools.FileCache;
+import com.dodola.views.InfosListAdapter;
+
+public class ContentTask extends TaskBase {
+
+ public ContentActivity contentActivity;
+
+ public ContentTask(ContentActivity newsContentActivity) {
+ super();
+ this.contentActivity = newsContentActivity;
+ }
+
+ @Override
+ protected List<Map<String, Object>> doInBackground(String... params) {
+ try {
+ parseNewsJSON(params[0]);
+ }
+ catch (IOException e) {
+ e.printStackTrace();