B4A Library AHSwipeToRefresh - Wrapper for Android SwipeToRefresh implementation

Scunkaneli

New Member
Licensed User
Longtime User
I tested it with your example and and my app and custom colors

Auf Deutsch: egal ob ich meine App probiere oder dein Beispiel von oben, die Farben ändern sich nicht, soweit ich das gesehen habe, haben sich ein paar Methoden in der "SwipeRefreshLayout" Class geändert, mit der "alten" Support Library hat alles funktioniert

Android 5.1 and CyanogenMod
 

corwin42

Expert
Licensed User
Longtime User
Sorry that my answer took so long. You are right. Unfortunately the old version of the SwipeRefreshLayout in the support library did not have methods to set the colors directly but only with colors defined in resources. So I had to use reflection to implement a "hack" that it is possible with B4A to change the colors. Now Google has fixed this problem and provided new methods for setting colors directly.

I just worked on an update and I think I have a new version ready for release. This version will have some nice improvements and should be compatible with ULV (at least with simple lists. Don't know if the advanced swipe gestures of ULV still work but they should). Needs some additional testing but looks quite good at the moment.
 

Reids

Member
Licensed User
Longtime User
Hey something went wrong with

STR.SetColorScheme()
STR.SetColorScheme2()

it say

java.lang.NoSuchMethodError: de.amberhome.strefresh.base.CustomSwipeRefreshLayout.setColorSchemeColors

removing those line will fix it, but the loader doesn't have any color
 

corwin42

Expert
Licensed User
Longtime User
it say

java.lang.NoSuchMethodError: de.amberhome.strefresh.base.CustomSwipeRefreshLayout.setColorSchemeColors

Update your android-support-v4.jar.

See release notes. You need at least v22.
 

Reids

Member
Licensed User
Longtime User
Cool problem solved, It require android-support-v4.jar placed in library folder too not just copy-ing v4 folder to library folder
thank you very much!
 

corwin42

Expert
Licensed User
Longtime User
Added a new example "ViewPagerSwipeToRefreshExample" to the first post.

The example shows the usage of the CanChildScrollUp event. It has a Viewpager (AHViewPager library needed) with four pages and a ListView on each page.
All four ListViews can trigger a single SwipeToRefresh object. The logic, when to trigger the refresh and when not is done in the CanChildScrollUp event.
 

corwin42

Expert
Licensed User
Longtime User
It's can't be used for webview?
You can use it for WebView, if you use the CanChildScrollUp event. See ViewPagerSwipeToRefreshExample how to use it.
 
Last edited:

frenkipi

Member
Licensed User
Longtime User
Hello, I have an infinite scroll with pulltorefresh wich is containing customlistview, but now my method for when I'm on the end of scroll doesn't work.

Any sugestions?

Regards!
 

Attachments

  • CustomListView.zip
    95.4 KB · Views: 218

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Hello corwin42 I trying your library and get this error:

B4A line: 35
Activity.AddView(STR, 0, 0, 100%x, 100%y)
javac 1.8.0_73
src\de\amberhome\swipetorefreshulv\main.java:337: error: cannot access SwipeRefreshLayout
mostCurrent._activity.AddView((android.view.View)(mostCurrent._str.getObject()),(int) (0),(int) (0),anywheresoftware.b4a.keywords.Common.PerXToCurrent((float) (100),mostCurrent.activityBA),anywheresoftware.b4a.keywords.Common.PerYToCurrent((float) (100),mostCurrent.activityBA));
^
class file for android.support.v4.widget.SwipeRefreshLayout not found
1 error


I compiling with C:\Android\platforms\android-22\android.jar and C:\Program Files\Java\jdk1.8.0_73
 

fbritop

Active Member
Licensed User
Longtime User
Great library, but can this Lib be used with another types of views, for example a Custom List View or a Panel?

When I tried it outputs an error of:
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
 

peacemaker

Expert
Licensed User
Longtime User
The lib is working with WebView, but
1) not all links
2) and only under old Android versions, 4.4 works, but 5.0, 6.0 - not.

If "STR_CanChildScrollUp As Boolean" exists - only this is fired.
If no - "STR_Refresh" is fired, but under Android 5+ - the webview is blank. But in the default browsser, Chrome browser and just Webview (without adding it to a STR object) the ULR is opened OK.
So, no idea why not all ULRs are visible, but i have to stop using the lib as users complain.

B4X:
Sub STR_Refresh
    'Disable the STR object so we can not start a new refresh process
STR.Refreshing = True
STR.Enabled = False
    wv.StopLoading
    wv.LoadUrl(LastURL)
End Sub
 

eps

Expert
Licensed User
Longtime User
I'm trying to use the ViewPagerSwipeToRefresh example, but it doesn't seem to want to display anything for me... It's carried out all the processing but doesn't display the Page Content. I had to change this line

B4X:
VP.Initialize(PC,"")

to

VP.Initialize("PC")

but apart from that I've left it unchanged.

I've updated the android-support-v4.jar to v22.2.1 version as well...

Any thoughts? I'm using BA 6.80 and Android 7.0 on an HTC 10..

It's probably something I haven't set up correctly.
 

eps

Expert
Licensed User
Longtime User
using android-support-v4.jar in b4a 6.8 is, i think, the wrong solution.

You should remove it and add a reference to the google maven repo

start a new thread if you want to know more.

I thought so as well - but it doesn't work without it either

Basically the example doesn't work and I can't work out why.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…