|
|
@@ -7,6 +7,7 @@ import android.os.Bundle;
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
+import com.usai.redant.apexdrivers.ApexDriverApplication;
|
|
|
import com.usai.redant.apexdrivers.R;
|
|
|
|
|
|
import org.json.JSONException;
|
|
|
@@ -20,8 +21,29 @@ import static java.lang.Thread.sleep;
|
|
|
|
|
|
public class Network extends com.usai.redant.rautils.Utils.Network {
|
|
|
|
|
|
- public static String URL_HOST = "";
|
|
|
- private static boolean FAKE_DATA = true;
|
|
|
+ private static final String URL_HOST = "http://192.168.0.124:8080";
|
|
|
+ private static final String URL_LOGIN = URL_HOST + "/j/mobile/login.mo/";
|
|
|
+ private static final String URL_HOME = URL_HOST + "/j/mobile/truckPage.mo/";
|
|
|
+ private static final String URL_MORE_ORDER = URL_HOST + "/j/mobile/morePickupOrders.mo/";
|
|
|
+ private static final String URL_DETAIL = URL_HOST + "/j/mobile/orderDetails.mo/";
|
|
|
+ private static final String URL_UPDATE = URL_HOST + "/j/mobile/actionDetails.mo/";
|
|
|
+
|
|
|
+ private static boolean FAKE_DATA = false;
|
|
|
+
|
|
|
+ private static void prepareParams(Bundle params) {
|
|
|
+ if (params == null) {
|
|
|
+ params = new Bundle();
|
|
|
+ }
|
|
|
+ String user = ApexDriverApplication.sharedApplication().encryptUser();
|
|
|
+ String password = ApexDriverApplication.sharedApplication().encryptPassword();
|
|
|
+
|
|
|
+ if (user != null && user.length() > 0 && password != null && password.length() != 0) {
|
|
|
+ params.putString("name","WMoy059hzweXPSC74plhBA==");
|
|
|
+ params.putString("password","CzADM7u51eNR7ScfQtJw7w==");
|
|
|
+ }
|
|
|
+
|
|
|
+ params.putString("platform","android");
|
|
|
+ }
|
|
|
|
|
|
public static boolean NetworkIsAvailable(Application application) {
|
|
|
return com.usai.redant.rautils.Utils.Network.isNetworkAvailable(application);
|
|
|
@@ -84,7 +106,36 @@ public class Network extends com.usai.redant.rautils.Utils.Network {
|
|
|
}
|
|
|
|
|
|
public static int login(String user, String password) {
|
|
|
- return RESULT_TRUE;
|
|
|
+
|
|
|
+ Bundle params = new Bundle();
|
|
|
+
|
|
|
+ user = ApexDriverApplication.sharedApplication().encryptString(user);
|
|
|
+ password = ApexDriverApplication.sharedApplication().encryptString(password);
|
|
|
+
|
|
|
+ if (user != null) {
|
|
|
+ params.putString("name","WMoy059hzweXPSC74plhBA=="); // "WMoy059hzweXPSC74plhBA=="
|
|
|
+ }
|
|
|
+ if (password != null) {
|
|
|
+ params.putString("password","CzADM7u51eNR7ScfQtJw7w=="); // "CzADM7u51eNR7ScfQtJw7w=="
|
|
|
+ }
|
|
|
+
|
|
|
+ prepareParams(params);
|
|
|
+
|
|
|
+ String jsonStr = getJson(URL_LOGIN,params);
|
|
|
+ if (jsonStr == null || jsonStr.isEmpty()) {
|
|
|
+ return RESULT_NET_ERROR;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ JSONObject json = new JSONObject(jsonStr);
|
|
|
+ int result = json.getInt("result");
|
|
|
+
|
|
|
+ return result;
|
|
|
+
|
|
|
+ } catch (JSONException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return RESULT_ERROR;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static JSONObject requestOrderList(Context context) {
|
|
|
@@ -99,7 +150,9 @@ public class Network extends com.usai.redant.rautils.Utils.Network {
|
|
|
}
|
|
|
|
|
|
Bundle params = new Bundle();
|
|
|
- String jsonStr = getJson(URL_HOST,params);
|
|
|
+
|
|
|
+ prepareParams(params);
|
|
|
+ String jsonStr = getJson(URL_HOME,params);
|
|
|
if (jsonStr == null || jsonStr.isEmpty()) {
|
|
|
return null;
|
|
|
}
|
|
|
@@ -125,7 +178,12 @@ public class Network extends com.usai.redant.rautils.Utils.Network {
|
|
|
}
|
|
|
|
|
|
Bundle params = new Bundle();
|
|
|
- String jsonStr = getJson(URL_HOST,params);
|
|
|
+ params.putInt("type",orderType);
|
|
|
+ params.putInt("offset",offset);
|
|
|
+ params.putInt("limit",limit);
|
|
|
+
|
|
|
+ prepareParams(params);
|
|
|
+ String jsonStr = getJson(URL_MORE_ORDER,params);
|
|
|
if (jsonStr == null || jsonStr.isEmpty()) {
|
|
|
return null;
|
|
|
}
|
|
|
@@ -140,7 +198,7 @@ public class Network extends com.usai.redant.rautils.Utils.Network {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public static JSONObject requestOrderDetail(Context context,String orderID) {
|
|
|
+ public static JSONObject requestOrderDetail(Context context,String orderID,int status,String type2) {
|
|
|
|
|
|
if (FAKE_DATA) {
|
|
|
try {
|
|
|
@@ -157,8 +215,13 @@ public class Network extends com.usai.redant.rautils.Utils.Network {
|
|
|
|
|
|
Bundle params = new Bundle();
|
|
|
params.putString("orderID",orderID);
|
|
|
+ if (type2 != null) {
|
|
|
+ params.putString("orderType2",type2);
|
|
|
+ }
|
|
|
+ params.putInt("orderType",status);
|
|
|
|
|
|
- String jsonStr = getJson(URL_HOST,params);
|
|
|
+ prepareParams(params);
|
|
|
+ String jsonStr = getJson(URL_DETAIL,params);
|
|
|
if (jsonStr == null || jsonStr.isEmpty()) {
|
|
|
return null;
|
|
|
}
|
|
|
@@ -190,7 +253,8 @@ public class Network extends com.usai.redant.rautils.Utils.Network {
|
|
|
Bundle params = new Bundle();
|
|
|
params.putString("orderID",orderID);
|
|
|
|
|
|
- String jsonStr = getJson(URL_HOST,params);
|
|
|
+ prepareParams(params);
|
|
|
+ String jsonStr = getJson(URL_UPDATE,params);
|
|
|
if (jsonStr == null || jsonStr.isEmpty()) {
|
|
|
return null;
|
|
|
}
|