android - Long delay between ProgressDialog.dismiss() and AlertDialog.show() -



android - Long delay between ProgressDialog.dismiss() and AlertDialog.show() -

i'm using standard progressdialog implementation: set thread run long task, , when it's done dismisses progressdialog.

@override public void oncreate( bundle bundle ) { super.oncreate( bundle ); context = this; progress = progressdialog.show( this, "running", "please wait..", true, false); progress.setondismisslistener( new ondismisslistener() { public void ondismiss(dialoginterface dialog) { showresults(); } }); new deletethread().start(); }

and thread looks this:

private class deletethread extends thread { public deletethread() {} @override public void run() { // long process during populate // linearlayout many other views progress.dismiss(); } }

and in showresults() take linearlayout filled views , set content of alertdialog.

the problem is, progressdialog goes away , there's still long period of time (10-12sec) nil happening before alertdialog pops up. there way create transition instantaneously?

i know reply might coming in bit late, heck.

i see you're triggering showresults() method ondismiss callback. suggest other way around. may need utilize asynctask class.

the asynctask allows setup tasks run in spawned thread, update progress bar if needed (not required, might nice touch in case) , of course of study run code on ui thread 1 time spawned thread completes. case, place populating of layoutview in asynctask.doinbackground() method. then, you'd want add together showresults() method phone call in asynctask.onpostexecute(). @ bottom of onpostexecute() should dismiss progress dialog. should give results want.

as bonus, might want create constructor asynctask class , place creation of progressdialog in there. way progressdialog encapsulated within class , nice , clean. so, this:

class myasyncclass extends asyncclass { progressdialog m_progress; public myasyncclass() { m_progress = progressdialog.show( this, "running", "please wait..", true, false); } protected long doinbackground(object... data) { // long process of populating linearlayout many other views } protected void onpostexecute(long result) { showresults(); m_progress.dismiss(); } }

note: above needs parameters class, idea.

android optimization progressdialog

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -