Android Question [B4X] B4XPages Pixabay - A working example

Peter Simpson

Expert
Licensed User
Longtime User
Hello fellow B4X'ers ;)
NO - This is not a tutorial.

PLEASE NOTE: To test the attached file, you need to sign up below for free to receive your free develop API key

This morning after reading Erels B4XPages tutorial, I spent about 30 minutes converting my B4A (Android) Pixabay code over to work with B4X Pages. Wow it's now working exactly like B4i (iOS), that's BRILLIANT :cool:

Previously when searching for and then selecting an image from the downloaded image list, the previous Activity would stop populating the list whilst the WebView (in the newly opened Activity) loaded to show you more information about the Image you selected. This DOES NOT happen in iOS, iOS keeps loading the searched for images into the list in the background on the previous page. Okay yes, there are ways to accomplish continuing loading images AFTER going back to the first Activity in B4A (Android), but that means adding more lines of code to the project and managing multiple panel code in just one Activity. Using B4XPages in B4A (Android) means that when selecting an Image to view more information, the previous list (B4XPage) still continues to load the images in the background, that's EXCELLENT. Now when you go back to the previously searched for images in the list, you will see that all the images have loaded into the list (an xCLV in this case) and not just the first few images.

Conclusion: This is a serious game changer for B4A, multiple pages accomplishing multiple tasks at the exact same time. I don't know what this means for CPU(speed)/Memory usage, but my basic tests done on a Pixel 3XL shows me excellent results. Please note that I DID NOT say multiple Activities as they are not Activities, they are pages (I think stacked above each other). I've only used B4XPages in B4A for about 30 minutes this morning and again just now for about 15 or 20 minutes whilst creating this post, but I can already see how B4XPages can make using Activities almost redundant. I can see how in certain circumstances processing visible data (lists, cards, images etc) or just processing plain old data on the first B4XPage (in the background) whilst viewing a second B4XPage (In the foreground) can be beneficial, this can already be accomplished easily in iOS using Pages and now it's possible in B4A using B4XPages. I can also see how using B4XPages can and will cut down on code whilst developing cross platform XUI applications whilst using B4A and B4i. On the odd occasion, I can see me using B4XPages for background processing in Android. The attached project is perfect proof of one of those odd occasions.

I did not do too much debugging, this test code is not 100% perfect as this is ONLY AN INITIAL FIRST TEST for me of using B4XPages.

First test of the Pixabay app using B4XPages
Screenshot_20200612-161514.png


Lets hope that new developers find B4X.com and at least gives the B4X suite of RAD tools a chance to show them what Anyway Software can do for them. Hopefully all B4A developers will donate and keep donating as Erel does a lot of R&D to make cross platform development easier for B4X developers to accomplish.

Thank you Anywhere Software, and by the way if you want to move this post to Chit Chat or wherever then please be my guest ;)


>>> CLICK HERE <<< to download the test example project



Enjoy...

#gamechanger
 
Last edited:

JohnC

Expert
Licensed User
Longtime User
Your sample might not be buggy, but your signature sure is! (you got me - I tried flicking it away!)
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
I'm afraid it will crash at line 45
Don't be afraid ;)

Hmm I missed that one.
For me it's just about learning the basics of B4XPages at the mo, so cheers for the info and I've re-uploaded the project but I've not tested it (all the phones are downstairs).

And now it's time to watch the movie called The Irishman, again :cool:
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
This is a serious game changer for B4A, multiple pages accomplishing multiple tasks at the exact same time.

I think you used a wrong way of building apps.

If you used a bunch of panels that you show/hide you would have had the same result years ago aswell :)

I've used this method in all my games and the behaviour is always the same being on Android or IOS. only webviews can be slighty different event/speed/style wise.

I never saw the need for more than one activity or (ios) page. activities were slow when I tested if years ago and a lack of control of some background gradiants etc made me swicth to the panel method right away and never look back to/at them.

I will have a look at the B4Xpages this weekend, maybe I can remove some hide/display code by using it instead.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
I think you used a wrong way of building apps.
Nah :p
If you used a bunch of panels that you show/hide you would have had the same result years ago aswell :)
Yes that is more than true. Buuuuuuuuuuuuuuuut as I've mentioned above, that takes more coding, I've had to suffer that pain in the past.

Now coding multiple panels hiding them and showing them compared to using B4XPages is like light and day. If B4XPages was around when I last did that hiding and showing panels malarkey, developing the code would have been a lot easier to accomplish at the time and using B4XPages definitely would have cut down on development time and also complications.

But hey, progress is progress and that's how apps were developed back then in B4A. But no longer do we have to suffer that painful programming issue, P4XPages is simple to integrate and really simply to use.

Now back to my movie...
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
hiding/showing is a oneliner if you play it smart.

here's how it progressed over the years to xui based views

B4X:
Sub showItem(v As B4XView)   
 Dim panels() As B4XView=Array As B4XView (pnlMenu,pnlInfo,pnlGame,pnlCode,pnlLeaderboard,pnlPrivacyPolicy)
 For x=0 To panels.Length-1
  panels(x).Left=pnlGame.Width
 Next
 v.Left=0
End Sub

using .left instead of .visible had its reasons as .visible seemed to fail sometimes or overlaying invisible panels still spoiled interactions.

I hope B4Xpages are also page groups so that it uses a similar show loop then I can get rid of mine ;)

But you're right... progress is always nice and you are never too old to learn and your source will probably clean up aswell.

By the way I flinged/swiped my screen ealier thinking that bug on the right was a real one.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Now back to my movie...
No, please.

I created my key in Pixabay, put code in the app, but I don't see the image list when I made the search.
The job return sucess in SearchImages and DownloadImages subs.
What I could missing?

By the way: which movie?
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Hmm, is there an actual JSON feed returned from the API requested. I tested it on 2 laptops in debug mode then I uploaded the zip file. I did do a quick update without testing it, but the update was logical so it didn't need testing.

Sorry, no laptops on at the moment, just my tablet.

By the way: which movie?
The Irishman on Netflix.
I like all those sort of movies from Goodfellas, Casino, A Bronx Tale, Donnie Brasco etc etc etc.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
is there an actual JSON feed returned from the API requested.
Yes. Part of the JSON returned:
B4X:
{"total":5,"totalHits":5,"hits":[{"id":1731386,"pageURL":"https://pixabay.com/photos/boeing-787-aircraft-airplane-1731386/","type":"photo","tags":"boeing, 787, aircraft","previewURL":"https://cdn.pixabay.com/photo/2016/10/11/12/12/boeing-1731386_150.jpg","previewWidth":150,"previewHeight":99,"webformatURL":"https://pixabay.com/get/57e7d642495aaa14f1dc8460962c3679163ddfe24e507440742673d3964ec0_640.jpg","webformatWidth":640,"webformatHeight":426,"largeImageURL":"https://pixabay.com/get/57e7d642495aaa14f6da8c7dda79337f123cdce4544c704c7c2e72dc904cc65d_
Sorry, no laptops on at the moment, just my tablet.
The Irishman on Netflix.
No problem. When you have time.
Good movie.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
@asales,
After looking at the code in more detail, I noticed that the code worked as expected in Debug mode and Release mode, but in Release (obfuscated) mode the code in the B4XMainPage module stops executing on line 92, but only in Release (obfuscated) mode.

I've probably missed something glaringly obvious, so I'll look at the code again in the morning.

Good movie.
I would hate to disagree with you, but I think that you need to .Replace("Good movie", "Great movie") :D I watched it the same day it was first released.

I've tidied up the code and you can re-download it using the link in the first post, but that does not fix the Release (obfuscated) mode issue that I've come across...
 
Last edited:
Upvote 0

asales

Expert
Licensed User
Longtime User
I've tidied up the code and you can re-download it using the link in the first post, but that does not fix the Release (obfuscated) mode issue that I've come across...
It works. Thanks!

I would hate to disagree with you, but I think that you need to .Replace("Good movie", "Great movie") :D I watched it the same day it was first released.
"Good movie" it means:
Have a "good" time watching a great "movie" šŸ˜€šŸ‘
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Hello @asales,
Please try downloading the zip file again using the link in the first page.

It appears that even though the sub called 'AddItem' works perfectly fine in Release (obfuscated) mode when using Activities, when using B4XPages that sub does not work at all. I've now changed that sub name from 'AddItem' to 'Add_Item' (with an underscore) and images are now loading as expected in Release (obfuscated) mode.

Release (obfuscated) skips obfuscation of subs with underscores in their event name.

Edit: I missed your last post. Anyway I'm pleased that it's working for you now.


Enjoy...
 
Upvote 0
Hi Peter,
I want to find some herb photos by keyword such as Dried Radix and Polygonatum Root.
However, the Pixabay return Sorry, we couldn't find any matches.
Can I upload such herb photos with corresponding keywords to search them?
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Pixabay return Sorry, we couldn't find any matches.
I presume that you've also tested those searches via pixabay.com and got the same Sorry message.

Can I upload such herb photos with corresponding keywords to search them?
If you signup to pixabay.com, you can then upload quality photos directly, please read the 'Image quality guidelines' as bad quality photos will not be accepted and removed.


Enjoy...
 
Upvote 0
Top