private void setProgress(final Progress progress, final P message) {
        if (progress == null) {
            return;
        }
        progress.setMessage(messageMapper.apply(message));
        if (!indeterminate && progressMapper != null) {
            final Integer progressValue = progressMapper.apply(message);
            if (progressValue != null) {
                progress.setProgress(Math.min(maxValue, Math.max(0, progressValue)));
            }
        }
    }
Feature to surround execution of a worker task visually with a progress dialog
main/src/main/java/cgeo/geocaching/utils/workertask/ProgressDialogFeature.java