Android Question Gallery class (or lib) for unlimited pictures qty

peacemaker

Expert
Licensed User
Longtime User
I have OutOfMemory error for looong pictures gallery, if to use nice class ClsCustomGallery of Informatix.
All gallery libs of lonleystar are with strange work in the latest B4A v.6.80 version, errors, strange picture list with some extra internal pictures...

So, do we have more picture Gallery solution for unlimited pictures qty ?
 

peacemaker

Expert
Licensed User
Longtime User
TempDownload.png
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
I remember that it was told that B4A ListView is for endless lists as it re-uses the views in the lines, re-loads content.

Now i have tried to show long picture gallery by ListView with modification like:
B4X:
    lv.Clear

    lv.TwoLinesAndBitmap.ItemHeight = 70%y
    lv.TwoLinesAndBitmap.Label.Height = 0
    lv.TwoLinesAndBitmap.SecondLabel.Height = 0
    lv.TwoLinesAndBitmap.ImageView.Height = 65%y
    lv.TwoLinesAndBitmap.ImageView.Width = lv.TwoLinesAndBitmap.ImageView.Height / 1.5
    lv.TwoLinesAndBitmap.ImageView.Left = (100%x - lv.TwoLinesAndBitmap.ImageView.Width)/2

It works, but.... soon again i see in the log:
B4X:
Downsampling image due to lack of memory: 8
Downsampling image due to lack of memory.
Downsampling image due to lack of memory: 2
Downsampling image due to lack of memory: 4
Downsampling image due to lack of memory: 8
Downsampling image due to lack of memory: 16
Downsampling image due to lack of memory.
Downsampling image due to lack of memory: 2
Downsampling image due to lack of memory: 4
Downsampling image due to lack of memory: 8
Downsampling image due to lack of memory: 16
Downsampling image due to lack of memory: 32
Error occurred on line: 88 (Main)
java.lang.OutOfMemoryError: Failed to allocate a 64 byte allocation with 32 free bytes and 32B until OOM
    at android.os.Message.obtain(Message.java:146)
    at android.os.Handler.getPostMessage(Handler.java:802)
    at android.os.Handler.post(Handler.java:335)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:69)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:163)
    at anywheresoftware.b4a.phone.Phone$LogCat$1.run(Phone.java:751)
    at java.lang.Thread.run(Thread.java:818)
java.lang.RuntimeException: Error loading bitmap (OutOfMemoryError)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.InitializeSample(CanvasWrapper.java:570)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Initialize(CanvasWrapper.java:514)
    at anywheresoftware.b4a.keywords.Common.LoadBitmap(Common.java:1160)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)

:(
Any ideas ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
THanks, it helps. But ... if pictures qty will be several times bigger ?
I think, the view must for sure unload pictures that are not visible now to a user. And preload next to be visible...
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
From FTP server of the customer, files qty rises all the time... Preview small pictures. Big picture is downloaded after the preview selection.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
ok you can use this mine library RESIZE PICTURE :

B4X:
FTP.Initialize("FTP", "xxx, 21, "yyyyy", "zzzzz")
FTP.DownloadFile(  "/hotel/bigphoto.jpg", False, File.DirRootExternal, "original.jpg")

Dim pic As ResizePicture
Dim nomepath As String = File.DirRootExternal
pic.resize( File.DirRootExternal, "original.jpg", 600, 400, File.DirRootExternal, "compress","jpeg", "yes")

in this mode you have original size 1 or 2 Mb, after compress you have very small size.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Resizing is not a problem. Think - pictures qty is rising... anyway, if resources are not free dynamically - OOM error will be anyway
 
Upvote 0
Top