B4A Library [Lib] CoverFlow v2.0

Hi guys, as I have promised, CoverFlow is here.

Download the Coverflow.zip

The zip contains the library and an example that´s all


The CoverFlow Class = Neil Davies




B4ACoverFlow
Author:
Giuseppe Salvi
Version: 2
  • PhotoFlow
    Events:
    • ItemClick (Position As Int, Value As Object)
    • ItemLongClick (Position As Int, Value As Object)
    • ItemSelected (Position As Int, Value As Object)
    Methods:
    • AddImage (Dir As String, FileName As String)
      Add an image at the end of the PhotoFlow from sdcard or AssetsDir
      Example:
      PhotoFlow.AddImage(File.DirRootExternal,"a.jpg")
    • AddImageAt (index As Int, Dir As String, FileName As String)
      Add an image to the desired position in the PhotoFlow from sdcard or AssetsDir
      Example:
      PhotoFlow.AddImage(1,File.DirRootExternal,"a.jpg")
    • BringToFront
    • ClearCache
      Delete entire disk and memory cache created before
    • GetImageListFromAssets (path As String) As List
      Get entire list of images stored in assets folder
      Examples:
      Dim lv as ListView
      Dim l as list
      l.Initialize
      lv.Initialize("lv")
      Sub Menu_Click
      Activity.AddView(lv,0,0,100%x,100%y)
      l = Coverflow.GetImageListFromAssets("Here the Images path u've in assets")
      For n = 0 To l.Size-1
      lv.AddSingleLine(l.Get(n))
      next
      End Sub
    • GetItem (position As Int) As String
      Returns Item
      Example:
      i.Bitmap=LoadBitmap("",PhotoFlow.GetItem(Position))
    • InitializeCarousel (EventName As String)
      Initialize the Carousel
    • InitializeCoverflow (EventName As String)
      Initialize the PhotoFlow
    • IsInitialized As Boolean
    • PopulatePhotoFlow (dir As String, path As String)
      Populate PhotoFlow from sdcard not from assets
    • PopulatePhotoFlowFromAssets (path As String)
      Populate CoverFlow from assets not from sdcard
    • RemoveView
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    Permissions:
    • android.permission.WRITE_EXTERNAL_STORAGE
    Properties:
    • AnimationDuration As Int [write only]
      Sets how long the transition animation should run when a child view changes position.
    • Carousel As Boolean [write only]
      Set as Carousel
    • Color As Int [write only]
    • CreateCache As String [write only]
      Sets the name of your own cache
      Examples:
      PhotoFlow.CreateCache = "Your cache Name Here")
      It'll create a cache in "Android/data/Your cache name/cache/.thumbs" in to SdCard
    • Enabled As Boolean
    • FadingEdgeLength As Int [write only]
      Set the size of the faded edge used to indicate that more content in this view is available.
    • Height As Int
    • ItemHeight As Int
      Get or Set ItemHeight
    • ItemWidth As Int
      Get or Sets ItemWidth
    • Left As Int
    • Length As Int [read only]
      Returns lenght
    • Reverse As Boolean [write only]
      Set reverse
    • Selection As Int [write only]
      Jump directly to a specific item in the adapter data.
    • ShowText As Boolean
      Get or Sets the visibility of the text - by default is hide
    • Spacing As Int [write only]
      Sets the spacing between items in a Gallery
    • Tag As Object
    • TextColor As Int
      Get or Sets Text Color - by default is White
    • TextSize As Int
      Get or Sets Text size
    • Top As Int
    • Version As String [read only]
      Return Author and Version of this library
    • Visible As Boolean
    • Width As Int
 

Attachments

  • coverflow.jpg
    coverflow.jpg
    83.8 KB · Views: 2,378
  • coverflow2.jpg
    coverflow2.jpg
    81.1 KB · Views: 2,176
  • CoverFlow with Text.jpg
    CoverFlow with Text.jpg
    115.6 KB · Views: 1,590
  • B4ACoverFlow v.1.70.zip
    36.2 KB · Views: 462
  • B4ACoverFlow v.1.80.zip
    40.2 KB · Views: 464
  • B4ACoverFlow v2.0 fix.zip
    40.6 KB · Views: 1,072
Last edited:

ronovar

Active Member
Licensed User
Longtime User
It's ok..i know that is very complicated way of doing java code to make library...so i have just ask..just make it when you have time...i know that making vertical flow scroller is not an easy task.
 

udg

Expert
Licensed User
Longtime User
Edit: below problem solved modifying ItemWidth larger than smallest image width. Using ItemWidth/ItemHeight exactly as the smallest image dimensions raises the problem.

Hi lonleystar,

on a working project using this library, I simply modified the image files dimensions and the ItemWidth/Itemheight properties set in code, but suddenly received the following runtime error:
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@416129b8
    at android.graphics.Canvas.throwIfRecycled(Canvas.java:1026)
    at android.graphics.Canvas.drawBitmap(Canvas.java:1096)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:646)
    at it.giuseppe.salvi.downloader.PhotoFlowDownloader.reflectionBitmap(PhotoFlowDownloader.java:328)
    at it.giuseppe.salvi.downloader.PhotoFlowDownloader$BitmapDownloaderTask.onPostExecute(PhotoFlowDownloader.java:179)
    at it.giuseppe.salvi.downloader.PhotoFlowDownloader$BitmapDownloaderTask.onPostExecute(PhotoFlowDownloader.java:1)
    at android.os.AsyncTask.finish(AsyncTask.java:631)
    at android.os.AsyncTask.access$600(AsyncTask.java:177)
    at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:175)
    at android.app.ActivityThread.main(ActivityThread.java:5279)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
I tried with ClearCache, commenting out the whole cache creation, even loading again the png files in the Files folder. Nothing.
What else should I try?

TIA

Umberto
 
Last edited:

udg

Expert
Licensed User
Longtime User
Hi Giuseppe,

thank you for your response.
Is there any reason the value set for ItemWidth should be larger than actual width of the smallest image? I ask because that cured the problem.
BTW, same project with same images (but smaller) worked until I resized original pictures and reloaded them in Files folder. And the error seems to lead to a "cached" bitmap that the library tries to load instead of sampling again the new version of the same image. Here I refer to "image" instead of "file" because I even tried to rename the png file and to modifiy a couple of pixels just to produce a "different" image, but to no avail.
Hope the above could be useful to trace an eventual devious quirk somewhere in the lib code.

Umberto
 

udg

Expert
Licensed User
Longtime User
<ENG>
Hi Giuseppe,
thank you for your response. I'll try to setup a minimal project with the offending image in order to reproduce the problem.
It's even possible that it is caused by something on my device (I manually deleted old folders and files) so don't waste your time on it until we discover an eventually reproducible quirk.
</ENG>

<ITA>
Ciao Giuseppe,
ti ringrazio per la risposta ed il tempo che avrai già dedicato al problema da me segnalato. Spero di poter postare in giornata un progetto di esempio corredato dall'immagine che provoca il problema segnalato. In effetti, il tutto potrebbe essere confinato al mio device dove, tra l'altro, ho cancellato manualmente alcune vecchie dir e file.. Per ora non perderci altro tempo; prima verifichiamo se riusciamo a predisporre un caso riproducibile.

P.S. quando vuoi fare due chiacchiere in italiano, vedo che il forum in lingua è sempre attivo e frequentato da gente simpatica.
</ITA>
 

M.LAZ

Active Member
Licensed User
Longtime User
I have a little problem when i try to put my donation button in the signature doesnt display nothing ,I don't know where I'm wrong please can help me to write a little guide so i can put my own donation button in my signature?
This help will be appreciated. Thanks in advance.


Hiii,,
How did u solve this problem mr. lonleystar?
 

sorex

Expert
Licensed User
Longtime User
don't worry, it was just out of curriosity that I asked. so it should work on 2.x devices aswell?
 

georgelbs

Member
Licensed User
Longtime User
Hi lonleystar
Is possible to add a image from a bitmap?
I want show images from a database, the images are encoded in base64, then are decoded to bitmap
 
Top