|
@@ -47,6 +47,7 @@ import com.core.utils.CommonUtil;
|
|
|
import com.core.utils.DialogUtils;
|
|
import com.core.utils.DialogUtils;
|
|
|
import com.core.utils.FlexJsonUtil;
|
|
import com.core.utils.FlexJsonUtil;
|
|
|
import com.core.utils.ToastUtil;
|
|
import com.core.utils.ToastUtil;
|
|
|
|
|
+import com.core.widget.CustomProgressDialog;
|
|
|
import com.core.widget.crouton.Crouton;
|
|
import com.core.widget.crouton.Crouton;
|
|
|
import com.core.widget.crouton.Style;
|
|
import com.core.widget.crouton.Style;
|
|
|
import com.me.network.app.base.HttpCallback;
|
|
import com.me.network.app.base.HttpCallback;
|
|
@@ -81,16 +82,9 @@ public class ViewUtil {
|
|
|
private static MaterialDialog loginERPDialog;
|
|
private static MaterialDialog loginERPDialog;
|
|
|
private static List<LoginEntity> erpEntities;
|
|
private static List<LoginEntity> erpEntities;
|
|
|
private static boolean hasErp = true;//是否有erp
|
|
private static boolean hasErp = true;//是否有erp
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- private static String oldMsg;
|
|
|
|
|
- private static long time;
|
|
|
|
|
- private static String oldMsg2;
|
|
|
|
|
- private static long time2;
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
public static Crouton crouton;
|
|
public static Crouton crouton;
|
|
|
|
|
|
|
|
|
|
+ public static CustomProgressDialog progressDialog;
|
|
|
|
|
|
|
|
public static void ToastMessage(Context cont, String msg) {
|
|
public static void ToastMessage(Context cont, String msg) {
|
|
|
ToastUtil.showToast(cont,msg);
|
|
ToastUtil.showToast(cont,msg);
|
|
@@ -99,21 +93,6 @@ public class ViewUtil {
|
|
|
|
|
|
|
|
public static void ToastMessage(Context cont, String msg, int toastColor, int toastTime) {
|
|
public static void ToastMessage(Context cont, String msg, int toastColor, int toastTime) {
|
|
|
ToastUtil.showToast(cont,msg);
|
|
ToastUtil.showToast(cont,msg);
|
|
|
-// if (cont instanceof Activity) {
|
|
|
|
|
-// if (crouton != null) {
|
|
|
|
|
-// crouton.cancel();
|
|
|
|
|
-// crouton = Crouton.makeText((Activity) cont, msg, toastColor, toastTime);
|
|
|
|
|
-// crouton.show();
|
|
|
|
|
-// } else {
|
|
|
|
|
-// crouton = Crouton.makeText((Activity) cont, msg, toastColor, toastTime);
|
|
|
|
|
-// crouton.show();
|
|
|
|
|
-// }
|
|
|
|
|
-// } else {
|
|
|
|
|
-// if (cont != null) {
|
|
|
|
|
-// Toast.makeText(cont, msg, Toast.LENGTH_SHORT).show();
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static void ShowMessageTitle(Context ct, String msg) {
|
|
public static void ShowMessageTitle(Context ct, String msg) {
|
|
@@ -275,6 +254,7 @@ public class ViewUtil {
|
|
|
*/
|
|
*/
|
|
|
public static void LoginTask(final String user_phone, final String user_password, final Context ct) {
|
|
public static void LoginTask(final String user_phone, final String user_password, final Context ct) {
|
|
|
ViewUtil.ct = ct;
|
|
ViewUtil.ct = ct;
|
|
|
|
|
+ progressDialog= CustomProgressDialog.createDialog(ct);
|
|
|
LogUtil.d("AppInfo","password:"+user_password+" phone:"+user_phone);
|
|
LogUtil.d("AppInfo","password:"+user_password+" phone:"+user_phone);
|
|
|
mdProcessDialog = new MaterialDialog.Builder(ct).title(
|
|
mdProcessDialog = new MaterialDialog.Builder(ct).title(
|
|
|
MyApplication.getInstance().getString(R.string.app_dialog_title))
|
|
MyApplication.getInstance().getString(R.string.app_dialog_title))
|
|
@@ -285,24 +265,6 @@ public class ViewUtil {
|
|
|
if (!((BaseActivity) ViewUtil.ct).isFinishing()) {
|
|
if (!((BaseActivity) ViewUtil.ct).isFinishing()) {
|
|
|
mdProcessDialog.show();
|
|
mdProcessDialog.show();
|
|
|
}
|
|
}
|
|
|
-// if (!(ct instanceof LoginActivity)) {
|
|
|
|
|
- //取缓存
|
|
|
|
|
-// if (!StringUtil.isEmpty(CommonUtil.getSharedPreferences(ct, "loginJson"))) {
|
|
|
|
|
-// showDialogCompany(CommonUtil.getSharedPreferences(ct, "loginJson"), user_phone, user_password);
|
|
|
|
|
-// }
|
|
|
|
|
-// } else {
|
|
|
|
|
- //登录界面过来,不走缓存
|
|
|
|
|
- /*String url = Constants.BASE_URL_LOGIN;
|
|
|
|
|
- Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
- params.put("user", user_phone);
|
|
|
|
|
- params.put("password", user_password);
|
|
|
|
|
- Message message = new Message();
|
|
|
|
|
- Bundle bundle = new Bundle();
|
|
|
|
|
- bundle.putString("phone", user_phone);
|
|
|
|
|
- bundle.putString("password", user_password);
|
|
|
|
|
- startNetThread(url, params, handler, Constants.SUCCESS_LOGIN, message,
|
|
|
|
|
- bundle, "get");*/
|
|
|
|
|
-// }
|
|
|
|
|
HttpRequest.getInstance().sendRequest(Constants.ACCOUNT_CENTER_HOST,
|
|
HttpRequest.getInstance().sendRequest(Constants.ACCOUNT_CENTER_HOST,
|
|
|
new HttpParams.Builder()
|
|
new HttpParams.Builder()
|
|
|
.url("sso/login/mobile")
|
|
.url("sso/login/mobile")
|
|
@@ -454,14 +416,14 @@ public class ViewUtil {
|
|
|
ChangeStatusERP(result);
|
|
ChangeStatusERP(result);
|
|
|
} else {
|
|
} else {
|
|
|
String reason = JSON.parseObject(result).getString("reason");
|
|
String reason = JSON.parseObject(result).getString("reason");
|
|
|
- ToastMessage(ct, reason, Style.holoGreenLight, 3000);
|
|
|
|
|
|
|
+ ToastMessage(MyApplication.getInstance(), reason, Style.holoGreenLight, 3000);
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- ToastMessage(ct, "接口数据非法!", Style.holoRedLight, 3000);
|
|
|
|
|
|
|
+ ToastMessage(MyApplication.getInstance(), "接口数据非法!", Style.holoRedLight, 3000);
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
- ToastMessage(ct, MyApplication.getInstance().getString(R.string.login_error_erp), Style.holoRedLight, 3000);
|
|
|
|
|
|
|
+ ToastMessage(MyApplication.getInstance(), MyApplication.getInstance().getString(R.string.login_error_erp), Style.holoRedLight, 3000);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -526,7 +488,7 @@ public class ViewUtil {
|
|
|
ct.startActivity(new Intent("com.modular.main.DataDownloadActivity"));
|
|
ct.startActivity(new Intent("com.modular.main.DataDownloadActivity"));
|
|
|
}
|
|
}
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_baseurl", erp_baseurl);
|
|
CommonUtil.setSharedPreferences(ct, "erp_baseurl", erp_baseurl);
|
|
|
- } else {
|
|
|
|
|
|
|
+ }else{
|
|
|
if (!StringUtil.isEmpty(CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_baseurl"))) {
|
|
if (!StringUtil.isEmpty(CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_baseurl"))) {
|
|
|
} else {
|
|
} else {
|
|
|
MyApplication.getInstance().startActivity(new Intent("com.modular.main.DataDownloadActivity"));
|
|
MyApplication.getInstance().startActivity(new Intent("com.modular.main.DataDownloadActivity"));
|
|
@@ -638,8 +600,10 @@ public class ViewUtil {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- /*@功能:管理平台的返回信息处理*/
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /*@功能:管理平台的返回信息处理*/
|
|
|
public static void LoginSucess(String json, String phone, String password) {
|
|
public static void LoginSucess(String json, String phone, String password) {
|
|
|
|
|
+ LogUtil.d("AppInfo","phone:"+phone+"password:"+password);
|
|
|
CommonUtil.setSharedPreferences(ct, "loginJson", json);
|
|
CommonUtil.setSharedPreferences(ct, "loginJson", json);
|
|
|
try {
|
|
try {
|
|
|
JSONArray array = JSON.parseArray(json);
|
|
JSONArray array = JSON.parseArray(json);
|
|
@@ -652,7 +616,7 @@ public class ViewUtil {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
if (JSONUtil.validate(json)) {
|
|
if (JSONUtil.validate(json)) {
|
|
|
// showDialogCompany(json, phone, password);
|
|
// showDialogCompany(json, phone, password);
|
|
@@ -663,7 +627,9 @@ public class ViewUtil {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
public static void showLoginDialog(String loginResult, final String phone, final String password) {
|
|
public static void showLoginDialog(String loginResult, final String phone, final String password) {
|
|
|
|
|
+ LogUtil.d("AppInfo","phone:"+phone+"password:"+password);
|
|
|
List<LoginEntity> loginMsg = JSON.parseArray(loginResult, LoginEntity.class);
|
|
List<LoginEntity> loginMsg = JSON.parseArray(loginResult, LoginEntity.class);
|
|
|
List<LoginEntity> loginEntities = new ArrayList<>();
|
|
List<LoginEntity> loginEntities = new ArrayList<>();
|
|
|
boolean isHasUas = false;
|
|
boolean isHasUas = false;
|
|
@@ -720,16 +686,16 @@ public class ViewUtil {
|
|
|
erpEntities = loginEntities;
|
|
erpEntities = loginEntities;
|
|
|
String[] items = new String[loginEntities.size()];
|
|
String[] items = new String[loginEntities.size()];
|
|
|
int select = 0;
|
|
int select = 0;
|
|
|
- List<ItemsSelectType1> itemsSelectType1s = new ArrayList<>();
|
|
|
|
|
|
|
+ List<ItemsSelectType1> itemsSelectType1s=new ArrayList<>();
|
|
|
for (int j = 0; j < loginEntities.size(); j++) {
|
|
for (int j = 0; j < loginEntities.size(); j++) {
|
|
|
- ItemsSelectType1 model = new ItemsSelectType1();
|
|
|
|
|
|
|
+ ItemsSelectType1 model=new ItemsSelectType1();
|
|
|
model.setName(loginEntities.get(j).getName());
|
|
model.setName(loginEntities.get(j).getName());
|
|
|
items[j] = loginEntities.get(j).getName();
|
|
items[j] = loginEntities.get(j).getName();
|
|
|
itemsSelectType1s.add(model);
|
|
itemsSelectType1s.add(model);
|
|
|
- String companyName = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_commpany");
|
|
|
|
|
- if (!StringUtil.isEmpty(companyName)) {
|
|
|
|
|
- if (companyName.equals(loginEntities.get(j).getName())) {
|
|
|
|
|
- selectId = j;
|
|
|
|
|
|
|
+ String companyName=CommonUtil.getSharedPreferences(MyApplication.getInstance(),"erp_commpany");
|
|
|
|
|
+ if (!StringUtil.isEmpty(companyName)){
|
|
|
|
|
+ if (companyName.equals(loginEntities.get(j).getName())){
|
|
|
|
|
+ selectId=j;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -740,8 +706,9 @@ public class ViewUtil {
|
|
|
// if (select > items.length) {
|
|
// if (select > items.length) {
|
|
|
// select = 0;
|
|
// select = 0;
|
|
|
// }
|
|
// }
|
|
|
- popupWindow = null;
|
|
|
|
|
- showPopDialog((Activity) ct, itemsSelectType1s, phone, password);
|
|
|
|
|
|
|
+ LogUtil.d("AppInfo","phone:"+phone+"password:"+password);
|
|
|
|
|
+
|
|
|
|
|
+ showPopDialog((Activity) ct,itemsSelectType1s,phone,password);
|
|
|
// loginERPDialog = new MaterialDialog.Builder(ct)
|
|
// loginERPDialog = new MaterialDialog.Builder(ct)
|
|
|
// .title(ct.getString(R.string.user_dialog_company))
|
|
// .title(ct.getString(R.string.user_dialog_company))
|
|
|
// .items(items)
|
|
// .items(items)
|
|
@@ -760,23 +727,27 @@ public class ViewUtil {
|
|
|
|
|
|
|
|
|
|
|
|
|
public static PopupWindow popupWindow = null;
|
|
public static PopupWindow popupWindow = null;
|
|
|
- public static int selectId = 0;
|
|
|
|
|
|
|
+ public static int selectId=0;
|
|
|
public static ItemPopListAdapter adapter;
|
|
public static ItemPopListAdapter adapter;
|
|
|
-
|
|
|
|
|
- public static void showPopDialog(final Activity ct, List<ItemsSelectType1> itemsSelectType1s
|
|
|
|
|
- , final String phone, final String password) {
|
|
|
|
|
- erp_phone = phone;
|
|
|
|
|
- erp_password = password;
|
|
|
|
|
|
|
+ public static void showPopDialog(final Activity ct, List<ItemsSelectType1> itemsSelectType1s
|
|
|
|
|
+ , final String phone, final String password){
|
|
|
|
|
+ erp_phone=phone;
|
|
|
|
|
+ erp_password=password;
|
|
|
View view = null;
|
|
View view = null;
|
|
|
- if (DialogUtils.isDialogShowing(mdProcessDialog)) {
|
|
|
|
|
|
|
+ if (DialogUtils.isDialogShowing(mdProcessDialog)){
|
|
|
mdProcessDialog.dismiss();
|
|
mdProcessDialog.dismiss();
|
|
|
}
|
|
}
|
|
|
- WindowManager windowManager = (WindowManager) ct.getSystemService(Context.WINDOW_SERVICE);
|
|
|
|
|
|
|
+ if (DialogUtils.isDialogShowing(popupWindow)){
|
|
|
|
|
+ popupWindow.dismiss();
|
|
|
|
|
+ popupWindow=null;
|
|
|
|
|
+ }
|
|
|
|
|
+ popupWindow=null;
|
|
|
|
|
+ WindowManager windowManager = (WindowManager)ct. getSystemService(Context.WINDOW_SERVICE);
|
|
|
if (popupWindow == null) {
|
|
if (popupWindow == null) {
|
|
|
LayoutInflater layoutInflater = (LayoutInflater) ct.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
LayoutInflater layoutInflater = (LayoutInflater) ct.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
view = layoutInflater.inflate(R.layout.pop_dialog_list, null);
|
|
view = layoutInflater.inflate(R.layout.pop_dialog_list, null);
|
|
|
ListView plist = view.findViewById(R.id.mList);
|
|
ListView plist = view.findViewById(R.id.mList);
|
|
|
- List<ItemsSelectType1> datas = itemsSelectType1s;
|
|
|
|
|
|
|
+ List<ItemsSelectType1> datas =itemsSelectType1s;
|
|
|
adapter = new ItemPopListAdapter(ct, datas);
|
|
adapter = new ItemPopListAdapter(ct, datas);
|
|
|
adapter.setSelectId(selectId);
|
|
adapter.setSelectId(selectId);
|
|
|
plist.setAdapter(adapter);
|
|
plist.setAdapter(adapter);
|
|
@@ -790,12 +761,12 @@ public class ViewUtil {
|
|
|
selectId = position;
|
|
selectId = position;
|
|
|
adapter.setSelectId(selectId);
|
|
adapter.setSelectId(selectId);
|
|
|
adapter.notifyDataSetChanged();
|
|
adapter.notifyDataSetChanged();
|
|
|
- ItemPopListAdapter.ViewHolder viewHolder = (ItemPopListAdapter.ViewHolder) view.getTag();
|
|
|
|
|
- String text = viewHolder.tvItemName.getText().toString();
|
|
|
|
|
- selectCompanyItems(selectId, text, phone, password);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- popupWindow = new PopupWindow(view, windowManager.getDefaultDisplay().getWidth() - DensityUtil.dp2px(50), LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
|
|
+ ItemPopListAdapter.ViewHolder viewHolder= (ItemPopListAdapter.ViewHolder) view.getTag();
|
|
|
|
|
+ String text= viewHolder.tvItemName.getText().toString();
|
|
|
|
|
+
|
|
|
|
|
+ selectCompanyItems(selectId, text,erp_phone, erp_password);
|
|
|
|
|
+ }});
|
|
|
|
|
+ popupWindow = new PopupWindow(view, windowManager.getDefaultDisplay().getWidth()- DensityUtil.dp2px(50), LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
|
}
|
|
}
|
|
|
popupWindow.setFocusable(true);
|
|
popupWindow.setFocusable(true);
|
|
|
popupWindow.setOutsideTouchable(true);
|
|
popupWindow.setOutsideTouchable(true);
|
|
@@ -810,9 +781,11 @@ public class ViewUtil {
|
|
|
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
popupWindow.showAtLocation(ct.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
popupWindow.showAtLocation(ct.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private static boolean selectCompanyItems(int which, CharSequence text, String phone, String password) {
|
|
private static boolean selectCompanyItems(int which, CharSequence text, String phone, String password) {
|
|
|
|
|
+ LogUtil.d("AppInfo","text;"+text+"phone:"+phone+" password:"+password);
|
|
|
if (!CommonUtil.isNetWorkConnected(ct)) {
|
|
if (!CommonUtil.isNetWorkConnected(ct)) {
|
|
|
ToastUtil.showToast(ct, R.string.networks_out);
|
|
ToastUtil.showToast(ct, R.string.networks_out);
|
|
|
return true;
|
|
return true;
|
|
@@ -1191,19 +1164,21 @@ public class ViewUtil {
|
|
|
// 登录ERP
|
|
// 登录ERP
|
|
|
public static void LoginERPTask(String url, String enuu, String master, String username, String password) {
|
|
public static void LoginERPTask(String url, String enuu, String master, String username, String password) {
|
|
|
mdProcessDialog.setContent(MyApplication.getInstance().getString(R.string.login_progress_erp));
|
|
mdProcessDialog.setContent(MyApplication.getInstance().getString(R.string.login_progress_erp));
|
|
|
|
|
+ progressDialog.show();
|
|
|
String loginToken = CommonUtil.getSharedPreferences(ct, Constants.CACHE.ACCOUNT_CENTER_TOKEN);
|
|
String loginToken = CommonUtil.getSharedPreferences(ct, Constants.CACHE.ACCOUNT_CENTER_TOKEN);
|
|
|
HttpRequest.getInstance().sendRequest(url,
|
|
HttpRequest.getInstance().sendRequest(url,
|
|
|
new HttpParams.Builder()
|
|
new HttpParams.Builder()
|
|
|
.url("mobile/login.action")
|
|
.url("mobile/login.action")
|
|
|
.addParam("token", loginToken)
|
|
.addParam("token", loginToken)
|
|
|
.addParam("enuu", enuu)
|
|
.addParam("enuu", enuu)
|
|
|
- .connectTimeOut(5)
|
|
|
|
|
- .readTimeOut(5)
|
|
|
|
|
|
|
+ .connectTimeOut(3)
|
|
|
|
|
+ .readTimeOut(3)
|
|
|
.method(Method.POST)
|
|
.method(Method.POST)
|
|
|
.build(), new HttpCallback() {
|
|
.build(), new HttpCallback() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onSuccess(int flag, Object o) throws Exception {
|
|
public void onSuccess(int flag, Object o) throws Exception {
|
|
|
Log.d("erp登录成功", o.toString());
|
|
Log.d("erp登录成功", o.toString());
|
|
|
|
|
+ progressDialog.dismiss();
|
|
|
if (o != null) {
|
|
if (o != null) {
|
|
|
loginErpSuccess(o.toString());
|
|
loginErpSuccess(o.toString());
|
|
|
}
|
|
}
|
|
@@ -1211,8 +1186,9 @@ public class ViewUtil {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onFail(int flag, String failStr) throws Exception {
|
|
public void onFail(int flag, String failStr) throws Exception {
|
|
|
- Log.e("erp登录失败", "登录失败:" + failStr);
|
|
|
|
|
- ToastMessage(MyApplication.getInstance(), "登录失败:" + failStr);
|
|
|
|
|
|
|
+ Log.e("erp登录失败", "登录失败:"+failStr);
|
|
|
|
|
+ progressDialog.dismiss();
|
|
|
|
|
+ ToastMessage(MyApplication.getInstance(),"登录失败:"+failStr);
|
|
|
mdProcessDialog.setContent("登录失败");
|
|
mdProcessDialog.setContent("登录失败");
|
|
|
new Handler().postDelayed(new Runnable() {
|
|
new Handler().postDelayed(new Runnable() {
|
|
|
@Override
|
|
@Override
|