android-Ultra-Pull-To-Refresh icon indicating copy to clipboard operation
android-Ultra-Pull-To-Refresh copied to clipboard

Disable ptrClassicFrameLayout after first refresh complete

Open stanbar opened this issue 10 years ago • 2 comments

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.

stanbar avatar Oct 08 '15 11:10 stanbar

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!

jonastheis avatar Nov 02 '15 08:11 jonastheis

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);
   }
});

imknown avatar Dec 15 '16 07:12 imknown