|
|
@@ -3,12 +3,22 @@ package com.core.net.http;
|
|
|
import android.app.Activity;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
+import android.graphics.drawable.BitmapDrawable;
|
|
|
+import android.graphics.drawable.Drawable;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.support.v4.content.LocalBroadcastManager;
|
|
|
import android.util.Log;
|
|
|
+import android.view.Gravity;
|
|
|
+import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
+import android.view.WindowManager;
|
|
|
+import android.widget.AdapterView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.ListView;
|
|
|
+import android.widget.PopupWindow;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.afollestad.materialdialogs.MaterialDialog;
|
|
|
@@ -20,8 +30,11 @@ import com.common.LogUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
|
import com.common.data.ListUtils;
|
|
|
import com.common.data.StringUtil;
|
|
|
+import com.common.system.DisplayUtil;
|
|
|
import com.common.thread.ThreadPool;
|
|
|
import com.common.thread.ThreadUtil;
|
|
|
+import com.core.adapter.ItemPopListAdapter;
|
|
|
+import com.core.adapter.ItemsSelectType1;
|
|
|
import com.core.api.wxapi.ApiConfig;
|
|
|
import com.core.api.wxapi.ApiPlatform;
|
|
|
import com.core.api.wxapi.ApiUtils;
|
|
|
@@ -41,6 +54,7 @@ import com.me.network.app.base.HttpCallback;
|
|
|
import com.me.network.app.base.HttpParams;
|
|
|
import com.me.network.app.http.HttpRequest;
|
|
|
import com.me.network.app.http.Method;
|
|
|
+import com.scwang.smartrefresh.layout.util.DensityUtil;
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -638,16 +652,10 @@ public class ViewUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * @author Administrator
|
|
|
- * @功能:管理平台的返回信息处理
|
|
|
- */
|
|
|
+
|
|
|
+ /*@功能:管理平台的返回信息处理*/
|
|
|
public static void LoginSucess(String json, String phone, String password) {
|
|
|
-// String json = msg.getData().getString("result");
|
|
|
-// LogUtil.prinlnLongMsg("HttpLogs", "管理平台登录:" + json);
|
|
|
CommonUtil.setSharedPreferences(ct, "loginJson", json);
|
|
|
-// String phone = msg.getData().getString("phone");
|
|
|
-// String password = msg.getData().getString("password");
|
|
|
try {
|
|
|
JSONArray array = JSON.parseArray(json);
|
|
|
if (!ListUtils.isEmpty(array)) {
|
|
|
@@ -659,7 +667,7 @@ public class ViewUtil {
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
if (JSONUtil.validate(json)) {
|
|
|
// showDialogCompany(json, phone, password);
|
|
|
@@ -693,8 +701,7 @@ public class ViewUtil {
|
|
|
boolean isHas = false;
|
|
|
for (int k = 0; k < loginMsg.size(); k++) {
|
|
|
if (sModel.get(j).getName().equals(loginMsg.get(k).getName())) {
|
|
|
- //存在 uas系统里面存在同名的
|
|
|
- isHas = true;
|
|
|
+ isHas = true; //存在 uas系统里面存在同名的
|
|
|
}
|
|
|
}
|
|
|
if (!isHas) {
|
|
|
@@ -724,14 +731,17 @@ public class ViewUtil {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //
|
|
|
LogUtil.d("HttpLogs", "login dialog:" + JSON.toJSONString(loginEntities));
|
|
|
if (ListUtils.isEmpty(loginEntities)) return;
|
|
|
erpEntities = loginEntities;
|
|
|
String[] items = new String[loginEntities.size()];
|
|
|
int select = 0;
|
|
|
+ List<ItemsSelectType1> itemsSelectType1s=new ArrayList<>();
|
|
|
for (int j = 0; j < loginEntities.size(); j++) {
|
|
|
+ ItemsSelectType1 model=new ItemsSelectType1();
|
|
|
+ model.setName(loginEntities.get(j).getName());
|
|
|
items[j] = loginEntities.get(j).getName();
|
|
|
+ itemsSelectType1s.add(model);
|
|
|
}
|
|
|
if (!DialogUtils.isDialogShowing(loginERPDialog)) {
|
|
|
if (loginERPDialog != null) {
|
|
|
@@ -740,23 +750,73 @@ public class ViewUtil {
|
|
|
if (select > items.length) {
|
|
|
select = 0;
|
|
|
}
|
|
|
- LogUtil.d("AppLogs", "select:" + select + "");
|
|
|
- loginERPDialog = new MaterialDialog.Builder(ct)
|
|
|
- .title(ct.getString(R.string.user_dialog_company))
|
|
|
- .items(items)
|
|
|
- .itemsCallbackSingleChoice(select,
|
|
|
- new MaterialDialog.ListCallbackSingleChoice() {
|
|
|
- @Override
|
|
|
- public boolean onSelection(MaterialDialog dialog,
|
|
|
- View view, int which, CharSequence text) {
|
|
|
- return selectCompanyItems(which, text, phone, password);
|
|
|
- }
|
|
|
- }).positiveText(ct.getString(R.string.common_sure)).show();
|
|
|
+
|
|
|
+ showPopDialog((Activity) ct,itemsSelectType1s,phone,password);
|
|
|
+// loginERPDialog = new MaterialDialog.Builder(ct)
|
|
|
+// .title(ct.getString(R.string.user_dialog_company))
|
|
|
+// .items(items)
|
|
|
+// .itemsCallbackSingleChoice(select,
|
|
|
+// new MaterialDialog.ListCallbackSingleChoice() {
|
|
|
+// @Override
|
|
|
+// public boolean onSelection(MaterialDialog dialog,
|
|
|
+// View view, int which, CharSequence text) {
|
|
|
+// return selectCompanyItems(which, text, phone, password);
|
|
|
+// }
|
|
|
+// }).positiveText(ct.getString(R.string.common_sure)).show();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static PopupWindow popupWindow = null;
|
|
|
+ public static int selectId;
|
|
|
+ public static void showPopDialog(final Activity ct, List<ItemsSelectType1> itemsSelectType1s
|
|
|
+ , final String phone, final String password){
|
|
|
+ View view = null;
|
|
|
+ if (DialogUtils.isDialogShowing(mdProcessDialog)){
|
|
|
+ mdProcessDialog.dismiss();
|
|
|
+ }
|
|
|
+ WindowManager windowManager = (WindowManager)ct. getSystemService(Context.WINDOW_SERVICE);
|
|
|
+ if (popupWindow == null) {
|
|
|
+ LayoutInflater layoutInflater = (LayoutInflater) ct.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
+ view = layoutInflater.inflate(R.layout.pop_dialog_list, null);
|
|
|
+ ListView plist = view.findViewById(R.id.mList);
|
|
|
+ List<ItemsSelectType1> datas =itemsSelectType1s;
|
|
|
+ final ItemPopListAdapter adapter = new ItemPopListAdapter(ct, datas);
|
|
|
+ plist.setAdapter(adapter);
|
|
|
+ Drawable drawable = ct.getResources().getDrawable(R.drawable.selector_check_items);
|
|
|
+ plist.setSelector(drawable);
|
|
|
+ plist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
|
+ popupWindow.dismiss();
|
|
|
+ selectId = position;
|
|
|
+ adapter.setSelectId(selectId);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ popupWindow.setFocusable(true);
|
|
|
+ popupWindow.setOutsideTouchable(true);
|
|
|
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ DisplayUtil.backgroundAlpha(ct, 1f);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ DisplayUtil.backgroundAlpha(ct, 0.5f);
|
|
|
+ popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
|
|
+ popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
+ popupWindow.showAtLocation(ct.getWindow().getDecorView(), Gravity.CENTER, 0, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private static boolean selectCompanyItems(int which, CharSequence text, String phone, String password) {
|
|
|
if (!CommonUtil.isNetWorkConnected(ct)) {
|
|
|
ToastUtil.showToast(ct, R.string.networks_out);
|