|
|
@@ -1,9 +1,11 @@
|
|
|
package com.usai.redant.apexdrivers.upload;
|
|
|
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
import android.content.ComponentName;
|
|
|
import android.content.Context;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
+import android.content.IntentFilter;
|
|
|
import android.content.ServiceConnection;
|
|
|
import android.content.SharedPreferences;
|
|
|
import android.net.ConnectivityManager;
|
|
|
@@ -38,6 +40,8 @@ import com.usai.redant.rautils.utils.dbgUtil;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
|
|
|
+import static com.usai.redant.apexdrivers.ApexDriversBackgroundService.APEX_DRIVER_UPLOAD_COUNT_CHANGE_NOTIFICATION;
|
|
|
+
|
|
|
|
|
|
public class TaskActivity extends BasicActivity {
|
|
|
|
|
|
@@ -53,6 +57,43 @@ public class TaskActivity extends BasicActivity {
|
|
|
private ServiceConnection serviceConnection;
|
|
|
|
|
|
boolean serviceConnectionFlag;
|
|
|
+
|
|
|
+ private BroadcastReceiver uploadReceiver = new BroadcastReceiver() {
|
|
|
+ @Override
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
+
|
|
|
+ String action = intent.getAction();
|
|
|
+ if (action.equals(APEX_DRIVER_UPLOAD_COUNT_CHANGE_NOTIFICATION)) {
|
|
|
+
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ notifyDataChanged();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ public void notifyDataChanged() {
|
|
|
+
|
|
|
+ if (uploadManager != null && tasklist != null) {
|
|
|
+ task_arr = (ArrayList<Bundle>) uploadManager.get_arr_queue().clone(); //uploadManager.arr_queue;
|
|
|
+ TaskAdapter adapter = (TaskAdapter)tasklist.getAdapter();
|
|
|
+ if (adapter != null) {
|
|
|
+ adapter.notifyDataSetChanged();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void registerBroadcastReceiver() {
|
|
|
+
|
|
|
+ IntentFilter intentFilter = new IntentFilter();
|
|
|
+ intentFilter.addAction(APEX_DRIVER_UPLOAD_COUNT_CHANGE_NOTIFICATION);
|
|
|
+
|
|
|
+ registerReceiver(uploadReceiver,intentFilter);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
@@ -144,6 +185,7 @@ public class TaskActivity extends BasicActivity {
|
|
|
|
|
|
bindService();
|
|
|
|
|
|
+ registerBroadcastReceiver();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -151,6 +193,8 @@ public class TaskActivity extends BasicActivity {
|
|
|
|
|
|
unbindService(serviceConnection);
|
|
|
|
|
|
+ unregisterReceiver(uploadReceiver);
|
|
|
+
|
|
|
super.onDestroy();
|
|
|
}
|
|
|
|