Skip to content

Commit

Permalink
merge from dev, for 1.0.9.2-SNAPSHOT
Browse files Browse the repository at this point in the history
  • Loading branch information
liaohuqiu committed Jun 9, 2015
2 parents dc40950 + 7628ae3 commit 3cdc3ad
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 24 deletions.
6 changes: 3 additions & 3 deletions README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Github: https://github.com/liaohuqiu

项目已经发布到了Maven中央库,包括`aar``apklib`两种格式。在Maven或者Gradle下可如下直接引入:

最新版版本号: `1.0.9.1-SNAPSHOT`, 发布到了: https://oss.sonatype.org/content/repositories/snapshots
最新版版本号: `1.0.9.2-SNAPSHOT`, 发布到了: https://oss.sonatype.org/content/repositories/snapshots

在gradle中:

Expand All @@ -92,7 +92,7 @@ mavenCentral()
<type>aar</type>
<!-- or apklib format, if you want -->
<!-- <type>apklib</type> -->
<version>1.0.9.1-SNAPSHOT</version>
<version>1.0.9.2-SNAPSHOT</version>
</dependency>

稳定版
Expand All @@ -111,7 +111,7 @@ mavenCentral()
gradle / Android Studio, 最新版

```
compile 'in.srain.cube:ultra-ptr:1.0.9.1-SNAPSHOT'
compile 'in.srain.cube:ultra-ptr:1.0.9.2-SNAPSHOT'
```

gradle / Android Studio, 稳定版
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
[![Android Gems](http://www.android-gems.com/badge/liaohuqiu/android-Ultra-Pull-To-Refresh.svg?a=b)](http://www.android-gems.com/lib/liaohuqiu/android-Ultra-Pull-To-Refresh)

###### [Please follow me on GitHub, I need your support](http://www.liaohuqiu.net/posts/follow-me-on-github/)

Github: https://github.com/liaohuqiu
Expand Down Expand Up @@ -66,7 +64,7 @@ Support `API LEVEL >= 8`, all snapshots are taken from Genymotion, 2.3.7.

This project has been pushed to Maven Central, both in `aar` and `apklib`.

The latest version: `1.0.9.1-SNAPSHOT`, has been published to: https://oss.sonatype.org/content/repositories/snapshots, in gradle:
The latest version: `1.0.9.2-SNAPSHOT`, has been published to: https://oss.sonatype.org/content/repositories/snapshots, in gradle:

```
maven {
Expand All @@ -89,7 +87,7 @@ pom.xml, latest version:
<type>aar</type>
<!-- or apklib format, if you want -->
<!-- <type>apklib</type> -->
<version>1.0.9.1-SNAPSHOT</version>
<version>1.0.9.2-SNAPSHOT</version>
</dependency>
```

Expand All @@ -109,7 +107,7 @@ pom.xml, stable version:
gradle, latest version:

```
compile 'in.srain.cube:ultra-ptr:1.0.9.1-SNAPSHOT'
compile 'in.srain.cube:ultra-ptr:1.0.9.2-SNAPSHOT'
```

gradle, stable version:
Expand Down
2 changes: 1 addition & 1 deletion ptr-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<groupId>in.srain.cube</groupId>
<artifactId>ultra-ptr</artifactId>
<type>aar</type>
<version>1.0.9.1-SNAPSHOT</version>
<version>1.0.9.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>in.srain.cube</groupId>
Expand Down
4 changes: 2 additions & 2 deletions ptr-demo/res/drawable/text_view_bg.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/cube_mints_app_base_background" android:state_pressed="true" />
<item android:drawable="@color/cube_mints_4d90fe" />
<item android:drawable="@color/cube_holo_orange_light" android:state_pressed="true" />
<item android:drawable="@color/cube_holo_orange_dark" />
</selector>
66 changes: 66 additions & 0 deletions ptr-demo/res/layout/fragment_classic_header_with_scroll_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<in.srain.cube.views.ptr.PtrClassicFrameLayout
android:id="@+id/rotate_header_web_view_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cube_mints_f1f1f1"
app:ptr_duration_to_close="200"
app:ptr_duration_to_close_header="1000"
app:ptr_keep_header_when_refresh="true"
app:ptr_pull_to_fresh="false"
app:ptr_ratio_of_header_height_to_refresh="1.2"
app:ptr_resistance="1.7">

<ScrollView
android:id="@+id/rotate_header_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="@dimen/cube_mints_content_view_padding"
android:background="@drawable/text_view_bg"
android:clickable="true"
android:gravity="center"
android:text="text 1"
android:textColor="@color/cube_mints_white"
android:textSize="30sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_margin="@dimen/cube_mints_content_view_padding"
android:background="@drawable/text_view_bg"
android:clickable="true"
android:gravity="center"
android:text="text 2"
android:textColor="@color/cube_mints_white"
android:textSize="30sp" />

<TextView
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_margin="@dimen/cube_mints_content_view_padding"
android:background="@drawable/text_view_bg"
android:clickable="true"
android:gravity="center"
android:text="text 3"
android:textColor="@color/cube_mints_white"
android:textSize="30sp" />

</LinearLayout>
</ScrollView>

</in.srain.cube.views.ptr.PtrClassicFrameLayout>
</RelativeLayout>
1 change: 1 addition & 0 deletions ptr-demo/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<string name="ptr_demo_block_grid_view">Contains A GridView</string>
<string name="ptr_demo_block_list_view">Contains A ListView</string>
<string name="ptr_demo_block_web_view">Contains A WebView</string>
<string name="ptr_demo_block_scroll_view">Contains ScrollView</string>
<string name="ptr_demo_block_frame_layout">Contains A FrameLayout</string>
<string name="ptr_demo_block_only_text_view">Contains Even A TextView</string>
<string name="ptr_demo_block_with_list_view_and_empty_view">EmptyView and ListView</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void onClick(View v) {
getContext().pushFragmentToBackStack(WithWebView.class, null);
}
}));

itemInfos.add(newItemInfo(R.string.ptr_demo_block_with_list_view_and_empty_view, R.color.cube_mints_4d90fe, new OnClickListener() {

@Override
Expand All @@ -70,6 +71,16 @@ public void onClick(View v) {
}
}));

itemInfos.add(newItemInfo(R.string.ptr_demo_block_scroll_view, R.color.cube_mints_4d90fe, new OnClickListener() {

@Override
public void onClick(View v) {
getContext().pushFragmentToBackStack(WithScrollView.class, null);
}
}));
itemInfos.add(null);
itemInfos.add(null);

itemInfos.add(newItemInfo(R.string.ptr_demo_block_keep_header, R.color.cube_mints_4d90fe, new OnClickListener() {

@Override
Expand All @@ -84,7 +95,6 @@ public void onClick(View v) {
getContext().pushFragmentToBackStack(HideHeader.class, null);
}
}));
itemInfos.add(null);

itemInfos.add(newItemInfo(R.string.ptr_demo_block_release_to_refresh, R.color.cube_mints_4d90fe, new OnClickListener() {

Expand All @@ -108,6 +118,7 @@ public void onClick(View v) {
getContext().pushFragmentToBackStack(AutoRefresh.class, null);
}
}));
itemInfos.add(null);

itemInfos.add(newItemInfo(R.string.ptr_demo_block_storehouse_header_using_string_array, R.color.cube_mints_4d90fe, new OnClickListener() {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package in.srain.cube.views.ptr.demo.ui.classic;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;
import in.srain.cube.mints.base.TitleBaseFragment;
import in.srain.cube.views.ptr.PtrClassicFrameLayout;
import in.srain.cube.views.ptr.PtrDefaultHandler;
import in.srain.cube.views.ptr.PtrFrameLayout;
import in.srain.cube.views.ptr.PtrHandler;
import in.srain.cube.views.ptr.demo.R;

public class WithScrollView extends TitleBaseFragment {

private PtrClassicFrameLayout mPtrFrame;
private ScrollView mScrollView;

@Override
public View createView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

setHeaderTitle(R.string.ptr_demo_block_scroll_view);

final View contentView = inflater.inflate(R.layout.fragment_classic_header_with_scroll_view, null);
mScrollView = (ScrollView) contentView.findViewById(R.id.rotate_header_scroll_view);
mPtrFrame = (PtrClassicFrameLayout) contentView.findViewById(R.id.rotate_header_web_view_frame);
mPtrFrame.setLastUpdateTimeRelateObject(this);
mPtrFrame.setPtrHandler(new PtrHandler() {
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return PtrDefaultHandler.checkContentCanBePulledDown(frame, mScrollView, header);
}

@Override
public void onRefreshBegin(PtrFrameLayout frame) {
mPtrFrame.postDelayed(new Runnable() {
@Override
public void run() {
mPtrFrame.refreshComplete();
}
}, 100);
}
});

// the following are default settings
mPtrFrame.setResistance(1.7f);
mPtrFrame.setRatioOfHeaderHeightToRefresh(1.2f);
mPtrFrame.setDurationToClose(200);
mPtrFrame.setDurationToCloseHeader(1000);
// default is false
mPtrFrame.setPullToRefresh(false);
// default is true
mPtrFrame.setKeepHeaderWhenRefresh(true);
mPtrFrame.postDelayed(new Runnable() {
@Override
public void run() {
mPtrFrame.autoRefresh();
}
}, 100);
return contentView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.webkit.WebViewClient;
import in.srain.cube.mints.base.TitleBaseFragment;
import in.srain.cube.views.ptr.PtrClassicFrameLayout;
import in.srain.cube.views.ptr.PtrDefaultHandler;
import in.srain.cube.views.ptr.PtrFrameLayout;
import in.srain.cube.views.ptr.PtrHandler;
import in.srain.cube.views.ptr.demo.R;
Expand All @@ -34,13 +35,13 @@ public void onPageFinished(WebView view, String url) {
mPtrFrame.setLastUpdateTimeRelateObject(this);
mPtrFrame.setPtrHandler(new PtrHandler() {
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
updateData();
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return PtrDefaultHandler.checkContentCanBePulledDown(frame, mWebView, header);
}

@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return mWebView.getScrollY() == 0;
public void onRefreshBegin(PtrFrameLayout frame) {
updateData();
}
});
// the following are default settings
Expand Down
2 changes: 1 addition & 1 deletion ptr-lib/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=1.0.9.1-SNAPSHOT
VERSION_NAME=1.0.9.2-SNAPSHOT

POM_GROUP=in.srain.cube
POM_ARTIFACT_ID=ultra-ptr
Expand Down
2 changes: 1 addition & 1 deletion ptr-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>ultra-ptr</artifactId>
<packaging>aar</packaging>
<name>Ultra Pull to Refresh</name>
<version>1.0.9.1-SNAPSHOT</version>
<version>1.0.9.2-SNAPSHOT</version>

<description>Ultra Pull to Refresh in Android</description>
<url>https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh</url>
Expand Down
13 changes: 8 additions & 5 deletions ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public class PtrFrameLayout extends ViewGroup {
// disable when detect moving horizontally
private boolean mPreventForHorizontal = false;

private MotionEvent mDownEvent;
private MotionEvent mLastMoveEvent;

private PtrUIHandlerHook mRefreshCompleteHook;
Expand Down Expand Up @@ -279,7 +278,6 @@ public boolean dispatchTouchEvent(MotionEvent e) {

case MotionEvent.ACTION_DOWN:
mHasSendCancelEvent = false;
mDownEvent = e;
mPtrIndicator.onPressDown(e.getX(), e.getY());

mScrollChecker.abortIfWorking();
Expand All @@ -288,7 +286,8 @@ public boolean dispatchTouchEvent(MotionEvent e) {
// The cancel event will be sent once the position is moved.
// So let the event pass to children.
// fix #93, #102
return dispatchTouchEventSupper(e);
dispatchTouchEventSupper(e);
return true;

case MotionEvent.ACTION_MOVE:
mLastMoveEvent = e;
Expand Down Expand Up @@ -905,8 +904,12 @@ private void sendCancelEvent() {
if (DEBUG) {
PtrCLog.d(LOG_TAG, "send cancel event");
}
MotionEvent last = mDownEvent;
last = mLastMoveEvent;
// The ScrollChecker will update position and lead to send cancel event when mLastMoveEvent is null.
// fix #104, #80, #92
if (mLastMoveEvent == null) {
return;
}
MotionEvent last = mLastMoveEvent;
MotionEvent e = MotionEvent.obtain(last.getDownTime(), last.getEventTime() + ViewConfiguration.getLongPressTimeout(), MotionEvent.ACTION_CANCEL, last.getX(), last.getY(), last.getMetaState());
dispatchTouchEventSupper(e);
}
Expand Down
2 changes: 1 addition & 1 deletion update-project.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
vars = {
'ptr_lib_version': '1.0.9.1-SNAPSHOT',
'ptr_lib_version': '1.0.9.2-SNAPSHOT',
'ptr_lib_stable_version': '1.0.9',
'cube_sdk_version': '1.0.44.39-SNAPSHOT'
}
Expand Down

0 comments on commit 3cdc3ad

Please sign in to comment.