Android Question Droppy_onDismissed() on runs first time

Discussion in 'Android Questions' started by RB Smissaert, Sep 1, 2019.

  1. RB Smissaert

    RB Smissaert Well-Known Member Licensed 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:

    Code:
    Sub AddDroppy
     
     
    'Droppy is wrapper library from this:
     'https://github.com/shehabic/Droppy
     '------------------------------------
       
     
    Dim i As Int
     
    Dim arrLabels(25As Label
     
    Dim arrSeparators(25As Boolean
     
     btnDroppyAnchor.Initialize(
    "btnDroppyAnchor")
     btnDroppyAnchor.Color =  
    Colors.ARGB(0,25525532'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 + 242'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 + 
    242'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
     
  2. RB Smissaert

    RB Smissaert Well-Known Member Licensed User

    To avoid confusion, title of this post should be:
    Droppy_onDismissed() only runs first time

    RBS
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice