Sub Activity_Create(FirstTime As Boolean)
badge=badge+1
CallSub(Me,"btnBadge_Click")
ToolbarHelper.Initialize
ToolbarHelper.ShowUpIndicator = True 'set to true to show the up arrow
ToolbarHelper.UpIndicatorDrawable = BitmapToBitmapDrawable(LoadBitmap(File.DirAssets, "hamburger.png"))
ACToolBarLight1.InitMenuListener
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ACToolBarLight1_NavigationItemClick
sm.ShowMenu
End Sub
Sub Activity_CreateMenu(Menu As ACMenu)
Menu.Clear
Menu.Add(5, 0, "Today", Null)
Menu.Add(6, 0, "Review", Null)
Menu.Add(7, 0, "Share", Null)
Dim item As ACMenuItem = ACToolBarLight1.Menu.Add2(8, 0, "cart", Null)
Dim bd As BitmapDrawable
bd.Initialize(refreshbitmap)
Dim item2 As ACMenuItem = ACToolBarLight1.Menu.Add2(1,1,"Refresh",bd)
item2.ShowAsAction=item2.SHOW_AS_ACTION_ALWAYS
item.ShowAsAction = item.SHOW_AS_ACTION_ALWAYS
UpdateIcon("cart", AddBadgeToIcon(notifbitmap, badge))
End Sub
Sub btnBadge_Click
Try
UpdateIcon("cart", AddBadgeToIcon(notifbitmap, badge))
Catch
End Try
End Sub
Sub btnClearBadge_Click
Try
badge = 0
UpdateIcon("cart", AddBadgeToIcon(notifbitmap, badge))
Catch
End Try
End Sub
Sub AddBadgeToIcon(bmp As Bitmap, Number As Int) As Bitmap
Dim cvs As Canvas
Dim mbmp As Bitmap
mbmp.InitializeMutable(32dip, 32dip)
cvs.Initialize2(mbmp)
Dim target As Rect
target.Initialize(0, 0, mbmp.Width, mbmp.Height)
cvs.DrawBitmap(bmp, Null, target)
If Number > 0 Then
cvs.DrawCircle(mbmp.Width - 8dip, 8dip, 8dip, Colors.Red, True, 0)
cvs.DrawText(Min(Number, 9), mbmp.Width - 8dip, 12dip, Typeface.DEFAULT_BOLD, 12, Colors.White, "CENTER")
End If
Return mbmp
End Sub
public Sub UpdateIcon(MenuTitle As String, Icon As Bitmap)
Dim m As ACMenuItem = GetMenuItem(MenuTitle)
m.Icon = BitmapToBitmapDrawable(Icon)
End Sub
Sub BitmapToBitmapDrawable (bitmap As Bitmap) As BitmapDrawable
Dim bd As BitmapDrawable
bd.Initialize(bitmap)
Return bd
End Sub
Sub ACToolBarLight1_MenuItemClick (Item As ACMenuItem)
If Item.id=5 Then
curtop=0
ScrollView1.Panel.RemoveAllViews
ProgressDialogShow("Loading Games....")
TabStrip1.ScrollTo(0,True)
loadhomegames
Return
End If
If Item.Id=6 Then
Dim in As Intent
in.Initialize(in.ACTION_VIEW, "")
StartActivity(in)
Return
End If
If Item.Id=7 Then
Dim share As Intent
share.Initialize(share.ACTION_SEND,"")
share.SetType("text/plain")
share.PutExtra("android.intent.extra.TEXT","")
share.WrapAsIntentChooser("Share text via")
StartActivity(share)
Return
End If
If Item.Id=8 Then
CallSub(Me,"btnClearBadge_Click")
StartActivity(notifications)
Return
End If
Dim Position As Int= TabStrip1.CurrentPage
If Position=1 Then
curtop=0
ScrollView2.Panel.RemoveAllViews
ProgressDialogShow("Loading Games....")
loadlivegames
End If
If Position=0 Then
curtop=0
ScrollView1.Panel.RemoveAllViews
ProgressDialogShow("Loading Games....")
loadhomegames
End If
If Position=2 Then
curtop=0
ScrollView3.Panel.RemoveAllViews
ProgressDialogShow("Loading Games....")
loadnewgames
End If
If Position=3 Then
curtop=0
ScrollView4.Panel.RemoveAllViews
ProgressDialogShow("Loading Games....")
loadmygames
End If
End Sub
Sub GetMenuItem(Title As String) As ACMenuItem
For i = 0 To ACToolBarLight1.Menu.Size - 1
Dim m As ACMenuItem = ACToolBarLight1.Menu.GetItem(i)
If m.Title = Title Then
Return m
End If
Next
Return Null
End Sub
#If Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
if (processBA.subExists("activity_createmenu")) {
processBA.raiseEvent2(null, true, "activity_createmenu", false, new de.amberhome.objects.appcompat.ACMenuWrapper(menu));
return true;
}
else
return false;
}
#End If