LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); popupWindowView = inflater1.inflate(R.layout.item_selectmap, null); popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, true); popupWindow.setBackgroundDrawable(new BitmapDrawable()); // 设置PopupWindow的弹出和消失效果 popupWindow.setAnimationStyle(R.style.popupAnimation); LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo); if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) { ll_tvTwo.setVisibility(View.GONE); } LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne); if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) { ll_tvOne.setVisibility(View.GONE); } cancleButton = (Button) popupWindowView .findViewById(R.id.cancleButton); cancleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Toast.makeText(ZhanDetailsNew.this, "NO", Toast.LENGTH_SHORT).show(); popupWindow.dismiss(); } }); tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree); tvThree.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplication(), BasicNaviActivity.class); intent.putExtra("start_jing", center.longitude + ""); intent.putExtra("start_wei", center.latitude + ""); intent.putExtra("stop_jing", ll.longitude + ""); intent.putExtra("stop_wei", ll.latitude + ""); startActivity(intent); detailsBack = true; popupWindow.dismiss(); HashMap<String, String> map = new HashMap<String, String>(); map.put("Name", zhan_name); map.put("CostWay", charge_cost_way); map.put("City", city); MobclickAgent.onEvent(context, "0033", map); map.clear(); } }); tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne); tvOne.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = null; int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1; int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1; if (position_jing > 13 || position_wei > 13) { getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei)); } else { bd_jing = Double.parseDouble(poi_jing); bd_wei = Double.parseDouble(poi_wei); } getBaidu(center.longitude, center.latitude); try { String s = "intent://map/direction?" + "origin=" + bd_lat + "," + bd_lon + "&" + "destination=" + bd_wei + "," + bd_jing + "&mode=driving&" + "src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end"; // Log.e("sss", s); intent = Intent.getIntent(s); detailsBack = true; HashMap<String, String> map = new HashMap<String, String>(); map.put("Name", zhan_name); map.put("CostWay", charge_cost_way); map.put("City", city); MobclickAgent.onEvent(context, "0031", map); map.clear(); } catch (URISyntaxException e) { e.printStackTrace(); } startActivity(intent); popupWindow.dismiss(); } }); tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo); tvTwo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent intent4 = new Intent("android.intent.action.VIEW", android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + center.latitude + "&slon=" + center.longitude + "&sname=我的位置&dlat=" + ll.latitude + "&dlon=" + ll.longitude + "&dname=" + zhan_name + "&dev=0&m=0&t=2")); intent4.setPackage("com.autonavi.minimap"); startActivity(intent4); detailsBack = true; popupWindow.dismiss(); HashMap<String, String> map = new HashMap<String, String>(); map.put("Name", zhan_name); map.put("CostWay", charge_cost_way); map.put("City", city); MobclickAgent.onEvent(context, "0032", map); map.clear(); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show(); } } }); popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0); // startNavi(center, ll); } else { ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT); } } } }).setNegativeButton("取消", new View.OnClickListener() { @Override public void onClick(View v) { } }).show(); } else { new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder() .setTitle("站点故障") .setMsg("该站点充电桩均为离线或故障\n" + "可能无法正常充电,是否继续前往") .setPositiveButton("继续", new View.OnClickListener() { @Override public void onClick(View v) { if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") && !isAvilible(getApplicationContext(), "com.autonavi.minimap")) { Intent intent = new Intent(getApplication(), BasicNaviActivity.class); intent.putExtra("start_jing", center.longitude + ""); intent.putExtra("start_wei", center.latitude + ""); intent.putExtra("stop_jing", ll.longitude + ""); // Log.e("123", ll.longitude + ""); intent.putExtra("stop_wei", ll.latitude + ""); // Log.e("123", ll.latitude + ""); startActivity(intent); detailsBack = true; HashMap<String, String> map = new HashMap<String, String>(); map.put("Name", zhan_name); map.put("CostWay", charge_cost_way); map.put("City", city); MobclickAgent.onEvent(context, "0033", map); map.clear(); } else { if (center != null) { LayoutInflater inflater1 = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); popupWindowView = inflater1.inflate(R.layout.item_selectmap, null); popupWindow = new PopupWindow(popupWindowView, ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, true); popupWindow.setBackgroundDrawable(new BitmapDrawable()); // 设置PopupWindow的弹出和消失效果 popupWindow.setAnimationStyle(R.style.popupAnimation); LinearLayout ll_tvTwo = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvTwo); if (!isAvilible(getApplicationContext(), "com.autonavi.minimap")) { ll_tvTwo.setVisibility(View.GONE); } LinearLayout ll_tvOne = (LinearLayout) popupWindowView.findViewById(R.id.ll_tvOne); if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap")) { ll_tvOne.setVisibility(View.GONE); } cancleButton = (Button) popupWindowView .findViewById(R.id.cancleButton); cancleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Toast.makeText(ZhanDetailsNew.this, "NO", Toast.LENGTH_SHORT).show(); popupWindow.dismiss(); } }); tvThree = (TextView) popupWindowView.findViewById(R.id.tvThree); tvThree.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplication(), BasicNaviActivity.class); intent.putExtra("start_jing", center.longitude + ""); intent.putExtra("start_wei", center.latitude + ""); intent.putExtra("stop_jing", ll.longitude + ""); intent.putExtra("stop_wei", ll.latitude + ""); startActivity(intent); detailsBack = true; popupWindow.dismiss(); HashMap<String, String> map = new HashMap<String, String>(); map.put("Name", zhan_name); map.put("CostWay", charge_cost_way); map.put("City", city); MobclickAgent.onEvent(context, "0033", map); map.clear(); } }); tvOne = (TextView) popupWindowView.findViewById(R.id.tvOne); tvOne.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = null; int position_jing = poi_jing.length() - poi_jing.indexOf(".") - 1; int position_wei = poi_wei.length() - poi_wei.indexOf(".") - 1; if (position_jing > 13 || position_wei > 13) { getBaidu1(Double.parseDouble(poi_jing), Double.parseDouble(poi_wei)); } else { bd_jing = Double.parseDouble(poi_jing); bd_wei = Double.parseDouble(poi_wei); } getBaidu(center.longitude, center.latitude); try { String s = "intent://map/direction?" + "origin=" + bd_lat + "," + bd_lon + "&" + "destination=" + bd_wei + "," + bd_jing + "&mode=driving&" + "src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end"; // Log.e("sss", s); intent = Intent.getIntent(s); detailsBack = true; HashMap<String, String> map = new HashMap<String, String>(); map.put("Name", zhan_name); map.put("CostWay", charge_cost_way); map.put("City", city); MobclickAgent.onEvent(context, "0031", map); map.clear(); } catch (URISyntaxException e) { e.printStackTrace(); } startActivity(intent); popupWindow.dismiss(); } }); tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo); tvTwo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { Intent intent4 = new Intent("android.intent.action.VIEW", android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + center.latitude + "&slon=" + center.longitude + "&sname=我的位置&dlat=" + ll.latitude + "&dlon=" + ll.longitude + "&dname=" + zhan_name + "&dev=0&m=0&t=2")); intent4.setPackage("com.autonavi.minimap"); startActivity(intent4); detailsBack = true; popupWindow.dismiss(); HashMap<String, String> map = new HashMap<String, String>(); map.put("Name", zhan_name); map.put("CostWay", charge_cost_way); map.put("City", city); MobclickAgent.onEvent(context, "0032", map); map.clear(); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getApplication(), "请您确认是否安装高德地图APP", Toast.LENGTH_SHORT).show(); } } }); popupWindow.showAtLocation(cancleButton, Gravity.CENTER, 0, 0); // startNavi(center, ll); } else { ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT); } } } }).setNegativeButton("取消", new View.OnClickListener() { @Override public void onClick(View v) { } }).show(); } } private void zhanGrade(String zhan_id) { long appTime1 = System.currentTimeMillis() / 1000; long updatetime = appTime1 - MainMapActivity.cha - 3; String token = String.valueOf(updatetime); String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanstar/getstar" + "?supplier=星星充电&timer=" + token + "&ver=1.0&zhan_id=" + zhan_id + "&sign=" + Md5Util.md5("supplier=星星充电&timer=" + token + "&zhan_id=" + zhan_id + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a"); // Log.e("zhanGrade===", url); OkHttpUtils.get() .url(url) .build() .execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { if (null != response) { // Log.e("zhanGrade===", response); String code = JsonUtils.getKeyResult(response, "code"); String star_num = JsonUtils.getKeyResult(response, "star_level"); if (star_num.equals("") || star_num.equals("0")) { windowGrade.setText("暂无评分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_0xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } else { String star_level = star_num; double d; d = Double.parseDouble(star_level); String grade = String.format("%.1f", d); if (d > 0 && d < 1) { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_05xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } else if (d >= 1 && d < 1.5) { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_1xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } else if (d >= 1.5 && d < 2) { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_15xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } else if (d >= 2 && d < 2.5) { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_2xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } else if (d >= 2.5 && d < 3) { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_25xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } else if (d >= 3 && d < 3.5) { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_3xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } else if (d >= 3.5 && d < 4) { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_35xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); } else if (d >= 4 && d < 4.5) { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_4xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } else if (d >= 4.5 && d < 5) { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_45xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } else { windowGrade.setText(grade + "分"); Drawable rightDrawable = getResources().getDrawable(R.drawable.icon_5xing); rightDrawable.setBounds(0, 0, rightDrawable.getMinimumWidth(), rightDrawable.getMinimumHeight()); windowGrade.setCompoundDrawables(rightDrawable, null, null, null); windowGrade.setCompoundDrawablePadding(dp2px(MainApplication.context, 6)); } } } } }); } private void resetMarker() { if (nMarker != null) { nMarker.hideInfoWindow(); if (current_chargePoint.getOwn_pay().equals("1")) { nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1)); } else { if (current_chargePoint.getSuit_car().equals("特斯拉")) { nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3)); } else { if (WelcomeActivity.canCost.contains(MainMapActivity.current_chargePoint.getSupplier())) { nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2)); } else { nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3)); } } } } } private void getShareIntegral() { String url = MainApplication.url + "/zhannew/basic/web/index.php/member/insert-task?userid=" + MainApplication.userId; OkHttpUtils.get().url(url).build().execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { Log.e(TAG, "onResponse: getShareIntegral=" + response); String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if (rtnCode.equals("01")) { } else { // ToastUtil.showToast(getApplicationContext(),"分享成功",Toast.LENGTH_SHORT); } } }); } private void getMessageNum() { long appTime1 = System.currentTimeMillis() / 1000; String token = String.valueOf(appTime1); if (MainApplication.msgTime.equals("0")) { MainApplication.firstOpenTime = token; ProfileManager.getInstance().setFirstOpenTime(getApplicationContext(), token); MainApplication.msgTime = token; ProfileManager.getInstance().setSystemMsgTime(getApplicationContext(), token); } String url = MainApplication.url + "/zhannew/basic/web/index.php/question/center?user_id=" + MainApplication.userId + "&timer=" + MainApplication.msgTime + "&phone=" + MainApplication.userPhone + "&password=" + MainApplication.userPassword; // Log.e(TAG, "getMessageNum: url="+url ); OkHttpUtils.get().tag(MainMapActivity.this).url(url).build().connTimeOut(6000).readTimeOut(6000).execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { // Log.e(TAG, "onResponse: "+response ); String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if ("01".equals(rtnCode)) { String rtnMsg = JsonUtils.getKeyResult(response, "rtnMsg"); question_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "question_unread")); comment_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "comment_unread")); system_unread = Integer.parseInt(JsonUtils.getKeyResult(rtnMsg, "system_unread")); total_unread = question_unread + comment_unread + system_unread; if (total_unread > 0) { tv_msg_num.setVisibility(View.VISIBLE); tv_msg_num.setText(total_unread + ""); } else { tv_msg_num.setVisibility(View.GONE); } } } }); } //Eventbus的方法 @Subscribe(threadMode = ThreadMode.MAIN) public void handleEvent(BaseEvent event) { if (event.getType().equals(BaseConstants.EVENT_SELECT_CITY)) { String locationCity = MainApplication.getInstance().getmCurrentCity(); tv_atCity.setText(locationCity); MainApplication.atCity = locationCity; final LatLng cityLatLng = new LatLng(event.getPoi_lat(), event.getPoi_lon()); new Handler().postDelayed(new Runnable() { @Override public void run() { aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(cityLatLng, 14.0f)); } }, 500); } else { if (!isFirstLoc) { isFirstLoc = true; mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy); aMap.setLocationSource(this);// 设置定位监听 aMap.setMyLocationEnabled(true);// 是否可触发定位并显示定位层 aMap.moveCamera(CameraUpdateFactory.zoomTo(14)); mlocationClient.setLocationListener(this); mlocationClient.startLocation(); } } } private void showSimpleBottomSheetGrid(final ChargingShareBean chargingShareBean) { final int TAG_SHARE_WECHAT_FRIEND = 0; final int TAG_SHARE_WECHAT_MOMENT = 1; final int TAG_SHARE_QQ = 2; QMUIBottomSheet.BottomGridSheetBuilder builder = new QMUIBottomSheet.BottomGridSheetBuilder(MainMapActivity.this); QMUIBottomSheet build = builder.addItem(R.drawable.icon_share_wechat, "微信", TAG_SHARE_WECHAT_FRIEND, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE) .addItem(R.drawable.icon_share_wechatquan, "朋友圈", TAG_SHARE_WECHAT_MOMENT, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE) .addItem(R.drawable.icon_share_qq, "QQ", TAG_SHARE_QQ, QMUIBottomSheet.BottomGridSheetBuilder.FIRST_LINE) .setOnSheetItemClickListener(new QMUIBottomSheet.BottomGridSheetBuilder.OnSheetItemClickListener() { @Override public void onClick(QMUIBottomSheet dialog, View itemView) { dialog.dismiss(); int tag = (int) itemView.getTag(); switch (tag) { case TAG_SHARE_WECHAT_FRIEND: share(Wechat.NAME, chargingShareBean); break; case TAG_SHARE_WECHAT_MOMENT: share(WechatMoments.NAME, chargingShareBean); break; case TAG_SHARE_QQ: share(QQ.NAME, chargingShareBean); break; } } }).build(); // build. build.show(); } private void share(final String name, ChargingShareBean chargingShareBean) { Platform.ShareParams paramsToShare = new Platform.ShareParams(); paramsToShare.setText(chargingShareBean.getText()); paramsToShare.setTitle(chargingShareBean.getTitle()); paramsToShare.setTitleUrl(chargingShareBean.getUrl()); paramsToShare.setUrl(chargingShareBean.getUrl()); paramsToShare.setImageUrl(chargingShareBean.getIcon()); paramsToShare.setShareType(Platform.SHARE_WEBPAGE); Platform platform = ShareSDK.getPlatform(name); platform.setPlatformActionListener(new PlatformActionListener() { @Override public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) { if (MainApplication.isLogin()) { getShareIntegral(); } // ToastUtil.showToast(getApplicationContext(),"分享成功",Toast.LENGTH_SHORT); } @Override public void onError(Platform platform, int i, Throwable throwable) { LogUtils.e(throwable.getMessage()); } @Override public void onCancel(Platform platform, int i) { } }); platform.share(paramsToShare); } private void getRecyclerViewData() { String findDate = ProfileManager.getInstance().getFindDate(MainMapActivity.this); if (EmptyUtils.isEmpty(findDate)) { findDate = String.valueOf(System.currentTimeMillis() / 1000); ProfileManager.getInstance().setFindDate(MainMapActivity.this, findDate); } String url = MainApplication.url + "/zhannew/basic/web/index.php/discovery/menu-list"; OkHttpUtils.get().url(url).addParams("timer", findDate).build().execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(String response) { if (EmptyUtils.isNotEmpty(response)) { String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if ("01".equals(rtnCode)) { String data = JsonUtils.getKeyResult(response, "data"); List<FindData> list = JsonUtils.parseToObjectList(data, FindData.class); if (list.size() > 0) { for (FindData findData : list) { if (findData.getUnread().equals("0")) { FindActivity.haveFindMessage = true; iVpoint.setVisibility(View.VISIBLE); return; } } } } } } }); } private void loadDmpData() { OkHttpUtils.get().url(MainApplication.url + "/zhannew/xd_url.php").build().connTimeOut(3000).readTimeOut(3000) .execute(new StringCallback() { @Override public void onError(Call call, Exception e) { e.printStackTrace(); } @Override public void onResponse(String response) { String show_url = JsonUtils.getKeyResult(response, "show_url"); String click_url = JsonUtils.getKeyResult(response, "click_url"); uploadDmp(show_url); sav.setClick_url(click_url); } }); } private void uploadDmp(String url) { url = Util.generateDmpUrl(url); OkHttpUtils.get().url(url).build().connTimeOut(3000).readTimeOut(3000) .execute(new StringCallback() { @Override public void onError(Call call, Exception e) { e.printStackTrace(); } @Override public void onResponse(String response) { } }); } } cdzApp - Gogs: Go Git Service

充电桩app代码

MyLetterListView.java 3.7KB

    package com.electric.chargingpile.view; import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import com.electric.chargingpile.application.MainApplication; public class MyLetterListView extends View { OnTouchingLetterChangedListener onTouchingLetterChangedListener; String[] b = {"定位", "最近", "全部", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; int choose = -1; Paint paint = new Paint(); boolean showBkg = false; public MyLetterListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } public MyLetterListView(Context context, AttributeSet attrs) { super(context, attrs); } public MyLetterListView(Context context) { super(context); } @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (showBkg) { canvas.drawColor(Color.parseColor("#8c8c8c")); } int height = getHeight(); int width = getWidth(); int singleHeight = height / b.length; for (int i = 0; i < b.length; i++) { paint.setColor(Color.parseColor("#8c8c8c")); if (MainApplication.mScreenWidth >= 720) { paint.setTextSize(26); } else { paint.setTextSize(16); } // paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setAntiAlias(true); /*if (i == choose) { paint.setColor(Color.parseColor("#3399ff")); paint.setFakeBoldText(true); }*/ float xPos = width / 2 - paint.measureText(b[i]) / 2; float yPos = singleHeight * i + singleHeight; canvas.drawText(b[i], xPos, yPos, paint); paint.reset(); } } @Override public boolean dispatchTouchEvent(MotionEvent event) { final int action = event.getAction(); final float y = event.getY(); final int oldChoose = choose; final OnTouchingLetterChangedListener listener = onTouchingLetterChangedListener; final int c = (int) (y / getHeight() * b.length); switch (action) { case MotionEvent.ACTION_DOWN: showBkg = true; if (oldChoose != c && listener != null) { if (c >= 0 && c < b.length) { listener.onTouchingLetterChanged(b[c]); choose = c; invalidate(); } } break; case MotionEvent.ACTION_MOVE: if (oldChoose != c && listener != null) { if (c >= 0 && c < b.length) { listener.onTouchingLetterChanged(b[c]); choose = c; invalidate(); } } break; case MotionEvent.ACTION_UP: showBkg = false; choose = -1; invalidate(); break; } return true; } @Override public boolean onTouchEvent(MotionEvent event) { return super.onTouchEvent(event); } public void setOnTouchingLetterChangedListener( OnTouchingLetterChangedListener onTouchingLetterChangedListener) { this.onTouchingLetterChangedListener = onTouchingLetterChangedListener; } public interface OnTouchingLetterChangedListener { public void onTouchingLetterChanged(String s); } }
cdzApp - Gogs: Go Git Service

充电桩app代码

SortPopWindow.java 3.3KB

    package com.electric.chargingpile.view; import android.app.Activity; import android.content.Context; import android.graphics.drawable.ColorDrawable; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup.LayoutParams; import android.widget.PopupWindow; import android.widget.TextView; import com.electric.chargingpile.R; /** * Created by demon on 2017/8/21. */ public class SortPopWindow extends PopupWindow { private View conentView; private TextView tv1, tv2; private Activity context; public SortPopWindow(final Activity context) { this.context = context; LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); conentView = inflater.inflate(R.layout.sort_popup_dialog, null); tv1 = (TextView) conentView.findViewById(R.id.tv_1); tv2 = (TextView) conentView.findViewById(R.id.tv_2); int h = context.getWindowManager().getDefaultDisplay().getHeight(); int w = context.getWindowManager().getDefaultDisplay().getWidth(); // 设置SelectPicPopupWindow的View this.setContentView(conentView); // 设置SelectPicPopupWindow弹出窗体的宽 this.setWidth(w / 2 - 120); // 设置SelectPicPopupWindow弹出窗体的高 this.setHeight(LayoutParams.WRAP_CONTENT); // 设置SelectPicPopupWindow弹出窗体可点击 this.setFocusable(true); this.setOutsideTouchable(true); // 刷新状态 this.update(); // 实例化一个ColorDrawable颜色为半透明 ColorDrawable dw = new ColorDrawable(0000000000); // 点back键和其他地方使其消失,设置了这个才能触发OnDismisslistener ,设置其他控件变化等操作 this.setBackgroundDrawable(dw); // mPopupWindow.setAnimationStyle(android.R.style.Animation_Dialog); // 设置SelectPicPopupWindow弹出窗体动画效果 this.setAnimationStyle(R.style.AnimationPreview); } public void setUi(String s) { //排序 ctime为时间顺序,agree为点赞排序 if ("agree".equals(s)) { tv1.setTextColor(context.getResources().getColor(R.color.lvse)); tv2.setTextColor(context.getResources().getColor(R.color.ui_68)); } else { tv2.setTextColor(context.getResources().getColor(R.color.lvse)); tv1.setTextColor(context.getResources().getColor(R.color.ui_68)); } } public void showPopupWindow(View parent, final View.OnClickListener listener) { tv1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { listener.onClick(v); } catch (Exception e) { e.printStackTrace(); } } }); tv2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { try { listener.onClick(view); } catch (Exception e) { e.printStackTrace(); } } }); if (!this.isShowing()) { this.showAsDropDown(parent, parent.getLayoutParams().width / 2, -5); } else { this.dismiss(); } } }
winniefrazer7 - Gogs: Go Git Service

フォロー