#Region Project Attributes
#ApplicationLabel: Banner Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#DebuggerForceStandardAssets: True
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
Dim TimerBanner As Timer
End Sub
Sub Globals
Dim gif As GifDecoder
Dim ImageViewAds As ImageView
Dim BannerLink As String
Dim Frame As Int
Dim JobTipo As String
Dim JobStatus As Boolean
End Sub
Sub Activity_Create(FirstTime As Boolean)
ImageViewAds.Initialize("ImageViewAds")
Activity.AddView(ImageViewAds,0dip, 100%y-50dip, 320dip, 50dip)
gif.DisposeFrames
TimerBanner.Initialize("TimerBanner",0)
Dim Job1 As HttpJob
Job1.Initialize("Job1", Me)
Job1.Download("http://aldinformatica.com/banner/link1.txt")
End Sub
Sub Activity_Resume
If File.Exists(File.DirInternal,"image1.gif") Then
Frame=0
gif.load(File.DirInternal,"image1.gif")
TimerBanner.Interval = gif.Delay(Frame)
TimerBanner.Enabled=True
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If TimerBanner.IsInitialized Then TimerBanner.Enabled = False
End Sub
Sub JobDone (Job As HttpJob)
If Job.Success = True Then
Select Job.JobName
Case "Job1"
Dim Link As String
File.Copy(File.DirInternalCache,"1",File.DirInternal,"link1.txt")
BannerLink=File.ReadString(File.DirInternal,"link1.txt")
If BannerLink.Contains("http://") OR BannerLink.Contains("market://") Then JobStatus=True Else JobStatus=False
Dim Job2 As HttpJob
Job2.Initialize("Job2", Me)
'I changed image1.gif in ftp site
Job2.Download("http://aldinformatica.com/banner/image1.gif")
Case "Job2"
File.Copy(File.DirInternalCache,"2",File.DirInternal,"image1.gif")
gif.load(File.DirInternal,"image1.gif")
Frame = 0
TimerBanner.Interval = gif.Delay(Frame)
Log(TimerBanner.Interval)
ImageViewAds.Bitmap = gif.Frame(Frame)
ImageViewAds.Gravity = Gravity.FILL
TimerBanner.Enabled = True
End Select
Else
Log("Error: " & Job.ErrorMessage)
End If
End Sub
Sub ImageViewAds_Click
If JobStatus Then
If BannerLink.Contains("market://") Then
Dim UriStr As String = BannerLink
Dim Market As Intent
Market.Initialize(Market.ACTION_VIEW,UriStr)
Else
Dim pp1 As PhoneIntents
StartActivity(pp1.OpenBrowser(BannerLink))
End If
End If
End Sub
Sub TimerBanner_Tick
TimerBanner.Enabled = False
Frame = Frame + 1
If Frame >= gif.FrameCount Then
Frame = 0
End If
'TimerBanner.Interval = gif.Delay(Frame)
ImageViewAds.Bitmap = gif.Frame(Frame)
TimerBanner.Enabled = True
End Sub