diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100755 index 0000000..06ad3b4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,13 @@ +Change Log +========== + +Version 1.0.1 *(2014-6-6)* +---------------------------- + +- 结束上拉加载更多从以前的endRefreshing()改为endLoadingMore() +- 刷新和加载更多过程中,内容控件可接收触摸事件 + +Version 1.0.0 *(2014-5-28)* +---------------------------- + +Initial release. \ No newline at end of file diff --git a/README.md b/README.md index b676617..d12ae70 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -:running:BGARefreshLayout-Android v1.0.0:running: +:running:BGARefreshLayout-Android v1.0.1:running: ============ >关于我
>微博:bingoogolapple    主页:bingoogolapple.cn    邮箱:bingoogolapple@gmail.com @@ -44,7 +44,7 @@ dependencies { compile 'com.android.support:recyclerview-v7:22.1.1' // 记得添加nineoldandroids compile 'com.nineoldandroids:library:2.4.0' - compile 'cn.bingoogolapple:bga-refreshlayout:1.0.0@aar' + compile 'cn.bingoogolapple:bga-refreshlayout:1.0.1@aar' } ``` @@ -120,7 +120,7 @@ public class ModuleNameActivity extends AppCompatActivity implements BGARefreshL // 在这里加载更多数据,或者更具产品需求实现上拉刷新也可以 // 加载完毕后在UI线程结束加载更多 - mRefreshLayout.endRefreshing(); + mRefreshLayout.endLoadingMore(); } } diff --git a/demo/build.gradle b/demo/build.gradle index 6617251..1cd4dfe 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -19,11 +19,11 @@ dependencies { compile 'com.android.support:recyclerview-v7:22.1.1' // 记得添加nineoldandroids compile 'com.nineoldandroids:library:2.4.0' - compile 'cn.bingoogolapple:bga-refreshlayout:1.0.0@aar' -// compile project(':library') +// compile 'cn.bingoogolapple:bga-refreshlayout:1.0.1@aar' + compile project(':library') compile 'cn.bingoogolapple:bga-banner:1.0.0@aar' - compile 'cn.bingoogolapple:bga-adapter:1.0.1@aar' + compile 'cn.bingoogolapple:bga-adapter:1.0.2@aar' compile 'cn.bingoogolapple:bga-swipeitemlayout:1.0.0@aar' } \ No newline at end of file diff --git a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/GridViewDemoActivity.java b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/GridViewDemoActivity.java index da653e8..cb53b31 100644 --- a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/GridViewDemoActivity.java +++ b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/GridViewDemoActivity.java @@ -83,7 +83,7 @@ public void onBGARefreshLayoutBeginRefreshing() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -106,7 +106,7 @@ public void onBGARefreshLayoutBeginLoadingMore() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -115,7 +115,7 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void aVoid) { - mRefreshLayout.endRefreshing(); + mRefreshLayout.endLoadingMore(); mAdapter.addDatas(DataEngine.loadMoreData()); } }.execute(); diff --git a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/MainActivity.java b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/MainActivity.java index ef2ee53..135ad33 100644 --- a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/MainActivity.java +++ b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/MainActivity.java @@ -14,6 +14,7 @@ */ public class MainActivity extends AppCompatActivity { private static final String TAG = MainActivity.class.getSimpleName(); + public static final int LOADING_DURATION = 3000; @Override protected void onCreate(Bundle savedInstanceState) { diff --git a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalListViewDemoActivity.java b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalListViewDemoActivity.java index 5a82697..9080ce6 100644 --- a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalListViewDemoActivity.java +++ b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalListViewDemoActivity.java @@ -91,7 +91,7 @@ public void onBGARefreshLayoutBeginRefreshing() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -114,7 +114,7 @@ public void onBGARefreshLayoutBeginLoadingMore() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -123,7 +123,7 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void aVoid) { - mRefreshLayout.endRefreshing(); + mRefreshLayout.endLoadingMore(); mAdapter.addDatas(DataEngine.loadMoreData()); } }.execute(); diff --git a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalRecyclerViewDemoActivity.java b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalRecyclerViewDemoActivity.java index eedb0ad..6508a7a 100644 --- a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalRecyclerViewDemoActivity.java +++ b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalRecyclerViewDemoActivity.java @@ -93,7 +93,7 @@ public void onBGARefreshLayoutBeginRefreshing() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -116,7 +116,7 @@ public void onBGARefreshLayoutBeginLoadingMore() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -125,7 +125,7 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void aVoid) { - mRefreshLayout.endRefreshing(); + mRefreshLayout.endLoadingMore(); mAdapter.addDatas(DataEngine.loadMoreData()); } }.execute(); diff --git a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalViewDemoActivity.java b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalViewDemoActivity.java index ae5adfe..1c1656d 100644 --- a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalViewDemoActivity.java +++ b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/NormalViewDemoActivity.java @@ -53,7 +53,7 @@ public void onBGARefreshLayoutBeginRefreshing() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -75,7 +75,7 @@ public void onBGARefreshLayoutBeginLoadingMore() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -84,7 +84,7 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void aVoid) { - mRefreshLayout.endRefreshing(); + mRefreshLayout.endLoadingMore(); Log.i(TAG, "上拉加载更多完成"); } }.execute(); diff --git a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/ScrollViewDemoActivity.java b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/ScrollViewDemoActivity.java index c4c78c8..f59c8d6 100644 --- a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/ScrollViewDemoActivity.java +++ b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/ScrollViewDemoActivity.java @@ -12,6 +12,7 @@ import cn.bingoogolapple.refreshlayout.BGARefreshLayout; import cn.bingoogolapple.refreshlayout.BGAStickinessRefreshViewHolder; import cn.bingoogolapple.refreshlayout.demo.R; +import cn.bingoogolapple.refreshlayout.demo.dialog.LoadingDialog; import cn.bingoogolapple.refreshlayout.demo.engine.DataEngine; /** @@ -23,11 +24,14 @@ public class ScrollViewDemoActivity extends AppCompatActivity implements BGARefr private static final String TAG = ScrollViewDemoActivity.class.getSimpleName(); private BGARefreshLayout mRefreshLayout; private TextView mClickableLabelTv; + private LoadingDialog mLoadingDialog; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_scrollview); + mLoadingDialog = new LoadingDialog(this); + mLoadingDialog.setMsg("正在加载中..."); initRefreshLayout(); @@ -54,10 +58,15 @@ private void initRefreshLayout() { public void onBGARefreshLayoutBeginRefreshing() { new AsyncTask() { + @Override + protected void onPreExecute() { + mLoadingDialog.show(); + } + @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -66,6 +75,7 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void aVoid) { + mLoadingDialog.dismiss(); mRefreshLayout.endRefreshing(); mClickableLabelTv.setText("加载最新数据完成"); } @@ -76,10 +86,15 @@ protected void onPostExecute(Void aVoid) { public void onBGARefreshLayoutBeginLoadingMore() { new AsyncTask() { + @Override + protected void onPreExecute() { + mLoadingDialog.show(); + } + @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -88,7 +103,8 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void aVoid) { - mRefreshLayout.endRefreshing(); + mLoadingDialog.dismiss(); + mRefreshLayout.endLoadingMore(); Log.i(TAG, "上拉加载更多完成"); } }.execute(); diff --git a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/SwipeListViewDemoActivity.java b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/SwipeListViewDemoActivity.java index 1f56acb..dbade1a 100644 --- a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/SwipeListViewDemoActivity.java +++ b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/SwipeListViewDemoActivity.java @@ -88,7 +88,7 @@ public void onBGARefreshLayoutBeginRefreshing() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -111,7 +111,7 @@ public void onBGARefreshLayoutBeginLoadingMore() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -120,7 +120,7 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void aVoid) { - mRefreshLayout.endRefreshing(); + mRefreshLayout.endLoadingMore(); mAdapter.addDatas(DataEngine.loadMoreData()); } }.execute(); diff --git a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/SwipeRecyclerViewDemoActivity.java b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/SwipeRecyclerViewDemoActivity.java index 4cae551..1a3f4f2 100644 --- a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/SwipeRecyclerViewDemoActivity.java +++ b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/activity/SwipeRecyclerViewDemoActivity.java @@ -37,7 +37,6 @@ public class SwipeRecyclerViewDemoActivity extends AppCompatActivity implements protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recyclerview); - initRefreshLayout(); initRecyclerView(); } @@ -74,7 +73,7 @@ public void onBGARefreshLayoutBeginRefreshing() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -97,7 +96,7 @@ public void onBGARefreshLayoutBeginLoadingMore() { @Override protected Void doInBackground(Void... params) { try { - Thread.sleep(2000); + Thread.sleep(MainActivity.LOADING_DURATION); } catch (InterruptedException e) { e.printStackTrace(); } @@ -106,7 +105,7 @@ protected Void doInBackground(Void... params) { @Override protected void onPostExecute(Void aVoid) { - mRefreshLayout.endRefreshing(); + mRefreshLayout.endLoadingMore(); mAdapter.addDatas(DataEngine.loadMoreData()); } }.execute(); diff --git a/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/dialog/LoadingDialog.java b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/dialog/LoadingDialog.java new file mode 100644 index 0000000..f69e07a --- /dev/null +++ b/demo/src/main/java/cn/bingoogolapple/refreshlayout/demo/dialog/LoadingDialog.java @@ -0,0 +1 @@ +package cn.bingoogolapple.refreshlayout.demo.dialog; import android.app.Dialog; import android.content.Context; import android.graphics.drawable.AnimationDrawable; import android.widget.ImageView; import android.widget.TextView; import cn.bingoogolapple.refreshlayout.demo.R; public class LoadingDialog extends Dialog { private ImageView mProgressIv; private TextView mMsgTv; private String mMsg; private AnimationDrawable mAd; public LoadingDialog(Context context) { super(context, R.style.DialogTheme); setContentView(R.layout.dialog_loading); setCancelable(false); mProgressIv = (ImageView) findViewById(R.id.iv_loading_progress); mMsgTv = (TextView) findViewById(R.id.tv_loading_msg); mAd = (AnimationDrawable) mProgressIv.getDrawable(); } /** * 设置加载数据时的提示消息 * * @param msg */ public void setMsg(String msg) { mMsg = msg; } public void setMsg(int msgResId) { mMsg = getContext().getString(msgResId); } @Override public void show() { mMsgTv.setText(mMsg); if (!isShowing()) { super.show(); mAd.start(); } } @Override public void dismiss() { super.dismiss(); if (mAd.isRunning()) { mAd.stop(); } } } \ No newline at end of file diff --git a/demo/src/main/res/anim/loding.xml b/demo/src/main/res/anim/loding.xml new file mode 100644 index 0000000..b120db0 --- /dev/null +++ b/demo/src/main/res/anim/loding.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/layout/dialog_loading.xml b/demo/src/main/res/layout/dialog_loading.xml new file mode 100644 index 0000000..b866da3 --- /dev/null +++ b/demo/src/main/res/layout/dialog_loading.xml @@ -0,0 +1,23 @@ + + + + + + + + \ No newline at end of file diff --git a/demo/src/main/res/mipmap-hdpi/loading_01.png b/demo/src/main/res/mipmap-hdpi/loading_01.png new file mode 100644 index 0000000..1c190a9 Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_01.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_02.png b/demo/src/main/res/mipmap-hdpi/loading_02.png new file mode 100644 index 0000000..bc930f2 Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_02.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_03.png b/demo/src/main/res/mipmap-hdpi/loading_03.png new file mode 100644 index 0000000..e461335 Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_03.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_04.png b/demo/src/main/res/mipmap-hdpi/loading_04.png new file mode 100644 index 0000000..071af1e Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_04.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_05.png b/demo/src/main/res/mipmap-hdpi/loading_05.png new file mode 100644 index 0000000..43ba85f Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_05.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_06.png b/demo/src/main/res/mipmap-hdpi/loading_06.png new file mode 100644 index 0000000..67c6faa Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_06.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_07.png b/demo/src/main/res/mipmap-hdpi/loading_07.png new file mode 100644 index 0000000..797c5d8 Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_07.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_08.png b/demo/src/main/res/mipmap-hdpi/loading_08.png new file mode 100644 index 0000000..bbeecf2 Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_08.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_09.png b/demo/src/main/res/mipmap-hdpi/loading_09.png new file mode 100644 index 0000000..397c08d Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_09.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_10.png b/demo/src/main/res/mipmap-hdpi/loading_10.png new file mode 100644 index 0000000..2c4c58b Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_10.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_11.png b/demo/src/main/res/mipmap-hdpi/loading_11.png new file mode 100644 index 0000000..587c1df Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_11.png differ diff --git a/demo/src/main/res/mipmap-hdpi/loading_12.png b/demo/src/main/res/mipmap-hdpi/loading_12.png new file mode 100644 index 0000000..162ffd4 Binary files /dev/null and b/demo/src/main/res/mipmap-hdpi/loading_12.png differ diff --git a/demo/src/main/res/values/styles.xml b/demo/src/main/res/values/styles.xml index 83f5976..9dad9d2 100644 --- a/demo/src/main/res/values/styles.xml +++ b/demo/src/main/res/values/styles.xml @@ -14,4 +14,14 @@ ?android:attr/textAppearanceMedium + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index aa4b18d..021093e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,5 +3,5 @@ ANDROID_BUILD_TARGET_SDK_VERSION=22 ANDROID_BUILD_SDK_VERSION=22 ANDROID_BUILD_TOOLS_VERSION=22.0.1 -VERSION_NAME=1.0.0 -VERSION_CODE=100 \ No newline at end of file +VERSION_NAME=1.0.1 +VERSION_CODE=101 \ No newline at end of file diff --git a/library/src/main/java/cn/bingoogolapple/refreshlayout/BGARefreshLayout.java b/library/src/main/java/cn/bingoogolapple/refreshlayout/BGARefreshLayout.java index fe7632b..c8b7266 100755 --- a/library/src/main/java/cn/bingoogolapple/refreshlayout/BGARefreshLayout.java +++ b/library/src/main/java/cn/bingoogolapple/refreshlayout/BGARefreshLayout.java @@ -283,7 +283,7 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun } private boolean shouldHandleAbsListViewLoadingMore() { - if (mIsLoadingMore || mLoadMoreFooterView == null || mDelegate == null || mAbsListView.getAdapter() == null || mAbsListView.getAdapter().getCount() == 0) { + if (mIsLoadingMore || mCurrentRefreshStatus == RefreshStatus.REFRESHING || mLoadMoreFooterView == null || mDelegate == null || mAbsListView.getAdapter() == null || mAbsListView.getAdapter().getCount() == 0) { return false; } @@ -296,7 +296,7 @@ private boolean shouldHandleAbsListViewLoadingMore() { } private boolean shouldHandleRecyclerViewLoadingMore() { - if (mIsLoadingMore || mLoadMoreFooterView == null || mDelegate == null || mRecyclerView.getAdapter() == null || mRecyclerView.getAdapter().getItemCount() == 0) { + if (mIsLoadingMore || mCurrentRefreshStatus == RefreshStatus.REFRESHING || mLoadMoreFooterView == null || mDelegate == null || mRecyclerView.getAdapter() == null || mRecyclerView.getAdapter().getItemCount() == 0) { return false; } @@ -323,7 +323,7 @@ private boolean shouldHandleRecyclerViewLoadingMore() { * @return */ private boolean shouldHandleLoadingMore() { - if (mIsLoadingMore || mLoadMoreFooterView == null || mDelegate == null) { + if (mIsLoadingMore || mCurrentRefreshStatus == RefreshStatus.REFRESHING || mLoadMoreFooterView == null || mDelegate == null) { return false; } @@ -360,29 +360,24 @@ public boolean onInterceptTouchEvent(MotionEvent event) { mInterceptTouchDownY = event.getRawY(); break; case MotionEvent.ACTION_MOVE: - if (mIsLoadingMore || (mCurrentRefreshStatus == RefreshStatus.REFRESHING)) { - // ACTION_DOWN时没有消耗掉事件,子控件会处于按下状态,这里设置ACTION_CANCEL,使子控件取消按下状态 - event.setAction(MotionEvent.ACTION_CANCEL); - super.onInterceptTouchEvent(event); - return true; - } - - if (mInterceptTouchDownX == -1) { - mInterceptTouchDownX = (int) event.getRawX(); - } - if (mInterceptTouchDownY == -1) { - mInterceptTouchDownY = (int) event.getRawY(); - } + if (!mIsLoadingMore && (mCurrentRefreshStatus != RefreshStatus.REFRESHING)) { + if (mInterceptTouchDownX == -1) { + mInterceptTouchDownX = (int) event.getRawX(); + } + if (mInterceptTouchDownY == -1) { + mInterceptTouchDownY = (int) event.getRawY(); + } - int interceptTouchMoveDistanceY = (int) (event.getRawY() - mInterceptTouchDownY); - // 可以没有上拉加载更多,但是必须有下拉刷新,否则就不拦截事件 - if (Math.abs(event.getRawX() - mInterceptTouchDownX) < Math.abs(interceptTouchMoveDistanceY) && mRefreshHeaderView != null) { - if ((interceptTouchMoveDistanceY > 0 && shouldHandleRefresh()) || (interceptTouchMoveDistanceY < 0 && shouldHandleLoadingMore()) || interceptTouchMoveDistanceY < 0 && !isWholeHeaderViewCompleteInvisible()) { + int interceptTouchMoveDistanceY = (int) (event.getRawY() - mInterceptTouchDownY); + // 可以没有上拉加载更多,但是必须有下拉刷新,否则就不拦截事件 + if (Math.abs(event.getRawX() - mInterceptTouchDownX) < Math.abs(interceptTouchMoveDistanceY) && mRefreshHeaderView != null) { + if ((interceptTouchMoveDistanceY > 0 && shouldHandleRefresh()) || (interceptTouchMoveDistanceY < 0 && shouldHandleLoadingMore()) || interceptTouchMoveDistanceY < 0 && !isWholeHeaderViewCompleteInvisible()) { - // ACTION_DOWN时没有消耗掉事件,子控件会处于按下状态,这里设置ACTION_CANCEL,使子控件取消按下状态 - event.setAction(MotionEvent.ACTION_CANCEL); - super.onInterceptTouchEvent(event); - return true; + // ACTION_DOWN时没有消耗掉事件,子控件会处于按下状态,这里设置ACTION_CANCEL,使子控件取消按下状态 + event.setAction(MotionEvent.ACTION_CANCEL); + super.onInterceptTouchEvent(event); + return true; + } } } break; @@ -403,7 +398,7 @@ public boolean onInterceptTouchEvent(MotionEvent event) { * @return */ private boolean shouldHandleRefresh() { - if (mRefreshHeaderView == null) { + if (mIsLoadingMore || mCurrentRefreshStatus == RefreshStatus.REFRESHING || mRefreshHeaderView == null || mDelegate == null) { return false; } @@ -547,7 +542,7 @@ private boolean isWholeHeaderViewCompleteInvisible() { */ private boolean handleActionMove(MotionEvent event) { if (mCurrentRefreshStatus == RefreshStatus.REFRESHING || mIsLoadingMore) { - return true; + return false; } if ((mCustomHeaderView == null || !mIsCustomHeaderViewScrollable) && mRefreshDownY == -1) { @@ -581,11 +576,11 @@ private boolean handleActionMove(MotionEvent event) { float scale = 1 - paddingTop * 1.0f / mMinWholeHeaderViewPaddingTop; /** * 往下滑 - * paddingTop mMinWholeHeaderViewPaddingTop ==> 0 - * scale 0 ==> 1 + * paddingTop mMinWholeHeaderViewPaddingTop 到 0 + * scale 0 到 1 * 往上滑 - * paddingTop 0 ==> mMinWholeHeaderViewPaddingTop - * scale 1 ==> 0 + * paddingTop 0 到 mMinWholeHeaderViewPaddingTop + * scale 1 到 0 */ mRefreshViewHolder.handleScale(scale, refreshDiffY); } @@ -701,14 +696,10 @@ private void handleRefreshStatusChanged() { } /** - * 结束下拉刷新和上拉加载更多 + * 结束下拉刷新 */ public void endRefreshing() { - if (mIsLoadingMore) { - mIsLoadingMore = false; - hiddenLoadMoreFooterView(); - mRefreshViewHolder.onEndLoadingMore(); - } else { + if (mCurrentRefreshStatus == RefreshStatus.REFRESHING) { mCurrentRefreshStatus = RefreshStatus.IDLE; hiddenRefreshHeaderView(); handleRefreshStatusChanged(); @@ -716,6 +707,17 @@ public void endRefreshing() { } } + /** + * 结束上拉加载更多 + */ + public void endLoadingMore() { + if (mIsLoadingMore) { + mIsLoadingMore = false; + hiddenLoadMoreFooterView(); + mRefreshViewHolder.onEndLoadingMore(); + } + } + /** * 隐藏下拉刷新控件,带动画 */ diff --git a/library/src/main/java/cn/bingoogolapple/refreshlayout/BGARefreshViewHolder.java b/library/src/main/java/cn/bingoogolapple/refreshlayout/BGARefreshViewHolder.java index df7075f..19374ec 100644 --- a/library/src/main/java/cn/bingoogolapple/refreshlayout/BGARefreshViewHolder.java +++ b/library/src/main/java/cn/bingoogolapple/refreshlayout/BGARefreshViewHolder.java @@ -214,7 +214,7 @@ public View getLoadMoreFooterView() { /** * 下拉刷新控件可见时,处理上下拉进度 * - * @param scale 下拉过程0 ==> 1,回弹过程1 ==> 0,没有加上弹簧距离移动时的比例 + * @param scale 下拉过程0 到 1,回弹过程1 到 0,没有加上弹簧距离移动时的比例 * @param moveYDistance 整个下拉刷新控件paddingTop变化的值,如果有弹簧距离,会大于整个下拉刷新控件的高度 */ public abstract void handleScale(float scale, int moveYDistance); diff --git a/library/src/main/java/cn/bingoogolapple/refreshlayout/BGAStickinessRefreshView.java b/library/src/main/java/cn/bingoogolapple/refreshlayout/BGAStickinessRefreshView.java index 2f7eef5..d5bf339 100755 --- a/library/src/main/java/cn/bingoogolapple/refreshlayout/BGAStickinessRefreshView.java +++ b/library/src/main/java/cn/bingoogolapple/refreshlayout/BGAStickinessRefreshView.java @@ -159,8 +159,8 @@ public void onDraw(Canvas canvas) { // 二阶贝塞尔曲线,第一个是控制点,第二个是终点 // mPath.quadTo(mTopBound.right - mTopSize / 8, mTopBound.bottom, mBottomBound.right, mBottomBound.bottom - mBottomBound.height() / 2); - // mCurrentBottomHeight 0 ==> mMaxBottomHeight - // scale 0.2 ==> 1 + // mCurrentBottomHeight 0 到 mMaxBottomHeight + // scale 0.2 到 1 float scale = Math.max(mCurrentBottomHeight * 1.0f / mMaxBottomHeight, 0.2f); float bottomControlXOffset = mTopSize * ((4 + (float) Math.pow(scale, 7) * 15) / 32);