|
|
@@ -1,18 +1,27 @@
|
|
|
package com.xzjmyk.pm.activity.ui.me;
|
|
|
|
|
|
+import android.app.Activity;
|
|
|
import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
import android.os.Message;
|
|
|
import android.support.v7.app.AlertDialog;
|
|
|
+import android.text.Editable;
|
|
|
+import android.text.Selection;
|
|
|
import android.text.TextUtils;
|
|
|
+import android.util.DisplayMetrics;
|
|
|
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.BaseAdapter;
|
|
|
import android.widget.Button;
|
|
|
+import android.widget.EditText;
|
|
|
import android.widget.ImageView;
|
|
|
+import android.widget.PopupWindow;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
@@ -33,6 +42,7 @@ import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
+import com.xzjmyk.pm.activity.util.DisplayUtil;
|
|
|
import com.xzjmyk.pm.activity.view.MyListView;
|
|
|
import com.xzjmyk.pm.activity.wxapi.ApiConfig;
|
|
|
import com.xzjmyk.pm.activity.wxapi.ApiPlatform;
|
|
|
@@ -326,6 +336,7 @@ public class OfficeAddressSettingsActivity extends BaseActivity {
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ progressDialog.dismiss();
|
|
|
}
|
|
|
|
|
|
private void doShowSignAddress(String get_sign_address_result) {
|
|
|
@@ -386,6 +397,7 @@ public class OfficeAddressSettingsActivity extends BaseActivity {
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ progressDialog.dismiss();
|
|
|
}
|
|
|
|
|
|
private void clickEvent() {
|
|
|
@@ -558,16 +570,90 @@ public class OfficeAddressSettingsActivity extends BaseActivity {
|
|
|
if (poi == null) return;
|
|
|
// 将每次点击地址返回的值add到自定义列表中,
|
|
|
address_lv.setVisibility(View.VISIBLE);
|
|
|
- address_names.add(poi.name);
|
|
|
address_location.add(poi.address);
|
|
|
address_latitud.add(String.valueOf(poi.location.latitude));
|
|
|
address_longitude.add(String.valueOf(poi.location.longitude));
|
|
|
LogUtil.prinlnLongMsg("getpoi", JSON.toJSONString(poi));
|
|
|
+
|
|
|
+ doEditShortName(poi); //编辑地址简称
|
|
|
}
|
|
|
- myadapter.setAddress_names(address_names);
|
|
|
- myadapter.notifyDataSetChanged();
|
|
|
}
|
|
|
-
|
|
|
+ private PopupWindow popupWindow = null;
|
|
|
+ private void doEditShortName(final PoiInfo poi) {
|
|
|
+ // 一个自定义的布局,作为显示的内容
|
|
|
+ View contentView = LayoutInflater.from(ct).inflate(
|
|
|
+ R.layout.item_select_aim_pop, null);
|
|
|
+
|
|
|
+ // 设置按钮的点击事件
|
|
|
+ final EditText company_et = (EditText) contentView.findViewById(R.id.company_et);
|
|
|
+ TextView address_tv = (TextView) contentView.findViewById(R.id.address_tv);
|
|
|
+ company_et.setText(poi.name);
|
|
|
+ address_tv.setText("详细地址: " + poi.address);
|
|
|
+ Editable etext = company_et.getText();
|
|
|
+ Selection.setSelection(etext, etext.length());
|
|
|
+ DisplayMetrics dm = getResources().getDisplayMetrics();
|
|
|
+ int w_screen = dm.widthPixels;
|
|
|
+ int h_screen = dm.heightPixels;
|
|
|
+ w_screen = DisplayUtil.dip2px(this, 300);
|
|
|
+ h_screen = DisplayUtil.dip2px(this, 185);
|
|
|
+ contentView.findViewById(R.id.goto_tv).setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ address_names.add(poi.name);
|
|
|
+ myadapter.setAddress_names(address_names);
|
|
|
+ myadapter.notifyDataSetChanged();
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ contentView.findViewById(R.id.sure_tv).setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View view) {
|
|
|
+ String com = company_et.getText().toString();
|
|
|
+ if (!StringUtils.isEmpty(com)) {
|
|
|
+ address_names.add(com);
|
|
|
+ }else {
|
|
|
+ address_names.add(poi.name);
|
|
|
+ }
|
|
|
+ myadapter.setAddress_names(address_names);
|
|
|
+ myadapter.notifyDataSetChanged();
|
|
|
+ popupWindow.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ popupWindow = new PopupWindow(contentView, w_screen, h_screen, true);
|
|
|
+ popupWindow.setTouchable(true);
|
|
|
+ popupWindow.setOutsideTouchable(false);
|
|
|
+ // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
|
|
|
+// popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_main));
|
|
|
+ // 设置好参数之后再show
|
|
|
+ popupWindow.showAtLocation(contentView, Gravity.CENTER, 0, 0);
|
|
|
+ setbg(0.4f);
|
|
|
+ }
|
|
|
+ private void setbg(float alpha) {
|
|
|
+ setBackgroundAlpha(this, alpha);
|
|
|
+ if (popupWindow == null) return;
|
|
|
+ popupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss() {
|
|
|
+ setBackgroundAlpha(OfficeAddressSettingsActivity.this, 1f);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 设置页面的透明度
|
|
|
+ * 兼容华为手机(在个别华为手机上 设置透明度会不成功)
|
|
|
+ *
|
|
|
+ * @param bgAlpha 透明度 1表示不透明
|
|
|
+ */
|
|
|
+ public void setBackgroundAlpha(Activity activity, float bgAlpha) {
|
|
|
+ WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
|
|
|
+ lp.alpha = bgAlpha;
|
|
|
+ if (bgAlpha == 1) {
|
|
|
+ activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);//不移除该Flag的话,在有视频的页面上的视频会出现黑屏的bug
|
|
|
+ } else {
|
|
|
+ activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);//此行代码主要是解决在华为手机上半透明效果无效的bug
|
|
|
+ }
|
|
|
+ activity.getWindow().setAttributes(lp);
|
|
|
+ }
|
|
|
//地点显示列表适配器
|
|
|
public class OfficeAddressAdapter extends BaseAdapter {
|
|
|
private OfficeAddressBean mOfficeAddressBean;
|