Splash Screen while data loads

NFOBoy

Active Member
Licensed User
Longtime User
Ok, have looked over the sample splash screens, and have yet to figure out a way to get the desired action... which is... have a splash screen show while data gets loaded into arrays...

I have an array of Type ThaiCharacterRecord:

Type ThaiCharacterRecord (Character As String, cTypeEnglish As String, cClassEnglish As String, CharacterNameSound As String, CharacterSound As String )


which i declare in Process_Globals

in Activity_Create, I load an array that gets filled from a .csv file.
Included for each character is a sound file, that also gets loaded on activity_create into a SoundPool object (approximately 200 short sound files)

What I would like to have happen is that when the application starts, an imageView gets displayed, and then code continues for loading data, and initializing buttons.

However, I can only ever get black screen until activity_create finishes

UNLESS, I put in a msgbox statement.

If I have a msgbox after displaying an imageview, but Before all my SP.loadid and stringutils.load statement... the image displays behind the msgbox, and then after i hit "ok', the code continues as I would expect, the imageview is unloaded, and my buttons are visible...

I've tried doing as two activities, but, when I start up the "Main" (my applications Main, not Android, I used the splash screen as the "Main" activity) then when new activity is started, the splash screen disappears, and still the wait with black screen while the data loads...

As far as panels... again, can't get a panel to display until after alll the load stuff is done...

Any suggestions?

Ross
 

Jost aus Soest

Active Member
Licensed User
Longtime User
I would fasten the whole process by using a kind of "lazy evaluation", e. g. in this case:

Load the sound files not in Activity_Create, but only at the moment when they are first time needed in your app, then cache them for reusing.

Here some pseudo code:
B4X:
Sub getSound(Name As String) As Sound

  Dim ReturnSound As Sound

  ReturnSound = SoundPoolMap(Name) 
  If ReturnSound = Null Then 'First time
    ReturnSound = LoadSoundfile(Name)
    SoundPoolMap(Name) = ReturnSound
  End If
  Return ReturnSound

End Sub
 
Last edited:
Upvote 0

NFOBoy

Active Member
Licensed User
Longtime User
Agh!

Erel,

thanks so much... should've stopped banging my head earlier! :BangHead: :sign0104:

Jost,

Good idea, unfortunatlely, my whole program revolves around all those sounds (default-and what I expect most user interaction with the program- is for all the sounds to be available on start)

Ross
 
Upvote 0

rikky1966

Member
Licensed User
Longtime User
thanx

I spent a lot of time trying to solve the problem of showing a splash screen while the activity was loading without any luck, and I felt so silly it was enough just a doevents to solve the problem...:BangHead:
Thank you


You should add several DoEvents statements to allow the views to redraw themselves.
 
Upvote 0
Top