public int incrementProgress(int increment) { if (subNotifications.isEmpty()) { if (!isCompleted()) { // Log.d("Aptoide-ViewNotification", "current progress: "+this.currentProgress.get()+" // increment: "+increment+" notificationprogress: "+this.notificationUpdateProgress.get()+" // progressUpdateTrigger: "+(this.progressCompletionTarget/20)+" progressCompletionTarget: // "+this.progressCompletionTarget); if ((this.progressCompletionTarget / 20) > 0 && (((this.currentProgress.get() + increment) - this.notificationUpdateProgress.get()) / (this.progressCompletionTarget / 20) >= 1)) { // Log.d("Aptoide-ViewNotification", "updating notification"); this.currentProgress.addAndGet(increment); this.notificationUpdateProgress.set(this.currentProgress.get()); managerNotifications.updateDisplay(this); // Log.d("Aptoide-ViewNotification", "target size: "+progressCompletionTarget+" // current progress: "+currentProgress); } else { // Log.d("Aptoide-ViewNotification", "not updating notification"); this.currentProgress.addAndGet(increment); } if (this.currentProgress.get() >= this.progressCompletionTarget) { // Log.d("Aptoide-ViewNotification", "target size: "+progressCompletionTarget+" // current progress: "+currentProgress); setCompleted( true); // TODO send Message to listening clients in Managing class if iscompleted // after this invocation } } return this.currentProgress.get(); } else { return -1; // TODO raise exception } }
public int getCurrentProgress() { if (!subNotifications.isEmpty()) { this.progressCompletionTarget = 0; this.currentProgress.set(0); for (ViewNotification subNotification : this.subNotifications) { this.progressCompletionTarget += subNotification.progressCompletionTarget; this.currentProgress.addAndGet(subNotification.getCurrentProgress()); } } if (this.currentProgress.get() >= this.progressCompletionTarget) { setCompleted( true); // TODO send Message to listening clients in Managing class if iscompleted after // this invocation } return this.currentProgress.get(); }