├── settings.gradle ├── screenshots ├── s1.png ├── s2.png ├── s3.png └── s4.png ├── app ├── libs │ └── litepal-1.2.0-src.jar ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── ic_launcher.png │ │ │ │ └── abc_menu_dropdown_panel_holo_light.9.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_meizhi_228.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_refresh_white_24dp.png │ │ │ ├── values │ │ │ │ ├── attrs.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── strings.xml │ │ │ │ └── android_material_design_colours.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ ├── menu │ │ │ │ ├── menu_main.xml │ │ │ │ └── menu_picture.xml │ │ │ └── layout │ │ │ │ ├── activity_picture.xml │ │ │ │ ├── view_toolbar.xml │ │ │ │ ├── activity_webview.xml │ │ │ │ ├── item_meizhi.xml │ │ │ │ └── activity_main.xml │ │ ├── assets │ │ │ └── litepal.xml │ │ ├── java │ │ │ └── me │ │ │ │ └── drakeet │ │ │ │ └── meizhi │ │ │ │ ├── App.java │ │ │ │ ├── util │ │ │ │ ├── TaskUtils.java │ │ │ │ ├── DateUtils.java │ │ │ │ ├── ToastUtils.java │ │ │ │ └── HttpUtils.java │ │ │ │ ├── model │ │ │ │ └── Meizhi.java │ │ │ │ ├── SwipeRefreshBaseActivity.java │ │ │ │ ├── widget │ │ │ │ ├── FABAutoHideBehavior.java │ │ │ │ └── MultiSwipeRefreshLayout.java │ │ │ │ ├── ToolbarActivity.java │ │ │ │ ├── PictureActivity.java │ │ │ │ ├── WebviewActivity.java │ │ │ │ ├── MeizhiListAdapter.java │ │ │ │ ├── OldMeizhi.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── me │ │ └── drakeet │ │ └── meizhi │ │ └── ApplicationTest.java ├── .gitignore ├── proguard-rules.pro └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── README.md ├── gradlew.bat └── gradlew /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /screenshots/s1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/screenshots/s1.png -------------------------------------------------------------------------------- /screenshots/s2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/screenshots/s2.png -------------------------------------------------------------------------------- /screenshots/s3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/screenshots/s3.png -------------------------------------------------------------------------------- /screenshots/s4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/screenshots/s4.png -------------------------------------------------------------------------------- /app/libs/litepal-1.2.0-src.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/app/libs/litepal-1.2.0-src.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/app/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_meizhi_228.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/app/src/main/res/mipmap-hdpi/ic_meizhi_228.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_refresh_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/app/src/main/res/mipmap-xhdpi/ic_refresh_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/abc_menu_dropdown_panel_holo_light.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daimajia/Meizhi/HEAD/app/src/main/res/drawable/abc_menu_dropdown_panel_holo_light.9.png -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/assets/litepal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jun 20 21:27:50 CST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 56dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #4b342f 4 | #231714 5 | #e91e63 6 | #00b0ff 7 | @color/theme_primary 8 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/androidTest/java/me/drakeet/meizhi/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_picture.xml: -------------------------------------------------------------------------------- 1 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/App.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi; 2 | 3 | import android.database.sqlite.SQLiteDatabase; 4 | 5 | import org.litepal.LitePalApplication; 6 | import org.litepal.tablemanager.Connector; 7 | 8 | /** 9 | * Created by drakeet on 6/21/15. 10 | */ 11 | public class App extends LitePalApplication { 12 | 13 | @Override 14 | public void onCreate() { 15 | super.onCreate(); 16 | SQLiteDatabase db = Connector.getDatabase();//初始化数据库 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_picture.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 妹纸.gank.io 3 | PictureActivity 4 | 5 | Hello world! 6 | Settings 7 | 正在加载更多... 8 | 今天没有妹纸 9 | http://gank.io/ 10 | 正在加载: 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/util/TaskUtils.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi.util; 2 | 3 | import android.os.AsyncTask; 4 | import android.os.Build; 5 | 6 | /** 7 | * Created by drak11t on 8/16/14. 8 | */ 9 | public class TaskUtils { 10 | 11 | @SafeVarargs 12 | public static void executeAsyncTask( 13 | AsyncTask task, Params... params) { 14 | if (Build.VERSION.SDK_INT >= 11) { 15 | task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params); 16 | } else { 17 | task.execute(params); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | .DS_Store 5 | /build 6 | # built application files 7 | *.apk 8 | *.ap_ 9 | 10 | # files for the dex VM 11 | *.dex 12 | 13 | # Java class files 14 | *.class 15 | .DS_Store 16 | 17 | # generated files 18 | bin/ 19 | gen/ 20 | Wiki/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Eclipse project files 26 | .classpath 27 | .project 28 | .settings/ 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | #Android Studio 34 | build/ 35 | 36 | # Intellij project files 37 | *.iml 38 | *.ipr 39 | *.iws 40 | .idea/ 41 | 42 | #gradle 43 | .gradle/ 44 | captures -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/drakeet/Applications/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_toolbar.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_webview.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 端午节回家的时候,无聊之中,做了一个专门欣赏妹纸的小应用,数据来自[代码家](https://github.com/daimajia)的干货网站:http://gank.io 我只抓取了妹纸图做了个新的开源小应用: 2 | 3 | 直接下载:https://fir.im/mengmeizhi 4 | 5 | 源代码:https://github.com/drakeet/Meizhi 6 | 7 | 本来就是自用或内部使用的,也只开发了一个晚上加一个早上时间,并没有很高级很完善,只适配了小米2s 的屏幕尺寸,一些效果也只有 Android 5.0 以上的系统才会有,就酱啦~ 8 | 9 | 通过这个项目,你可能可以学习到的内容有: 10 | 11 | * 多渠道打包 12 | * 使用 ORM 快速操作数据库 13 | * 访问网络,简单解析 HTML 14 | * RecyclerView 瀑布流的使用 15 | * RecyclerView 底部加载更多的简单实现 16 | * Material Design 的下拉刷新 17 | * 使用最新的 Design 兼容库 18 | * 使用 5.0 的 Share 组件或元素动画 19 | * 使用 Toolbar 完全替代 ActionBar 20 | 21 | screenshot screenshot 22 | 23 | screenshot screenshot 24 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/util/DateUtils.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi.util; 2 | 3 | import java.text.DateFormat; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | 8 | /** 9 | * Created by drakeet on 6/20/15. 10 | */ 11 | public class DateUtils { 12 | 13 | public static String toDate(Date date) { 14 | DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); 15 | return dateFormat.format(date); 16 | } 17 | 18 | public static Date getLastdayDate(Date date) { 19 | Calendar calendar = Calendar.getInstance(); 20 | calendar.setTime(date); 21 | calendar.add(Calendar.DATE, -1); 22 | return calendar.getTime(); 23 | } 24 | 25 | public static Date getNextdayDate(Date date) { 26 | Calendar calendar = Calendar.getInstance(); 27 | calendar.setTime(date); 28 | calendar.add(Calendar.DATE, 1); 29 | return calendar.getTime(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/util/ToastUtils.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi.util; 2 | 3 | import android.content.Context; 4 | import android.widget.Toast; 5 | 6 | import me.drakeet.meizhi.App; 7 | 8 | 9 | /** 10 | * Created by drakeet on 9/27/14. 11 | */ 12 | public class ToastUtils { 13 | 14 | Context mContext; 15 | 16 | private ToastUtils() { 17 | } 18 | 19 | private static void show(Context context, int resId, int duration) { 20 | Toast.makeText(context, resId, duration).show(); 21 | } 22 | 23 | private static void show(Context context, String message, int duration) { 24 | Toast.makeText(context, message, duration).show(); 25 | } 26 | 27 | public static void showShort(int resId) { 28 | Toast.makeText(App.getContext(), resId, Toast.LENGTH_SHORT).show(); 29 | } 30 | 31 | public static void showShort(String message) { 32 | Toast.makeText(App.getContext(), message, Toast.LENGTH_SHORT).show(); 33 | } 34 | 35 | public static void showLong(int resId) { 36 | Toast.makeText(App.getContext(), resId, Toast.LENGTH_LONG).show(); 37 | } 38 | 39 | public static void showLong(String message) { 40 | Toast.makeText(App.getContext(), message, Toast.LENGTH_LONG).show(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/util/HttpUtils.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.InputStreamReader; 5 | import java.net.HttpURLConnection; 6 | import java.net.URL; 7 | 8 | /** 9 | * Created by drak11t on 8/16/14. 10 | */ 11 | public class HttpUtils { 12 | 13 | private URL url = null; 14 | 15 | public String download(String urlStr) { 16 | StringBuffer sb = new StringBuffer(); 17 | String line = null; 18 | BufferedReader buffer = null; 19 | try { 20 | url = new URL(urlStr); 21 | HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); 22 | buffer = new BufferedReader( 23 | new InputStreamReader( 24 | urlConn.getInputStream() 25 | ) 26 | ); 27 | while ((line = buffer.readLine()) != null) { 28 | sb.append(line); 29 | } 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | } finally { 33 | try { 34 | buffer.close(); 35 | } catch (Exception e) { 36 | e.printStackTrace(); 37 | } 38 | } 39 | return sb.toString(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/model/Meizhi.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi.model; 2 | 3 | import org.litepal.crud.DataSupport; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * Created by drakeet on 6/20/15. 9 | */ 10 | public class Meizhi extends DataSupport implements Serializable { 11 | 12 | private String mid; 13 | private String url; 14 | private int thumbWidth; 15 | private int thumbHeight; 16 | 17 | public Meizhi(String id, String url) { 18 | this.mid = id; 19 | this.url = url; 20 | } 21 | 22 | public Meizhi(String mid, String url, int thumbWidth, int thumbHeight) { 23 | this.mid = mid; 24 | this.url = url; 25 | this.thumbWidth = thumbWidth; 26 | this.thumbHeight = thumbHeight; 27 | } 28 | 29 | public Meizhi() { 30 | } 31 | 32 | public int getThumbWidth() { 33 | return thumbWidth; 34 | } 35 | 36 | public void setThumbWidth(int thumbWidth) { 37 | this.thumbWidth = thumbWidth; 38 | } 39 | 40 | public int getThumbHeight() { 41 | return thumbHeight; 42 | } 43 | 44 | public void setThumbHeight(int thumbHeight) { 45 | this.thumbHeight = thumbHeight; 46 | } 47 | 48 | public String getMid() { 49 | return mid; 50 | } 51 | 52 | public void setMid(String id) { 53 | this.mid = id; 54 | } 55 | 56 | public String getUrl() { 57 | return url; 58 | } 59 | 60 | public void setUrl(String url) { 61 | this.url = url; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return getMid() + "-->, \"" + getThumbWidth() + "\", " + "\"" + getThumbHeight() + "\""; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_meizhi.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 20 | 21 | 28 | 29 | 37 | 38 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 10 | 11 | 12 | 13 | 18 | 19 | 23 | 24 | 25 | 26 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/SwipeRefreshBaseActivity.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.widget.SwipeRefreshLayout; 5 | 6 | import me.drakeet.meizhi.widget.MultiSwipeRefreshLayout; 7 | 8 | 9 | /** 10 | * Created by drakeet on 1/3/15. 11 | */ 12 | public abstract class SwipeRefreshBaseActivity extends ToolbarActivity { 13 | 14 | MultiSwipeRefreshLayout mSwipeRefreshLayout; 15 | 16 | @Override 17 | protected void onPostCreate(Bundle savedInstanceState) { 18 | super.onPostCreate(savedInstanceState); 19 | trySetupSwipeRefresh(); 20 | } 21 | 22 | void trySetupSwipeRefresh() { 23 | mSwipeRefreshLayout = (MultiSwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout); 24 | if (mSwipeRefreshLayout != null) { 25 | mSwipeRefreshLayout.setColorSchemeResources( 26 | R.color.refresh_progress_3, 27 | R.color.refresh_progress_2, 28 | R.color.refresh_progress_1 29 | ); 30 | mSwipeRefreshLayout.setOnRefreshListener( 31 | new SwipeRefreshLayout.OnRefreshListener() { 32 | @Override 33 | public void onRefresh() { 34 | requestDataRefresh(); 35 | } 36 | } 37 | ); 38 | } 39 | } 40 | 41 | public void requestDataRefresh() {} 42 | 43 | public void setRefreshing(boolean refreshing) { 44 | if (mSwipeRefreshLayout == null) { 45 | return; 46 | } 47 | if (!refreshing) { 48 | mSwipeRefreshLayout.setRefreshing(false); 49 | } else { 50 | mSwipeRefreshLayout.setRefreshing(true); 51 | } 52 | } 53 | 54 | public void setProgressViewOffset(boolean scale, int start, int end) { 55 | mSwipeRefreshLayout.setProgressViewOffset(scale, start, end); 56 | } 57 | 58 | public void setSwipeableChildren( 59 | MultiSwipeRefreshLayout.CanChildScrollUpCallback canChildScrollUpCallback) { 60 | mSwipeRefreshLayout.setCanChildScrollUpCallback( 61 | canChildScrollUpCallback 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/widget/FABAutoHideBehavior.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi.widget; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.os.Build; 6 | import android.support.design.widget.CoordinatorLayout; 7 | import android.support.design.widget.FloatingActionButton; 8 | import android.util.AttributeSet; 9 | import android.view.MotionEvent; 10 | import android.view.View; 11 | import android.view.ViewTreeObserver; 12 | 13 | import me.drakeet.meizhi.R; 14 | 15 | /* 16 | * A hacky Behavior class for FloatingActionButton to collapse 17 | * With the AppBarLayout 18 | * Only works with a collapsing toolbar (AppBarLayout) 19 | * 20 | */ 21 | public class FABAutoHideBehavior extends CoordinatorLayout.Behavior 22 | { 23 | public FABAutoHideBehavior(Context context, AttributeSet attrs) { 24 | super(context, attrs); 25 | } 26 | 27 | @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 28 | @Override 29 | public boolean onInterceptTouchEvent(final CoordinatorLayout parent, final View child, MotionEvent ev) { 30 | if (!(child instanceof FloatingActionButton)) throw new IllegalArgumentException("Cannot work for non-FAB views"); 31 | 32 | CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams(); 33 | View anchor = parent.findViewById(lp.getAnchorId()); 34 | 35 | if (anchor == null) { 36 | throw new IllegalStateException("must be anchored"); 37 | } 38 | 39 | Object tag = anchor.getTag(R.id.appbar); 40 | 41 | if (tag == null) tag = false; 42 | 43 | if (!Boolean.parseBoolean(tag.toString())) { 44 | final View appbar = parent.findViewById(R.id.appbar); 45 | final View toolbar = parent.findViewById(R.id.toolbar); 46 | 47 | anchor.getViewTreeObserver().addOnDrawListener(new ViewTreeObserver.OnDrawListener() { 48 | @Override 49 | public void onDraw() { 50 | int childHeight = child.getMeasuredHeight() + (parent.getMeasuredHeight() - child.getBottom()); 51 | int toolbarHeight = toolbar.getMeasuredHeight(); 52 | float translationY = appbar.getTranslationY(); 53 | child.setTranslationY(- translationY / (float) toolbarHeight * childHeight); 54 | } 55 | }); 56 | 57 | anchor.setTag(R.id.appbar, true); 58 | } 59 | 60 | return super.onInterceptTouchEvent(parent, child, ev); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/ToolbarActivity.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi; 2 | 3 | import android.os.Build; 4 | import android.os.Bundle; 5 | import android.support.design.widget.AppBarLayout; 6 | import android.support.design.widget.TabLayout; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.Toolbar; 9 | import android.view.MenuItem; 10 | import android.view.View; 11 | import android.view.animation.DecelerateInterpolator; 12 | 13 | public abstract class ToolbarActivity extends AppCompatActivity { 14 | 15 | abstract protected int getLayoutResource(); 16 | 17 | public void onToolbarClick() {} 18 | 19 | protected AppBarLayout mAppBar; 20 | protected Toolbar mToolbar; 21 | protected TabLayout mTabLayout; 22 | protected boolean isHidden = false; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(getLayoutResource()); 28 | 29 | mAppBar = (AppBarLayout) findViewById(R.id.appbar); 30 | mToolbar = (Toolbar) findViewById(R.id.toolbar); 31 | 32 | if (mToolbar == null || mAppBar == null) { 33 | throw new IllegalStateException("no toolbar"); 34 | } 35 | 36 | mToolbar.setOnClickListener( 37 | new View.OnClickListener() { 38 | @Override 39 | public void onClick(View v) { 40 | onToolbarClick(); 41 | } 42 | } 43 | ); 44 | 45 | setSupportActionBar(mToolbar); 46 | 47 | if (Build.VERSION.SDK_INT >= 21) { 48 | mAppBar.setElevation(10.6f); 49 | } 50 | 51 | } 52 | 53 | @Override 54 | public boolean onOptionsItemSelected(MenuItem item) { 55 | if (item.getItemId() == android.R.id.home) { 56 | onBackPressed(); 57 | return true; 58 | } else { 59 | return super.onOptionsItemSelected(item); 60 | } 61 | } 62 | 63 | protected void setAppBarAlpha(float alpha) { 64 | mAppBar.setAlpha(alpha); 65 | } 66 | 67 | protected void hideOrShowToolbar() { 68 | mAppBar.animate() 69 | .translationY(isHidden ? 0 : -mAppBar.getHeight()) 70 | .setInterpolator(new DecelerateInterpolator(2)) 71 | .start(); 72 | 73 | isHidden = !isHidden; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/PictureActivity.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.view.ViewCompat; 5 | import android.view.Menu; 6 | import android.view.MenuItem; 7 | import android.view.View; 8 | import android.widget.ImageView; 9 | 10 | import com.squareup.picasso.Picasso; 11 | 12 | import uk.co.senab.photoview.PhotoViewAttacher; 13 | 14 | public class PictureActivity extends ToolbarActivity { 15 | 16 | public static final String EXTRA_IMAGE_URL = "image_url"; 17 | public static final String EXTRA_IMAGE_TITLE = "image_title"; 18 | public static final String TRANSIT_PIC = "picture"; 19 | 20 | private ImageView mImageView; 21 | private PhotoViewAttacher mPhotoViewAttacher; 22 | 23 | @Override 24 | protected int getLayoutResource() { 25 | return R.layout.activity_picture; 26 | } 27 | 28 | @Override 29 | protected void onCreate(Bundle savedInstanceState) { 30 | super.onCreate(savedInstanceState); 31 | mImageView = (ImageView) findViewById(R.id.picture); 32 | mPhotoViewAttacher = new PhotoViewAttacher(mImageView); 33 | Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE_URL)).into(mImageView); 34 | 35 | setAppBarAlpha(0.7f); 36 | setTitle(getIntent().getStringExtra(EXTRA_IMAGE_TITLE)); 37 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 38 | 39 | ViewCompat.setTransitionName(mImageView, TRANSIT_PIC); 40 | 41 | mPhotoViewAttacher.setOnViewTapListener( 42 | new PhotoViewAttacher.OnViewTapListener() { 43 | @Override 44 | public void onViewTap(View view, float v, float v1) { 45 | hideOrShowToolbar(); 46 | } 47 | } 48 | ); 49 | } 50 | 51 | @Override 52 | public boolean onCreateOptionsMenu(Menu menu) { 53 | // Inflate the menu; this adds items to the action bar if it is present. 54 | getMenuInflater().inflate(R.menu.menu_picture, menu); 55 | return true; 56 | } 57 | 58 | @Override 59 | public boolean onOptionsItemSelected(MenuItem item) { 60 | // Handle action bar item clicks here. The action bar will 61 | // automatically handle clicks on the Home/Up button, so long 62 | // as you specify a parent activity in AndroidManifest.xml. 63 | int id = item.getItemId(); 64 | 65 | //noinspection SimplifiableIfStatement 66 | if (id == R.id.action_settings) { 67 | return true; 68 | } 69 | 70 | return super.onOptionsItemSelected(item); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/widget/MultiSwipeRefreshLayout.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package me.drakeet.meizhi.widget; 18 | 19 | import android.content.Context; 20 | import android.content.res.TypedArray; 21 | import android.graphics.drawable.Drawable; 22 | import android.support.v4.widget.SwipeRefreshLayout; 23 | import android.util.AttributeSet; 24 | 25 | import me.drakeet.meizhi.R; 26 | 27 | 28 | /** 29 | * Created by drakeet on 1/3/15. 30 | */ 31 | public class MultiSwipeRefreshLayout extends SwipeRefreshLayout { 32 | 33 | private CanChildScrollUpCallback mCanChildScrollUpCallback; 34 | 35 | private Drawable mForegroundDrawable; 36 | 37 | public MultiSwipeRefreshLayout(Context context) { 38 | this(context, null); 39 | } 40 | 41 | public MultiSwipeRefreshLayout(Context context, AttributeSet attrs) { 42 | super(context, attrs); 43 | final TypedArray a = context.obtainStyledAttributes(attrs, 44 | R.styleable.MultiSwipeRefreshLayout, 0, 0); 45 | 46 | mForegroundDrawable = a.getDrawable(R.styleable.MultiSwipeRefreshLayout_foreground); 47 | if (mForegroundDrawable != null) { 48 | mForegroundDrawable.setCallback(this); 49 | setWillNotDraw(false); 50 | } 51 | a.recycle(); 52 | } 53 | 54 | @Override 55 | protected void onSizeChanged(int w, int h, int oldw, int oldh) { 56 | super.onSizeChanged(w, h, oldw, oldh); 57 | if (mForegroundDrawable != null) { 58 | mForegroundDrawable.setBounds(0, 0, w, h); 59 | } 60 | } 61 | 62 | public void setCanChildScrollUpCallback(CanChildScrollUpCallback canChildScrollUpCallback) { 63 | mCanChildScrollUpCallback = canChildScrollUpCallback; 64 | } 65 | 66 | public interface CanChildScrollUpCallback { 67 | boolean canSwipeRefreshChildScrollUp(); 68 | } 69 | 70 | @Override 71 | public boolean canChildScrollUp() { 72 | if (mCanChildScrollUpCallback != null) { 73 | return mCanChildScrollUpCallback.canSwipeRefreshChildScrollUp(); 74 | } 75 | return super.canChildScrollUp(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/WebviewActivity.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi; 2 | 3 | import android.content.Context; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.KeyEvent; 7 | import android.webkit.WebChromeClient; 8 | import android.webkit.WebView; 9 | import android.widget.Toast; 10 | 11 | import com.daimajia.numberprogressbar.NumberProgressBar; 12 | 13 | import me.drakeet.meizhi.model.Meizhi; 14 | 15 | public class WebViewActivity extends AppCompatActivity { 16 | 17 | private NumberProgressBar mProgressbar; 18 | private Context mContext; 19 | private WebView mWebView; 20 | private Meizhi meizhi; 21 | 22 | @Override 23 | protected void onCreate(Bundle savedInstanceState) { 24 | super.onCreate(savedInstanceState); 25 | mContext = this; 26 | meizhi = (Meizhi) getIntent().getSerializableExtra("meizhi"); 27 | if (meizhi == null) { 28 | Toast.makeText(mContext, "Oh No.", Toast.LENGTH_SHORT).show(); 29 | finish(); 30 | } 31 | setContentView(R.layout.activity_webview); 32 | mWebView = (WebView) findViewById(R.id.webview); 33 | mProgressbar = (NumberProgressBar) findViewById(R.id.progressbar); 34 | mWebView.getSettings().setJavaScriptEnabled(true); 35 | mWebView.setWebChromeClient(new WebChrome()); 36 | mWebView.getSettings().setLoadWithOverviewMode(true); 37 | mWebView.getSettings().setAppCacheEnabled(true); 38 | mWebView.loadUrl("http://gank.io/" + meizhi.getMid()); 39 | } 40 | 41 | @Override 42 | public boolean onKeyDown(int keyCode, KeyEvent event) { 43 | if (event.getAction() == KeyEvent.ACTION_DOWN) { 44 | switch (keyCode) { 45 | case KeyEvent.KEYCODE_BACK: 46 | if (mWebView.canGoBack()) { 47 | mWebView.goBack(); 48 | } else { 49 | finish(); 50 | } 51 | return true; 52 | } 53 | 54 | } 55 | return super.onKeyDown(keyCode, event); 56 | } 57 | 58 | @Override 59 | protected void onDestroy() { 60 | super.onDestroy(); 61 | if (mWebView != null) 62 | mWebView.destroy(); 63 | } 64 | 65 | @Override 66 | protected void onPause() { 67 | if (mWebView != null) 68 | mWebView.onPause(); 69 | super.onPause(); 70 | } 71 | 72 | @Override 73 | protected void onResume() { 74 | super.onResume(); 75 | if (mWebView != null) 76 | mWebView.onResume(); 77 | } 78 | 79 | private class WebChrome extends WebChromeClient { 80 | @Override 81 | public void onProgressChanged(WebView view, int newProgress) { 82 | super.onProgressChanged(view, newProgress); 83 | mProgressbar.setProgress(newProgress); 84 | } 85 | 86 | @Override 87 | public void onReceivedTitle(WebView view, String title) { 88 | super.onReceivedTitle(view, title); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | def releaseTime() { 4 | return new Date().format("yyyy-MM-dd", TimeZone.getTimeZone("UTC")) 5 | } 6 | 7 | android { 8 | compileSdkVersion 22 9 | buildToolsVersion "22.0.1" 10 | 11 | defaultConfig { 12 | applicationId "me.drakeet.meizhi" 13 | minSdkVersion 14 14 | targetSdkVersion 22 15 | versionCode 13 16 | versionName "1.0.2" 17 | } 18 | sourceSets { 19 | main { 20 | jniLibs.srcDirs = ['libs'] 21 | } 22 | } 23 | 24 | packagingOptions { 25 | exclude 'META-INF/DEPENDENCIES.txt' 26 | exclude 'META-INF/LICENSE.txt' 27 | exclude 'META-INF/NOTICE.txt' 28 | exclude 'META-INF/NOTICE' 29 | exclude 'META-INF/LICENSE' 30 | exclude 'META-INF/DEPENDENCIES' 31 | exclude 'META-INF/notice.txt' 32 | exclude 'META-INF/license.txt' 33 | exclude 'META-INF/dependencies.txt' 34 | exclude 'META-INF/LGPL2.1' 35 | } 36 | 37 | lintOptions { 38 | disable 'MissingTranslation', 'ExtraTranslation' 39 | } 40 | 41 | lintOptions { 42 | abortOnError false 43 | } 44 | 45 | signingConfigs { 46 | app1 { 47 | storeFile file("s.keystore") 48 | storePassword STOREPASS 49 | keyAlias KEYALIAS 50 | keyPassword KEYPASS 51 | } 52 | } 53 | 54 | buildTypes { 55 | release { 56 | // 不显示Log 57 | buildConfigField "boolean", "LOG_DEBUG", "false" 58 | 59 | debuggable false 60 | minifyEnabled false 61 | shrinkResources false 62 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 63 | signingConfig signingConfigs.app1 64 | 65 | applicationVariants.all { variant -> 66 | variant.outputs.each { output -> 67 | def outputFile = output.outputFile 68 | if (outputFile != null && outputFile.name.endsWith('.apk')) { 69 | // 输出apk名称为boohee_v1.0_2015-01-15_wandoujia.apk 70 | def fileName = "Meizhi_v${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk" 71 | output.outputFile = new File(outputFile.parent, fileName) 72 | } 73 | } 74 | } 75 | } 76 | 77 | productFlavors { 78 | Xiaomi { 79 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "Xiaomi"] 80 | } 81 | _360 { 82 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "360"] 83 | } 84 | Baidu { 85 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "Baidu"] 86 | } 87 | Wandoujia { 88 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "Wandoujia"] 89 | } 90 | fir { 91 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "fir"] 92 | } 93 | Umeng { 94 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "Umeng"] 95 | } 96 | GooglePlay { 97 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "GooglePlay"] 98 | } 99 | Meizu { 100 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "Meizu"] 101 | } 102 | Huawei { 103 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "Huawei"] 104 | } 105 | QQ { 106 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "QQ"] 107 | } 108 | PP { 109 | manifestPlaceholders = [UMENG_CHANNEL_VALUE: "PP"] 110 | } 111 | } 112 | } 113 | } 114 | 115 | dependencies { 116 | compile fileTree(dir: 'libs', include: ['*.jar']) 117 | compile 'com.android.support:appcompat-v7:22.2.0' 118 | compile 'com.android.support:recyclerview-v7:22.2.0' 119 | compile 'com.squareup.picasso:picasso:2.5.2' 120 | compile 'com.android.support:cardview-v7:22.2.0' 121 | compile 'com.android.support:design:22.2.0' 122 | compile 'com.github.chrisbanes.photoview:library:1.2.3' 123 | compile 'com.daimajia.numberprogressbar:library:1.2@aar' 124 | } 125 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/MeizhiListAdapter.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.support.v4.app.ActivityCompat; 7 | import android.support.v4.app.ActivityOptionsCompat; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.view.ViewTreeObserver; 13 | import android.widget.ImageView; 14 | import android.widget.TextView; 15 | 16 | import com.squareup.picasso.Picasso; 17 | 18 | import java.util.List; 19 | 20 | import me.drakeet.meizhi.model.Meizhi; 21 | 22 | /** 23 | * Created by drakeet on 6/20/15. 24 | */ 25 | public class MeizhiListAdapter extends RecyclerView.Adapter { 26 | 27 | private List mList; 28 | private Context mContext; 29 | 30 | public MeizhiListAdapter(Context context, List meizhiList) { 31 | mList = meizhiList; 32 | mContext = context; 33 | } 34 | 35 | @Override 36 | public ViewHolder onCreateViewHolder(ViewGroup parent, int i) { 37 | View v = LayoutInflater.from(parent.getContext()) 38 | .inflate(R.layout.item_meizhi, parent, false); 39 | return new ViewHolder(v); 40 | } 41 | 42 | @Override 43 | public void onBindViewHolder(final ViewHolder viewHolder, final int position) { 44 | Meizhi meizhi = mList.get(position); 45 | viewHolder.meizhi = meizhi; 46 | viewHolder.titleView.setText(meizhi.getMid()); 47 | viewHolder.card.setTag(meizhi.getMid()); 48 | ViewTreeObserver vto = viewHolder.meizhiView.getViewTreeObserver(); 49 | vto.addOnGlobalLayoutListener( 50 | new ViewTreeObserver.OnGlobalLayoutListener() { 51 | @Override 52 | public void onGlobalLayout() { 53 | int thumbWidth = viewHolder.meizhi.getThumbWidth(); 54 | int thumbHeight = viewHolder.meizhi.getThumbHeight(); 55 | if (thumbWidth > 0 && thumbHeight > 0) { 56 | int width = viewHolder.meizhiView.getMeasuredWidth(); 57 | int height = Math.round(width * ((float) thumbHeight / thumbWidth)); 58 | viewHolder.meizhiView.getLayoutParams().height = height; 59 | viewHolder.meizhiView.setMinimumHeight(height); 60 | } 61 | viewHolder.meizhiView.getViewTreeObserver().removeGlobalOnLayoutListener(this); 62 | } 63 | } 64 | ); 65 | 66 | Picasso.with(mContext).load(meizhi.getUrl()).into(viewHolder.meizhiView); 67 | } 68 | 69 | @Override 70 | public void onViewRecycled(ViewHolder holder) { 71 | super.onViewRecycled(holder); 72 | if (holder.meizhiView != null) holder.meizhiView.setImageBitmap(null); 73 | } 74 | 75 | @Override 76 | public int getItemCount() { 77 | return mList.size(); 78 | } 79 | 80 | public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { 81 | 82 | Meizhi meizhi; 83 | ImageView meizhiView; 84 | TextView titleView; 85 | View card; 86 | 87 | public ViewHolder(View itemView) { 88 | super(itemView); 89 | card = itemView; 90 | meizhiView = (ImageView) itemView.findViewById(R.id.iv_meizhi); 91 | titleView = (TextView) itemView.findViewById(R.id.tv_title); 92 | meizhiView.setOnClickListener(this); 93 | card.setOnClickListener(this); 94 | } 95 | 96 | @Override 97 | public void onClick(View v) { 98 | if (meizhi == null) 99 | return; 100 | if (v == meizhiView) { 101 | Intent i = new Intent(mContext, PictureActivity.class); 102 | i.putExtra(PictureActivity.EXTRA_IMAGE_URL, meizhi.getUrl()); 103 | i.putExtra(PictureActivity.EXTRA_IMAGE_TITLE, meizhi.getMid()); 104 | 105 | if (mContext instanceof Activity) { 106 | ActivityOptionsCompat optionsCompat = ActivityOptionsCompat.makeSceneTransitionAnimation( 107 | (Activity) mContext, meizhiView, PictureActivity.TRANSIT_PIC 108 | ); 109 | ActivityCompat.startActivity((Activity) mContext, i, optionsCompat.toBundle()); 110 | } else { 111 | mContext.startActivity(i); 112 | } 113 | } else if (v == card) { 114 | Intent intent = new Intent(mContext, WebViewActivity.class); 115 | intent.putExtra("meizhi", meizhi); 116 | mContext.startActivity(intent); 117 | } 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/OldMeizhi.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi; 2 | 3 | import org.litepal.crud.DataSupport; 4 | 5 | import java.util.List; 6 | 7 | import me.drakeet.meizhi.model.Meizhi; 8 | 9 | /** 10 | * Created by drakeet on 6/21/15. 11 | */ 12 | public class OldMeizhi { 13 | 14 | public static boolean init() { 15 | List qList = DataSupport.where("mid = ?", "2015/06/19").find(Meizhi.class); 16 | if (qList.size() > 0) { 17 | return true; 18 | } 19 | // 以下内容乃自动化生成,大家不用替俺担心~~ 20 | new Meizhi("2015/03/26", "今天没有妹纸", 162, 174).save(); 21 | new Meizhi("2015/03/30", "http://ww2.sinaimg.cn/large/610dc034gw1eqnjfdn45qj20h30mk443.jpg", 450, 594).save(); 22 | new Meizhi("2015/03/31", "http://ww2.sinaimg.cn/large/610dc034gw1eqoqwkyy8cj20h20h10wz.jpg", 401, 400).save(); 23 | new Meizhi("2015/04/01", "http://ww4.sinaimg.cn/large/610dc034gw1eqpx7qtursj20go0go779.jpg", 300, 300).save(); 24 | new Meizhi("2015/04/02", "http://ww3.sinaimg.cn/large/610dc034gw1eqr2vp3xtcj20m80m8jwd.jpg", 400, 400).save(); 25 | new Meizhi("2015/04/03", "http://ww3.sinaimg.cn/large/610dc034gw1eqs82kt4e9j20m80tnwjo.jpg", 400, 534).save(); 26 | new Meizhi("2015/04/07", "http://ww3.sinaimg.cn/large/610dc034gw1eqwuw1t94yj20ga0ib405.jpg", 400, 450).save(); 27 | new Meizhi("2015/04/08", "http://ww4.sinaimg.cn/large/610dc034gw1eqxzn23bc3j20m80etjuo.jpg", 500, 333).save(); 28 | new Meizhi("2015/04/09", "http://ww2.sinaimg.cn/large/610dc034gw1eqz66m9qctj20go0okdif.jpg", 450, 663).save(); 29 | new Meizhi("2015/04/10", "http://ww1.sinaimg.cn/large/610dc034gw1er0c8agag2j20m80bjt93.jpg", 549, 285).save(); 30 | new Meizhi("2015/04/13", "http://ww2.sinaimg.cn/large/610dc034jw1er3t0hhn8dj20m80tn76d.jpg", 450, 600).save(); 31 | new Meizhi("2015/04/14", "http://ww3.sinaimg.cn/large/610dc034gw1er4yt4dy15j20m80etwff.jpg", 500, 333).save(); 32 | new Meizhi("2015/04/15", "http://ww1.sinaimg.cn/large/610dc034gw1er645i2y90j20hb0kimyr.jpg", 623, 738).save(); 33 | new Meizhi("2015/04/16", "http://ww3.sinaimg.cn/large/610dc034gw1er79vdrfvqj20b40jraao.jpg", 400, 711).save(); 34 | new Meizhi("2015/04/17", "http://ww2.sinaimg.cn/large/610dc034gw1er8fhea7vnj20b40deq3i.jpg", 400, 482).save(); 35 | new Meizhi("2015/04/20", "http://ww3.sinaimg.cn/large/610dc034gw1erbum2ltm6j20go0caab3.jpg", 600, 442).save(); 36 | new Meizhi("2015/04/21", "http://ww3.sinaimg.cn/large/610dc034gw1erd1rhreacj20m80efjsd.jpg", 640, 415).save(); 37 | new Meizhi("2015/04/22", "http://ww2.sinaimg.cn/large/610dc034gw1ere7awhfj0j20go0b3dg8.jpg", 600, 399).save(); 38 | new Meizhi("2015/04/23", "http://ww4.sinaimg.cn/large/610dc034gw1erfcxwxlvuj20m80gzmyw.jpg", 640, 489).save(); 39 | new Meizhi("2015/04/24", "http://ww4.sinaimg.cn/large/610dc034gw1ergiue1xlbj20m80gq757.jpg", 450, 339).save(); 40 | new Meizhi("2015/04/27", "http://ww3.sinaimg.cn/large/610dc034gw1erjtx9odarj20m80e2mxw.jpg", 640, 405).save(); 41 | new Meizhi("2015/04/29", "http://ww3.sinaimg.cn/large/610dc034gw1erm9yr0v83j20m80snjt2.jpg", 450, 580).save(); 42 | new Meizhi("2015/04/30", "http://ww4.sinaimg.cn/large/610dc034gw1erng5ktg5ij20m80eumy7.jpg", 450, 300).save(); 43 | new Meizhi("2015/05/04", "http://ww1.sinaimg.cn/large/610dc034gw1ers1ue9tizj20m80euq3k.jpg", 480, 320).save(); 44 | new Meizhi("2015/05/06", "http://ww3.sinaimg.cn/large/610dc034jw1erudbbww3xj20go0p075j.jpg", 480, 720).save(); 45 | new Meizhi("2015/05/07", "http://ww1.sinaimg.cn/large/610dc034gw1ervje0eqqbj20b40gmjry.jpg", 384, 580).save(); 46 | new Meizhi("2015/05/08", "http://ww3.sinaimg.cn/large/610dc034gw1erwpilp4kjj20go0p00tr.jpg", 480, 720).save(); 47 | new Meizhi("2015/05/11", "http://ww1.sinaimg.cn/large/610dc034jw1es0jgf2v91j20go0p2ab1.jpg", 480, 722).save(); 48 | new Meizhi("2015/05/12", "http://ww2.sinaimg.cn/large/610dc034gw1es1dap6rvgj20m80eugmi.jpg", 480, 320).save(); 49 | new Meizhi("2015/05/13", "http://ww1.sinaimg.cn/large/610dc034jw1es2hkc090aj20go0p0dgu.jpg", 480, 720).save(); 50 | new Meizhi("2015/05/14", "http://ww3.sinaimg.cn/large/610dc034jw1es3mty6nm2j20go0n60t9.jpg", 600, 834).save(); 51 | new Meizhi("2015/05/15", "http://ww2.sinaimg.cn/large/610dc034gw1es4si7kzebj20m80eu0te.jpg", 450, 300).save(); 52 | new Meizhi("2015/05/18", "http://ww3.sinaimg.cn/large/610dc034gw1es89uzch20j20pw0xcadb.jpg", 400, 515).save(); 53 | new Meizhi("2015/05/19", "今天没有妹纸", 640, 246).save(); 54 | new Meizhi("2015/05/20", "http://ww1.sinaimg.cn/large/7a8aed7bgw1esahpyv86sj20hs0qomzo.jpg", 400, 600).save(); 55 | new Meizhi("2015/05/21", "http://ww2.sinaimg.cn/large/7a8aed7bgw1esbmanpn0tj20hr0qo0w8.jpg", 400, 601).save(); 56 | new Meizhi("2015/05/22", "http://ww1.sinaimg.cn/large/7a8aed7bgw1escs1cl4f5j20qo0jsn3m.jpg", 450, 334).save(); 57 | new Meizhi("2015/05/25", "http://ww4.sinaimg.cn/large/7a8aed7bgw1esfbgw6vc3j20gy0pedic.jpg", 480, 719).save(); 58 | new Meizhi("2015/05/26", "http://ww4.sinaimg.cn/large/7a8aed7bgw1eshfawk6bmj20hs0qo41i.jpg", 640, 960).save(); 59 | new Meizhi("2015/05/27", "http://ww1.sinaimg.cn/large/7a8aed7bgw1esijbxxwkfj20f00qotb6.jpg", 540, 960).save(); 60 | new Meizhi("2015/05/28", "http://ww4.sinaimg.cn/large/7a8aed7bgw1esjpu1vxggj20qo0hrgqw.jpg", 650, 433).save(); // 代码家[笑哭] 61 | new Meizhi("2015/05/29", "http://ww3.sinaimg.cn/large/7a8aed7bgw1esk47n9j93j20hs0qoacp.jpg", 500, 750).save(); 62 | new Meizhi("2015/06/01", "http://ww1.sinaimg.cn/large/610dc034jw1esofhleczfj20qo0hsgoq.jpg", 600, 373).save(); 63 | new Meizhi("2015/06/02", "http://ww1.sinaimg.cn/large/7a8aed7bgw1esojpl5gmgj20qo0hstbs.jpg", 650, 433).save(); 64 | new Meizhi("2015/06/03", "http://ww3.sinaimg.cn/large/7a8aed7bgw1esq1f0899qj20hs0qo780.jpg", 600, 900).save(); 65 | new Meizhi("2015/06/04", "http://ww2.sinaimg.cn/large/7a8aed7bgw1esr71e2oulj20gz0pb40u.jpg", 550, 820).save(); 66 | new Meizhi("2015/06/05", "http://ww2.sinaimg.cn/large/7a8aed7bgw1essxtqxs6jj20mj0tzdhl.jpg", 493, 655).save(); 67 | new Meizhi("2015/06/08", "http://ww1.sinaimg.cn/large/7a8aed7bgw1eswem6zx1mj20qo0hrwgs.jpg", 650, 433).save(); 68 | new Meizhi("2015/06/09", "http://ww4.sinaimg.cn/large/7a8aed7bgw1eswx1z5iu6j20hs0qo428.jpg", 600, 900).save(); 69 | new Meizhi("2015/06/10", "http://ww1.sinaimg.cn/large/7a8aed7bgw1esxxiw20rej20qo0hstcp.jpg", 650, 433).save(); 70 | new Meizhi("2015/06/11", "http://ww2.sinaimg.cn/large/7a8aed7bgw1esz3jq17foj20hs0qodj9.jpg", 550, 825).save(); 71 | new Meizhi("2015/06/12", "http://ww4.sinaimg.cn/large/7a8aed7bgw1et11xp5wwij20hs0qotb2.jpg", 640, 960).save(); 72 | new Meizhi("2015/06/15", "http://ww4.sinaimg.cn/large/7a8aed7bgw1et3qjtenw1j20qo0hsdj3.jpg", 650, 433).save(); 73 | new Meizhi("2015/06/16", "http://ww3.sinaimg.cn/large/7a8aed7bgw1et5nl9mno8j20hs0qoacj.jpg", 450, 675).save(); 74 | new Meizhi("2015/06/17", "http://ww1.sinaimg.cn/large/7a8aed7bgw1et6yio5s7rj20hs0qogop.jpg", 450, 675).save(); 75 | new Meizhi("2015/06/18", "http://ww1.sinaimg.cn/large/7a8aed7bgw1et80fw2p80j20qo0hsdj1.jpg", 660, 440).save(); 76 | new Meizhi("2015/06/19", "http://ww3.sinaimg.cn/large/7a8aed7bgw1et95oadpnjj20qo0hs0vk.jpg", 720, 480).save(); 77 | 78 | return true; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /app/src/main/java/me/drakeet/meizhi/MainActivity.java: -------------------------------------------------------------------------------- 1 | package me.drakeet.meizhi; 2 | 3 | import android.os.AsyncTask; 4 | import android.os.Bundle; 5 | import android.os.Handler; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.support.v7.widget.StaggeredGridLayoutManager; 8 | import android.view.Menu; 9 | import android.view.MenuItem; 10 | import android.view.View; 11 | 12 | import org.litepal.crud.DataSupport; 13 | 14 | import java.util.ArrayList; 15 | import java.util.Calendar; 16 | import java.util.Date; 17 | import java.util.List; 18 | 19 | import me.drakeet.meizhi.model.Meizhi; 20 | import me.drakeet.meizhi.util.DateUtils; 21 | import me.drakeet.meizhi.util.HttpUtils; 22 | import me.drakeet.meizhi.util.TaskUtils; 23 | import me.drakeet.meizhi.util.ToastUtils; 24 | 25 | public class MainActivity extends SwipeRefreshBaseActivity { 26 | 27 | RecyclerView mRecyclerView; 28 | Handler mHandler; 29 | MeizhiListAdapter mMeizhiListAdapter; 30 | List mMeizhiList; 31 | boolean mIsDbInited, mIsFirstTimeTouchBottom = true; 32 | int mOffset = 0; 33 | 34 | @Override 35 | protected int getLayoutResource() { 36 | return R.layout.activity_main; 37 | } 38 | 39 | @Override 40 | protected void onCreate(Bundle savedInstanceState) { 41 | super.onCreate(savedInstanceState); 42 | mHandler = new Handler(); 43 | mMeizhiList = new ArrayList<>(); 44 | setUpRecyclerView(); 45 | } 46 | 47 | @Override 48 | protected void onPostCreate(Bundle savedInstanceState) { 49 | super.onPostCreate(savedInstanceState); 50 | mHandler.postDelayed( 51 | new Runnable() { 52 | @Override 53 | public void run() { 54 | getData(); 55 | } 56 | }, 358 57 | ); 58 | } 59 | 60 | private void setUpRecyclerView() { 61 | mRecyclerView = (RecyclerView) findViewById(R.id.rv_meizhi); 62 | final StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager( 63 | 2, StaggeredGridLayoutManager.VERTICAL 64 | ); 65 | mRecyclerView.setLayoutManager(layoutManager); 66 | mMeizhiListAdapter = new MeizhiListAdapter(this, mMeizhiList); 67 | mRecyclerView.setAdapter(mMeizhiListAdapter); 68 | mRecyclerView.addOnScrollListener( 69 | new RecyclerView.OnScrollListener() { 70 | @Override 71 | public void onScrolled(RecyclerView rv, int dx, int dy) { 72 | if (!mSwipeRefreshLayout.isRefreshing() && layoutManager.findLastCompletelyVisibleItemPositions( 73 | new int[2] 74 | )[1] >= mMeizhiListAdapter.getItemCount() - 2) { 75 | if (!mIsFirstTimeTouchBottom) { 76 | mSwipeRefreshLayout.setRefreshing(true); 77 | mOffset += 20; 78 | getData(); 79 | } else { 80 | mIsFirstTimeTouchBottom = false; 81 | } 82 | } 83 | } 84 | } 85 | ); 86 | } 87 | 88 | private void getData(final boolean addFromDb) { 89 | setRefreshing(true); 90 | TaskUtils.executeAsyncTask( 91 | new AsyncTask() { 92 | @Override 93 | protected Boolean doInBackground(Object... params) { 94 | if (!mIsDbInited) { 95 | mIsDbInited = OldMeizhi.init(); 96 | } 97 | HttpUtils httpUtils = new HttpUtils(); 98 | Calendar calendar = Calendar.getInstance(); 99 | Date today = new Date(); 100 | calendar.set(2015, 5, 21); 101 | Date thatDay = calendar.getTime(); 102 | 103 | int oLength = mMeizhiList.size(); 104 | while (thatDay.compareTo(today) <= 0) { 105 | String dateString = DateUtils.toDate(thatDay); 106 | thatDay = DateUtils.getNextdayDate(thatDay); 107 | List qList = DataSupport.where("mid = ?", dateString).find(Meizhi.class); 108 | if (qList.size() > 0) { 109 | continue; 110 | } 111 | publishProgress(dateString); 112 | 113 | Meizhi meizhi = new Meizhi(); 114 | meizhi.setMid(dateString); 115 | 116 | String httpContent = httpUtils.download(getString(R.string.api) + dateString); 117 | int s0 = httpContent.indexOf(" meizhiList = DataSupport.offset(mOffset) 145 | .limit(20) 146 | .order("id desc") 147 | .find(Meizhi.class); 148 | for (Meizhi meizhi : meizhiList) { 149 | if (!meizhi.getUrl().equals(getString(R.string.no_data_the_day))) { 150 | mMeizhiList.add(meizhi); 151 | } 152 | } 153 | } 154 | return mMeizhiList.size() > oLength; 155 | } 156 | 157 | @Override 158 | protected void onProgressUpdate(Object... values) { 159 | super.onProgressUpdate(values); 160 | ToastUtils.showShort(getString(R.string.loading_num_of) + values[0]); 161 | } 162 | 163 | @Override 164 | protected void onPostExecute(Boolean o) { 165 | super.onPostExecute(o); 166 | if (o) 167 | mMeizhiListAdapter.notifyDataSetChanged(); 168 | setRefreshing(false); 169 | } 170 | } 171 | ); 172 | 173 | } 174 | 175 | private void getData() { 176 | getData(true); 177 | } 178 | 179 | @Override 180 | public void onToolbarClick() { 181 | super.onToolbarClick(); 182 | mRecyclerView.smoothScrollToPosition(0); 183 | } 184 | 185 | public void onFab(View v) { 186 | mRecyclerView.smoothScrollToPosition(0); 187 | requestDataRefresh(); 188 | } 189 | 190 | @Override 191 | public void requestDataRefresh() { 192 | super.requestDataRefresh(); 193 | getData(/* add from db */ false); 194 | } 195 | 196 | @Override 197 | public boolean onCreateOptionsMenu(Menu menu) { 198 | // Inflate the menu; this adds items to the action bar if it is present. 199 | getMenuInflater().inflate(R.menu.menu_main, menu); 200 | return true; 201 | } 202 | 203 | @Override 204 | public boolean onOptionsItemSelected(MenuItem item) { 205 | // Handle action bar item clicks here. The action bar will 206 | // automatically handle clicks on the Home/Up button, so long 207 | // as you specify a parent activity in AndroidManifest.xml. 208 | int id = item.getItemId(); 209 | 210 | //noinspection SimplifiableIfStatement 211 | if (id == R.id.action_settings) { 212 | return true; 213 | } 214 | 215 | return super.onOptionsItemSelected(item); 216 | } 217 | 218 | } 219 | -------------------------------------------------------------------------------- /app/src/main/res/values/android_material_design_colours.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | #fde0dc 9 | #f9bdbb 10 | #f69988 11 | #f36c60 12 | #e84e40 13 | #e51c23 14 | #dd191d 15 | #d01716 16 | #c41411 17 | #b0120a 18 | #ff7997 19 | #ff5177 20 | #ff2d6f 21 | #e00032 22 | 23 | 24 | #fce4ec 25 | #f8bbd0 26 | #f48fb1 27 | #f06292 28 | #ec407a 29 | #e91e63 30 | #d81b60 31 | #c2185b 32 | #ad1457 33 | #880e4f 34 | #ff80ab 35 | #ff4081 36 | #f50057 37 | #c51162 38 | 39 | 40 | #f3e5f5 41 | #e1bee7 42 | #ce93d8 43 | #ba68c8 44 | #ab47bc 45 | #9c27b0 46 | #8e24aa 47 | #7b1fa2 48 | #6a1b9a 49 | #4a148c 50 | #ea80fc 51 | #e040fb 52 | #d500f9 53 | #aa00ff 54 | 55 | 56 | #ede7f6 57 | #d1c4e9 58 | #b39ddb 59 | #9575cd 60 | #7e57c2 61 | #673ab7 62 | #5e35b1 63 | #512da8 64 | #4527a0 65 | #311b92 66 | #b388ff 67 | #7c4dff 68 | #651fff 69 | #6200ea 70 | 71 | 72 | #e8eaf6 73 | #c5cae9 74 | #9fa8da 75 | #7986cb 76 | #5c6bc0 77 | #3f51b5 78 | #3949ab 79 | #303f9f 80 | #283593 81 | #1a237e 82 | #8c9eff 83 | #536dfe 84 | #3d5afe 85 | #304ffe 86 | 87 | 88 | #e7e9fd 89 | #d0d9ff 90 | #afbfff 91 | #91a7ff 92 | #738ffe 93 | #5677fc 94 | #4e6cef 95 | #455ede 96 | #3b50ce 97 | #2a36b1 98 | #a6baff 99 | #6889ff 100 | #4d73ff 101 | #4d69ff 102 | 103 | 104 | #e1f5fe 105 | #b3e5fc 106 | #81d4fa 107 | #4fc3f7 108 | #29b6f6 109 | #03a9f4 110 | #039be5 111 | #0288d1 112 | #0277bd 113 | #01579b 114 | #80d8ff 115 | #40c4ff 116 | #00b0ff 117 | #0091ea 118 | 119 | 120 | #e0f7fa 121 | #b2ebf2 122 | #80deea 123 | #4dd0e1 124 | #26c6da 125 | #00bcd4 126 | #00acc1 127 | #0097a7 128 | #00838f 129 | #006064 130 | #84ffff 131 | #18ffff 132 | #00e5ff 133 | #00b8d4 134 | 135 | 136 | #e0f2f1 137 | #b2dfdb 138 | #80cbc4 139 | #4db6ac 140 | #26a69a 141 | #009688 142 | #00897b 143 | #00796b 144 | #00695c 145 | #004d40 146 | #a7ffeb 147 | #64ffda 148 | #1de9b6 149 | #00bfa5 150 | 151 | 152 | #d0f8ce 153 | #a3e9a4 154 | #72d572 155 | #42bd41 156 | #2baf2b 157 | #259b24 158 | #0a8f08 159 | #0a7e07 160 | #056f00 161 | #0d5302 162 | #a2f78d 163 | #5af158 164 | #14e715 165 | #12c700 166 | 167 | 168 | #f1f8e9 169 | #dcedc8 170 | #c5e1a5 171 | #aed581 172 | #9ccc65 173 | #8bc34a 174 | #7cb342 175 | #689f38 176 | #558b2f 177 | #33691e 178 | #ccff90 179 | #b2ff59 180 | #76ff03 181 | #64dd17 182 | 183 | 184 | #f9fbe7 185 | #f0f4c3 186 | #e6ee9c 187 | #dce775 188 | #d4e157 189 | #cddc39 190 | #c0ca33 191 | #afb42b 192 | #9e9d24 193 | #827717 194 | #f4ff81 195 | #eeff41 196 | #c6ff00 197 | #aeea00 198 | 199 | 200 | #fffde7 201 | #fff9c4 202 | #fff59d 203 | #fff176 204 | #ffee58 205 | #ffeb3b 206 | #fdd835 207 | #fbc02d 208 | #f9a825 209 | #f57f17 210 | #ffff8d 211 | #ffff00 212 | #ffea00 213 | #ffd600 214 | 215 | 216 | #fff8e1 217 | #ffecb3 218 | #ffe082 219 | #ffd54f 220 | #ffca28 221 | #ffc107 222 | #ffb300 223 | #ffa000 224 | #ff8f00 225 | #ff6f00 226 | #ffe57f 227 | #ffd740 228 | #ffc400 229 | #ffab00 230 | 231 | 232 | #fff3e0 233 | #ffe0b2 234 | #ffcc80 235 | #ffb74d 236 | #ffa726 237 | #ff9800 238 | #fb8c00 239 | #f57c00 240 | #ef6c00 241 | #e65100 242 | #ffd180 243 | #ffab40 244 | #ff9100 245 | #ff6d00 246 | 247 | 248 | #fbe9e7 249 | #ffccbc 250 | #ffab91 251 | #ff8a65 252 | #ff7043 253 | #ff5722 254 | #f4511e 255 | #e64a19 256 | #d84315 257 | #bf360c 258 | #ff9e80 259 | #ff6e40 260 | #ff3d00 261 | #dd2c00 262 | 263 | 264 | #efebe9 265 | #d7ccc8 266 | #bcaaa4 267 | #a1887f 268 | #8d6e63 269 | #795548 270 | #6d4c41 271 | #5d4037 272 | #4e342e 273 | #3e2723 274 | 275 | 276 | #fafafa 277 | #f5f5f5 278 | #eeeeee 279 | #e0e0e0 280 | #bdbdbd 281 | #9e9e9e 282 | #757575 283 | #616161 284 | #424242 285 | #212121 286 | #000000 287 | #ffffff 288 | 289 | 290 | #eceff1 291 | #cfd8dc 292 | #b0bec5 293 | #90a4ae 294 | #78909c 295 | #607d8b 296 | #546e7a 297 | #455a64 298 | #37474f 299 | #263238 300 | 301 | --------------------------------------------------------------------------------