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,450
  • coverflow2.jpg
    coverflow2.jpg
    81.1 KB · Views: 2,242
  • CoverFlow with Text.jpg
    CoverFlow with Text.jpg
    115.6 KB · Views: 1,649
  • B4ACoverFlow v.1.70.zip
    36.2 KB · Views: 540
  • B4ACoverFlow v.1.80.zip
    40.2 KB · Views: 534
  • B4ACoverFlow v2.0 fix.zip
    40.6 KB · Views: 1,141
Last edited:

DSD

Member
Licensed User
Longtime User
HI DSD, i test it now like u show in post above work fine.

Thanks for helping me.
When testing my code, did you load images from File.DirAssets?
Are there any restrictions on image format?
I'm using jpegs...
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Thanks for helping me.
When testing my code, did you load images from File.DirAssets?
Are there any restrictions on image format?
I'm using jpegs...


no restriction i use jpg too the ext. below.


".jpg",".jpeg",".jpe",".jfif",".png",".bmp",".dib",".gif",".peg",".tif",".tiff",".mpf",".ppf"
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi guys, B4ACoverFlow is Update to v2.0.

What's new:

PopulatePhotoFlowFromAssets, GetImageListFromAssets.

Example:

B4X:
Coverflow.PopulatePhotoFlowFromAssets( "Images" ) - Images is a folder


B4X:
Sub Menu_Click

  Activity.AddView( lv, 0, 0, 100%x, 100%y )

  l = Coverflow.GetImageListFromAssets( "Images" ) - Images is a folder

  For n = 0 To l.Size-1   

     lv.AddSingleLine ( l.Get(n) )

  Next

End Sub

Coverflow.AddImage,Coverflow.AddImageAt Work better now.
inide the zip is a new lib v2.0 and demo
 

DSD

Member
Licensed User
Longtime User
Hi guys, B4ACoverFlow is Update to v2.0.

What's new:

PopulatePhotoFlowFromAssets, GetImageListFromAssets.

Coverflow.AddImage,Coverflow.AddImageAt Work better now.
inide the zip is a new lib v2.0 and demo

Thanks for adding this, I'm now able to use the coverflow, great work! :)
The images are scaled wrong (for me), although I've set the ItemWidth and ItemHeight to the correct height and width of the images (they are all of the same height and width). Do I need to compensate for something when setting the height and width in order to get the pictures to the correct aspect?

The height is 260 and width is 186, but the sample app show each item having heigth 390 and width 279. I've tried setting the ItemHeight and ItemWidth before and after adding images, but it does not seem to work.
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi dsd and all the lib is fixed as dsd as reported.

p.s
For the correct ItemWidth and ItemHeight use this way below.

ItemWidth = 186, ItemHeight = 260 instead of ItemWidth = 186dip, ItemHeight = 260dip or ItemWidth = 30%x and ItemHeight = 40%y

Another problem fixed is when you wanted to display images from assets it gave the error file not found now it work, below is the example.

B4X:
Sub Coverflow_ItemClick(Position As Int, Value As Object)

below when you want to to display the image from sdcard.

Coverflow.SetBackgroundImage(LoadBitmapSample("",Value,600,1024))

*****************************************************

below when you want to to display the image from assets.

Coverflow.SetBackgroundImage(Value)

End Sub

Sorry for the inconvenience.



pic1.jpg
 
Last edited:
  • Like
Reactions: DSD

DSD

Member
Licensed User
Longtime User
Thanks Lonleystar for fixing this.

I've given you a donation of 10 Euros for all your help and work.
 

IlCasti

Active Member
Licensed User
Longtime User
Hi lonleystar
Great Lib!
But..
...How can i change tilt in carousel?
In your attached pictures i see that there are different tilt..
Thanks to explain method

Bye
IlCasti
 

IlCasti

Active Member
Licensed User
Longtime User
Image in carousel are not flat but has tilt
In that three attachments the different images are tilted in different way
How can i do different angle? It dipende by spacing values?
Thanks
PS: if u dont understand i show u some example

Le immagini non sono piatte ma inclinate
Nelle tre immagini allegate queste sono inclinate in modo diverso
Come posso mettere un angolo diverso? Dipende dalla spaziatura?
Grazie
Ps: se non capisci ti mostro degli esempi

Ciao

CoverFlowTiltImage.png


https://www.dropbox.com/s/dx11ard5mw2mwvj/CoverFlowTiltImage.png
 

IlCasti

Active Member
Licensed User
Longtime User
Hi Giuseppe
Thank you
I solved this afternoon with the spacing of elements and their width
But... if you wanted, in the future, to implement the gradation of elements, the forum would be grateful to you :D

Now i go on to test your lib in my app ;-)
Bye
 

Mrjoey

Active Member
Licensed User
Longtime User
Hello , gd work man , it seems a beautiful library , i didnt tested it yet but i saw all the functions and properties in the 1st post and i would like to ask u if u make a new function to displays images from loaded bitmaps i mean like coverflow.addbitmap(bmp as bitmap) it would really help me for my music app so i can display the song covers , i hope u consider my wish in the next update , and i appreciate ur hard work , thank u
 

Mrjoey

Active Member
Licensed User
Longtime User
10x for ur reply , i mean instead of addimage(dir , filename) it would be addimage(bmp as bitmap) 10x dear :)
 
Top