Region Project Attributes
#ApplicationLabel: geo1
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#AdditionalRes: $AndroidSDK$\extras\google\google_play_services\libproject\google-play-services_lib\res, com.google.android.gms
#ExcludeClasses: .games, .drive, .fitness, .wearable, .measurement, .cast, .auth, .nearby
#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .vision, .gcm
'remove the following line if you use AdMob
#ExcludeClasses: .ads
#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.
Dim parser As SaxParser
Private currentTab As Int
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 bar As StdActionBar
Private panel1, panel2, panel3,panel4,panel5 As Panel
Private qrcrv As QRCodeReaderView
Private gmap As GoogleMap
Private MapFragment1 As MapFragment
Dim button1, button2 As Button
Dim nome, Link, lat, lon As String
Dim latd, lond As Double
Dim trovato_placemark As Int
Dim last_title As String
Dim infopage,wvcredits,wvhome As WebView
Private b1 As Button
Private b2 As Button
Private p1 As Panel
Dim Url2Show As String
Dim creato As Boolean
End Sub
Sub set_tab(testo As String, img As String,pan As Panel)
pan.Initialize("")
Dim tb As StdTab = bar.AddTab(testo)
tb.Tag = pan
Dim bd As BitmapDrawable
bd.Initialize(LoadBitmap(File.DirAssets, img))
tb.Icon = bd
End Sub
Sub Activity_Create(FirstTime As Boolean)
creato=False
Url2Show="http://www.mysite.it/oblist.html"
bar.Initialize("bar")
bar.NavigationMode = bar.NAVIGATION_MODE_TABS
bar.Subtitle = "subtitle"
Activity.Title = "title"
Activity.AddMenuItem3("MenuItem", "mi", LoadBitmap(File.DirAssets, "ic_small.png"), True)
set_tab("Home","ic_home.png",panel1)
set_tab("QRCode","ic_qrcode.png",panel2)
set_tab("Guida","ic_info.png",panel3)
set_tab("Mappa","ic_map.png",panel4)
set_tab("Credits","ic_rotary.png",panel5)
'set the current selected tab
bar.SelectedIndex = currentTab
If currentTab = 0 Then bar_TabChanged(currentTab, bar.SelectedTab)
If MapFragment1.IsGooglePlayServicesAvailable = False Then
ToastMessageShow("Per usare questa appplicazione devi installare Google Play Services.", True)
End If
If FirstTime Then
parser.Initialize
End If
End Sub
Sub bar_Tabshow(url As String)
Activity.RemoveAllViews
Dim height As Int
If 100%y > 100%x Then
height = 100%y - 48dip
Else
height = 100%y
End If
bar.SelectedIndex=2
Activity.AddView(panel3, 0, 0, 100%x, height)
'infopage.LoadUrl("http://www.mysite.it/"& url)
Url2Show="http://www.mysite.it/"& url
End Sub
Sub bar_TabChanged(Index As Int, STab As StdTab)
Activity.RemoveAllViews
Dim pnl As Panel = STab.Tag
Dim height As Int
If 100%y > 100%x Then
height = 100%y - 48dip
Else
height = 100%y
End If
If pnl.NumberOfViews = 0 Then
pnl.LoadLayout(Index)
End If
Activity.AddView(pnl, 0, 0, 100%x, height)
Select Case Index
Case 0
wvhome.LoadUrl("file:///android_asset/index.html")
Case 2
infopage.LoadUrl(Url2Show)
Case 4
wvcredits.LoadUrl("file:///android_asset/credits.html")
End Select
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If bar.SelectedTab.IsInitialized Then currentTab = bar.SelectedTab.Position
'it will not be initialized if the mode is not tabs mode.
End Sub
Sub MapFragment1_Ready
gmap = MapFragment1.GetMap
If gmap.IsInitialized = False Then
ToastMessageShow("Error initializing map.", True)
Else
Dim cp As CameraPosition
cp.Initialize(39.222157131132094, 9.110994976307074, 17)
gmap.AnimateCamera(cp)
End If
Dim in As InputStream
in = File.OpenInput(File.DirAssets, "list_pois.kml")
parser.Parse(in, "Parser")
in.Close
End Sub
Sub Parser_StartElement (Uri As String, Name As String, Attributes As Attributes)
If Name = "Placemark" Then
trovato_placemark=1
End If
End Sub
Sub coord2latlng (acoordinates As String) As LatLng
Dim TempAllList,SafeList As List
Dim TempAllCoords,TempCoords As String
SafeList.Initialize
TempAllCoords=acoordinates
TempCoords=TempAllCoords.Replace("0 ","")
TempAllList.Initialize
TempAllList=Regex.Split(",",TempCoords)
For i=0 To TempAllList.Size/2 Step 2
Dim ln As LatLng
ln.Initialize(TempAllList.Get(i+1),TempAllList.Get(i))
Next
Return ln
End Sub
Sub Parser_EndElement (Uri As String, Name As String, Text As StringBuilder)
If Name = "name" And trovato_placemark=1 Then
trovato_placemark=2
last_title=Text.ToString
End If
If Name = "coordinates" And trovato_placemark=2 Then
Dim mylatlng As LatLng
trovato_placemark=3
mylatlng=coord2latlng(Text.ToString)
Select Case last_title
Case "Palmeto"
gmap.AddMarker2(mylatlng.Latitude, mylatlng.Longitude, last_title, 70)
Case "Succulente americane"
gmap.AddMarker2(mylatlng.Latitude, mylatlng.Longitude, last_title,70)
Case "Albero fiamma"
gmap.AddMarker2(mylatlng.Latitude, mylatlng.Longitude, last_title, 70)
Case Else
gmap.AddMarker2(mylatlng.Latitude, mylatlng.Longitude, last_title, 0)
End Select
'gmap.AddMarker(mylatlng.Latitude, mylatlng.Longitude, last_title)
End If
If Name = "Placemark" And trovato_placemark=3 Then
trovato_placemark=0
last_title=""
End If
End Sub
Sub button1_click()
gmap.MapType=gmap.MAP_TYPE_TERRAIN
End Sub
Sub Button2_Click
gmap.MapType=gmap.MAP_TYPE_SATELLITE
End Sub
Sub MapFragment1_MarkerClick (SelectedMarker As Marker) As Boolean 'Return True to consume the click
Select Case SelectedMarker.title
Case "Palmeto"
bar_Tabshow("ox4.html")
Case "Succulente americane"
bar_Tabshow("ox2.html")
Case "Albero fiamma"
bar_Tabshow("ox5.html")
Case Else
Msgbox(SelectedMarker.title,"marker")
End Select
End Sub
Sub b1_Click
qrcrv.Visible = True
DoEvents
qrcrv.startScan
End Sub
Sub b2_Click
qrcrv.stopScan
DoEvents
qrcrv.Visible = False
End Sub
Sub qrcrv_result_found(retval As String)
Msgbox(retval,"lettura")
End Sub