pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Lanham <li...@sael.com.au>
Subject Re: Activity Indicator During Load
Date Tue, 23 Mar 2010 04:49:30 GMT
Howdy Chris

I did a mix and match of ideas including Gregs input for an activity indicator 
and it loads in a fraction of the time using about six data loading threads 
and a nice big 'busy' indicator in the middle of the screen :-)

As an aside note. I was inadvertently doing UI stuff in non-UI threads and 
Pivot didn't break. Either I am lucky or Pivot is robust enough to take it ;-)

Cheers,

Scott.


On Mon, 22 Mar 2010 10:03:35 pm Christopher Brind wrote:
> Hi Scott,
> 
> Have a look at TaskAdapter:
> http://pivot.apache.org/1.4/docs/api/org/apache/pivot/wtk/TaskAdapter.html
> 
> So at the end of the startup method after the UI is initialised and hooked
> up create a Task to do your data loading and execute it with a
>  TaskListener. If you pass your task listener in to an instance of
>  TaskAdapter the methods of your listener are called on the UI thread at
>  which point you can change the UI state without problem.
> 
> So here is a 'cheap' example using anonymous inner classes:
> > public void startup(...) {
> >
> >
> > //   ... initialise the app ...
> >
> >
> >    new Task<V>() {
> 
>       public V execute() {
> 
>          // do your data loading here
> 
>       }
> 
>    }.execute(new TaskAdapter(new TaskListener<V>() {
> 
> 
> 
>            public void executeFailed(Task<V> task) {
> 
>                // e.g. display a message to the user
> 
>            }
> 
> >            public void taskExecuted(Task<V> task) {
> 
>                // change the ui state
> 
>            }
> 
> >         }));
> >
> >
> > }
> 
> Note that V is a generic type - I recommend using Void if you don't want to
> use a return type and just return null from the execute method.
> 
> Let us know how you get on. :)
> 
> Cheers,
> Chris
> 
> On 22 March 2010 00:41, Scott Lanham <lists@sael.com.au> wrote:
> > In my case a thread other than the UI thread will be closing the dialog (
> > or
> > other object ), will this cause a problem?
> >
> > On Fri, 19 Mar 2010 07:35:37 pm Christopher Brind wrote:
> > > I perhaps shouldn't have said 'when Pivot has finished' loading. :)
> > >
> > > So typically in the startup method you'll call window.open() to show
> > > the UI, just after that open your modal dialog and then kick off your
> > > data loading threads.  Once your data loading threads have finished,
> > > close
> >
> > the
> >
> > >  dialog.
> > >
> > > Hope that helps.
> > >
> > > Cheers,
> > > Chris
> > >
> > > On 19 March 2010 09:12, Scott Lanham <lists@sael.com.au> wrote:
> > > > That is a good idea but I don't know how to tell when Pivot has
> >
> > finished
> >
> > > > loading.
> > > >
> > > > On Fri, 19 Mar 2010 05:52:39 pm Christopher Brind wrote:
> > > > > How about just before you start your data loading, after Pivot has
> > > >
> > > > loaded,
> > > >
> > > > > but before the user has chance to start clicking, popup a *modal
> >
> > dialog
> >
> > > > >  *with just a progress indicator in it (and maybe a label which you
> > > > > could use to show status messages).  Then when your data loading
> > > > > has finished, close the dialog programatically.
> > > > >
> > > > > Cheers,
> > > > > Chris
> > > > >
> > > > > On 19 March 2010 04:14, Scott Lanham <lists@sael.com.au> wrote:
> > > > > > Hi Guys,
> > > > > >
> > > > > > It has been a while since I have asked a question on this list
> > > > > > :-)
> > > > > >
> > > > > > When my application starts up it loads a heap of data into
> > > > > > various components.
> > > > > > This was fine for a while but now it is taking a long time and
> >
> > while
> >
> > > > the
> > > >
> > > > > > seconds tick away I just see a blank window. It looks like the
> > > > > > program has hung which is not a good thing.
> > > > > >
> > > > > > I can offload the data loading into separate threads and all
the
> > > > > > components will
> > > > > > appear quickly but I don't want the user to start trying to
use
> >
> > those
> >
> > > > > > components until they are populated with data.
> > > > > >
> > > > > > Is there a way that I can have a progress indicator take over
the
> > > >
> > > > screen
> > > >
> > > > > > (after the components have displayed) until my data loading
> > > > > > threads
> > > >
> > > > have
> > > >
> > > > > > finished?
> > > > > >
> > > > > > Thanks heaps,
> > > > > >
> > > > > > Scott.
> 

Mime
View raw message