mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Do not hardcode service name in HandlerService
This commit is contained in:
parent
ac5e94bf25
commit
67e3b645cb
2 changed files with 10 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ import android.os.*;
|
||||||
public abstract class HandlerService<T> extends Service {
|
public abstract class HandlerService<T> extends Service {
|
||||||
private volatile Looper threadLooper;
|
private volatile Looper threadLooper;
|
||||||
private volatile ServiceHandler threadHandler;
|
private volatile ServiceHandler threadHandler;
|
||||||
|
private String serviceName;
|
||||||
|
|
||||||
private final class ServiceHandler extends Handler {
|
private final class ServiceHandler extends Handler {
|
||||||
public ServiceHandler(Looper looper) {
|
public ServiceHandler(Looper looper) {
|
||||||
|
|
@ -39,10 +40,14 @@ public abstract class HandlerService<T> extends Service {
|
||||||
return localBinder;
|
return localBinder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected HandlerService(String serviceName) {
|
||||||
|
this.serviceName = serviceName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
HandlerThread thread = new HandlerThread("UploadService");
|
HandlerThread thread = new HandlerThread(serviceName);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
threadLooper = thread.getLooper();
|
threadLooper = thread.getLooper();
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,10 @@ public class UploadService extends HandlerService<Contribution> {
|
||||||
public static final int NOTIFICATION_UPLOAD_COMPLETE = 2;
|
public static final int NOTIFICATION_UPLOAD_COMPLETE = 2;
|
||||||
public static final int NOTIFICATION_UPLOAD_FAILED = 3;
|
public static final int NOTIFICATION_UPLOAD_FAILED = 3;
|
||||||
|
|
||||||
|
protected UploadService(String serviceName) {
|
||||||
|
super("UploadService");
|
||||||
|
}
|
||||||
|
|
||||||
private class NotificationUpdateProgressListener implements ProgressListener {
|
private class NotificationUpdateProgressListener implements ProgressListener {
|
||||||
|
|
||||||
String notificationTag;
|
String notificationTag;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue