Android Question Cover flow with timer

microbox

Active Member
Licensed User
Longtime User
Hello everyone, I'm testing B4APhotoFlow by lonleystar, works fine on my device. Can anyone tell me how to view the images without swiping the screen (to left or to-right) I need to use only a timer for my purpose. I tried to use this method Coverflow.Selection = x but I need to show the the smooth transition from one image to the next.


Thanks in advance,
microbox
 

microbox

Active Member
Licensed User
Longtime User
Hi LucaMs, thanks for replying. Sorry if I was not clear. I need the effects between transition, but just need to be like auto scrolling when I run the app and with my limited knowledge I was thinking the timer will do the trick but I also want the effects.
For now this the code I have using timer..
B4X:
#Region Module Attributes
    #FullScreen: True
    #IncludeTitle: False
    #ApplicationLabel: B4APhotoFlow
    #VersionCode: 180
    #VersionName: 1.80
    #SupportedOrientations: landscape
    #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
   Dim tmr1 As Timer
End Sub

Sub Globals
    Dim Coverflow As PhotoFlow
    Dim l As List
    Dim lv As ListView   
   
    Dim  cntrMin,cntrMax As Int
    Private Panel1 As Panel
   
    Private btnClick As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("2")
    Activity.AddMenuItem("Get list from Path","d")
    Activity.AddMenuItem("Add Image","b")
    Activity.AddMenuItem("Add ImageAt","c")
    Activity.AddMenuItem("Clear Disk And Memory Cache","a")
    Panel1.Initialize("")
    lv.Initialize("lv")
    l.Initialize
    'Panel1.BringToFront
    Coverflow.InitializeCoverflow("Coverflow")
    tmr1.Initialize("Tmr1",2500)
    tmr1.Enabled  = False
    '************************
    'Coverflow.ClearCache
    '************************
   
    Coverflow.CreateCache = "Pippo.Pluto.Paperino"
   
    '************************
    'Coverflow.ClearCache
    '************************
   
    Activity.AddView(Coverflow, 0dip, 0dip, 100%x, 100%y)
    Coverflow.Spacing= -20
    Coverflow.ItemWidth = 200
    Coverflow.ItemHeight = 300
    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 = 0
   
    '************************
    'Coverflow.ClearCache
    '************************
   
   

End Sub

Sub d_Click

    Activity.AddView(lv,0,0,100%x,100%y)
    l=Coverflow.GetImageListFromAssets("Immagini")
    For n = 0 To l.Size-1   
        lv.AddSingleLine(l.Get(n))
    Next


End Sub

Sub a_Click
    Coverflow.ClearCache
    Activity.Title = "G.Salvi - Items = " & Coverflow.Length & " -  Width = " & Coverflow.ItemWidth&" | Height = "&Coverflow.ItemHeight
End Sub

Sub b_Click
    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")
    Activity.Title = "G.Salvi - Items = " & Coverflow.Length & " -  Width = " & Coverflow.ItemWidth&" | Height = "&Coverflow.ItemHeight
    cntrMin = 0
   
    cntrMax=Coverflow.Length
    tmr1.Enabled  = True
   
End Sub

Sub c_Click
    Coverflow.AddImageAt(0,File.DirRootExternal,"1876-01.jpg")
    Coverflow.AddImageAt(0,File.DirRootExternal,"mobot1.jpg")
    Activity.Title = "G.Salvi - Items = " & Coverflow.Length & " -  Width = " & Coverflow.ItemWidth&" | Height = "&Coverflow.ItemHeight
End Sub

Sub Activity_Resume
End Sub
Sub Activity_Pause(UserClosed As Boolean)
End Sub

Sub Coverflow_ItemClick(Position As Int, Value As Object)
   ' Coverflow.SetBackgroundImage(LoadBitmapSample("",Value,600,1024))
End Sub

Sub Coverflow_ItemLongClick (Position As Int, Value As Object)
    ExitApplication
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 lv_ItemClick (Position As Int, Value As Object)
    lv.RemoveView
End Sub

Sub Delay (DurationMs As Int)
Dim target As Long = DateTime.Now + DurationMs
Do While DateTime.Now < target
Loop
''ToastMessageShow("Delay Done!",False)
End Sub

Sub Tmr1_Tick
    Dim position  As Int
If cntrMin < 9 Then
    cntrMin = cntrMin + 1
Else
    cntrMin = 0
End If
    position = cntrMin   
    Coverflow.Selection = cntrMin
    Delay(200)
   
   
End Sub
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
I'm trying to understand how to use Gesture Detector in the following codes by Rick Harris,
B4X:
Sub Tmr1_tick
    Dim MEv As Object = GD.CreateMotionEvent(DateTime.Now, DateTime.Now, GD.ACTION_DOWN, 40%x, 50%y)
    GD.PassTouchEventTo(MEv, WebView1)
    Dim MEv As Object = GD.CreateMotionEvent(DateTime.Now, DateTime.Now, GD.ACTION_UP, 40%x, 50%y)
    GD.PassTouchEventTo(MEv, WebView1)
    Timer1.Enabled = False
End Sub
GD.PassTouchEventTo(MEv, WebView1) - I was thinking maybe by changing WebView1 to Panel1 would work but not the case. Can anyone tell what I'm missing?
 
Upvote 0

microbox

Active Member
Licensed User
Longtime User
Sorry if I'm still hanging on this..I was able to run the example given by Informatix in GestureDetector_dispatch and then try to merge it to the coverflow example by lonleystar. But I don't understand how to target the coverflow to simulate a click.
B4X:
#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
Hope anyone can help out.

Thanks in advance
 
Upvote 0
Top