|
|
@@ -1,6 +1,7 @@
|
|
|
package com.usai.redant.apexdrivers.receiver;
|
|
|
|
|
|
import android.app.AlarmManager;
|
|
|
+import android.app.Application;
|
|
|
import android.app.PendingIntent;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
@@ -158,21 +159,25 @@ public class ApexDriverAlarmReceiver extends AlarmReceiver {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
|
|
|
- JSONObject json = com.usai.redant.apexdrivers.network.Network.pullNotification();
|
|
|
+ if (ApexDriverApplication.sharedApplication().isLogin()) {
|
|
|
|
|
|
- if (json != null) {
|
|
|
+ JSONObject json = com.usai.redant.apexdrivers.network.Network.pullNotification();
|
|
|
|
|
|
- int result = json.optInt("result",0);
|
|
|
- if (result == RESULT_TRUE) {
|
|
|
+ if (json != null) {
|
|
|
|
|
|
- JSONArray notifications = json.optJSONArray("notifications");
|
|
|
- if (notifications != null) {
|
|
|
+ int result = json.optInt("result",0);
|
|
|
+ if (result == RESULT_TRUE) {
|
|
|
|
|
|
- for (int i = 0; i < notifications.length(); i++) {
|
|
|
- JSONObject notification = notifications.optJSONObject(i);
|
|
|
- if (notification != null) {
|
|
|
- ApexDriverApplication.sharedApplication().receiveNotificationOnMainThread(notification);
|
|
|
+ JSONArray notifications = json.optJSONArray("notifications");
|
|
|
+ if (notifications != null) {
|
|
|
+
|
|
|
+ for (int i = 0; i < notifications.length(); i++) {
|
|
|
+ JSONObject notification = notifications.optJSONObject(i);
|
|
|
+ if (notification != null) {
|
|
|
+ ApexDriverApplication.sharedApplication().receiveNotificationOnMainThread(notification);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|