Ho all,
I'm dealing with the optimization of an app that uses the rest api of a remote CMS (Drupal) that downloads about 40 nodes (all content on a Drupal website is stored and treated as "nodes". A node is a piece of individual content).
So for this case I'm using the OKHttpUtils2 from @Erel https://www.b4x.com/.../b4x-okhttputils2-with-wait-for.../ (i have to say that the code has a clean syntax and works very well).
DOWNLOAD TIME
The time to download all this nodes (that my app use) is about 10 secs when app start for the first time.
In order not to make the user impatient for waiting for the download before being able to use the app, I have implemented a main screen with an animated gif, but unfortunately we are realizing that it is not enough, the download time has increased (we are investigating what is the cause on the server side).
THE ISSUE
in this case the user waits 8 / 10 seconds (timer) in the first screen of the animated gif then when he touches the button to view the data, not being completely downloaded, a waiting message is displayed (until the data has been completely downloaded), inhibiting the opening of the data list screen and for the end user this is frustrating.
SOLUTION ?
in this case what is the most correct approach to make the app well usable for the end user, without doing so waits every time he opens the app? To save data locally on the phone (a kind of cache)?
I'm dealing with the optimization of an app that uses the rest api of a remote CMS (Drupal) that downloads about 40 nodes (all content on a Drupal website is stored and treated as "nodes". A node is a piece of individual content).
So for this case I'm using the OKHttpUtils2 from @Erel https://www.b4x.com/.../b4x-okhttputils2-with-wait-for.../ (i have to say that the code has a clean syntax and works very well).
DOWNLOAD TIME
The time to download all this nodes (that my app use) is about 10 secs when app start for the first time.
In order not to make the user impatient for waiting for the download before being able to use the app, I have implemented a main screen with an animated gif, but unfortunately we are realizing that it is not enough, the download time has increased (we are investigating what is the cause on the server side).
THE ISSUE
in this case the user waits 8 / 10 seconds (timer) in the first screen of the animated gif then when he touches the button to view the data, not being completely downloaded, a waiting message is displayed (until the data has been completely downloaded), inhibiting the opening of the data list screen and for the end user this is frustrating.
SOLUTION ?
in this case what is the most correct approach to make the app well usable for the end user, without doing so waits every time he opens the app? To save data locally on the phone (a kind of cache)?
Download relevant code:
Public Sub Initialize 'Class
Download1
End sub
Sub Download1 As ResumableSub
For Each nid As Int In nidsList
Wait For (GetContent (nid, user, psw)) Complete (Content1 As Map)
Next
End Sub
Sub GetContent (nid As Int, aUser As String, aPsw As String) As ResumableSub
Wait For (GetJSONByNID (nid, aUser, aPsw)) Complete (WSResult As String)
Private WSResponse As String = WSResult
'......
end sub
Sub GetJSONByNID (nid As Int, aUser As String, aPsw As String) As ResumableSub
Dim j As HttpJob : j.Initialize("j", Me)
j.Username = aUser
j.Password = aPsw
Private WSNodeURL As String = WebHostURL & "/node/"
Private WSFormat As String = "?_format=json"
Private WSUrl As String = WSNodeURL & nid & WSFormat
j.Download (WSUrl)
'Log ("GetJSONByNID | WSUrl: " & WSUrl)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Private WSResponse As String = j.GetString2("UTF8")
'Log ("GetJSONByNID | WSResponse " & WSResponse)
End If
j.Release
'Parse JSON....
End Sub