aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/activity
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2014-02-27 23:23:17 +0100
committerSamuel Tardieu <sam@rfc1149.net>2014-02-27 23:23:17 +0100
commit91c6ac9cb60ed951c2579982cf33fa0fa868f7ab (patch)
tree2354e28038c7faeeeba375cc5199fcca3e9e131d /main/src/cgeo/geocaching/activity
parent57fffc6e3af2ddd8ec61482370265142d94561af (diff)
downloadcgeo-91c6ac9cb60ed951c2579982cf33fa0fa868f7ab.zip
cgeo-91c6ac9cb60ed951c2579982cf33fa0fa868f7ab.tar.gz
cgeo-91c6ac9cb60ed951c2579982cf33fa0fa868f7ab.tar.bz2
refactoring: clean progress dialog handling
Diffstat (limited to 'main/src/cgeo/geocaching/activity')
-rw-r--r--main/src/cgeo/geocaching/activity/Progress.java17
1 files changed, 6 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/activity/Progress.java b/main/src/cgeo/geocaching/activity/Progress.java
index 2710023..8ee88a7 100644
--- a/main/src/cgeo/geocaching/activity/Progress.java
+++ b/main/src/cgeo/geocaching/activity/Progress.java
@@ -17,7 +17,7 @@ public class Progress {
private ProgressDialog dialog;
private int progress = 0;
private int progressDivider = 1;
- private boolean hideAbsolute = false;
+ final private boolean hideAbsolute;
public Progress(boolean hideAbsolute) {
this.hideAbsolute = hideAbsolute;
@@ -28,7 +28,7 @@ public class Progress {
}
public synchronized void dismiss() {
- if (dialog != null && dialog.isShowing()) {
+ if (isShowing()) {
try {
dialog.dismiss();
} catch (final Exception e) {
@@ -54,13 +54,8 @@ public class Progress {
}
}
- private void createProgressDialog(Context context, String title, String message, Message cancelMessage) {
- if (hideAbsolute) {
- dialog = new CustomProgressDialog(context);
- }
- else {
- dialog = new ProgressDialog(context);
- }
+ private void createProgressDialog(final Context context, final String title, final String message, final Message cancelMessage) {
+ dialog = hideAbsolute ? new CustomProgressDialog(context) : new ProgressDialog(context);
dialog.setTitle(title);
dialog.setMessage(message);
if (cancelMessage != null) {
@@ -87,7 +82,7 @@ public class Progress {
}
public synchronized void setMaxProgressAndReset(final int max) {
- if (dialog != null && dialog.isShowing()) {
+ if (isShowing()) {
final int modMax = max / this.progressDivider;
dialog.setMax(modMax);
dialog.setProgress(0);
@@ -97,7 +92,7 @@ public class Progress {
public synchronized void setProgress(final int progress) {
final int modProgress = progress / this.progressDivider;
- if (dialog != null && dialog.isShowing()) {
+ if (isShowing()) {
dialog.setProgress(modProgress);
}
this.progress = modProgress;