B4A Library AHSwipeToRefresh - Wrapper for Android SwipeToRefresh implementation

With the v19.1 version of the Android support library Google added a SwipeToRefresh view to the android system. This is usable with API version 4 and up but it needs the android-support-v4.jar library.

Google uses two different implementations of the SwipeToRefresh usepattern in their own apps. This one is similar to the "Google Now" implementation. Nearly all other Google apps use another (in my opinion slightly nicer) solution but the Google Now version is, what made it into the official Android SDK.

Usage:
Add the AHSwipeToRefresh Object to the activity. This can be done manually or with the designer as a custom view.
Then you have to add a view to the AHSwipeToRefresh object which then can be pulled to start the refresh process. You can only add one single view to the AHSwipeToRefresh object. This should be something like a ListView or ScrollView.
When the user starts a refresh process the "Refresh" event is fired where you can start your refresh process (like loading some data over the net). When the refresh process is complete just set the Refresh property to false to stop the animation.

Installation:
Copy the AHSwipeToRefresh.jar and AHSwipeToRefresh.xml files to your custom libraries folder.

Additionally you will need the android-support-v4.jar. Check with the Android SDK Manager if you have the latest Android Support Library (You will need at least v22) installed. You can find the library in the <SDK_HOME>\extras\android\support\v4 folder. Copy the library to your custom libraries folder.

History:
V1.00
- Initial version

V1.10
- Requires Support Library v22 or up
- Fixed problems with UltimateListView (hopefully, simple example provided)
- Added ability to change background color of the progress indicator
- Added ability to set any number of colors for the progress indicator
- Supports a larger progress indicator
- New event (STR_CanChildScrollUp) to determine when a swipe event should be triggered or not.
- Support for multiple views (See example)
- Added method to set the offset (position) of the progress indicator
 

Attachments

  • AHSwipeToRefreshExample.zip
    13.2 KB · Views: 488
  • AHSwipeToRefreshULVExample.zip
    11.8 KB · Views: 364
  • AHSwipeToRefreshMultiExample.zip
    12.2 KB · Views: 393
  • AHSwipeToRefresh1_10.zip
    13.8 KB · Views: 612
  • ViewPagerSwipeToRefreshExample.zip
    12.4 KB · Views: 404
Last edited:

NJDude

Expert
Licensed User
I have the latest support library (v4) and I get THIS error.

Also, I think I've mentioned this to you before, but v13 also seems to work (your AHViewPager works just fine using v13)

I tested the sample on KitKat (4.4.2)
 

corwin42

Expert
Licensed User
I have the latest support library (v4) and I get THIS error.

Also, I think I've mentioned this to you before, but v13 also seems to work (your AHViewPager works just fine using v13

I don't see any advantage in using the v13 version of the support library.

Sure that SDK Manager shows 19.1 for the version of the support library? (not 19.01)

Can you post the exception stack trace?
 

FireDroid

Member
Licensed User
I have the latest support library (v4) and I get THIS error.

Also, I think I've mentioned this to you before, but v13 also seems to work (your AHViewPager works just fine using v13)

I tested the sample on KitKat (4.4.2)

Try to compile with platform - android-19 ... in my case it worked perfectly

(ex. C:\Android\android-sdk\platforms\android-19\android.jar)
 

NJDude

Expert
Licensed User
Ok, I see a NEWER update showed up on the SDK Manager for the support library, the version has to be at least 19.1 (as you mentioned).

Cool.
 

Informatix

Expert
Licensed User
Someone reported that UltimateListView does not work well with the AHSwipeToRefresh library. Indeed, AHSwipeToRefresh tries to intercept the touch events of the associated view to handle the swipe gesture and UltimateListView does the same with its internal ListView, so the result is a bit unpredictable when you mix both libraries. That being said, ULV does not need AHSwipeToRefresh (and its extra 650 Kb of code) as it can reproduce easily the same behavior with its native functions and events. An example is available on request.
 

MhdBoy

Member
Licensed User
is anybody that can upload the latest version of android-support-v4 ?
please i need this
tnx a lot
 

omidaghakhani1368

Well-Known Member
Licensed User
Hi.
Thank you to sharing library,
I test it and it's working but loadingbar is not circle.
Maybe android-support-v4 is old version.
Please attachment last version android-support-v4.jar
 

DonManfred

Expert
Licensed User

corwin42

Expert
Licensed User

omidaghakhani1368

Well-Known Member
Licensed User
Hi again and i'm sorry for ask many question.
I'm working with appcompat library
I have 2 problem please help me to solve this problems
1- How to change ACActiomMode Background color ? ( for me always black)
2- How to work with ACSearchview (im initializing but cant show?)
 

corwin42

Expert
Licensed User
Hi again and i'm sorry for ask many question.
I'm working with appcompat library
I have 2 problem please help me to solve this problems
1- How to change ACActiomMode Background color ? ( for me always black)
2- How to work with ACSearchview (im initializing but cant show?)

Please open new threads for this questions because they are not related to AHSwipeToRefresh library.
 

Scunkaneli

New Member
Licensed User
Should work if you set the colors with AHSwipeToRefresh.SetColorScheme()

doesn't work for me, ther is only a black circle with white background

B4X:
AHSwipeToRefresh.SetColorScheme(Colors.Red, Colors.White, Colors.Green, Colors.Magenta)
 

corwin42

Expert
Licensed User
doesn't work for me, ther is only a black circle with white background

B4X:
AHSwipeToRefresh.SetColorScheme(Colors.Red, Colors.White, Colors.Green, Colors.Magenta)

Can you please create a sample project which shows this problem?
 
Top