Progress Bar

It should be noted that the Android toolkit provides as well a separate GUI thread to process user interface interactions. Again it is not recommended to process long running jobs via this thread. Even the Android OS will recognize the waiting and might ask the end-user whether he wants to kill the mobile application. An unwanted behaviour.

To prevent such a behaviour we also provided a progress bar in the case of the mobile appli-cation. The progress bar works very similar as the progress bar as the standalone application. We also start the long running job as a simple thread in the background and then submit a GUI event. Only the delivery method of the GUI event is different:

    /**
* <p>Start a job.</p>
*
* @param job The long running job.
* @param job2 The GUI update job.
*/
private void startJob(final Runnable job, final Runnable job2) {
new Thread((Runnable) () -> {
job.run();
root.post(() -> {
job2.run();
});
}).start();

A further difference is found in the way on how we switch in the progress bar. The approach is that we work with addView() and removeView(), and directly switch in the desired GUI compo-nent. This requires more Java program code that uses the Android library. Testing so far has showed that there is no problem with revalidation and repainting. Especially compared to Swing there is no requirement of packing the activity.

Comments