0

Basically I have a popup window that I am trying to launch and have open while the rest of my UI loads(it's some canvas calls that take a second or two), but the behavior I'm getting is that the popup window doesn't display until everything has finished running. I'm literally just calling show on the popup window right before the canvas draws. Nothing fancy. How can I make the popup window show up first, so I can obscure the rest of my loading?

jagrakye
  • 357
  • 1
  • 2
  • 11

2 Answers2

2

If you're drawing for a second or two, you should be doing it on another thread, not the UI thread. Then you notify the UI thread to update again when its done. DO it that way and you'll have a responsive app and it will show the dialog.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • This sounds like the right way to do it. Better, do it in a AsyncTask, so that you can easily update the views when finished on the ui thread. See https://developer.android.com/training/displaying-bitmaps/process-bitmap.html for an examples. – lionscribe Aug 24 '16 at 22:48
0

Just put the code that initializes the canvas part into a runnable, and post it to ui thread. This way popup can be shown before ui finishes the setup.

lionscribe
  • 3,413
  • 1
  • 16
  • 21
  • Just tried that, it might be quicker but it's hard to tell. It's certainly not loading the pop up window as fast as if I wasn't drawing to canvas at all. Without the canvas draws, the popup widow comes up more or less instantaneously. – jagrakye Aug 24 '16 at 21:35
  • So try posting it delayed by 1000 ms. – lionscribe Aug 24 '16 at 22:38
  • Gabe's idea of doing it in a separate thread is the right one. Use an AsyncTask. – lionscribe Aug 24 '16 at 22:49