|
|
@@ -92,18 +92,20 @@ public class ViewUtil {
|
|
|
|
|
|
private static String oldMsg;
|
|
|
private static long time;
|
|
|
+
|
|
|
/**
|
|
|
* 弹出Toast消息
|
|
|
* 间隔时间不超过三秒的重复信息不会反复弹出
|
|
|
+ *
|
|
|
* @param msg
|
|
|
*/
|
|
|
public static void ToastMessage(Context cont, String msg) {
|
|
|
if (cont instanceof Activity) {
|
|
|
- if (!msg.equals(oldMsg)){
|
|
|
+ if (!msg.equals(oldMsg)) {
|
|
|
Crouton.makeText((Activity) cont, msg, cont.getResources().getColor(R.color.light_green), 3000).show();
|
|
|
time = System.currentTimeMillis();
|
|
|
} else {
|
|
|
- if ((System.currentTimeMillis() - time) > 3000){
|
|
|
+ if ((System.currentTimeMillis() - time) > 3000) {
|
|
|
Crouton.makeText((Activity) cont, msg, cont.getResources().getColor(R.color.light_green), 3000).show();
|
|
|
time = System.currentTimeMillis();
|
|
|
}
|
|
|
@@ -156,8 +158,8 @@ public class ViewUtil {
|
|
|
result = hClient.sendPostRequest(url, params);
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- CommonUtil.getExceptionStack(ct,e,true);
|
|
|
- Log.i("HttpResquest", "getDataFromServer"+CommonUtil.getExceptionStack(ct,e,true));
|
|
|
+ CommonUtil.getExceptionStack(ct, e, true);
|
|
|
+ Log.i("HttpResquest", "getDataFromServer" + CommonUtil.getExceptionStack(ct, e, true));
|
|
|
handler.sendEmptyMessage(Constants.SocketTimeoutException);
|
|
|
}
|
|
|
return result;
|
|
|
@@ -358,7 +360,11 @@ public class ViewUtil {
|
|
|
ToastMessage(MyApplication.getInstance(),
|
|
|
JSON.parseObject(msg.getData().getString("result")).getString("exception"));
|
|
|
} else {
|
|
|
- ToastMessage(MyApplication.getInstance(), "系统内部错误!");
|
|
|
+ boolean isNetHas = CommonUtil.isNetWorkConnected(ct);
|
|
|
+ if (isNetHas)
|
|
|
+ ToastMessage(MyApplication.getInstance(), "系统内部错误!");
|
|
|
+ else
|
|
|
+ ToastMessage(MyApplication.getInstance(), MyApplication.getInstance().getResources().getString(R.string.networks_out));
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
@@ -395,7 +401,7 @@ public class ViewUtil {
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_uu", String.valueOf(dataMap.get("uu")));
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_masterId", erp_masterId);
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_login", true);
|
|
|
- CommonUtil.setSharedPreferences(ct,"erp_emname",String.valueOf(dataMap.get("emname")));
|
|
|
+ CommonUtil.setSharedPreferences(ct, "erp_emname", String.valueOf(dataMap.get("emname")));
|
|
|
}
|
|
|
if (erp_phone != null) {
|
|
|
Log.i("login_status", "ChangeStatusERP:" + erp_phone);
|
|
|
@@ -461,17 +467,17 @@ public class ViewUtil {
|
|
|
private static void loginERPItemDialog(final String phone,
|
|
|
final String password) {
|
|
|
String[] items = new String[erpEntities.size()];
|
|
|
- int select=0;
|
|
|
+ int select = 0;
|
|
|
for (int j = 0; j < erpEntities.size(); j++) {
|
|
|
items[j] = erpEntities.get(j).getName();
|
|
|
}
|
|
|
if (CommonUtil.isDialogShowing(loginERPDialog)) {
|
|
|
return;
|
|
|
} else {
|
|
|
- if (loginERPDialog!=null) {
|
|
|
- select= loginERPDialog.getSelectedIndex();
|
|
|
+ if (loginERPDialog != null) {
|
|
|
+ select = loginERPDialog.getSelectedIndex();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
loginERPDialog = new MaterialDialog.Builder(ct)
|
|
|
.title("选择登录的UAS账套")
|
|
|
.items(items)
|
|
|
@@ -480,28 +486,28 @@ public class ViewUtil {
|
|
|
@Override
|
|
|
public boolean onSelection(MaterialDialog dialog,
|
|
|
View view, int which, CharSequence text) {
|
|
|
- LogUtil.d("onSelection:"+which);
|
|
|
+ LogUtil.d("onSelection:" + which);
|
|
|
if (!StringUtils.isEmpty(text.toString())) {
|
|
|
// for (int j2 = 0; j2 < erpEntities.size(); j2++) {
|
|
|
// if (text.toString().equals(
|
|
|
// erpEntities.get(j2).getName())) {
|
|
|
-
|
|
|
- LoginEntity entity = erpEntities
|
|
|
- .get(which);
|
|
|
- erp_phone = phone;
|
|
|
- erp_password = password;
|
|
|
- erp_username = entity.getAccount();
|
|
|
- erp_master = entity.getMaster();
|
|
|
- erp_baseurl = entity.getWebsite();
|
|
|
- erp_company = entity.getName();
|
|
|
- erp_uu = String.valueOf(entity
|
|
|
- .getEnuu());
|
|
|
- erp_masterId = String.valueOf(entity.getMasterId());
|
|
|
- LoginERPTask(entity.getWebsite(),
|
|
|
- entity.getMaster(), phone, password);
|
|
|
- //清除账套列表缓存
|
|
|
- CommonUtil.clearSharedPreferences(ct, "erp_masterlist");
|
|
|
-
|
|
|
+
|
|
|
+ LoginEntity entity = erpEntities
|
|
|
+ .get(which);
|
|
|
+ erp_phone = phone;
|
|
|
+ erp_password = password;
|
|
|
+ erp_username = entity.getAccount();
|
|
|
+ erp_master = entity.getMaster();
|
|
|
+ erp_baseurl = entity.getWebsite();
|
|
|
+ erp_company = entity.getName();
|
|
|
+ erp_uu = String.valueOf(entity
|
|
|
+ .getEnuu());
|
|
|
+ erp_masterId = String.valueOf(entity.getMasterId());
|
|
|
+ LoginERPTask(entity.getWebsite(),
|
|
|
+ entity.getMaster(), phone, password);
|
|
|
+ //清除账套列表缓存
|
|
|
+ CommonUtil.clearSharedPreferences(ct, "erp_masterlist");
|
|
|
+
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
@@ -523,12 +529,12 @@ public class ViewUtil {
|
|
|
String phone = msg.getData().getString("phone");
|
|
|
String password = msg.getData().getString("password");
|
|
|
Log.i("Login", "login sucess:" + json);
|
|
|
- if(new JsonValidator().validate(json)){
|
|
|
+ if (new JsonValidator().validate(json)) {
|
|
|
showDialogCompany(json, phone, password);
|
|
|
- }else{
|
|
|
- ToastMessage(ct,"接口数据非法!");
|
|
|
+ } else {
|
|
|
+ ToastMessage(ct, "接口数据非法!");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private static void showDialogCompany(String json, String phone, String password) {
|