#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
End Sub
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim GD_Green, GD_Red,GD As GestureDetector
    Dim pnlGreen, pnlRed As Panel
    '----------------------------------
    Dim Coverflow As PhotoFlow
    Dim l As List
    Dim lv As ListView       
End Sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
     Activity.LoadLayout("Layout1")
   
    lv.Initialize("lv")
    l.Initialize
    Coverflow.InitializeCoverflow("Coverflow")
    Coverflow.CreateCache = "Pippo.Pluto.Paperino"
   
    Activity.AddView(Coverflow, 0dip, 0dip, 100%x, 100%y-70dip)
    Coverflow.Spacing= -20
    Coverflow.ItemWidth = 500
    Coverflow.ItemHeight = 600
    Coverflow.AnimationDuration=300
   
    '************************
    'Coverflow.ClearCache
    '************************
    Coverflow.PopulatePhotoFlowFromAssets("Immagini")   
    'Coverflow.PopulatePhotoFlow(File.DirRootExternal, "Image")   
    Activity.Title = "G.Salvi - Items = " & Coverflow.Length & " -  Width = " & Coverflow.ItemWidth&" | Height = "&Coverflow.ItemHeight
   
    '************************
    'Coverflow.ClearCache
    '************************
   
    Coverflow.ShowText = True
    Coverflow.TextColor = Colors.Yellow
    Coverflow.TextSize = 12
    Coverflow.Carousel = True
    'Coverflow.Reverse = True
    Coverflow.Selection = 3
    GD_Green.SetOnGestureListener(pnlGreen, "GD_Green")
    GD_Red.SetOnGestureListener(pnlRed, "Coverflow_ItemSelected")
   
    b_Click
End Sub
Sub b_Click
    Coverflow.AddImage(File.DirAssets,"9.jpg")
    Coverflow.AddImage(File.DirAssets,"10.jpg")
    Coverflow.AddImage(File.DirAssets,"1.jpg")
    Coverflow.AddImage(File.DirAssets,"2.jpg")
    Coverflow.AddImage(File.DirAssets,"3.jpg")
    Coverflow.AddImage(File.DirAssets,"4.jpg")
    Coverflow.AddImage(File.DirAssets,"5.jpg")
    Coverflow.AddImage(File.DirAssets,"6.jpg")
    Coverflow.AddImage(File.DirAssets,"7.jpg")
    Coverflow.AddImage(File.DirAssets,"8.jpg")
    Coverflow.AddImage(File.DirAssets,"9.jpg")
    Coverflow.AddImage(File.DirAssets,"10.jpg")
    Coverflow.AddImage(File.DirAssets,"1.jpg")
    Coverflow.AddImage(File.DirAssets,"2.jpg")
    Activity.Title = "G.Salvi - Items = " & Coverflow.Length & " -  Width = " & Coverflow.ItemWidth&" | Height = "&Coverflow.ItemHeight
   
    Coverflow.Selection = 2
    'pnlGreen.BringToFront
    'pnlRed.BringToFront
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Coverflow_ItemSelected(Position As Int, Value As Object)
    'Activity.Title = "G.Salvi - Items = " & Coverflow.Length & " | Position = " & Position & _
    '" |  Width = " & Coverflow.ItemWidth&" | Height = "&Coverflow.ItemHeight
    'ToastMessageShow("Position " & Position & " value " & Value ,False)
End Sub
Sub Activity_Touch(Action As Int, X As Float, Y As Float)
    If Action = Activity.ACTION_DOWN Then
        Activity.Color = Colors.Blue
        Log("ACTIVITY_Touch action=" & Action & ", x=" & X & ", y=" & Y)
       
    Else
        If Action = Activity.ACTION_UP Then
            Activity.Color = Colors.Black
        End If
        Log("   ACTIVITY_Touch action=" & Action & ", x=" & X & ", y=" & Y)
    End If
End Sub
Sub GD_Green_onTouch(Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
    Log("GREEN_Touch action=" & Action & ", x=" & X & ", y=" & Y & ", ev=" & MotionEvent)
    Return GD_Green.PassTouchEventTo(MotionEvent, pnlRed)
End Sub
Sub GD_Red_onTouch(Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
     Dim MEv As Object = GD.CreateMotionEvent(DateTime.Now, DateTime.Now, GD.ACTION_DOWN, 40%x, 50%y)
    GD.PassTouchEventTo(MEv, Coverflow)
    Dim MEv As Object = GD.CreateMotionEvent(DateTime.Now, DateTime.Now, GD.ACTION_UP, 40%x, 50%y)
    GD.PassTouchEventTo(MEv, Coverflow)
    Log("RED_Touch action=" & Action & ", x=" & X & ", y=" & Y & ", ev=" & MotionEvent)
    Return False 'The event is ignored and passed down to another view (the activity behind)
End Sub