|
|
@@ -1,12 +1,16 @@
|
|
|
package com.usai.redant.apexdrivers;
|
|
|
|
|
|
import android.app.Notification;
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
+import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
+import android.content.IntentFilter;
|
|
|
import android.location.Location;
|
|
|
import android.util.Log;
|
|
|
|
|
|
import com.usai.redant.rautils.receiver.RABroadcast;
|
|
|
import com.usai.redant.rautils.service.RAService;
|
|
|
+import com.usai.redant.rautils.upload.RAUploadManager;
|
|
|
import com.usai.redant.rautils.utils.dbgUtil;
|
|
|
|
|
|
import org.json.JSONObject;
|
|
|
@@ -20,6 +24,36 @@ public class ApexDriversBackgroundService extends RAService implements RAService
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private BroadcastReceiver serviceReceiver = new BroadcastReceiver() {
|
|
|
+ @Override
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
+
|
|
|
+ String action = intent.getAction();
|
|
|
+ if (action.equals(RAUploadManager.UPLOAD_COUNT_CHANGED_NOTIFICATION)) {
|
|
|
+
|
|
|
+ sendUploadCountChangeNotification();
|
|
|
+
|
|
|
+ } else if (action.equals(RAUploadManager.UPLOAD_FINISH_TASK_NOTIFICATION)) {
|
|
|
+
|
|
|
+ sendUploadCountChangeNotification();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ public final static String APEX_DRIVER_UPLOAD_COUNT_CHANGE_NOTIFICATION = "com.usai.apex.driver.upload_count_change";
|
|
|
+ private void sendUploadCountChangeNotification() {
|
|
|
+
|
|
|
+ Intent intent = new Intent(APEX_DRIVER_UPLOAD_COUNT_CHANGE_NOTIFICATION);
|
|
|
+ intent.putExtra("upload_count",getUploadCount());
|
|
|
+
|
|
|
+ sendBroadcast(intent);
|
|
|
+ }
|
|
|
+
|
|
|
+ public int getUploadCount() {
|
|
|
+
|
|
|
+ return getUploadManager().get_arr_queue().size();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void Setup() {
|
|
|
// service_flag=FLAG_SERVICE_UPLOAD|FLAG_SERVICE_NOTIFICATION|FLAG_SERVICE_LOCATION;
|
|
|
@@ -28,9 +62,25 @@ public class ApexDriversBackgroundService extends RAService implements RAService
|
|
|
CHANNEL_NAME=ApexDriverApplication.sharedApplication().CHANNEL_NAME;
|
|
|
initServiceLocation(this);
|
|
|
// initServiceNotification(this,"replace this string with notification checking url");
|
|
|
+
|
|
|
+ RAUploadManager.configureUploadManager(getApplicationContext(), new RAUploadManager.configureBlock() {
|
|
|
+ @Override
|
|
|
+ public void configure(RAUploadManager.RAUploadManagerConfigure configure) {
|
|
|
+
|
|
|
+ configure.removeFinish = true;
|
|
|
+ configure.maxRetry = 10;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
initServiceUpload(this);
|
|
|
|
|
|
dbgUtil.fileLog(this,"ApexDriversBackgroundService Setup()");
|
|
|
+
|
|
|
+ IntentFilter intentFilter = new IntentFilter();
|
|
|
+ intentFilter.addAction(RAUploadManager.UPLOAD_COUNT_CHANGED_NOTIFICATION);
|
|
|
+ intentFilter.addAction(RAUploadManager.UPLOAD_FINISH_TASK_NOTIFICATION);
|
|
|
+
|
|
|
+ registerReceiver(serviceReceiver,intentFilter);
|
|
|
}
|
|
|
|
|
|
// @Override
|
|
|
@@ -81,4 +131,6 @@ public class ApexDriversBackgroundService extends RAService implements RAService
|
|
|
//// throw new UnsupportedOperationException("Not yet implemented");
|
|
|
// return super.onBind(intent);
|
|
|
// }
|
|
|
+
|
|
|
+
|
|
|
}
|