Android Question Droppy_onDismissed() on runs first time

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Using the Droppy library:
https://www.b4x.com/android/forum/threads/droppy-dropdown-menu.81918/

All working fine, but found one minor problem.
Droppy_onDismissed() only runs the droppy menu is dismissed first time.
As I am using sub menu's now (so another droppy menu is shown by clicking a droppy menu item)
I need to keep track of the visible droppy menu's.
I have a fix for this via a Try Catch, but wonder if this is a bug in the Droppy library or if I might be doing something wrong.

This is the code that sets up the droppy menu:

B4X:
Sub AddDroppy
 
 'Droppy is wrapper library from this:
 'https://github.com/shehabic/Droppy
 '------------------------------------
   
 Dim i As Int
 Dim arrLabels(25) As Label
 Dim arrSeparators(25) As Boolean
 
 btnDroppyAnchor.Initialize("btnDroppyAnchor")
 btnDroppyAnchor.Color =  Colors.ARGB(0,255, 255, 32) 'color of actionbar
 btnDroppyAnchor.Visible = True 'needs to be visible to anchor to the button
 'pnlLogo is a panel added to the Actionbar in Activity_Create
 pnlLogo.AddView(btnDroppyAnchor,104dip,40dip,1dip,1dip)
 
 pop.Initialize("Droppy", btnDroppyAnchor)
 pop2.Initialize("Droppy2", btnDroppyAnchor)
 
 arrSeparators(4) = True
 arrSeparators(10) = True
 arrSeparators(16) = True
 
 For i = 0 To 24 '20 to 46
  
  arrLabels(i).Initialize("lblOverflow")
  arrLabels(i).Height = 28dip
  arrLabels(i).Gravity = Gravity.CENTER_VERTICAL
  arrLabels(i).TextSize = 16
  arrLabels(i).TextColor = Colors.RGB(0,0,160) 'dark blue, so it stands out from other texts
  arrLabels(i).Text = arrMenuIconFilesTitles(i + 24, 2) 'as 24 non-overflow menu items
  
  If arrOverflowIconFiles(i).Length > 0 Or arrOverflowIconChars(i) > 0 Then
   
   'overflow menu item with icon
   '----------------------------
   Dim pnlOverflowItem As Panel
   Dim imvwOverflowImgView As ImageView
   Dim bmp As Bitmap

   pnlOverflowItem.Initialize("")
   imvwOverflowImgView.Initialize("imvwOverflowImgView")
   imvwOverflowImgView.Tag = arrMenuIconFilesTitles(i + 24, 2) 'no text property for imageviews
   pnlOverflowItem.Height = 28dip
   pnlOverflowItem.Width = 240dip
   
   If arrOverflowIconFiles(i).Length > 0 Then
    bmp.Initialize(File.DirAssets,arrOverflowIconFiles(i))
   Else
    bmp = TextToBitmap(Chr(arrOverflowIconChars(i)),20,Colors.Black,48,48,Typeface.FONTAWESOME,"CENTER")
   End If
   
   imvwOverflowImgView.Bitmap = bmp
   pnlOverflowItem.AddView(imvwOverflowImgView,0,0,28dip,28dip)
   pnlOverflowItem.AddView(arrLabels(i),28dip,0,212dip,28dip)
   
   Select Case arrOverflowGroups(i)
    Case 0
     pop.addMenuItem3(pnlOverflowItem)
    Case 1
     pop2.addMenuItem3(pnlOverflowItem)
   End Select
  Else
   'overflow menu item with no icon
   '-------------------------------
   arrLabels(i).Padding = Array As Int(8dip,0,0,0)
   arrLabels(i).Width = 240dip
   Select Case arrOverflowGroups(i)
    Case 0
     pop.addMenuItem3(arrLabels(i))
    Case 1
     pop2.addMenuItem3(arrLabels(i))
   End Select
  End If

  If arrSeparators(i) Then
   pop.addSeparator
  End If
 Next
 
 pop.addclickcallback.addonDismissCallback.triggerOnAnchorClick(False).build
 pop2.addclickcallback.addonDismissCallback.triggerOnAnchorClick(False).build
 
End Sub

Sub Droppy_onDismissed()
 bPopVisible = False
 Log($"Droppy_onDismissed()"$)
End Sub

Sub Droppy2_onDismissed()
 bPop2Visible = False
 Log($"Droppy2_onDismissed()"$)
End Sub


RBS
 
Top