|
|
@@ -8,6 +8,7 @@ import android.text.TextUtils;
|
|
|
|
|
|
|
|
|
import com.usai.redant.apexdrivers.ApexDriverApplication;
|
|
|
+import com.usai.redant.rautils.utils.RAUtil;
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
@@ -34,6 +35,8 @@ public class Network extends com.usai.redant.rautils.utils.Network {
|
|
|
public static final String URL_DRIVER_AVAILABLE = URL_HOST + "/j/mobile/updateDriverAvailable.mo/";
|
|
|
public static final String URL_CHANGE_PASSWORD = URL_HOST + "/j/mobile/changePassword.mo/";
|
|
|
public static final String URL_MESSAGE_LIST = URL_HOST + "/j/mobile/moreDriverMessages.mo/";
|
|
|
+ public static final String URL_UPLOAD_TOKEN = URL_HOST + "/j/mobile/uploadToken.mo/";
|
|
|
+ public static final String URL_PULL_NOTIFICATION = URL_HOST + "/j/mobile/pullNotification.mo/";
|
|
|
|
|
|
private static void prepareParams(Bundle params) {
|
|
|
if (params == null) {
|
|
|
@@ -74,6 +77,14 @@ public class Network extends com.usai.redant.rautils.utils.Network {
|
|
|
return com.usai.redant.rautils.utils.Network.isNetworkAvailable(application);
|
|
|
}
|
|
|
|
|
|
+ public static String getJson(String url, Bundle parms) {
|
|
|
+ return getJson(url,parms, com.usai.redant.rautils.utils.Network.SO_TIMEOUT);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static String getJSON(String url, Bundle params, int timeout) {
|
|
|
+ return getJson(url,params,timeout);
|
|
|
+ }
|
|
|
+
|
|
|
public static JSONObject retrieve_pass(Application application, String user, String email) {
|
|
|
|
|
|
Bundle parms = new Bundle();
|
|
|
@@ -357,4 +368,39 @@ public class Network extends com.usai.redant.rautils.utils.Network {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @brief 上传推送令牌,在登陆成功的时候 以及 程序启动时自动登陆的情况下
|
|
|
+ * */
|
|
|
+ public static JSONObject uploadToken(String token) {
|
|
|
+
|
|
|
+ Bundle params = new Bundle();
|
|
|
+ if (token != null) {
|
|
|
+ params.putString("token",token);
|
|
|
+ }
|
|
|
+
|
|
|
+ prepareParams(params);
|
|
|
+ String jsonStr = getJson(URL_UPLOAD_TOKEN,params);
|
|
|
+
|
|
|
+ return handleJson(jsonStr);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static JSONObject pullNotification() {
|
|
|
+
|
|
|
+ Bundle params = new Bundle();
|
|
|
+ // token
|
|
|
+ params.putString("token", RAUtil.getDeviceId(ApexDriverApplication.sharedApplication().getApplicationContext()));
|
|
|
+
|
|
|
+ // id
|
|
|
+ long id = ApexDriverApplication.sharedApplication().getNotificationID();
|
|
|
+ params.putLong("id",id);
|
|
|
+
|
|
|
+ prepareParams(params);
|
|
|
+
|
|
|
+ int timeout = 5 * 1000;
|
|
|
+ String jsonStr = getJSON(URL_UPLOAD_TOKEN,params,timeout);
|
|
|
+
|
|
|
+ return handleJson(jsonStr);
|
|
|
+ }
|
|
|
+
|
|
|
}
|