Using HorizontalViewPager1 instead of Canvas and Imagespirite

Hello MIT App Inventor Team!

I am trying to apply this blocks:

but I am facing a difficulty because in my previous app I was using canvase and imageSpirite

and now I need to use it by HorizontalViewPager1

So, I need your advise please : Is it possible to using HorizontalViewPager1 instead of canvas and imagespirite?

Thank you so much!

Probably, but why not stick with what already works for you ?

What difficulty are you facing ?

I like the using HorizontalViewPager1 because it is much nicer and all people like it.
This is my .aia using canvas
Book_slide.aia (61.1 KB)

I have tried but when I test it, it just stick in the first image and doesn't move.

From what you provide it is difficult to advise.

Suggest you simplify your blocks, get two pages working, and build from there.

Hello Tim,

I have simplified it and tried it but there is something is missing. Please have a look on the blocks


swipe2.aia (74.5 KB)

This is what I mean by simplify:

hzPager.aia (53.2 KB)

Hello Tim,
Thank you very much for simplify it for me.
I have added my blocks in it but still I think there is something missing.

Hello Tim,

Please have a look to my edited blocks but it still I need to add something but I don't know how to add it. Please I need your help.

hzPager_3.aia (68.4 KB)

Will take a while (and I have other things to do today) to work through your blocks.

Also, I note that your page3.png is not accessible.

I am sorry, the link was wrong.
Please use this csv file :

pagelinks.csv (270 Bytes)

OK, have revised your aia, may not be quite what you intend, but possibly something to work on. One complication is that the pager uses a 0 based index (perhaps @vknow360 can fix this at some point), and I combined all your csv files into just one. This means you can work from the main list of lists, instead of having to maintain several lists (of lists). I choose to not handle the Readers, but this can be done by creating complete separate pagelinks files for each reader, or some other method if the pagelinks content would be the same ? I reorganised things so that the "pages" are downloaded when the app starts, but only does this once if the pages already exist in the ASD. Once this is done, you can then just work off the device. I guess the same approach can be used for the sound files, although you may want to just call these as required if large ? The blocks could be further simplified, but I aimed to keep it simple so that you could hopefully follow what I have done, and link back to your original blocks.

hzPager_3_revised.aia (50.3 KB)

Thank you very much Tim,

Sure, I prefer to download all pages in startup the app as you said. However, I need every csv in seperate because I have just simplify the blocks in order to let me understand how the blocks works. So, is it possible to do that.

Actually, I have 600 pages. and 20 readers.

Hello Tim,

I hope it would be possible to include around 600 pages because I am afraid if I include 600 VerticalArrangement components

image

You would probably only want three pages, then use logic to load other pages as required. Then you may need to change the way you download pages back to how you were doing, or something similar.

I remember doing something similar some time ago for Osama Sayer, I will see if I can find it.

Won't you end up with @ 60 csv files instead of 20 ?

Thank you very much Tim for helping.

Regarding csv files:
I have only three types of csv files:

1-
pagelinks.csv for downloading all pages.

2-

1Page_Sound.csv for Reader 1
2Page_Sound.csv for Reader 2
....
....
....
20Page_Sound.svv for Reader 20

3-
1soundlinks.csv contains link for downloading sound for reader 1
....
....
20soundlinks.csv

As I told you that I just simplify the block to be easy for me to understand the blocks is working.

Here is one approach to the logic needed to load pages as you swipe, using only five components in the pager. This relies on your page names containing their number in the same position. Additional logic would be needed to go to a specific page - beyond the next or previous page numbers. I guess you could setup a download routine to get the next page whilst on the previous page, so that it is already downloaded when one swipes forward. If you need to swipe to the next page from right to left (instead of how I have done it - left to right), you should be able to easily reverse the logic.

hzpLogic.aia (58.3 KB)

Credits @vknow360 for the Pager extension

Thank you very much @TIMAI2 & @vknow360 for the Pager extension.
I will try to add my blocks and see how it works.

I have added my block but I think I have done something wrong.


hzpLogic_Taha.aia (95.7 KB)

Make your list of pages first, then apply them from the list. As you add more pages, update the list and refresh.