|
@@ -93,13 +93,13 @@ public class ViewUtil {
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void ToastMessage(Context cont, String msg) {
|
|
public static void ToastMessage(Context cont, String msg) {
|
|
|
- ToastUtil.showToast(cont,msg);
|
|
|
|
|
|
|
+ ToastUtil.showToast(cont, msg);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
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 (cont instanceof Activity) {
|
|
|
// if (crouton != null) {
|
|
// if (crouton != null) {
|
|
|
// crouton.cancel();
|
|
// crouton.cancel();
|
|
@@ -276,7 +276,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;
|
|
|
- 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))
|
|
|
.content(MyApplication.getInstance().getString(R.string.login_progress_erp))
|
|
.content(MyApplication.getInstance().getString(R.string.login_progress_erp))
|
|
@@ -527,10 +527,10 @@ 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"));
|
|
|
}
|
|
}
|
|
|
CommonUtil.setSharedPreferences(ct, "erp_baseurl", erp_baseurl);
|
|
CommonUtil.setSharedPreferences(ct, "erp_baseurl", erp_baseurl);
|
|
|
}
|
|
}
|
|
@@ -639,8 +639,7 @@ public class ViewUtil {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
- /*@功能:管理平台的返回信息处理*/
|
|
|
|
|
|
|
+ /*@功能:管理平台的返回信息处理*/
|
|
|
public static void LoginSucess(String json, String phone, String password) {
|
|
public static void LoginSucess(String json, String phone, String password) {
|
|
|
CommonUtil.setSharedPreferences(ct, "loginJson", json);
|
|
CommonUtil.setSharedPreferences(ct, "loginJson", json);
|
|
|
try {
|
|
try {
|
|
@@ -654,7 +653,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);
|
|
@@ -665,7 +664,6 @@ 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) {
|
|
|
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<>();
|
|
@@ -723,16 +721,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;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -743,8 +741,8 @@ public class ViewUtil {
|
|
|
// if (select > items.length) {
|
|
// if (select > items.length) {
|
|
|
// select = 0;
|
|
// select = 0;
|
|
|
// }
|
|
// }
|
|
|
- popupWindow=null;
|
|
|
|
|
- showPopDialog((Activity) ct,itemsSelectType1s,phone,password);
|
|
|
|
|
|
|
+ popupWindow = null;
|
|
|
|
|
+ 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)
|
|
@@ -763,22 +761,23 @@ 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);
|
|
|
|
|
|
|
+ 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);
|
|
@@ -792,11 +791,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();
|
|
|
|
|
|
|
+ ItemPopListAdapter.ViewHolder viewHolder = (ItemPopListAdapter.ViewHolder) view.getTag();
|
|
|
|
|
+ String text = viewHolder.tvItemName.getText().toString();
|
|
|
selectCompanyItems(selectId, text, phone, password);
|
|
selectCompanyItems(selectId, text, phone, password);
|
|
|
- }});
|
|
|
|
|
- popupWindow = new PopupWindow(view, windowManager.getDefaultDisplay().getWidth()- DensityUtil.dp2px(50), LinearLayout.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ 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);
|
|
@@ -811,8 +811,7 @@ 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) {
|
|
|
if (!CommonUtil.isNetWorkConnected(ct)) {
|
|
if (!CommonUtil.isNetWorkConnected(ct)) {
|
|
@@ -1210,6 +1209,8 @@ public class ViewUtil {
|
|
|
.url("mobile/login.action")
|
|
.url("mobile/login.action")
|
|
|
.addParam("token", loginToken)
|
|
.addParam("token", loginToken)
|
|
|
.addParam("enuu", enuu)
|
|
.addParam("enuu", enuu)
|
|
|
|
|
+ .connectTimeOut(5)
|
|
|
|
|
+ .readTimeOut(5)
|
|
|
.method(Method.POST)
|
|
.method(Method.POST)
|
|
|
.build(), new HttpCallback() {
|
|
.build(), new HttpCallback() {
|
|
|
@Override
|
|
@Override
|
|
@@ -1222,8 +1223,8 @@ 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);
|
|
|
|
|
+ ToastMessage(MyApplication.getInstance(), "登录失败:" + failStr);
|
|
|
mdProcessDialog.setContent("登录失败");
|
|
mdProcessDialog.setContent("登录失败");
|
|
|
new Handler().postDelayed(new Runnable() {
|
|
new Handler().postDelayed(new Runnable() {
|
|
|
@Override
|
|
@Override
|