Android Question Get Images loop

munichxmedia

Member
Licensed User
Longtime User
Hi,

i am pretty new here. I want to programm an cinema app. We have a database with all Cinemas and Movies at Germany.

i have a problem to get all Cover images and show then.

First i parse our database with the json paser , that is no problem, but now i need to get the images as well e.g 1.jpg,2.jpg. How can i download the image within the loop and pass them to CreateListItem

Sub JobDone(job As HttpJob)
ProgressDialogHide
If job.Success Then
Dim res As String
res = job.GetString
Log("Response from server: " & res)
Dim parser As JSONParser
parser.Initialize(res)
Select job.JobName
Case "Job1"
Dim COUNTRIES As List
COUNTRIES = parser.NextArray 'returns a list with maps
clv3.Initialize(Me, "clv3")
Activity.AddView(clv3.AsView, 0, 0, 100%x, 100%y)
For i = 0 To COUNTRIES.Size - 1
Dim m As Map
m = COUNTRIES.Get(i)
'We are using a custom type named TwoLines (declared in Sub Globals).
'It allows us to later get the two values when the user presses on an item.
Dim tl As TwoLines
tl.First = m.Get("titel")
tl.Second = m.Get("darsteller")
tl.Third = m.Get("genre")

tl.Lid = m.Get("id")
Dim Cover As String
clv3.Add(CreateListItem("Titel : " & tl.First & CRLF & CRLF & "Darsteller : " & tl.Second & CRLF & CRLF & "Genre : "& tl.Third , clv3.AsView.Width, 150dip , res2), 150dip, "Item #" & i)

Next
End Select


End If
job.Release
End Sub

regrads Christian
 

DonManfred

Expert
Licensed User
Longtime User
First welcome to the great B4A-Community!

Please use Code-Tags when posting code... [ CODE][ /CODE] without the spaces.

Regarding to get a lot of images see this Tutorial
 
Upvote 0

munichxmedia

Member
Licensed User
Longtime User
hi,

here is the code and my question i need to load some files with the tl.Lid like http://www.up2city.de/kino/media/103674468/filmplakat_103674468.jpg from the server an safe it at this loop like :

out = File.OpenOutput(File.DirDefaultExternal, tl.Lid&".jpg", False)
b.WriteToStream(out, 100, "JPEG")

how can i get the images whithin this loop?

Regards


B4X:
Sub JobDone(job As HttpJob)
    ProgressDialogHide
    If job.Success Then
    Dim res As String
        res = job.GetString
        Log("Response from server: " & res)
        Dim parser As JSONParser
        parser.Initialize(res)
                Select job.JobName
                Case "Job1"
                Dim COUNTRIES As List
                COUNTRIES = parser.NextArray 'returns a list with maps
                clv3.Initialize(Me, "clv3")
                Activity.AddView(clv3.AsView, 0, 0, 100%x, 100%y)
               
                For i = 0 To COUNTRIES.Size - 1
                    Dim m As Map
                    m = COUNTRIES.Get(i)
                    'We are using a custom type named TwoLines (declared in Sub Globals).
                    'It allows us to later get the two values when the user presses on an item.
                    Dim tl As TwoLines
                    tl.First = m.Get("titel")
                    tl.Second = m.Get("darsteller")
                    tl.Third = m.Get("genre")
                   
                    tl.Lid = m.Get("id")
                        Dim Cover As String
                       
                    Dim b As Bitmap
                      b.InitializeMutable(200, 200)
                      Dim c As Canvas
                    c.Initialize2(b)
                    c.DrawCircle(100, 100, 50, Colors.Red, True, 0)
                    Log(res2)
                    'save image to file
                    Dim out As OutputStream
                    out = File.OpenOutput(File.DirDefaultExternal, tl.Lid&".jpg", False)
                    b.WriteToStream(out, 100, "JPEG")
                    out.Close
                    'clv1.AddTextItem("Titel #" & tl.First & CRLF & "Darsteller #" & tl.Second & CRLF & "Genre # "& tl.Third, tl.Lid)
                    clv3.Add(CreateListItem("Titel : " & tl.First & CRLF & CRLF & "Darsteller : " & tl.Second & CRLF & CRLF & "Genre :  "& tl.Third , clv3.AsView.Width, 150dip , tl.Lid), 150dip, "Item #" & i)
                    'clv3.Add(CreateListItem( , clv3.AsView.Width, 150dip , "http://www.up2city.de/kino/media/103674468/filmplakat_103674468.jpg"), 150dip, "Item #" & i)

                Next   
                End Select


    End If
    job.Release
End Sub
 
Upvote 0

munichxmedia

Member
Licensed User
Longtime User
hi,

maybe in do not understand httpjob. is it possible to start at the loop another httbjob to save all images. it seens the new job is processed alter the first job is done?

ragards

christian
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
hi,

maybe in do not understand httpjob. is it possible to start at the loop another httbjob to save all images. it seens the new job is processed alter the first job is done?

ragards

christian
You are correct. There are several examples that do exactly that (FlickrViewer and the list with images).
 
Upvote 0
Top