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,177
  • CoverFlow with Text.jpg
    CoverFlow with Text.jpg
    115.6 KB · Views: 1,590
  • B4ACoverFlow v.1.70.zip
    36.2 KB · Views: 463
  • B4ACoverFlow v.1.80.zip
    40.2 KB · Views: 465
  • B4ACoverFlow v2.0 fix.zip
    40.6 KB · Views: 1,073
Last edited:

M.LAZ

Active Member
Licensed User
Longtime User
ciao lonleystar
can i add a label under every picture as a title . ,, i mean every pic has a title (titolo)
grazie a te
 

lonleystar

Well-Known Member
Licensed User
Longtime User
hi luke2012, the problem is in to the class ActionDrawer.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
  
    'ACTION DRAWER
OverflowItems.Initialize
OverflowItems.Add("item1")
OverflowItems.Add("item2")
*************************************************************************************************************

'AD.Initialize("", "icon.png", True, Colors.RGB(100,100,100), "Dark", True, True, True, OverflowItems, "Drawer", Activity, Main)
'AD.AddAction("WhatsApp", "WhatsApp_Click", "whatsapp.png")

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

WhatsApp_Click

End Sub

so it works let me know.
 

luke2012

Well-Known Member
Licensed User
Longtime User
hi luke2012, the problem is in to the class ActionDrawer.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
 
    'ACTION DRAWER
OverflowItems.Initialize
OverflowItems.Add("item1")
OverflowItems.Add("item2")
*************************************************************************************************************

'AD.Initialize("", "icon.png", True, Colors.RGB(100,100,100), "Dark", True, True, True, OverflowItems, "Drawer", Activity, Main)
'AD.AddAction("WhatsApp", "WhatsApp_Click", "whatsapp.png")

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

WhatsApp_Click

End Sub

so it works let me know.

Problem solved!
The problem was that the image files extention was missing (pic instead of pic.jpg)
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi Guys, Coverflow is updated to v1.60.

Add:

ShowText = True - if u want to show the text by default is hide

TextColor = Colors.Yellow - change the color to the text by default is white

TextSize = 20 - change the color to the text by default is white

Carousel = True - this work only with InitializeCoverFlow as no effect with InitializeCarousel

Reverse = True - this work only with InitializeCarousel as no effect InitializeCoverFlow fixed

n.b.

if u use Selection it´ll be at the end Example:


B4X:
Sub Activity_Create(FirstTime As Boolean)

    Coverflow.InitializeCoverflow("Coverflow")
    Activity.AddView(Coverflow, 0dip, 0dip, 100%x, 100%y)
    Coverflow.Spacing= -30
    Coverflow.ItemWidth = 300dip
    Coverflow.ItemHeight = 400dip
    Coverflow.AnimationDuration=800
    Coverflow.PopulateCoverflow(File.DirRootExternal, "Images2")
    Activity.Title = "G.Salvi -- Items in Coverflow = " & Coverflow.Length
    Coverflow.ShowText = True
    Coverflow.TextColor = Colors.White
    Coverflow.TextSize = 20
    'Coverflow.Carousel = True
    'Coverflow.Reverse = True
   
    '***************************
    Coverflow.Selection = 3
    '***************************

End Sub
 

luke2012

Well-Known Member
Licensed User
Longtime User
Hi Guys, Coverflow is updated to v1.60.

Add:

ShowText = True - if u want to show the text by default is hide

TextColor = Colors.Yellow - change the color to the text by default is white

TextSize = 20 - change the color to the text by default is white

Carousel = True - this work only with InitializeCoverFlow as no effect with InitializeCarousel

Reverse = True - this work only with InitializeCarousel as no effect InitializeCoverFlow fixed

n.b.

if u use Selection it´ll be at the end Example:


B4X:
Sub Activity_Create(FirstTime As Boolean)

    Coverflow.InitializeCoverflow("Coverflow")
    Activity.AddView(Coverflow, 0dip, 0dip, 100%x, 100%y)
    Coverflow.Spacing= -30
    Coverflow.ItemWidth = 300dip
    Coverflow.ItemHeight = 400dip
    Coverflow.AnimationDuration=800
    Coverflow.PopulateCoverflow(File.DirRootExternal, "Images2")
    Activity.Title = "G.Salvi -- Items in Coverflow = " & Coverflow.Length
    Coverflow.ShowText = True
    Coverflow.TextColor = Colors.White
    Coverflow.TextSize = 20
    'Coverflow.Carousel = True
    'Coverflow.Reverse = True
  
    '***************************
    Coverflow.Selection = 3
    '***************************

End Sub

Very good work!
Only a question : how to set the text that I want to show above the images ?
 

luke2012

Well-Known Member
Licensed User
Longtime User
Hi luke, wich text u mean? u want use your on text manually? let me know. Thx for the donation

quale testo ti riferisci ? vuoi inserire un testo da te scelto manualmente? fammi sapere. Grazie per la donazione.
CoverFlow with Text.jpg


Mi riferisco al testo che vedo sopra le immagini.

Da dove lo prende? Dal nome del file ?

P.S.
ho inserito nel mio codice attuale :

Coverflow.ShowText = True
Coverflow.TextColor = Colors.White
Coverflow.TextSize = 20
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi luke, yes it display the name of the images, when u set ( Coverflow.ShowText = True ) it will display the text,
by default ShowText = false mean the text hide

If u use the Coverflow.Selection use it at the last of the code that's all.

Ciao luke, si visualizza il nome delle immagini, quando setti ( Coverflow.ShowText = True ) visualizza il testo, di default ShowText = false significa che il testo non viene visualizzato, questo è tutto.

Se usi il comando Coverflow.Selection usalo sempre alla fine del codice come nell'esempio sopra, questo è tutto.
 

luke2012

Well-Known Member
Licensed User
Longtime User
Hi luke, yes it display the name of the images, when u set ( Coverflow.ShowText = True ) it will display the text,
by default ShowText = false mean the text hide

If u use the Coverflow.Selection use it at the last of the code that's all.

Ciao luke, si visualizza il nome delle immagini, quando setti ( Coverflow.ShowText = True ) visualizza il testo, di default ShowText = false significa che il testo non viene visualizzato, questo è tutto.

Se usi il comando Coverflow.Selection usalo sempre alla fine del codice come nell'esempio sopra, questo è tutto.

Ciao prima di tutto grazie per la risposta.
Ho provato come da tue indicazioni ma vedo solo le immagini.
Forse sbaglio qualcosa io ? C'è qualche vincolo sul formato file o altro ?
 

luke2012

Well-Known Member
Licensed User
Longtime User
Hi @lonleystar.

Hi confirm that the text is displayed above the images but I have a problem with some file names.

Ciao @LonelyStar.
Ti confermo che il testo si vede come da tue indicazioni (Grazie).
Ho però un problema con alcuni nomi file visualizzati.

Esempio :

1) nome file : "Affettati_misti.jpg"
testo visualizzato : "Affett ti_misti"
2) nome file : "Anguille_marinate_di_Oristano.jpg"
testo visualizzato : "Anguille_m rinate_di_Oristano"
 
Top