[android-developers] Re: Drawing views in an AsyncTask
Following Romain's suggestion, I changed the code above to look as below. The interesting thing to note is that the behavior remains exactly the same. The dialog gets dismissed when the activity is new but won't dismiss when there is a configuration change. According to my understanding, the runnable is running on the UI thread so the thread-safety of the framework should not be an issue. Is this a framework bug? public class MyActivityClass { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.showtableview ); doBuild(savedInstanceState); } Bundle SIS; protected void doBuild( Bundle savedInstanceState ){ showDialog(drawingProgressDialogId); ScreenBuildRunnable sbRunnable = new ScreenBuildRunnable(); Handler screenBuildHandler = new Handler(); SIS = savedInstanceState; screenBuildHandler.postDelayed(sbRunnable, 100); // Wait 100 mS for progress dialog to get drawn } private class ScreenBuildRunnable implements Runnable { @Override public void run() { LinearLayout topLevelLayout = new LinearLayout(SpreadsheetActivity.this); doDraw( SIS , topLevelLayout ); dismissDialog( drawingProgressDialogId ); setContentView(topLevelLayout); } } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
I just figured out a slick workaround for this bug. The progress dialog stuff is clearly hosed so I just brute force it. I do a setContentView with the resource R.layout.tellsuserthatworkingisbeingdone, which tells the user to wait a moment. Then I give the framework 100 mS to update the screen, then I start work on the real screen. It works like a champ. I'm willing to package up and post (on b.android.com) a test project for the progress dialog bug if Romain and Mark agree that it's a bug. public class MyActivityClass { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); doBuild(savedInstanceState); } Bundle SIS; protected void doBuild( Bundle savedInstanceState ){ setContentView( R.layout.tellsuserthatworkingisbeingdone); // This line removed --- showDialog(drawingProgressDialogId); ScreenBuildRunnable sbRunnable = new ScreenBuildRunnable(); Handler screenBuildHandler = new Handler(); SIS = savedInstanceState; screenBuildHandler.postDelayed(sbRunnable, 100); // Wait 100 mS for progress dialog to get drawn } private class ScreenBuildRunnable implements Runnable { @Override public void run() { LinearLayout topLevelLayout = new LinearLayout(SpreadsheetActivity.this); doDraw( SIS , topLevelLayout ); // This line removed dismissDialog( drawingProgressDialogId ); setContentView(topLevelLayout); } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
It doesn't work because you are blocking the UI thread. You are not streaming the UI at all like I suggested you do. You need to show the dialog, then build the views by little batches so that you never block the UI thread for more than a few milliseconds at a time. Otherwise your app will appear frozen and might even get an ANR if the CPU is busy with another task, On Sun, Nov 7, 2010 at 9:49 AM, Bret Foreman bret.fore...@gmail.com wrote: Following Romain's suggestion, I changed the code above to look as below. The interesting thing to note is that the behavior remains exactly the same. The dialog gets dismissed when the activity is new but won't dismiss when there is a configuration change. According to my understanding, the runnable is running on the UI thread so the thread-safety of the framework should not be an issue. Is this a framework bug? public class MyActivityClass { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.showtableview ); doBuild(savedInstanceState); } Bundle SIS; protected void doBuild( Bundle savedInstanceState ){ showDialog(drawingProgressDialogId); ScreenBuildRunnable sbRunnable = new ScreenBuildRunnable(); Handler screenBuildHandler = new Handler(); SIS = savedInstanceState; screenBuildHandler.postDelayed(sbRunnable, 100); // Wait 100 mS for progress dialog to get drawn } private class ScreenBuildRunnable implements Runnable { @Override public void run() { LinearLayout topLevelLayout = new LinearLayout(SpreadsheetActivity.this); doDraw( SIS , topLevelLayout ); dismissDialog( drawingProgressDialogId ); setContentView(topLevelLayout); } } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
I'm not blocking the UI thread. In my test I stubbed out doDraw so it returns immediately and the behavior is the same. It's due to calling dismissDialog from the runnable. On Nov 7, 11:51 am, Romain Guy romain...@android.com wrote: It doesn't work because you are blocking the UI thread. You are not streaming the UI at all like I suggested you do. You need to show the dialog, then build the views by little batches so that you never block the UI thread for more than a few milliseconds at a time. Otherwise your app will appear frozen and might even get an ANR if the CPU is busy with another task, On Sun, Nov 7, 2010 at 9:49 AM, Bret Foreman bret.fore...@gmail.com wrote: Following Romain's suggestion, I changed the code above to look as below. The interesting thing to note is that the behavior remains exactly the same. The dialog gets dismissed when the activity is new but won't dismiss when there is a configuration change. According to my understanding, the runnable is running on the UI thread so the thread-safety of the framework should not be an issue. Is this a framework bug? public class MyActivityClass { �...@override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.showtableview ); doBuild(savedInstanceState); } Bundle SIS; protected void doBuild( Bundle savedInstanceState ){ showDialog(drawingProgressDialogId); ScreenBuildRunnable sbRunnable = new ScreenBuildRunnable(); Handler screenBuildHandler = new Handler(); SIS = savedInstanceState; screenBuildHandler.postDelayed(sbRunnable, 100); // Wait 100 mS for progress dialog to get drawn } private class ScreenBuildRunnable implements Runnable { �...@override public void run() { LinearLayout topLevelLayout = new LinearLayout(SpreadsheetActivity.this); doDraw( SIS , topLevelLayout ); dismissDialog( drawingProgressDialogId ); setContentView(topLevelLayout); } } } -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
By the way, Romain, you bring up a good point regarding ANRs. And it's not going to help splitting my work up into small groups of operations because a busy CPU might make one group of operations last long enough to trigger an ANR. Instead, I need to break the work into time slices so that the runnable never spends more than X mS working before yielding to the UI. That poses an interesting problem. Any suggestions? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
What is the best way to handle the case where drawing takes a few seconds? I need to put up some sort of progress dialog while I work on building the screen. On Nov 6, 11:18 am, Romain Guy romain...@android.com wrote: You should NEVER create or draw Views from a background thread. The UI toolkit (and the framework in general) is not thread safe. On Sat, Nov 6, 2010 at 10:21 AM, Bret Foreman bret.fore...@gmail.comwrote: It takes some time to draw my views so I want to put up a progress dialog while I do it. I set up the code like this: public class MyActivityClass { �...@override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.myView ); doBuild(savedInstanceState); } protected void doBuild( Bundle savedInstanceState ){ showDialog(drawingProgressDialogId); ScreenBuilder builder = new ScreenBuilder(); builder.execute(savedInstanceState); } private class ScreenBuilder extends AsyncTaskBundle , Integer , LinearLayout { �...@override protected LinearLayout doInBackground(Bundle... SIS) { LinearLayout topLevelLayout = new LinearLayout(MyActivityClass.this); doDraw( SIS[0] , topLevelLayout ); // Adds a bunch of child views return topLevelLayout; } �...@override protected void onPostExecute(LinearLayout topLevelLayout) { dismissDialog(drawingProgressDialogId); setContentView(topLevelLayout); super.onPostExecute(topLevelLayout); } } } This works the first time through, where savedInstanceState is null. But when there is a configuration change, like rotation and savedInstanceState is not null, the dismissDialog call does not work. The progress dialog remains on the screen. This is true even if doDraw is stubbed so that I'm not doing anything with the savedInstanceState. Any ideas why this behavior might occur? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
I should point out, by the way, that Dianne Hackborn recommended my current approach in this thread: http://groups.google.com/group/android-developers/browse_thread/thread/8c3fe5692fb6b0b0/79c04e8bf41843?q=#0079c04e8bf41843 -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
She did not suggest you crated the Views themselves in background thread, but that your computations were done in a background thread. You need to split the creation of the Views and whatever you are doing that's taking a long time to compute. You can also stream the UI by adding Views one after the other using Handler./View.post(Runnable). On Sat, Nov 6, 2010 at 11:24 AM, Bret Foreman bret.fore...@gmail.comwrote: What is the best way to handle the case where drawing takes a few seconds? I need to put up some sort of progress dialog while I work on building the screen. On Nov 6, 11:18 am, Romain Guy romain...@android.com wrote: You should NEVER create or draw Views from a background thread. The UI toolkit (and the framework in general) is not thread safe. On Sat, Nov 6, 2010 at 10:21 AM, Bret Foreman bret.fore...@gmail.com wrote: It takes some time to draw my views so I want to put up a progress dialog while I do it. I set up the code like this: public class MyActivityClass { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView( R.layout.myView ); doBuild(savedInstanceState); } protected void doBuild( Bundle savedInstanceState ){ showDialog(drawingProgressDialogId); ScreenBuilder builder = new ScreenBuilder(); builder.execute(savedInstanceState); } private class ScreenBuilder extends AsyncTaskBundle , Integer , LinearLayout { @Override protected LinearLayout doInBackground(Bundle... SIS) { LinearLayout topLevelLayout = new LinearLayout(MyActivityClass.this); doDraw( SIS[0] , topLevelLayout ); // Adds a bunch of child views return topLevelLayout; } @Override protected void onPostExecute(LinearLayout topLevelLayout) { dismissDialog(drawingProgressDialogId); setContentView(topLevelLayout); super.onPostExecute(topLevelLayout); } } } This works the first time through, where savedInstanceState is null. But when there is a configuration change, like rotation and savedInstanceState is not null, the dismissDialog call does not work. The progress dialog remains on the screen. This is true even if doDraw is stubbed so that I'm not doing anything with the savedInstanceState. Any ideas why this behavior might occur? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com android-developers%2bunsubscr...@googlegroups.comandroid-developers%252bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
I see. Well, I'm not doing much in the way of computations. The time taken is just in building the view hierarchy itself - creating and initializing the Views takes a few seconds. So it looks like I'll have to stream the UI with a Handler as I build it. It's a shame that the framework imposes so much added complexity for such a simple thing. On Nov 6, 11:38 am, Romain Guy romain...@android.com wrote: She did not suggest you crated the Views themselves in background thread, but that your computations were done in a background thread. You need to split the creation of the Views and whatever you are doing that's taking a long time to compute. You can also stream the UI by adding Views one after the other using Handler./View.post(Runnable). On Sat, Nov 6, 2010 at 11:24 AM, Bret Foreman bret.fore...@gmail.comwrote: -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
On Sat, Nov 6, 2010 at 2:51 PM, Bret Foreman bret.fore...@gmail.com wrote: The time taken is just in building the view hierarchy itself - creating and initializing the Views takes a few seconds. Use Traceview and find where your performance issue lies. Building the view hierarchy itself is a very broad statement. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
Streaming the UI creates an added complication - in what way should I notify the user that the UI is finished drawing? Partial data is going to confuse the user unless they know that more is coming. Since this is a limitation imposed by the Android framework, others must have encountered it. Is there a standard way to notify the user that the UI is incomplete? -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
On Sat, Nov 6, 2010 at 3:04 PM, Bret Foreman bret.fore...@gmail.com wrote: Streaming the UI creates an added complication - in what way should I notify the user that the UI is finished drawing? Partial data is going to confuse the user unless they know that more is coming. Since this is a limitation imposed by the Android framework, others must have encountered it. Is there a standard way to notify the user that the UI is incomplete? Use Traceview and find where your performance issue lies. Then fix that problem. That way, you won't have to worry about all this other stuff, and you'll have happier users as an extra bonus. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
I've used Traceview extensively on this code - it used to take 20 seconds and now it's down to 3, all of which is in the View constructors and the code where I set various drawing parameters. It's just a lot of Views and there is no smoking gun where a lot of time is being spent. I thought about creating a pool of pre-built Views but there's no guarantee that it will be any faster than the current approach and such a pool is very complex to implement in the Android framework. On Nov 6, 12:01 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Nov 6, 2010 at 2:51 PM, Bret Foreman bret.fore...@gmail.com wrote: The time taken is just in building the view hierarchy itself - creating and initializing the Views takes a few seconds. Use Traceview and find where your performance issue lies. Building the view hierarchy itself is a very broad statement. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
On Sat, Nov 6, 2010 at 3:10 PM, Bret Foreman bret.fore...@gmail.com wrote: I've used Traceview extensively on this code - it used to take 20 seconds and now it's down to 3, all of which is in the View constructors and the code where I set various drawing parameters. Most Views take next to no time to set up. How many Views are in this GUI? -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
A few hundred Views in a typical case but it could be up to a couple thousand in some cases. On Nov 6, 12:19 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Nov 6, 2010 at 3:10 PM, Bret Foreman bret.fore...@gmail.com wrote: I've used Traceview extensively on this code - it used to take 20 seconds and now it's down to 3, all of which is in the View constructors and the code where I set various drawing parameters. Most Views take next to no time to set up. How many Views are in this GUI? -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
On Sat, Nov 6, 2010 at 3:29 PM, Bret Foreman bret.fore...@gmail.com wrote: A few hundred Views in a typical case but it could be up to a couple thousand in some cases. And what makes you think that a couple thousand is sensible, on any platform? -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
My Moto Droid builds the Views in a few seconds and everything else works great - scrolling is fast and pretty, memory utilization is modest. The _only_ problem is how to handle the brief delay while the Views are built. I'm not sure what you mean by sensible. On Nov 6, 12:44 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Nov 6, 2010 at 3:29 PM, Bret Foreman bret.fore...@gmail.com wrote: A few hundred Views in a typical case but it could be up to a couple thousand in some cases. And what makes you think that a couple thousand is sensible, on any platform? -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
1000's of views I guessThats too much... On Sun, Nov 7, 2010 at 1:27 AM, Bret Foreman bret.fore...@gmail.com wrote: My Moto Droid builds the Views in a few seconds and everything else works great - scrolling is fast and pretty, memory utilization is modest. The _only_ problem is how to handle the brief delay while the Views are built. I'm not sure what you mean by sensible. On Nov 6, 12:44 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Nov 6, 2010 at 3:29 PM, Bret Foreman bret.fore...@gmail.com wrote: A few hundred Views in a typical case but it could be up to a couple thousand in some cases. And what makes you think that a couple thousand is sensible, on any platform? -- Mark Murphy (a Commons Guy)http://commonsware.com| http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguyhttp://github.com/commonsguyhttp://commonsware.com/blog%7Chttp://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
In what way is it too much? I'm not using much memory and the delay is only a few seconds. It will all be fine if I can figure out how to present the user a progress dialog or other indication that work is in progress. On Nov 6, 12:58 pm, Kumar Bibek coomar@gmail.com wrote: 1000's of views I guessThats too much... -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
You can display a progress bar or even a progress dialog and still stream the UI. Have you thought about using a ListView instead btw? On Sat, Nov 6, 2010 at 1:05 PM, Bret Foreman bret.fore...@gmail.com wrote: In what way is it too much? I'm not using much memory and the delay is only a few seconds. It will all be fine if I can figure out how to present the user a progress dialog or other indication that work is in progress. On Nov 6, 12:58 pm, Kumar Bibek coomar@gmail.com wrote: 1000's of views I guessThats too much... -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Romain Guy Android framework engineer romain...@android.com Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
Well, if you were to show 1000s views on the screen, you would obviously need more memory. Try creating a list view (a dumb one which returns a new view every-time) and see if the amount of memory is substantial. Delay is fine, but I cannot think of a situation where someone might have to bring up 1000s of views on a screen. On Sun, Nov 7, 2010 at 1:35 AM, Bret Foreman bret.fore...@gmail.com wrote: In what way is it too much? I'm not using much memory and the delay is only a few seconds. It will all be fine if I can figure out how to present the user a progress dialog or other indication that work is in progress. On Nov 6, 12:58 pm, Kumar Bibek coomar@gmail.com wrote: 1000's of views I guessThats too much... -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Kumar Bibek http://techdroid.kbeanie.com http://www.kbeanie.com -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Drawing views in an AsyncTask
On Sat, Nov 6, 2010 at 4:08 PM, Romain Guy romain...@android.com wrote: Have you thought about using a ListView instead btw? Agreed. Or any other AdapterView. Or writing your own AdapterView. Anything to reduce your heap and stack consumption. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Drawing views in an AsyncTask
Since the views are all different sizes, the various ListViews, GridViews, and Adapters don't work. Part of the secret sauce of my app is the algorithm for arranging the views in the most compact way to present the maximum amount of information in the screen space available. The main benefit of the Android framework for me is that it handles (horizontal and vertical) scrolling very nicely even when some of the views need to be pinned (non-scrolling) and even for 1000 views of different sizes and shapes. But for that to happen, all the views need to be there in the hierarchy, not just those on the immediately visible screen. But more to the point, the whole thing is working beautifully without consuming undue heap or stack space. The _only_ issue is that it takes about 3 seconds to build the view hierarchy in the most extreme cases and I need to let the user know work is being done. So back to the issue at hand. It sounds like Romain is suggesting that I call showDialog and then have the handler post some work to the queue. What if I just put all 3 seconds of work in that one post? I can live with the progress dialog frozen for a few seconds as long as it gets on the screen before the posted work arrives. Can I be sure the dialog will get on the screen before the post hits? If not, what do you think is the best way to slice up the 3 seconds of work, maybe using postDelayed and do some work every 50 mS or so? What if I'm running on a slow (or otherwise busy) platform and the 50 mS slices get completely consumed by the drawing work such that the UI thread can't get the dialog up? On Nov 6, 1:11 pm, Mark Murphy mmur...@commonsware.com wrote: On Sat, Nov 6, 2010 at 4:08 PM, Romain Guy romain...@android.com wrote: Have you thought about using a ListView instead btw? Agreed. Or any other AdapterView. Or writing your own AdapterView. Anything to reduce your heap and stack consumption. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9 Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en