Sub Globals
Public xui As XUI
Public Storage As ExternalStorage, lFile As ExternalFile
Public PersistantUri As String
Public ZoomImageView1 As ScaleImageView, ZoomImageView2 As ScaleImageView
Public pnlView As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
'######################################################################
'
' Run example with same tile loaded from different devices
'
' Load tile form File.DirDefaultExternal and from SDcard
'
'######################################################################
Private jRectLeft As Int, jRectTop As Int, jRectWidth As Int, jRectHeight As Int
Private iZ As Int = 13, iX As Int = 4400, iY As Int = 2686
Private cFileName As String
Private Outputstream1 As OutputStream
Private InputStream1 As InputStream
Private bmp As B4XBitmap
Log ("Run example with same tile loaded from different devices:")
Log ("Load tile form File.DirDefaultExternal and from SDcard")
Log (File.DirDefaultExternal)
jRectLeft = 0dip
jRectTop = 0dip
jRectWidth = Activity.Width
jRectHeight = Activity.Width / 2
pnlView.Initialize("")
Activity.AddView(pnlView, jRectLeft, jRectTop, jRectWidth, jRectHeight)
pnlView.Color=Colors.Magenta
' Tile 1: loaded from DirDefaultExternal
jRectLeft = 0dip
jRectTop = 0dip
jRectWidth = Activity.Width / 2
jRectHeight = Activity.Width / 2
ZoomImageView1.Initialize("")
pnlView.AddView(ZoomImageView1, jRectLeft, jRectTop, jRectWidth, jRectHeight)
' Tile 2: loaded from SDCard
jRectLeft = Activity.Width / 2
ZoomImageView2.Initialize("")
pnlView.AddView(ZoomImageView2, jRectLeft, jRectTop, jRectWidth, jRectHeight)
' Tile 1
cFileName = "Tile1_" & iZ & "_" & iX & "_" & iY & ".png"
bmp = xui.LoadBitmap(File.DirDefaultExternal, cFileName)
ZoomImageView1.Image = bmp
' Tile 2
Storage.Initialize (Me, "Storage")
Storage.SelectDir(True) ' set to False to define persistant Uri first time
Wait For Storage_ExternalFolderAvailable
cFileName = "Tile2_" & iZ & "_" & iX & "_" & iY & ".png"
lFile = Storage.FindFile(Storage.root, cFileName)
If lFile.IsInitialized = True And lFile.Length > 0 Then
InputStream1 = Storage.OpenInputstream(lFile)
Outputstream1 = File.OpenOutput(File.DirDefaultExternal, cFileName, False)
File.copy2(InputStream1,Outputstream1)
bmp = xui.LoadBitmap(File.DirDefaultExternal, cFileName)
Outputstream1.Close
ZoomImageView2.Image = bmp
Else
Log("File not found on external device")
End If
Log ("All done")
End Sub