diff --git a/app/build.gradle b/app/build.gradle index fabf891..e95703b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,14 +2,14 @@ apply plugin: 'com.android.application' android { compileSdkVersion 23 - buildToolsVersion "23.0.1" + buildToolsVersion "23.0.2" defaultConfig { applicationId "com.aspsine.swipetoloadlayout" minSdkVersion 10 targetSdkVersion 23 - versionCode 1 - versionName "1.0.0" + versionCode 2 + versionName "1.0.2" } buildTypes { release { @@ -23,11 +23,11 @@ dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile project(':library') - compile 'com.android.support:appcompat-v7:23.1.0' - compile 'com.android.support:recyclerview-v7:23.1.0' - compile 'com.android.support:support-v4:23.1.0' - compile 'com.android.support:design:23.1.0' - compile 'com.google.code.gson:gson:2.3.1' + compile 'com.android.support:appcompat-v7:23.1.1' + compile 'com.android.support:recyclerview-v7:23.1.1' + compile 'com.android.support:support-v4:23.1.1' + compile 'com.android.support:design:23.1.1' + compile 'com.google.code.gson:gson:2.4' compile 'com.mcxiaoke.volley:library-aar:1.0.1' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE' diff --git a/app/src/main/java/com/aspsine/swipetoloadlayout/demo/App.java b/app/src/main/java/com/aspsine/swipetoloadlayout/demo/App.java index 5f50983..4f9516f 100644 --- a/app/src/main/java/com/aspsine/swipetoloadlayout/demo/App.java +++ b/app/src/main/java/com/aspsine/swipetoloadlayout/demo/App.java @@ -33,9 +33,7 @@ private void setStrictMode() { public static RequestQueue getRequestQueue() { if (sRequestQueue == null) { - synchronized (App.class) { - sRequestQueue = Volley.newRequestQueue(sContext); - } + sRequestQueue = Volley.newRequestQueue(sContext); } return sRequestQueue; } diff --git a/app/src/main/java/com/aspsine/swipetoloadlayout/demo/DataSource.java b/app/src/main/java/com/aspsine/swipetoloadlayout/demo/DataSource.java deleted file mode 100644 index 0c5e1bf..0000000 --- a/app/src/main/java/com/aspsine/swipetoloadlayout/demo/DataSource.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.aspsine.swipetoloadlayout.demo; - -/** - * Created by aspsine on 15/9/3. - */ -public class DataSource { - -} diff --git a/art/demo.apk b/art/demo.apk index a5b2178..61f7a39 100644 Binary files a/art/demo.apk and b/art/demo.apk differ diff --git a/library/build.gradle b/library/build.gradle index 96dcddb..8114e67 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -2,13 +2,13 @@ apply plugin: 'com.android.library' android { compileSdkVersion 23 - buildToolsVersion "23.0.1" + buildToolsVersion "23.0.2" defaultConfig { minSdkVersion 8 targetSdkVersion 23 - versionCode 1 - versionName "1.0.0" + versionCode 2 + versionName "1.0.2" } buildTypes { release { @@ -20,5 +20,5 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:23.0.1' + compile 'com.android.support:support-v4:23.1.1' } diff --git a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java index e1d3d8e..6ccf0ec 100644 --- a/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java +++ b/library/src/main/java/com/aspsine/swipetoloadlayout/SwipeToLoadLayout.java @@ -66,6 +66,11 @@ public class SwipeToLoadLayout extends ViewGroup { private boolean mHasFooterView; + /** + * indicate whether in debug mode + */ + private boolean mDebug; + /** * the threshold of the touch event */ @@ -74,7 +79,7 @@ public class SwipeToLoadLayout extends ViewGroup { /** * status of SwipeToLoadLayout */ - private byte mStatus = STATUS.STATUS_DEFAULT; + private int mStatus = STATUS.STATUS_DEFAULT; /** * target view top offset @@ -296,6 +301,15 @@ public SwipeToLoadLayout(Context context, AttributeSet attrs, int defStyleAttr) mAutoScroller = new AutoScroller(); } + /** + * set debug mode(default value false) + * + * @param debug if true log on, false log off + */ + public void setDebug(boolean debug) { + this.mDebug = debug; + } + /** * is refresh function is enabled * @@ -1491,9 +1505,11 @@ abstract class LoadMoreCallback implements SwipeTrigger, SwipeLoadMoreTrigger { * * @param status */ - private void setStatus(byte status) { + private void setStatus(int status) { mStatus = status; - STATUS.printStatus(status); + if (mDebug) { + STATUS.printStatus(status); + } } /** @@ -1501,73 +1517,73 @@ private void setStatus(byte status) { * enum of status */ private final static class STATUS { - private static final byte STATUS_REFRESH_RETURNING = -5; - private static final byte STATS_REFRESH_COMPLETE = -4; - private static final byte STATUS_REFRESHING = -3; - private static final byte STATUS_RELEASE_TO_REFRESH = -2; - private static final byte STATUS_SWIPING_TO_REFRESH = -1; - private static final byte STATUS_DEFAULT = 0; - private static final byte STATUS_SWIPING_TO_LOAD_MORE = 1; - private static final byte STATUS_RELEASE_TO_LOAD_MORE = 2; - private static final byte STATUS_LOADING_MORE = 3; - private static final byte STATUS_LOAD_MORE_COMPLETE = 4; - private static final byte STATUS_LOAD_MORE_RETURNING = 5; - - private static boolean isRefreshing(final byte status) { + private static final int STATUS_REFRESH_RETURNING = -5; + private static final int STATS_REFRESH_COMPLETE = -4; + private static final int STATUS_REFRESHING = -3; + private static final int STATUS_RELEASE_TO_REFRESH = -2; + private static final int STATUS_SWIPING_TO_REFRESH = -1; + private static final int STATUS_DEFAULT = 0; + private static final int STATUS_SWIPING_TO_LOAD_MORE = 1; + private static final int STATUS_RELEASE_TO_LOAD_MORE = 2; + private static final int STATUS_LOADING_MORE = 3; + private static final int STATUS_LOAD_MORE_COMPLETE = 4; + private static final int STATUS_LOAD_MORE_RETURNING = 5; + + private static boolean isRefreshing(final int status) { return status == STATUS.STATUS_REFRESHING; } - private static boolean isLoadingMore(final byte status) { + private static boolean isLoadingMore(final int status) { return status == STATUS.STATUS_LOADING_MORE; } - private static boolean isRefreshComplete(final byte status) { + private static boolean isRefreshComplete(final int status) { return status == STATS_REFRESH_COMPLETE; } - private static boolean isLoadMoreComplete(final byte status) { + private static boolean isLoadMoreComplete(final int status) { return status == STATUS_LOAD_MORE_COMPLETE; } @SuppressWarnings({"unused"}) - private static boolean isRefreshReturning(final byte status) { + private static boolean isRefreshReturning(final int status) { return status == STATUS.STATUS_REFRESH_RETURNING; } @SuppressWarnings({"unused"}) - private static boolean isLoadMoreReturning(final byte status) { + private static boolean isLoadMoreReturning(final int status) { return status == STATUS.STATUS_LOAD_MORE_RETURNING; } - private static boolean isReleaseToRefresh(final byte status) { + private static boolean isReleaseToRefresh(final int status) { return status == STATUS.STATUS_RELEASE_TO_REFRESH; } - private static boolean isReleaseToLoadMore(final byte status) { + private static boolean isReleaseToLoadMore(final int status) { return status == STATUS.STATUS_RELEASE_TO_LOAD_MORE; } - private static boolean isSwipingToRefresh(final byte status) { + private static boolean isSwipingToRefresh(final int status) { return status == STATUS.STATUS_SWIPING_TO_REFRESH; } - private static boolean isSwipingToLoadMore(final byte status) { + private static boolean isSwipingToLoadMore(final int status) { return status == STATUS.STATUS_SWIPING_TO_LOAD_MORE; } - private static boolean isRefreshStatus(final byte status) { + private static boolean isRefreshStatus(final int status) { return status < STATUS.STATUS_DEFAULT; } - public static boolean isLoadMoreStatus(final byte status) { + public static boolean isLoadMoreStatus(final int status) { return status > STATUS.STATUS_DEFAULT; } - private static boolean isStatusDefault(final byte status) { + private static boolean isStatusDefault(final int status) { return status == STATUS.STATUS_DEFAULT; } - private static String getStatus(byte status) { + private static String getStatus(int status) { final String statusInfo; switch (status) { case STATUS_REFRESH_RETURNING: @@ -1610,7 +1626,7 @@ private static String getStatus(byte status) { return statusInfo; } - private static void printStatus(byte status) { + private static void printStatus(int status) { Log.d(TAG, "printStatus:" + getStatus(status)); } }