Android Question Loading pages dynamically with an unlimited count and swiping left or right to move between them.

Jim2025

Member
HI, I have an infinite number of pages that I want to display dynamically as shown below.

001.gif

The number of pages may be unlimited, it may be a 10 or 100, it may be a 100000. My solution is to dynamically load the page as shown. For this, at most two or three pages are not needed, but I did not find an example that has this situation. In the examples, the number of pages is usually specified in advance.

My problem is two issues, one is how load data dynamically and second is swiping between pages like in the image.
Does anyone know of an example or library?
 
Last edited:

Alexander Stolte

Expert
Licensed User
Longtime User
Does anyone know of an example or library?
And use the LazyLoading function, otherwise the performance will suffer very quickly if you fill 100 pages with content.
but you should reconsider this number, because I can assure you that nobody, even the Tiktok hardcore users would never swipe that often. It makes more sense to implement dynamic reloading, so that more pages are added as soon as the last 5 pages are reached.
 
Upvote 0

Jim2025

Member
I used the number 100000 just for this example so that we know that an infinite number of pages need to be displayed, the image and the title also showed exactly the same explanation as yours, which means loading the page dynamically

I had seen this library of yours before, the number of pages in your example is already specified, of course, I was working with B4َA a year ago and recently I see many changes in the program codes that I need to learn, but how can I make your example dynamic now, for example, I mentioned in the explanation that I think that in the end two or three pages are not needed, for example, in the swipe to the right mode, how can I make the next page dynamic and display it and delete the current page, or in the swipe to the left mode, how can I make the previous page dynamic and display it and delete the current page
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Maybe the question root is to make pages transparence animation ?
 
Upvote 0

Jim2025

Member
Thanks for the answers.

There is an ad site that has perhaps millions of ads registered on it and users are deleting or registering ads on the site at any given moment, so that Json information is always changing, I can extract the ad information with the help of Json, but since "I definitely have to give each ad separately on a page" and the number of ads is very large and the user also has to move between the ads by swiping left and right, I posted the explanation of the method and appearance of the implementation with an image at the beginning.



Maybe the question root is to make pages transparence animation?
I did not mean the transparent display effect at all just swipe has been matter. The transparent or fade effect was only for viewers to know that the information on that page when time must be read from that Json on internet (before being displayed means before swipes right), then the page must be created dynamically to be ready for show, or after being displayed, if the user swipes left, that information and the page must be deleted dynamically.



I am reviewing examples and libraries that I searched before creating the thread or examples and libraries that friends have suggested here. I will also be happy if I can get some code samples or examples from friends. When I reach a suitable result or output, I will definitely mention it here, but it will definitely take time.
 
Last edited:
Upvote 0

byz

Active Member
Licensed User
I have just developed a slideshow library that can dynamically switch during runtime for your requirement. But it may not be very complete yet. I am for personal use. The development logic is the logic mentioned above.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
"I definitely have to give each ad separately on a page"

You need to explain this statement.

I have a published app, several years old now, that presents data obtained from an internet site. There are hundreds of thousands of pages of data and new data is being added all the time. A user can enter at any point in the data and swipe left or right to adjacent items, just as you show in your first post, or jump to a new position. This is accomplished, as suggested in one of the posts above, by using only three panels.

If you are correct and each ad needs a separate page then there must be some extra requirement that you are not explaining, and without that explanation it is unlikely that anyone will guess an answer.

The other possibility, of course, is that you are not correct and perhaps have not been writing code long enough to learn how these seemingly magical things can be done.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Perhaps it is worth me explaining how to accomplish what you describe with only three panels, PanelA, PanelB and PanelC. Let us imagine that the User is viewing an advertisement in your series, maybe Ad#108. Ad#108 is loaded into PanelB and is central on the device screen. PanelA is positioned just off-screen to the left - it has Ad#107 loaded - and PanelC is just off-screen to the right and contains Ad#109.

The User swipes right. You start an animation that moves PanelB off-screen to the right and at the same time another animation that slides PanelA on to the screen from the left, just like in your first post. At this point PanelC has no purpose, so you reposition it just off-screen to the left and populate it with Ad#106.

PanelA is now on-screen with Ad#107, PanelB is just off-screen to the right with Ad#108, and PanelC is just off-screen to the left with Ad#106. If the User swipes left you animate PanelA off to the left and PanelB back on from the right; if the User swipes right you animate PanelA off to the right and slide PanelC on from the left. While the animations are in progress you repopulate and reposition the newly freed up panel with a new advert.

The reason that this works is that it takes a few tenths of a second to scroll a panel smoothly onto the screen but only a few milliseconds to populate a panel with new content. If it is going to take more than a few milliseconds to layout a panel then we need to know why. If your answer is that you need to download new information from the net, for instance, then that is the problem that needs to be fixed - not the means by which the data is displayed.
 
Upvote 0

Jim2025

Member
I've made something like this so far.
demo1.gif
Now I can swap infinitely left or right, have a swap effect and process the Json file immediately after the page changed swap disbaled too when json need process, only the part of processing the Json file data from the internet remains. I hope everything goes well, except for the splash page, I did this with 3 pages and of course I might need two temporary pages, I guess I need 5 pages in total.

Do you guys think it's good so far?
I think it's better if I put the source when I'm done
 

Attachments

  • demo1.apk
    220.9 KB · Views: 96
  • Like
Reactions: byz
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Do you guys think it's good so far?
It looks like good progress.

When are you starting the JSON download? It looks as though you are waiting until the User has swiped the page, but it is hard to be sure. If there is a way to fetch data before the User has committed to a swipe, so that the next page is already prepared, then that is the way to go. How much data are you downloading for each page?

I think it's better if I put the source when I'm done
It would be easier to help if you included at least some source code in your post - the apk tells nothing. You do not need to post the whole project - just a couple of key subroutines might be enough to understand if you are missing any tricks.
 
Upvote 0

byz

Active Member
Licensed User
I've made something like this so far.
demo1.gif
Now I can swap infinitely left or right, have a swap effect and process the Json file immediately after the page changed swap disbaled too when json need process, only the part of processing the Json file data from the internet remains. I hope everything goes well, except for the splash page, I did this with 3 pages and of course I might need two temporary pages, I guess I need 5 pages in total.

Do you guys think it's good so far?
I think it's better if I put the source when I'm done
Yes, I downloaded and ran it, and it feels pretty good. Sharing it is a feedback to the community.Additionally, I suggest that you download the JSON data of a certain page in advance to make it look smoother.
 
Upvote 0

Jim2025

Member
001.gif

I have perfected the program, but two questions have arisen: Even though I signed the program with my own customized key, Google Play still displays a warning on different devices, as shown in the image, and on some devices, it displays a warning similar to image number 0,1, 2. How can I solve this problem?
security.jpg
 
Upvote 0

Jim2025

Member
Yes, but I wanted to focus on the questions that arise about this work here because it is also related to this work.
Now I have a question: even though I had previously read articles that we should definitely try to use our own custom key for the final publication of the work, why do these warnings or alerts occur during installation on different phones and how to fix the problem? For example, on Android 11 or other devices, I displayed the output in the form of an image in the previous text. Does anyone have an idea how to solve the problem so that Google Play does not warn or a security error similar to the previous image does not occur?
 
Upvote 0
Top