Android Question SimpleMediaManager SMM Example Downloads 600 Images. What if Number is not Divisible by Four

Mahares

Expert
Licensed User
Longtime User
Erel’s example 2 of SMM downloads 600 images and works well. If I change the number of downloaded images to say 26 which is not a number divisible by 4 (number of images per row), the number of images is automatically padded by 2 more images to make it 28 which is divisible by 4. What happens if the available pictures to download or extract from a folder is 26, how would you pad the additional 2 slots where no images are available without crashing. Size mod 4 ???
Thank you
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This question is not really related to SMM.

There are many ways to do it.
You can for example add a global variable with the total number of images:
B4X:
For x = 0 To 3
            If data.IndexOfFirstImage + x >= TotalNumberOfImages Then Exit
            pnl.GetView(x).GetView(1).Text = data.IndexOfFirstImage + x
            MediaManager.SetMedia(pnl.GetView(x).GetView(0), $"https://picsum.photos/id/${data.IndexOfFirstImage + x}/200/300.jpg"$)
        Next
 
Upvote 0
Top