Sub Process_Globals
Dim SMB1 As SMB
Dim lstDir As String
Dim route As Map
Dim r As Int
Dim images As Map
Dim picfiles As MLfiles
Dim m As List
End Sub
Sub Globals
Dim Files As ListView
Dim BackButton As ImageView
Dim iTent As Intent
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim fType As String
If FirstTime Then
SMB1.Initialize("SMB1")
Activity.LoadLayout("main")
route.Initialize
lstDir = "smb://networkdrive/" ' my network drive
r = 0
route.Put(r,lstDir)
images.Initialize
m = File.ListFiles(File.DirAssets)
For a=0 To m.Size-1
fType = m.Get(a)
If fType.SubString(fType.Length-3) ="png" Then
fType = fType.SubString2(0,fType.Length-4)
images.Put(fType,LoadBitmap(File.DirAssets,m.get(a)))
End If
Next
End If
SMB1.ListFiles(lstDir,"")
End Sub
Sub SMB1_ListCompleted(Url As String, Success As Boolean, Entries() As SMBFile)
Dim bmp As Bitmap,fileEx As String, x As Int, title As String, bFile As String
If Not(Success) Then
Log(LastException)
Else
Files.Clear ' clear listview of old files
For i = 0 To Entries.Length - 1 'loop through entries
If Entries(i).Directory = True Then
'if the entry is a directory
bFile = "dir"
'bmp = LoadBitmap(File.DirAssets,"dir.png") 'put the directory PNG into the bitmap holder
title = Entries(i).Name.SubString2(0, Entries(i).Name.Length-1) ' get the name of the directory minus the last "/"
Else 'if the entry is a file
bFile=""
x=Entries(i).name.Length-1
Do While Entries(i).name.charat(x)<>"." AND x>0
x=x-1 'x decrements to find the first full stop to the end of the filename
Loop
fileEx = Entries(i).name.SubString(x+1) 'get the file extension
title = Entries(i).name.SubString2(0,x)
bFile = fileEx
End If
bmp = images.Getdefault(bFile,images.Get("default"))
Files.AddTwoLinesAndBitmap2(title,"",bmp,Url & Entries(i).name) ' add the name of the file/directoy and the bitmap along with its network filename/url
Next
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Files_ItemClick (Position As Int, Value As String)
If Value.charat(Value.Length-1)="/" Then
lstDir = Value
r = r + 1
route.Put(r, lstDir)
SMB1.ListFiles(lstDir,"")
End If
End Sub
Sub BackButton_Click
If r>0 Then
SMB1.ListFiles(route.Get(r-1),"")
lstDir = route.Get(r-1)
route.Remove(r)
r=r-1
End If
End Sub