android-Ultra-Pull-To-Refresh
android-Ultra-Pull-To-Refresh copied to clipboard
Disable ptrClassicFrameLayout after first refresh complete
Hello. Is it possible to disable all action after first refresh ? I want to notify user that data is loading and when complete i want to diable whole ptrClassicFrameLayout.
Hello, yes it is possible. I recently needed to disable the ptr and I solved it with a little workaround. Just set your PtrHandler to this:
ptrFrame.setPtrHandler(new PtrHandler() {
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
}
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return false;
}
});
It feels a little bit hacky, but for my needs where I decide to allow ptr depending on an incoming event it's totally fine.
Hope this helps!
Come from https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh/issues/156#issuecomment-152946504:
the callback source here:
https://github.com/liaohuqiu/android-Ultra-Pull-To-Refresh/blob/master/ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java#L336
do like:
mPtrFrame.setPtrHandler(new PtrHandler() {
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
refresh();
}
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return conditionCanBePulledDown && PtrDefaultHandler.checkContentCanBePulledDown(frame, content, header);
}
});