use of in.srain.cube.views.ptr.PtrHandler in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class WithScrollView method createView.
@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;
}
use of in.srain.cube.views.ptr.PtrHandler in project UltimateAndroid by cymcsg.
the class UltraPullToRefreshStoreHouseActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout);
setContentView(R.layout.ultra_pull_refresh_store_house_activity_main);
mPtrFrameLayout = (PtrFrameLayout) findViewById(R.id.store_house_ptr_frame);
// the following are default settings
mPtrFrameLayout.setResistance(1.7f);
mPtrFrameLayout.setRatioOfHeaderHeightToRefresh(1.2f);
mPtrFrameLayout.setDurationToClose(200);
mPtrFrameLayout.setDurationToCloseHeader(1000);
// default is false
mPtrFrameLayout.setPullToRefresh(false);
// default is true
mPtrFrameLayout.setKeepHeaderWhenRefresh(true);
final StoreHouseHeader header = new StoreHouseHeader(this);
header.setPadding(0, BasicUiUtils.dip2px(this, 15.0f), 0, 0);
/**
* using a string, support: A-Z 0-9 - .
* you can add more letters by {@link in.srain.cube.views.ptr.header.StoreHousePath#addChar}
*/
header.initWithString("Marshal Chen");
// header.initWithStringArray(R.array.akta);
mPtrFrameLayout.setHeaderView(header);
mPtrFrameLayout.addPtrUIHandler(header);
// mPtrFrameLayout.postDelayed(new Runnable() {
// @Override
// public void run() {
// // ptrFrame.autoRefresh();
// }
// }, 150);
mPtrFrameLayout.setPtrHandler(new PtrHandler() {
@Override
public boolean checkCanDoRefresh(PtrFrameLayout ptrFrameLayout, View view, View view2) {
boolean canbePullDown = PtrDefaultHandler.checkContentCanBePulledDown(ptrFrameLayout, view, view2);
Logs.d("canbepull----" + canbePullDown);
return canbePullDown;
}
@Override
public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) {
ptrFrameLayout.postDelayed(new Runnable() {
@Override
public void run() {
mPtrFrameLayout.refreshComplete();
}
}, 1800);
}
});
}
Aggregations