MergingUpdateQueue - how to get notified when it starts and stops processing updates ? Follow
Is there any way to get notified when a MergingUpdateQueue starts and finishes processing enqueued updates ?
I have found some startActivity and finishActivity methods but I don't really see how these could come in handy. And since they have private access I can't override them to intercept method calls in a subclass (such work-around came to my mind..).
I'm trying to show some 'busy notification' when an update queue starts flushing its contents and hide it when it has finished its chores.
Thanks in advance for any assistance
Please sign in to leave a comment.
I came up with a possible solution but I'm not sure whether it's correct and there's no better and cleaner way to achieve the same functionality :
method does what I think it does : calls the passed-in runnable's 'run' method when all actions associated with given busy object have been removed. Am I correct with my assumptions ? Will it even work ? Or maybe there's a better way to get notified when the merging update queue receives the first update to process and finishes flushing it's contents ?
I simply subclassed MergingUpdateQueue and added 'busy listeners' as my own event-handling infrastructure : they get notified when the first update is added to an empty queue ('busy mode entered') and when the 'processing session' ends ('busy mode exited'). Of course if
I'd really appreciate the help - it shouldn't pose a problem for a seasoned developer (I'm a noob, you know..) and it's kind of urgent since I'm stuck with my work.
Thx in advance
another question left unanswered ?:>
If you need clarification - ask, don't be shy :)
I will do my best to broaden the context.
Wlarification is needed actually. Code is open sourced. You can see that MergingUpdateQueue doesn't provide API that you're needed to. But also you can see that MergingUpdateQueue and MergingUpdateQueue#flush are not final so it can be overriden in any way. So what's the question?:)
You're right - I can override queue() and flush() methods and switch some 'busy' flag on in the former and off in the latter. But it seems that I would also need to intercept cancelAllUpdates() method calls which empty the queue. It should work but it doesn't seem very 'clean' since there are 'startActivity' and 'finishActivity' methods in MergingUpdateQueue which seem to delimit 'queue processing session' boundaries - unfortunatelly both are private and cannot be overridden in a subclass so I cannot get informed when they are called.
But these methods register some 'activity' in UiActivityMonitor and I thought that this is the notification dispatcher to be used on such occasions.
So do you suggest that I should stick to overriding queue(), flush() and cancelAllUpdates() methods to get informed when the update queue receives an update and when it finishes processing it?
What about 'startActivity' and 'finishActivity' methods and BusyObjects then - could they come in handy ?
What is their purpose ?
Thank you in advance for any further details.
one more thing : I would also like to be able to check the number of queued updates at any given moment in time but since both 'myScheduledUpdates' collection and 'put()' method are private - I can't do that.
I can only check whether the queue is empty or not (MergingUpdateQueue.isEmpty()) but I cannot test how many updates are awaiting execution.
If you want to control the whole proccess why do you not implement your own queue? Obviously MergingUpdateQueue doesn't fit for your purposes.
Well, that's not so obvious to me and I don't want to re-invent the wheel, you see.
And I'm certainly not as good a programmer as you JB folks :)
Mostly I was hoping on some more 'background' knowledge about busy objects, ui activities etc. and I would be very grateful if you could shed some light on this topic and maybe point me to some examples.
Personally I know about UiActivities and Busy objects not much more than you. These entities are used in several places inside IDEA core for blocking something until UI would initialized or for making UI-drawing-callbacks on data initialization finish. Inside MergingQueue it is used for two UI components only. So I believe that you don't really need pay attention on them and make your own simple and readable queue implementation (or reuse something from libraries like guava).
thanks a lot for your help, I'll stick to subclassing MergingUpdateQueue and overriding queue(), flush() and cancelAllUpdates() methods then.