Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Region Module Attributes
- #FullScreen: False
- #IncludeTitle: False
- #ApplicationLabel: CookIT
- #VersionCode: 1
- #VersionName:
- #SupportedOrientations: unspecified
- #CanInstallToExternalStorage: False
- #End Region
- 'Activity module
- Sub Process_Globals
- 'These global variables will be declared once when the application starts.
- 'These variables can be accessed from all modules.
- Dim ShowPanelTimer As Timer 'Timer to control the animation
- 'Constants for the actionbar
- Dim ID_ACTION_HOME As Int : ID_ACTION_HOME = 0
- Dim ID_ACTION_MENU As Int : ID_ACTION_MENU = 1
- Dim ID_ACTION_REGISTER As Int : ID_ACTION_REGISTER = 2
- 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 IME As IME
- Dim Dropmenu As AHPopupMenu
- Dim btnStart As Button
- Dim btnMenu As Button
- Dim btnBoodschappenlijst As Button
- Dim btnFavorieten As Button
- Dim btnRecepten As Button
- Dim btnSociaal As Button
- Dim AB As AHActionBar
- 'Initialize some bitmaps for the actionbar.
- Dim ABBackground As BitmapDrawable : ABBackground.Initialize(LoadBitmap(File.DirAssets,"banner.png"))
- Dim ABHome As BitmapDrawable : ABHome.Initialize(LoadBitmap(File.DirAssets,"cookitappklein.png"))
- Dim ABMenu As BitmapDrawable : ABMenu.Initialize(LoadBitmap(File.DirAssets,"menu.png"))
- Dim ABRegister As BitmapDrawable: ABRegister.Initialize(LoadBitmap(File.DirAssets,"register.png"))
- Dim pnlSearch As Panel
- Dim Counter As Int 'Will use this to set the TOP position of the panel
- Dim blnSearchOpen As Boolean 'Searchbar activated or not.
- Dim acetSearch As AutoCompleteEditText
- Dim imgvLogo As ImageView
- End Sub
- Sub Activity_Create(FirstTime As Boolean)
- 'If FirstTime = True Then
- ' StartActivity(actLogin)
- 'Else
- 'Load this particular layout.
- Activity.LoadLayout("Screenresol")
- 'End If
- 'Initialize the popup menu.
- Dropmenu.Initialize("AC")
- '3 options will be in th popup menu. Increase the last number to have more options.
- For i = 1 To 2
- Dim ai As AHActionItem
- Dim bd As BitmapDrawable
- Dim Filename, Text As String
- 'Select the id and set the icon (filename) and text for it.
- Select i
- Case 1
- Filename = "browse.png"
- Text = "Website"
- Case 2
- Filename = "help.png"
- Text = "Help"
- 'Case 3
- ' Filename = "sticky.png"
- ' Text = "Sticky"
- End Select
- 'Initialize a bitmap drawable (icon of option) and the action item (complete option with id, text and icon).
- bd.Initialize(LoadBitmap(File.DirAssets, Filename))
- ai.Initialize(i, Text, bd)
- ai.Selected = True
- 'Make the third item sticky so they will not close the popup.
- 'If i = 3 Then ai.Sticky = True
- 'Add the items to the popup menu.
- Dropmenu.AddActionItem(ai)
- Next
- 'ANIMATION OF THE SEARCHBOX!!!!
- 'ShowPanelTimer.Initialize("ShowPanelTimer", 20) 'Initialize the panel, the shorter the number the faster it will open
- 'pnlSearch.Top = pnlSearch.Top + pnlSearch.Height - pnlSearch.Height - 3 'The panel will be hidden regardless the height or position of the "search" panel
- 'Counter = pnlSearch.Top 'Set the Counter to that position
- 'ACTIONBAR
- AB.Initialize2("AB",ABBackground) 'Initializes the actionbar and sets the background of the actionbar.
- AB.ActionWidth = 42dip 'You can change the width of an action item. 42dip is default.
- AB.AddHomeAction(ID_ACTION_HOME,ABHome) 'Adds the home button to the actionbar.
- AB.AddAction(ID_ACTION_REGISTER,ABRegister) 'Adds an action button to the actionbar.
- AB.AddAction(ID_ACTION_MENU,ABMenu) 'Adds an action button to the actionbar.
- AB.TitleColor = Colors.White
- Activity.AddView(AB, 0, 0, 100%x, 42dip) 'Adds the actionbar to the activity.
- End Sub
- Sub Activity_Resume
- End Sub
- Sub Activity_Pause (UserClosed As Boolean)
- End Sub
- Sub Activity_Click
- 'Check if the search is open, if yes, close it.
- CheckSearchOpen
- End Sub
- Sub AB_ItemClicked(ItemID As Int)
- 'If the refresh action is pressed, show the progress indicator a few seconds.
- Select ItemID
- Case ID_ACTION_MENU
- Dropmenu.Show(AB.GetActionView(ID_ACTION_MENU))
- Case ID_ACTION_REGISTER
- StartActivity(actRegister)
- End Select
- End Sub
- 'Event sub when item is pressed on.
- Sub AC_Click (Position As Int, ActionItemID As Int)
- Dim Action As AHActionItem
- Action = Dropmenu.getActionItem(Position)
- Select Action.ActionId
- Case 1
- Dim p As PhoneIntents
- StartActivity(p.OpenBrowser("http://www.cookit-app.be"))
- Case 2
- Msgbox("In development.","Error")
- End Select
- End Sub
- Sub Search_Click()
- ShowPanelTimer.Enabled = True 'enable the timer to start "animating" the panel
- End Sub
- Sub btnBoodschappenlijst_Click
- 'open nieuw scherm
- Msgbox("Still in development.","Error")
- End Sub
- Sub btnRecepten_Click
- 'open nieuw scherm
- StartActivity(actCategories)
- End Sub
- Sub btnFavorieten_Click
- 'open nieuw scherm
- Msgbox("Still in development.","Error")
- End Sub
- Sub btnSociaal_Click
- 'open nieuw scherm
- Msgbox("Still in development.","Error")
- End Sub
- 'Takes care of the appearing and dissapearing of the searchbox and it's animation.
- Sub ShowPanelTimer_Tick
- If blnSearchOpen = False Then
- pnlSearch.Visible = True
- IME.ShowKeyboard(acetSearch)
- pnlSearch.Top = Counter
- Counter = Counter + 5dip
- If Counter > pnlSearch.top + pnlSearch.Height + 5dip - 3 Then 'When the panel is fully visible, stop
- ShowPanelTimer.Enabled = False
- blnSearchOpen = True
- End If
- Else
- pnlSearch.Top = Counter
- Counter = Counter - 5dip
- If Counter < pnlSearch.Top + pnlSearch.Height - pnlSearch.Height - 3 Then
- Counter = pnlSearch.Top + pnlSearch.Height - pnlSearch.Height - 3
- ShowPanelTimer.Enabled = False
- IME.HideKeyboard
- acetSearch.Text = ""
- pnlSearch.Visible = False
- blnSearchOpen = False
- End If
- End If
- End Sub
- Sub CheckSearchOpen
- If blnSearchOpen = True Then
- ShowPanelTimer.Enabled = True 'enable the timer to start "animating" the panel
- pnlSearch.Top = Counter
- Counter = Counter - 5dip
- If Counter < pnlSearch.Top + pnlSearch.Height - pnlSearch.Height - 3 Then
- Counter = pnlSearch.Top + pnlSearch.Height - pnlSearch.Height - 3
- ShowPanelTimer.Enabled = False
- blnSearchOpen = False
- End If
- IME.HideKeyboard
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement