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:

luke2012

Well-Known Member
Licensed User
Longtime User
Ciao @lonleystar.
First of all thanks for your support!
I'm experiencing a little issue with the CleaeCache method because I get the attached error.

Ciao @lonleystar .
Prima di tutto grazie per il tuo supporto.
Sto avendo un problema quando chiamo il metodo .ClearCache in quanto mi produce l'errore allegato.
 

Attachments

  • ClearCache.png
    ClearCache.png
    70.3 KB · Views: 220

luke2012

Well-Known Member
Licensed User
Longtime User
ciao Luke, i checked it and work fine.

I uploaded B4ACoverFlow v1.7 whit Demo, fixed minor bug.


a tip : give the name to the image "Anguille marinate di Oristano" instead "Anguille_marinate_di_Oristano"

if u have a long name will chopping the name.

Thanks for your quick response @lonleystar .
I'll check as soon as possible and I'll let you known.

P.S.

Tu di dove sei ?
 
Last edited:

luke2012

Well-Known Member
Licensed User
Longtime User
Ciao luke, sono di Taranto ma da 18 anni sono stato in giro per il mondo e adesso vivo in Germania da un anno e mezzo.

Hi luke, I'm in southern Italy ( Taranto ), but from 18 years I've been around the World and now I'm now in Germany for a year and a half.

Hi @lonleystar !

I tested the v.1.7 library :

The good :
The text above the images is now OK

The Issue :
I still have the problem with the .ClearCache method that raise a Java error
See my previous post : http://www.b4x.com/android/forum/threads/lib-coverflow-v1-70.27696/page-6#post-231974
 

luke2012

Well-Known Member
Licensed User
Longtime User
Hi luke, i tested it with G.tab 7 P1000, G Tab 7 v2, G. Tab Note 2, and G.S4 it work fine i've no error.

I call clear cache by menu and by button still work fine, let me know.

The error is raised if clearcache il called before PopulateCoverFlow.

1) Doesn't work
Coverflow.ClearCache
Coverflow.PopulateCoverflow(File.DirDefaultExternal, CoverflowFolder)

2) Work Fine (the cache is pruned but sometime I got an error*)
Coverflow.PopulateCoverflow(File.DirDefaultExternal, CoverflowFolder)
Coverflow.ClearCache

* for example : when the CoverFlow folder doesn't exist on SD
 
Last edited:

DSD

Member
Licensed User
Longtime User
I'm also experiencing the NullPointerException.

Can I populate the Coverflow by using the AddImage method or do I need to first call the PopulateCoverFlow?
My images are under File.DirAssets. Here's the tracelog:

I get this exception every time I call the CoverFlow.AddImage(File.DirAssets,"somefile.jpg")

java.lang.NullPointerException
at it.giuseppe.salvi.PhotoFlowActivity.AddImage(PhotoFlowActivity.java:206)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:680)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:308)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at it.giuseppe.salvi.coverflow.main.afterFirstLayout(main.java:98)
at it.giuseppe.salvi.coverflow.main.access$100(main.java:16)
at it.giuseppe.salvi.coverflow.main$WaitForLayout.run(main.java:76)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:5225)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
at dalvik.system.NativeStart.main(Native Method)

I'm running the sample app on a Sony Xperia Tablet Z.
 

luke2012

Well-Known Member
Licensed User
Longtime User
ciao luca, u call clearcache before to populate? let me know with some little example code.

I understand tomorrow after work i'll fix it, sorry for the inconvenients.

Well done @lonleystar !
The important thing is to solve the problems! :)

In this way we also test and improve the library.
Thanks for your outstanding support!
 

DSD

Member
Licensed User
Longtime User
Hi luke and dsd, the coverflow is to update to v1.80,

As Luke ask the clearcache work fine.
Aas DSD ask now can add images from assets too but u've to populate it before.

Thank's for adding support for AddImage.
Unfortunately calling the following will only show the name of the file not the image itself...
It seems as though the image is not loaded...

Coverflow.AddImage(File.DirAssets,"House.jpg")
 

DSD

Member
Licensed User
Longtime User
Hi DSD, I test it now just in this moment i write u and it work fine.

Hi,

I think I'm doing something wrong then.

Here's the code, I'm running the sample app:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.AddMenuItem("Clear Disk And Memory Cache","a")
    'Activity.AddMenuItem("Add ImageAt","b")
    Coverflow.InitializeCoverflow("Coverflow")
    Coverflow.CreateCache = "it.giuseppe.salvi"
    Activity.AddView(Coverflow, 0dip, 0dip, 100%x, 100%y)
    Coverflow.Spacing= -20
    Coverflow.ItemWidth = 30%x
    Coverflow.ItemHeight = 90%y   
    Coverflow.AnimationDuration=800
    Coverflow.PopulateCoverflow(File.DirRootExternal, "DCIM")
    Activity.Title = "G.S - Items = " & Coverflow.Length
    Coverflow.ShowText = True
    Coverflow.TextColor = Colors.Yellow
    Coverflow.TextSize = 12
    'Coverflow.Carousel = True
    'Coverflow.Reverse = True
    Coverflow.Selection = 3

   
End Sub

B4X:
Sub a_Click
    Coverflow.AddImage(File.DirAssets,"House1.jpg")
    Coverflow.AddImage(File.DirAssets,"House2.jpg")
    'Coverflow.ClearCache
    'Coverflow.AddImage(File.DirRootExternal,"ANY IMAGE HERE")
End Sub

The PopulateCoverFlow does not contain any images, it's an empty folder.
But the two images that are added when calling a_click is embedded with the app.
 
Top