@@ -38,7 +38,7 @@ public class UploadService extends IntentService {
38
38
39
39
public static String NAMESPACE = "com.alexbbb" ;
40
40
41
- protected static final String ACTION_UPLOAD = NAMESPACE + ".uploadservice.action.upload" ;
41
+ private static final String ACTION_UPLOAD_SUFFIX = ".uploadservice.action.upload" ;
42
42
protected static final String PARAM_NOTIFICATION_CONFIG = "notificationConfig" ;
43
43
protected static final String PARAM_ID = "id" ;
44
44
protected static final String PARAM_URL = "url" ;
@@ -47,7 +47,7 @@ public class UploadService extends IntentService {
47
47
protected static final String PARAM_REQUEST_HEADERS = "requestHeaders" ;
48
48
protected static final String PARAM_REQUEST_PARAMETERS = "requestParameters" ;
49
49
50
- public static final String BROADCAST_ACTION = NAMESPACE + ".uploadservice.broadcast.status" ;
50
+ private static final String BROADCAST_ACTION_SUFFIX = ".uploadservice.broadcast.status" ;
51
51
public static final String UPLOAD_ID = "id" ;
52
52
public static final String STATUS = "status" ;
53
53
public static final int STATUS_IN_PROGRESS = 1 ;
@@ -64,6 +64,14 @@ public class UploadService extends IntentService {
64
64
private UploadNotificationConfig notificationConfig ;
65
65
private int lastPublishedProgress ;
66
66
67
+ public static String getActionUpload () {
68
+ return NAMESPACE + ACTION_UPLOAD_SUFFIX ;
69
+ }
70
+
71
+ public static String getActionBroadcast () {
72
+ return NAMESPACE + BROADCAST_ACTION_SUFFIX ;
73
+ }
74
+
67
75
/**
68
76
* Utility method that creates the intent that starts the background file upload service.
69
77
*
@@ -81,7 +89,7 @@ public static void startUpload(final UploadRequest task) throws IllegalArgumentE
81
89
82
90
final Intent intent = new Intent (UploadService .class .getName ());
83
91
84
- intent .setAction (ACTION_UPLOAD );
92
+ intent .setAction (getActionUpload () );
85
93
intent .putExtra (PARAM_NOTIFICATION_CONFIG , task .getNotificationConfig ());
86
94
intent .putExtra (PARAM_ID , task .getUploadId ());
87
95
intent .putExtra (PARAM_URL , task .getServerUrl ());
@@ -113,7 +121,7 @@ protected void onHandleIntent(Intent intent) {
113
121
if (intent != null ) {
114
122
final String action = intent .getAction ();
115
123
116
- if (ACTION_UPLOAD .equals (action )) {
124
+ if (getActionUpload () .equals (action )) {
117
125
notificationConfig = intent .getParcelableExtra (PARAM_NOTIFICATION_CONFIG );
118
126
final String uploadId = intent .getStringExtra (PARAM_ID );
119
127
final String url = intent .getStringExtra (PARAM_URL );
@@ -311,7 +319,7 @@ private void broadcastProgress(final String uploadId, final long uploadedBytes,
311
319
312
320
updateNotificationProgress (progress );
313
321
314
- final Intent intent = new Intent (BROADCAST_ACTION );
322
+ final Intent intent = new Intent (getActionBroadcast () );
315
323
intent .putExtra (UPLOAD_ID , uploadId );
316
324
intent .putExtra (STATUS , STATUS_IN_PROGRESS );
317
325
intent .putExtra (PROGRESS , progress );
@@ -332,7 +340,7 @@ private void broadcastCompleted(final String uploadId, final int responseCode, f
332
340
else
333
341
updateNotificationError ();
334
342
335
- final Intent intent = new Intent (BROADCAST_ACTION );
343
+ final Intent intent = new Intent (getActionBroadcast () );
336
344
intent .putExtra (UPLOAD_ID , uploadId );
337
345
intent .putExtra (STATUS , STATUS_COMPLETED );
338
346
intent .putExtra (SERVER_RESPONSE_CODE , responseCode );
@@ -344,8 +352,8 @@ private void broadcastError(final String uploadId, final Exception exception) {
344
352
345
353
updateNotificationError ();
346
354
347
- final Intent intent = new Intent (BROADCAST_ACTION );
348
- intent .setAction (BROADCAST_ACTION );
355
+ final Intent intent = new Intent (getActionBroadcast () );
356
+ intent .setAction (getActionBroadcast () );
349
357
intent .putExtra (UPLOAD_ID , uploadId );
350
358
intent .putExtra (STATUS , STATUS_ERROR );
351
359
intent .putExtra (ERROR_EXCEPTION , exception );
0 commit comments