mirror of
https://github.com/TeamAmaze/AmazeFileManager.git
synced 2026-10-17 05:08:00 +08:00
Moved progress percent to ProgressHandler from services
This commit is contained in:
+5
-9
@@ -42,10 +42,6 @@ public abstract class AbstractProgressiveService extends Service implements Serv
|
||||
|
||||
protected abstract int getNotificationId();
|
||||
|
||||
protected abstract float getPercentProgress();
|
||||
|
||||
protected abstract void setPercentProgress(float progress);
|
||||
|
||||
protected abstract @StringRes int getTitle(boolean move);
|
||||
|
||||
protected abstract RemoteViews getNotificationCustomViewSmall();
|
||||
@@ -81,9 +77,9 @@ public abstract class AbstractProgressiveService extends Service implements Serv
|
||||
public void progressResumed() {
|
||||
// set notification to indeterminate unless progress resumes
|
||||
getNotificationCustomViewSmall().setProgressBar(R.id.notification_service_progressBar_small,
|
||||
100, Math.round(getPercentProgress()), false);
|
||||
100, Math.round(getProgressHandler().getPercentProgress()), false);
|
||||
getNotificationCustomViewBig().setProgressBar(R.id.notification_service_progressBar_big,
|
||||
100, Math.round(getPercentProgress()), false);
|
||||
100, Math.round(getProgressHandler().getPercentProgress()), false);
|
||||
getNotificationManager().notify(getNotificationId(), getNotificationBuilder().build());
|
||||
}
|
||||
|
||||
@@ -101,7 +97,7 @@ public abstract class AbstractProgressiveService extends Service implements Serv
|
||||
long writtenSize = getProgressHandler().getWrittenSize();
|
||||
|
||||
//notification
|
||||
setPercentProgress(((float) writtenSize / totalSize) * 100);
|
||||
getProgressHandler().setPercentProgress(((float) writtenSize / totalSize) * 100);
|
||||
|
||||
if (!isNotificationTitleSet) {
|
||||
getNotificationBuilder().setSubText(getString(getTitle(move)));
|
||||
@@ -127,9 +123,9 @@ public abstract class AbstractProgressiveService extends Service implements Serv
|
||||
}
|
||||
getNotificationCustomViewBig().setTextViewText(R.id.notification_service_textView_timeRemaining_big, remainingTime);
|
||||
getNotificationCustomViewSmall().setProgressBar(R.id.notification_service_progressBar_small,
|
||||
100, Math.round(getPercentProgress()), false);
|
||||
100, Math.round(getProgressHandler().getPercentProgress()), false);
|
||||
getNotificationCustomViewBig().setProgressBar(R.id.notification_service_progressBar_big,
|
||||
100, Math.round(getPercentProgress()), false);
|
||||
100, Math.round(getProgressHandler().getPercentProgress()), false);
|
||||
getNotificationManager().notify(getNotificationId(), getNotificationBuilder().build());
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,6 @@ public class CopyService extends AbstractProgressiveService {
|
||||
private final IBinder mBinder = new ObtainableServiceBinder<>(this);
|
||||
private ServiceWatcherUtil watcherUtil;
|
||||
private ProgressHandler progressHandler = new ProgressHandler();
|
||||
private volatile float progressPercent = 0f;
|
||||
private ProgressListener progressListener;
|
||||
// list of data packages, to initiate chart in process viewer fragment
|
||||
private ArrayList<DatapointParcelable> dataPackages = new ArrayList<>();
|
||||
@@ -179,11 +178,6 @@ public class CopyService extends AbstractProgressiveService {
|
||||
return NotificationConstants.COPY_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getPercentProgress() {
|
||||
return progressPercent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RemoteViews getNotificationCustomViewSmall() {
|
||||
return customSmallContentViews;
|
||||
@@ -194,17 +188,11 @@ public class CopyService extends AbstractProgressiveService {
|
||||
return customBigContentViews;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPercentProgress(float progress) {
|
||||
progressPercent = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getTitle(boolean move) {
|
||||
return move ? R.string.moving : R.string.copying;
|
||||
}
|
||||
|
||||
public ProgressListener getProgressListener() {
|
||||
return progressListener;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ public class DecryptService extends AbstractProgressiveService {
|
||||
private ProgressHandler progressHandler = new ProgressHandler();
|
||||
private NotificationManager notificationManager;
|
||||
private NotificationCompat.Builder notificationBuilder;
|
||||
private volatile float progressPercent = 0f;
|
||||
private ProgressListener progressListener;
|
||||
// list of data packages, to initiate chart in process viewer fragment
|
||||
private ArrayList<DatapointParcelable> dataPackages = new ArrayList<>();
|
||||
@@ -186,16 +185,6 @@ public class DecryptService extends AbstractProgressiveService {
|
||||
return NotificationConstants.DECRYPT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getPercentProgress() {
|
||||
return progressPercent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPercentProgress(float progress) {
|
||||
progressPercent = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getTitle(boolean move) {
|
||||
|
||||
@@ -48,7 +48,6 @@ public class EncryptService extends AbstractProgressiveService {
|
||||
private Context context;
|
||||
private IBinder mBinder = new ObtainableServiceBinder<>(this);
|
||||
private ProgressHandler progressHandler = new ProgressHandler();
|
||||
private volatile float progressPercent = 0f;
|
||||
private ProgressListener progressListener;
|
||||
// list of data packages, to initiate chart in process viewer fragment
|
||||
private ArrayList<DatapointParcelable> dataPackages = new ArrayList<>();
|
||||
@@ -133,16 +132,6 @@ public class EncryptService extends AbstractProgressiveService {
|
||||
return NotificationConstants.ENCRYPT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getPercentProgress() {
|
||||
return progressPercent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPercentProgress(float progress) {
|
||||
this.progressPercent = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getTitle(boolean move) {
|
||||
|
||||
@@ -65,7 +65,6 @@ public class ExtractService extends AbstractProgressiveService {
|
||||
private NotificationManager mNotifyManager;
|
||||
private NotificationCompat.Builder mBuilder;
|
||||
private ProgressHandler progressHandler = new ProgressHandler();
|
||||
private volatile float progressPercent = 0f;
|
||||
private ProgressListener progressListener;
|
||||
private int accentColor;
|
||||
private SharedPreferences sharedPreferences;
|
||||
@@ -152,16 +151,6 @@ public class ExtractService extends AbstractProgressiveService {
|
||||
return NotificationConstants.EXTRACT_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getPercentProgress() {
|
||||
return progressPercent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPercentProgress(float progress) {
|
||||
progressPercent = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getTitle(boolean move) {
|
||||
|
||||
@@ -73,7 +73,6 @@ public class ZipService extends AbstractProgressiveService {
|
||||
private NotificationManager mNotifyManager;
|
||||
private NotificationCompat.Builder mBuilder;
|
||||
private ProgressHandler progressHandler = new ProgressHandler();
|
||||
private volatile float progressPercent = 0f;
|
||||
private ProgressListener progressListener;
|
||||
// list of data packages, to initiate chart in process viewer fragment
|
||||
private ArrayList<DatapointParcelable> dataPackages = new ArrayList<>();
|
||||
@@ -160,16 +159,6 @@ public class ZipService extends AbstractProgressiveService {
|
||||
return NotificationConstants.ZIP_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getPercentProgress() {
|
||||
return progressPercent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setPercentProgress(float progress) {
|
||||
progressPercent = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getTitle(boolean move) {
|
||||
|
||||
@@ -43,6 +43,11 @@ public class ProgressHandler {
|
||||
*/
|
||||
private volatile boolean isCancelled = false;
|
||||
|
||||
/**
|
||||
* Percentage of progress
|
||||
*/
|
||||
private volatile float progressPercent = 0f;
|
||||
|
||||
/**
|
||||
* callback interface to interact with process viewer fragment and notification
|
||||
*/
|
||||
@@ -125,6 +130,14 @@ public class ProgressHandler {
|
||||
this.progressListener = progressListener;
|
||||
}
|
||||
|
||||
public float getPercentProgress() {
|
||||
return progressPercent;
|
||||
}
|
||||
|
||||
public void setPercentProgress(float progress) {
|
||||
progressPercent = progress;
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface responsible for talking to this object
|
||||
* Utilized by relevant service and eventually for notification generation
|
||||
|
||||
Reference in New Issue
Block a user