} @Override public void onResponse(File response) { String path = getDatabasePath("zhan_list").getPath(); com.blankj.utilcode.util.LogUtils.e(path); AppUtils.cleanAppData(path); Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); Uri uri; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Uri contentUri = FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", response); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(contentUri, "application/vnd.android.package-archive"); } else { uri = Uri.fromFile(response); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(uri, "application/vnd.android.package-archive"); } context.startActivity(intent); android.os.Process.killProcess(android.os.Process.myPid()); } }); } }).setNegativeButton("退出", new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences mySharedPreferences = getSharedPreferences("showdialog", Activity.MODE_PRIVATE); SharedPreferences.Editor editor1 = mySharedPreferences.edit(); editor1.clear(); finish(); ProfileManager.getInstance().setSearchAddress(getApplicationContext(), ""); // System.exit(0); android.os.Process.killProcess(android.os.Process.myPid()); } }).setCancelable(false).show(); } } public static int getVersionCode(Context context)//获取版本号(内部识别号) { try { PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); // Log.e("versionCode", pi.versionCode + ""); return pi.versionCode; } catch (PackageManager.NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); return 0; } } public void getVersion() { try { PackageManager manager = getApplication().getPackageManager(); PackageInfo info = manager.getPackageInfo(getApplication().getPackageName(), 0); app_version = info.versionName; // return this.getString(R.string.version_name) + version; // Log.e("version", app_version); } catch (Exception e) { e.printStackTrace(); // return this.getString(R.string.can_not_find_version_name); } } private void getPingLun() { new Thread(new Runnable() { @Override public void run() { String url = null; try { url = MainApplication.url + "/zhannew/basic/web/index.php/tpmember/commentcount?userid=" + MainApplication.userId; } catch (Exception e) { e.printStackTrace(); } submitPingLun(url); } }).start(); } private void submitPingLun(String sms) { // Log.e("url", sms); Request request = new Request.Builder().url(sms).build(); Response response = null; try { if (request == null) { Message msg = new Message(); msg.what = 5; hand.sendMessage(msg); return; } response = OkHttpUtil.execute(request); if (response.code() == 200) { String json = ""; try { json = response.body().string(); Message msg = new Message(); msg.obj = json; msg.what = 17; hand.sendMessage(msg); // Log.e("url", json); } catch (Exception e) { e.printStackTrace(); Message msg = new Message(); msg.what = 5; hand.sendMessage(msg); } } } catch (Exception e) { e.printStackTrace(); Message msg = new Message(); msg.what = 5; hand.sendMessage(msg); } } //获取系统消息 private void getMessage() { new Thread(new Runnable() { @Override public void run() { long appTime1 = System.currentTimeMillis() / 1000; // Log.i("appTime(long)---", appTime1 + ""); String token = String.valueOf(appTime1); // Log.e("token", token); String url = null; if (MainApplication.msgTime.equals("0")) { MainApplication.firstOpenTime = token; ProfileManager.getInstance().setFirstOpenTime(getApplicationContext(), token); MainApplication.msgTime = token; ProfileManager.getInstance().setSystemMsgTime(getApplicationContext(), token); } try { url = MainApplication.url + "/zhannew/basic/web/index.php/zhangonggao/release?timer=" + MainApplication.msgTime; // Log.e("890", url); } catch (Exception e) { e.printStackTrace(); } submitMessage(url); } }).start(); } private void submitMessage(String sms) { // Log.e("url", sms); Request request = new Request.Builder().url(sms).build(); Response response = null; try { if (request == null) { Message msg = new Message(); msg.what = 5; hand.sendMessage(msg); return; } response = OkHttpUtil.execute(request); if (response.code() == 200) { String json = ""; try { json = response.body().string(); Message msg = new Message(); msg.obj = json; msg.what = 7; hand.sendMessage(msg); // Log.e("url", json); } catch (Exception e) { e.printStackTrace(); Message msg = new Message(); msg.what = 5; hand.sendMessage(msg); } } } catch (Exception e) { e.printStackTrace(); Message msg = new Message(); msg.what = 5; hand.sendMessage(msg); } } public void MainMapp() { eteCityTime("{\"fun\":\"timer\"}"); clickMarker = false; SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication()); sharedPreferencesUtil.setFileName("CurrentMarkerInfo"); sharedPreferencesUtil.clearData(); } public void eteCityTime(final String params) { new Thread(new Runnable() { @Override public void run() { try { // 创建Socket // socket = new Socket("192.168.1.110",54321); socket = new Socket("cdz.evcharge.cc", 9503); // IP:10.14.114.127,端口54321 // 向服务器发送消息 PrintWriter out = new PrintWriter(new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())), true); out.println(params); // out.println("{\"fun\":\"getcity\"}"); // 接收来自服务器的消息 BufferedReader br = new BufferedReader(new InputStreamReader( socket.getInputStream())); // Message message = handle.obtainMessage(); // message.obj = line; // message.arg1 = 1; // handle.sendMessage(message); String msg = br.readLine(); // Log.d("dddddss",msg); // System.out.print("www:"+qqq); // Log.d("qqq",key); // if (msg != null) { // Message mes = new Message(); // mes.obj = msg; // mes.what = 2; // hand.sendMessage(mes); // } // Message message = handler.obtainMessage(); // message.obj = line; // message.arg1 = 17; // handler.sendMessage(message); token = msg; int time = (int) (System.currentTimeMillis() / 1000); // cha = String.valueOf(time - Integer.parseInt(msg)); cha = time - Integer.parseInt(msg); Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty"); // url = "http://cdz.d1ev.com/zhannew/basic/web/index.php/zhanlist/getlist?poi_lux=" + locLeftTop.longitude + "" + "&poi_luy=" + locLeftTop.latitude + "" + "&poi_rdx=" + llRightBottom.longitude + "" + "&poi_rdy=" + llRightBottom.latitude + "" + "&suit_car2=" + MainApplication.userTpye + "&status=" + MainApplication.mapStatus + "&charge_cost_way=" + MainApplication.costWay; String url = "{\"fun\":\"getcity\",\"suit_car2\":" + "\"" + MainApplication.userTpye + "\"" + ",\"status\":" + "\"" + MainApplication.mapStatus + "\"" + ",\"charge_cost_way\":" + "\"" + MainApplication.costWay + "\"" + ",\"belong_attribute\":" + "\"" + MainApplication.shuxing + "\"" + ",\"speed\":" + "\"" + MainApplication.sudu + "\"" + ",\"timer\":" + "\"" + Token + "\"" + "}"; // Log.d("wwwww", url); // System.out.print("qazwsx:"+url); if (MainApplication.userTpye == "") { MainApplication.userTpye = "1"; } eteCity("{\"fun\":\"getcity\",\"suit_car2\":" + "\"" + MainApplication.userTpye + "\"" + ",\"status\":" + "\"" + MainApplication.mapStatus + "\"" + ",\"charge_cost_way\":" + "\"" + MainApplication.costWay + "\"" + ",\"belong_attribute\":" + "\"" + MainApplication.shuxing + "\"" + ",\"speed\":" + "\"" + MainApplication.sudu + "\"" + ",\"timer\":" + "\"" + Token + "\"" + "}"); } catch (Exception e) { } } }).start(); } public void eteCity(final String params) { new Thread(new Runnable() { @Override public void run() { try { // 创建Socket // socket = new Socket("192.168.1.110",54321); // if (mBaiduMap.getMapStatus().zoom < 9.5f) { // socket.close(); // stringTid.clear(); // }else { socket = new Socket("cdz.evcharge.cc", 9503); // IP:10.14.114.127,端口54321 // 向服务器发送消息 PrintWriter out = new PrintWriter(new BufferedWriter( new OutputStreamWriter(socket.getOutputStream())), true); out.println(params); // out.println("{\"fun\":\"getcity\"}"); // 接收来自服务器的消息 BufferedReader br = new BufferedReader(new InputStreamReader( socket.getInputStream())); String msg = br.readLine(); // Log.d("dddddmsg",msg); if (msg != null) { Message mes = new Message(); mes.obj = msg; mes.what = 4; hand.sendMessage(mes); } // 关闭流 out.close(); br.close(); // 关闭Socket socket.close(); // } } catch (Exception e) { } } }).start(); } //登陆状态判断 private void setlogin() { if (TextUtils .isEmpty(ProfileManager.getInstance().getId(getApplication()))) { if (MainApplication.userNickname.equals("")) { // userLogin.setText(MainApplication.userNickname); } else { // userLogin.setText(Util.handlePhone("")); } MainApplication.sql = ProfileManager.getInstance().getSQL(this); } else { MainApplication.userPhone = ProfileManager.getInstance().getUsername(getApplication()); MainApplication.userId = ProfileManager.getInstance().getUserid(getApplication()); MainApplication.userIcon = ProfileManager.getInstance().getUsericon(getApplication()); MainApplication.userNickname = ProfileManager.getInstance().getNickname(getApplication()); MainApplication.sql = ProfileManager.getInstance().getSQL(getApplication()); // Log.e("MainApplication.sql===", MainApplication.sql); if (!MainApplication.userId.equals("")) { getPingLun(); } } } private boolean isAvilible(Context context, String packageName) { //获取packagemanager final PackageManager packageManager = context.getPackageManager(); //获取所有已安装程序的包信息 List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0); //用于存储所有已安装程序的包名 List<String> packageNames = new ArrayList<String>(); //从pinfo中将包名字逐一取出,压入pName list中 if (packageInfos != null) { for (int i = 0; i < packageInfos.size(); i++) { String packName = packageInfos.get(i).packageName; packageNames.add(packName); } } //判断packageNames中是否有目标程序的包名,有TRUE,没有FALSE return packageNames.contains(packageName); } private void getGaode(Double jing, Double wei) { double x_pi = 3.14159265358979324 * 3000.0 / 180.0; double gg_lon; double gg_lat; double x = jing - 0.0065, y = wei - 0.006; double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi); gg_lon = z * Math.cos(theta); gd_jing = String.valueOf(gg_lon); gg_lat = z * Math.sin(theta); gd_wei = String.valueOf(gg_lat); } private void getBaidu(Double jing, Double wei) { double x_pi = 3.14159265358979324 * 3000.0 / 180.0; double x = jing; double y = wei; double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi); bd_lon = z * Math.cos(theta) + 0.0065; bd_lat = z * Math.sin(theta) + 0.006; } private void getBaidu1(Double jing, Double wei) { double x_pi = 3.14159265358979324 * 3000.0 / 180.0; double x = jing; double y = wei; double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi); bd_jing = z * Math.cos(theta) + 0.0065; bd_wei = z * Math.sin(theta) + 0.006; } private void getBeginGaode(Double jing, Double wei) { double x_pi = 3.14159265358979324 * 3000.0 / 180.0; double gg_lon; double gg_lat; double x = jing - 0.0065, y = wei - 0.006; double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi); double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi); gg_lon = z * Math.cos(theta); bg_jing = String.valueOf(gg_lon); // Log.e("gg_lon",gg_lon+""); gg_lat = z * Math.sin(theta); bg_wei = String.valueOf(gg_lat); // Log.e("gg_lat", gg_lat + ""); } private void setUserData() { if (!ProfileManager.getInstance().getGuide(this)) { MainApplication.messageToken = "0"; MainApplication.userTpye = "1"; ProfileManager.getInstance().setGuide(this, true); MainApplication.sql = ProfileManager.getInstance().getSQL(this); MainApplication.sudu = ProfileManager.getInstance().getSudu(this); } else { MainApplication.userTpye = ProfileManager.getInstance().getTpey(this); // Log.e("type!", MainApplication.userTpye); MainApplication.mapStatus = ProfileManager.getInstance().getMapstatus(this); MainApplication.costWay = ProfileManager.getInstance().getCostway(this); MainApplication.map = ProfileManager.getInstance().getMap(this); MainApplication.shuxing = ProfileManager.getInstance().getShuxing(this); MainApplication.sudu = ProfileManager.getInstance().getSudu(this); MainApplication.atCity = ProfileManager.getInstance().getAtCity(this); MainApplication.sql = ProfileManager.getInstance().getSQL(this); MainApplication.support = ProfileManager.getInstance().getSupport(this); MainApplication.freestop = ProfileManager.getInstance().getFreeStop(this); MainApplication.selecthotel = ProfileManager.getInstance().getSelectHotel(this); MainApplication.selectexpressway = ProfileManager.getInstance().getSelectExpressway(this); MainApplication.selectjingdian = ProfileManager.getInstance().getSelectJingdian(this); MainApplication.logid = ProfileManager.getInstance().getLogid(this); // Log.i("MainApplication.costWay", MainApplication.costWay); MainApplication.messageToken = ProfileManager.getInstance().getKeyMessageToken(this); } } private void userChargingCheck() { OkHttpUtils.get().url(UrlConstants.USER_CHARGING_CHECK_URL) .addParams(ChargingConstants.USERID, MainApplication.userId) .addParams(ChargingConstants.PWD, MainApplication.userPassword) .build().connTimeOut(10000).readTimeOut(10000).execute(new StringCallback() { @Override public void onError(Call call, Exception e) { } @Override public void onResponse(final String response) { LogUtils.e(response); if (EmptyUtils.isNotEmpty(response)) { String rtnCode = JsonUtils.getKeyResult(response, "rtnCode"); if ("306".equals(rtnCode)) { LogUtils.e("有订单"); rl_charging_notice.setVisibility(View.VISIBLE); if (firstCheck) { if (isStatusBack == false) { String data = JsonUtils.getKeyResult(response, "data"); String orderid = JsonUtils.getKeyResult(data, "orderId"); Intent intent = new Intent(getApplicationContext(), ChargingStatusActivity.class); intent.putExtra(ChargingConstants.ORDERID, orderid); startActivity(intent); } firstCheck = false; } rl_charging_notice.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String data = JsonUtils.getKeyResult(response, "data"); String orderid = JsonUtils.getKeyResult(data, "orderId"); Intent intent = new Intent(getApplicationContext(), ChargingStatusActivity.class); intent.putExtra(ChargingConstants.ORDERID, orderid); startActivity(intent); } }); } else { LogUtils.e("没有订单"); rl_charging_notice.setVisibility(View.GONE); MainApplication.isAppStart = false; ProfileManager.getInstance().setAppStart(getApplicationContext(), MainApplication.isAppStart); } } } }); } // private void chargingStatus() { // 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/xxapi/status_v2" + // "?supplier=星星充电&timer=" + token + "&user_id=" + MainApplication.userId + "&password="+MainApplication.userPassword+"&ver=1.0&sign=" // + Md5Util.md5("password="+MainApplication.userPassword+"supplier=星星充电&timer=" + token + "&user_id=" + MainApplication.userId + "&key=661f9efdcb4f46fe7ab5f2e78a705a2a"); //// Log.e("urlstatus", url); // OkHttpUtils.get() // .url(url) // .build() // .connTimeOut(10000) // .readTimeOut(10000) // .execute(new StringCallback() { // @Override // public void onError(Call call, Exception e) { // Toast.makeText(getApplicationContext(), "网络不给力", Toast.LENGTH_SHORT).show(); // } // // @Override // public void onResponse(final String response) { // new Handler().postDelayed(new Runnable() { // @Override // public void run() { // String code = JsonUtils.getKeyResult(response, "code"); // if (code.equals("200")) { // rl_charging_notice.setVisibility(View.VISIBLE); // if (firstCheck) { // Intent intent3 = new Intent(getApplication(), MainScanActivity.class); // intent3.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); // startActivity(intent3); // overridePendingTransition(0, 0); // ActivityManagerApplication.addDestoryActivity(MainMapActivity.this, "MainMapActivity"); // MainScanActivity.tag = "1"; // firstCheck = false; // } // Log.e("首页查询订单=", "有"); // } else { // rl_charging_notice.setVisibility(View.GONE); // MainScanActivity.tag = ""; // Log.e("首页查询订单=", "没有"); // MainApplication.isAppStart = false; // ProfileManager.getInstance().setAppStart(getApplicationContext(),MainApplication.isAppStart); // } // } // }, 2000); // // } // }); // } private void getZhanListData(int level) { aMap.clear(); ZhanDBHelper dbHelper = new ZhanDBHelper(this); try { dbHelper.createDataBase(); SQLiteDatabase db = dbHelper.getWritableDatabase(); db.beginTransaction(); String sql = ""; if (level == 3) { sql = "SELECT count(*) as cnt,substr(poi_jing,0,4) as pjing,substr(poi_wei,0,3) as pwei,avg(poi_jing) as pjing2,avg(poi_wei) as pwei2 FROM zhan_list where city != '1'" + MainApplication.sql + "GROUP BY pjing,pwei"; // sql = "SELECT count(*) as cnt,substr(poi_jing,0,4) as pjing,substr(poi_wei,0,3) as pwei,avg(poi_jing) as pjing2,avg(poi_wei) as pwei2 FROM zhan_list WHERE suit_car = '国标' AND belong_attribute = '公共' AND ( status = '3' OR status = '4' ) AND own_pay = '1' AND charge_cost_way = '可使用本APP扫码支付' GROUP BY pjing,pwei"; } else if (level == 2) { sql = "SELECT count(*) as cnt,substr(poi_jing,0,6) as pjing,substr(poi_wei,0,5) as pwei,avg(poi_jing) as pjing2,avg(poi_wei) as pwei2 FROM zhan_list where city != '1'" + MainApplication.sql + "GROUP BY pjing,pwei"; // sql="SELECT count(*) as cnt,substr(poi_jing,0,4) as pjing,substr(poi_wei,0,3) as pwei,avg(poi_jing) as pjing2,avg(poi_wei) as pwei2 FROM zhan_list WHERE suit_car = '国标' AND belong_attribute = '公共' AND ( status = '3' OR status = '4' ) AND own_pay = '1' AND charge_cost_way = '可使用本APP扫码支付' GROUP BY pjing,pwei"; } // Log.e("sql===", sql); Cursor cursor = db.rawQuery(sql, null); ZhanDB zhan_db; while (cursor.moveToNext()) { zhan_db = new ZhanDB(); zhan_db.setCnt(cursor.getString(cursor.getColumnIndex("cnt"))); zhan_db.setPjing2(cursor.getString(cursor.getColumnIndex("pjing2"))); zhan_db.setPwei2(cursor.getString(cursor.getColumnIndex("pwei2"))); list_db.add(zhan_db); } // Log.e("size===",list_db.size()+""); // initOver(list_db); cursor.close(); db.endTransaction(); db.close(); } catch (IOException e) { e.printStackTrace(); } } private void delData(List<DataRefresh> list_del) { // DaoMaster daoMaster = new DaoMaster(SQLiteDatabase.openOrCreateDatabase(getDatabasePath("zhan_list"), null)); // DaoSession daoSession = daoMaster.newSession(); // zhan_listDao = daoSession.getZhan_listDao(); // for (int i = 0 ;i<list_del.size();i++) { // // zhan_list findUser = zhan_listDao.queryBuilder().where(com.electric.chargingpile.gen.zhan_listDao.Properties.Id.eq(list_del.get(i).getId())).build().unique(); // if (findUser != null) { // zhan_listDao.deleteByKey(); // } // } String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list"; // ZhanDBHelper dbHelper = new ZhanDBHelper(this); try { // dbHelper.createDataBase(); // SQLiteDatabase db = dbHelper.getWritableDatabase(); SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE); // String sql ="DELETE from zhan_list where id = '"+dr.getId()+"'"; db.beginTransaction();//开始事务 // Cursor cursor = null; try { for (int i = 0; i < list_del.size(); i++) { // String sql ="DELETE from zhan_list where id = '"+list_del.get(i).getId()+"'"; // db.execSQL(sql); // cursor = db.rawQuery(sql, null); String[] args = {String.valueOf(list_del.get(i).getId())}; // int mub = db.delete("zhan_list", "id=?", args); if (mub > 0) { // Log.e(TAG, "删除成功"); } else { // Log.e(TAG, "删除失败---" + list_del.get(i).getId()); } } db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务 } finally { db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务 } // cursor.close(); db.close(); } catch (Exception e) { e.printStackTrace(); } } private void addData(List<DataRefresh> list_add) { String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list"; // ZhanDBHelper dbHelper = new ZhanDBHelper(this); try { // dbHelper.createDataBase(); // SQLiteDatabase db = dbHelper.getWritableDatabase(); SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE); db.beginTransaction();//开始事务 // Cursor cursor = null; try { for (int i = 0; i < list_add.size(); i++) { // String sql ="INSERT INTO zhan_list (id,status,poi_jing,poi_wei,total_num,fast_num,slow_num,charge_cost_way," + // "belong_attribute,suit_car,own_pay,city) values ('" // +list_add.get(i).getId()+"','"+list_add.get(i).getStatus()+"','"+list_add.get(i).getPoi_jing()+"','" // +list_add.get(i).getPoi_wei()+"','"+list_add.get(i).getTotal_num()+"','" // +list_add.get(i).getFast_num()+"','"+list_add.get(i).getSlow_num()+"','"+list_add.get(i).getCharge_cost_way()+"','" // +list_add.get(i).getBelong_attribute()+"','"+list_add.get(i).getSuit_car()+ // "','"+list_add.get(i).getOwn_pay()+"','"+list_add.get(i).getCity()+"')"; //// cursor = db.rawQuery(sql, null); // db.execSQL(sql); ContentValues cv = new ContentValues(); cv.put("id", list_add.get(i).getId()); cv.put("status", list_add.get(i).getStatus()); cv.put("poi_jing", list_add.get(i).getPoi_jing()); cv.put("poi_wei", list_add.get(i).getPoi_wei()); cv.put("total_num", list_add.get(i).getTotal_num()); cv.put("fast_num", list_add.get(i).getFast_num()); cv.put("slow_num", list_add.get(i).getSlow_num()); cv.put("charge_cost_way", list_add.get(i).getCharge_cost_way()); cv.put("belong_attribute", list_add.get(i).getBelong_attribute()); cv.put("suit_car", list_add.get(i).getSuit_car()); cv.put("own_pay", list_add.get(i).getOwn_pay()); cv.put("city", list_add.get(i).getCity()); cv.put("supplier", list_add.get(i).getSupplier()); long mub = db.insert("zhan_list", null, cv); if (mub > 0) { Log.e(TAG, "添加成功"); // s++; } else { Log.e(TAG, "添加失败---" + list_add.get(i).getId()); // f++; } } db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务 } finally { db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务 } // cursor.close(); db.close(); } catch (Exception e) { e.printStackTrace(); } } private void upData(List<DataRefresh> list_up) { String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list"; // ZhanDBHelper dbHelper = new ZhanDBHelper(this); try { // dbHelper.createDataBase(); // SQLiteDatabase db = dbHelper.getWritableDatabase(); SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE); // String sql ="DELETE from zhan_list where id = '"+dr.getId()+"'"; db.beginTransaction();//开始事务 // Cursor cursor = null; try { for (int i = 0; i < list_up.size(); i++) { // String sql ="UPDATE zhan_list SET status = '"+list_up.get(i).getStatus()+"',poi_jing = '"+list_up.get(i).getPoi_jing()+"',poi_wei = '"+list_up.get(i).getPoi_wei()+"',total_num = '"+list_up.get(i).getTotal_num()+"',fast_num = '"+list_up.get(i).getFast_num()+"',slow_num = '"+list_up.get(i).getSlow_num()+"',charge_cost_way = '"+list_up.get(i).getCharge_cost_way()+"',belong_attribute = '"+list_up.get(i).getBelong_attribute()+"',suit_car = '"+list_up.get(i).getSuit_car()+"',own_pay = '"+list_up.get(i).getOwn_pay()+"',city = '"+list_up.get(i).getCity()+"' where id = '"+list_up.get(i).getId()+"'"; //// cursor = db.rawQuery(sql, null); // db.execSQL(sql); String[] args = {String.valueOf(list_up.get(i).getId())}; ContentValues cv = new ContentValues(); cv.put("id", list_up.get(i).getId()); cv.put("status", list_up.get(i).getStatus()); cv.put("poi_jing", list_up.get(i).getPoi_jing()); cv.put("poi_wei", list_up.get(i).getPoi_wei()); cv.put("total_num", list_up.get(i).getTotal_num()); cv.put("fast_num", list_up.get(i).getFast_num()); cv.put("slow_num", list_up.get(i).getSlow_num()); cv.put("charge_cost_way", list_up.get(i).getCharge_cost_way()); cv.put("belong_attribute", list_up.get(i).getBelong_attribute()); cv.put("suit_car", list_up.get(i).getSuit_car()); cv.put("own_pay", list_up.get(i).getOwn_pay()); cv.put("city", list_up.get(i).getCity()); cv.put("supplier", list_up.get(i).getSupplier()); long mub = db.update("zhan_list", cv, "id=?", args); if (mub > 0) { Log.e(TAG, "up成功"); } else { Log.e(TAG, "up失败---" + list_up.get(i).getId()); } } db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务 } finally { db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务 } // cursor.close(); db.close(); } catch (Exception e) { e.printStackTrace(); } } public String getAssetsCacheFile(Context context, String fileName) throws Exception { File cacheFile = new File(context.getCacheDir(), fileName); try { InputStream inputStream = context.getAssets().open(fileName); try { FileOutputStream outputStream = new FileOutputStream(cacheFile); try { byte[] buf = new byte[1024]; int len; while ((len = inputStream.read(buf)) > 0) { outputStream.write(buf, 0, len); } } finally { outputStream.close(); } } finally { inputStream.close(); } } catch (IOException e) { e.printStackTrace(); } // Log.d("db_path", cacheFile.getAbsolutePath()); getZhanData(); return cacheFile.getAbsolutePath(); } class NetworkChangeReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (null != networkInfo && networkInfo.isAvailable()) { } else { Toast.makeText(context, "当前网络不可用", Toast.LENGTH_SHORT).show(); } } } private void getZhanData() throws Exception { if (zhan_lists != null) { zhan_lists.clear(); } if (mClusterOverlay != null) { mClusterOverlay.onDestroy(); } // DaoMaster.DevOpenHelper mHelper = new DaoMaster.DevOpenHelper(this, "zhan_list", null); // SQLiteDatabase db = mHelper.getWritableDatabase(); // // 注意:该数据库连接属于 DaoMaster,所以多个 Session 指的是相同的数据库连接。 // DaoMaster mDaoMaster = new DaoMaster(db); // DaoSession mDaoSession = mDaoMaster.newSession(); // MyOpenHelper helper = new MyOpenHelper(this, "zhan_list", // null); // DaoMaster daoMaster = new DaoMaster(helper.getWritableDatabase()); DaoMaster daoMaster = new DaoMaster(SQLiteDatabase.openOrCreateDatabase(getDatabasePath("zhan_list"), null)); DaoSession mDaoSession = daoMaster.newSession(); // DaoSession mDaoSession = MainApplication.getInstance().getDaoSession(); zhan_listDao = mDaoSession.getZhan_listDao(); // final List<zhan_list> list = zhan_listDao.loadAll(); // new Thread(new Runnable() { // @Override // public void run() { // LogUtils.e("add is begin"); // for (int i = 0;i<list.size();i++){ // MainApplication.getInstance().getDaoSession().getZhan_listDao().insert(list.get(i)); // // } // LogUtils.e("add is ok"); // } // }).start(); // MainApplication.getInstance().getDaoSession().getZhan_listDao().get // zhan_lists = zhan_listDao.loadAll(); zhan_lists = zhan_listDao.queryRaw("where status = ? " + MainApplication.sql, new String[]{"4"}); if (onResumeRefresh == true) { ToastUtil.showToast(getApplicationContext(), "共" + zhan_lists.size() + "个符合条件的站点", Toast.LENGTH_SHORT); // isShow = false; } // Log.e(TAG, "getZhanData===" + zhan_lists.size()); new Thread() { public void run() { List<ClusterItem> items = new ArrayList<ClusterItem>(); if (zhan_lists != null && zhan_lists.size() > 0) { for (int i = 0; i < zhan_lists.size(); i++) { String jing = zhan_lists.get(i).getPoi_jing(); String wei = zhan_lists.get(i).getPoi_wei(); if (jing != null && !jing.equals("") && !wei.equals("") && wei != null) { int position_jing = jing.length() - jing.indexOf(".") - 1; int position_wei = wei.length() - wei.indexOf(".") - 1; LatLng ll; if (position_jing > 13 || position_wei > 13) { ll = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing)); } else { double dwei = Double.parseDouble(wei); double djing = Double.parseDouble(jing); getGaode(djing, dwei); ll = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing)); } if (null != String.valueOf(ll.longitude) && null != String.valueOf(ll.latitude)) { if (null != zhan_lists) { zhan_lists.get(i).setPoi_jing(String.valueOf(ll.longitude)); zhan_lists.get(i).setPoi_wei(String.valueOf(ll.latitude)); } } } } } for (int i = 0; i < zhan_lists.size(); i++) { if (null != zhan_lists.get(i).getPoi_jing() && null != zhan_lists.get(i).getPoi_wei()) { double lat, lon; if (zhan_lists.get(i).getPoi_wei().equals("") || zhan_lists.get(i).getPoi_wei() == null) { lat = 0.00; } else { lat = Double.parseDouble(zhan_lists.get(i).getPoi_wei()); } if (zhan_lists.get(i).getPoi_jing().equals("") || zhan_lists.get(i).getPoi_jing() == null) { lon = 0.00; } else { lon = Double.parseDouble(zhan_lists.get(i).getPoi_jing()); } LatLng latLng = new LatLng(lat, lon, false); RegionItem regionItem = new RegionItem(latLng, "test" + i); //注意这里在设置数据的时候把 自己的原始点的信息设置到区域Item中 方便在回调方法中拿到这些数据 // zhan_lists.get(i).setPoi_jing(String.valueOf(ll.longitude)); // zhan_lists.get(i).setPoi_wei(String.valueOf(ll.latitude)); regionItem.setChargePoint(zhan_lists.get(i)); items.add(regionItem); } } mClusterOverlay = new ClusterOverlay(aMap, items, dp2px(getApplicationContext(), clusterRadius), getApplicationContext()); mClusterOverlay.setClusterRenderer(MainMapActivity.this); mClusterOverlay.setOnClusterClickListener(MainMapActivity.this); } }.start(); } private void showMapMarker() { List<ClusterItem> items = new ArrayList<ClusterItem>(); for (int i = 0; i < zhan_lists.size(); i++) { if (null != zhan_lists.get(i).getPoi_jing() && null != zhan_lists.get(i).getPoi_wei()) { double lat, lon; if (zhan_lists.get(i).getPoi_wei().equals("") || zhan_lists.get(i).getPoi_wei() == null) { lat = 0.00; } else { lat = Double.parseDouble(zhan_lists.get(i).getPoi_wei()); } if (zhan_lists.get(i).getPoi_jing().equals("") || zhan_lists.get(i).getPoi_jing() == null) { lon = 0.00; } else { lon = Double.parseDouble(zhan_lists.get(i).getPoi_jing()); } LatLng latLng = new LatLng(lat, lon, false); RegionItem regionItem = new RegionItem(latLng, "test" + i); //注意这里在设置数据的时候把 自己的原始点的信息设置到区域Item中 方便在回调方法中拿到这些数据 // zhan_lists.get(i).setPoi_jing(String.valueOf(ll.longitude)); // zhan_lists.get(i).setPoi_wei(String.valueOf(ll.latitude)); regionItem.setChargePoint(zhan_lists.get(i)); items.add(regionItem); } } mClusterOverlay = new ClusterOverlay(aMap, items, dp2px(getApplicationContext(), clusterRadius), getApplicationContext()); mClusterOverlay.setClusterRenderer(MainMapActivity.this); mClusterOverlay.setOnClusterClickListener(MainMapActivity.this); } private void initDataBase() throws IOException { File databasePath = getDatabasePath("zhan_list"); databasePath.getParentFile().mkdirs(); databasePath.createNewFile(); // Log.e("path===", databasePath.getPath()); // Log.e("path===", databasePath.getAbsolutePath()); InputStream inputStream = getAssets().open("zhan_list.db"); FileOutputStream fileOutputStream = new FileOutputStream(databasePath); byte[] buf = new byte[1024 * 10]; int length = 0; while ((length = inputStream.read(buf)) != -1) { fileOutputStream.write(buf, 0, length); fileOutputStream.flush(); } inputStream.close(); fileOutputStream.close(); // Log.d(TAG, "initDataBase: length=" + databasePath.length()); eteinit("{\"fun\":\"timer\"}"); try { getZhanData(); } catch (Exception e) { e.printStackTrace(); } } @Override public Drawable getDrawAble(int clusterNum) { int radius = dp2px(getApplicationContext(), 60); if (clusterNum == 1) { Drawable bitmapDrawable = mBackDrawAbles.get(1); if (bitmapDrawable == null) { bitmapDrawable = getApplication().getResources().getDrawable( R.drawable.icon_sorange); mBackDrawAbles.put(1, bitmapDrawable); } return bitmapDrawable; } else if (clusterNum > 1 && clusterNum < 999) { Drawable bitmapDrawable = mBackDrawAbles.get(2); if (bitmapDrawable == null) { bitmapDrawable = getApplication().getResources().getDrawable( R.drawable.icon_marker1_999); mBackDrawAbles.put(2, bitmapDrawable); // bitmapDrawable = new BitmapDrawable(null, drawCircle(radius, // Color.argb(159, 210, 154, 6))); // mBackDrawAbles.put(2, bitmapDrawable); } return bitmapDrawable; } else if (clusterNum > 1000) { Drawable bitmapDrawable = mBackDrawAbles.get(3); if (bitmapDrawable == null) { bitmapDrawable = getApplication().getResources().getDrawable( R.drawable.icon_marker1000); // bitmapDrawable = new BitmapDrawable(null, drawCircle(radius, // Color.argb(199, 217, 114, 0))); mBackDrawAbles.put(3, bitmapDrawable); } return bitmapDrawable; } else { Drawable bitmapDrawable = mBackDrawAbles.get(4); if (bitmapDrawable == null) { bitmapDrawable = getApplication().getResources().getDrawable( R.drawable.icon_marker1_999); // bitmapDrawable = new BitmapDrawable(null, drawCircle(radius, // Color.argb(235, 215, 66, 2))); mBackDrawAbles.put(4, bitmapDrawable); } return bitmapDrawable; } } private Bitmap drawCircle(int radius, int color) { Bitmap bitmap = BitmapFactory.decodeResource(MainApplication.context.getResources(), R.drawable.icon_newmarker4); Bitmap bitmap1 = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(), false); // Bitmap bitmap = Bitmap.createBitmap(radius * 2, radius * 2, // Bitmap.Config.ARGB_8888); // Canvas canvas = new Canvas(bitmap1); // Paint paint = new Paint(); // RectF rectF = new RectF(0, 0, radius * 2, radius * 2); //// paint.setColor(color); // canvas.drawArc(rectF, 0, 360, true, paint); return bitmap1; } /** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) */ public int dp2px(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dpValue * scale + 0.5f); } @Override public void onClick(Marker marker, List<ClusterItem> clusterItems) { LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (ClusterItem clusterItem : clusterItems) { builder.include(clusterItem.getPosition()); } //这里处理一下Marker的点击事件 if (clusterItems.size() == 1) { MobclickAgent.onEvent(context, "0102"); Log.e(TAG, "onClick: !!" + "!!"); rl_control.setVisibility(View.GONE); moveRefresh = false; ClusterItem clusterItem = clusterItems.get(0); LatLng position = clusterItem.getPosition(); float zoom = aMap.getCameraPosition().zoom; // Log.e(TAG, "onClick: ==" + zoom); aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(marker.getPosition(), zoom)); RegionItem regionItem = (RegionItem) clusterItems.get(0); zhan_list chargePoint = regionItem.getChargePoint(); String own_pay = chargePoint.getOwn_pay(); String supplier = chargePoint.getSupplier(); String suit_car = chargePoint.getSuit_car(); if (null != own_pay && own_pay.equals("1")) { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig1)); } else { if (null != suit_car && suit_car.equals("特斯拉")) { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig3)); } else { if (null != supplier && WelcomeActivity.canCost.contains(supplier)) { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig2)); } else { marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newbig3)); } } } // Log.e(TAG, "onClick: " + own_pay + "=====" + supplier); if (nMarker != null && current_chargePoint.getId() != chargePoint.getId()) { MarkerOptions markerOptionss = new MarkerOptions(); if (null != current_chargePoint.getOwn_pay() && current_chargePoint.getOwn_pay().equals("1")) { nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker1)); } else { if (null != current_chargePoint.getSuit_car() && current_chargePoint.getSuit_car().equals("特斯拉")) { nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3)); } else { if (null != current_chargePoint.getSupplier() && WelcomeActivity.canCost.contains(current_chargePoint.getSupplier())) { nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2)); } else { nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3)); } } } nMarker = aMap.addMarker(markerOptionss); } // Log.d(TAG, "onClick: latitude=" + position.latitude + " long=" + position.longitude + "\n" + ((RegionItem) clusterItem).getChargePoint().toString()); Long zhan_id = ((RegionItem) clusterItem).getChargePoint().getId(); nMarker = marker; // add by hyg 显示气泡 nMarker.showInfoWindow(); current_chargePoint = chargePoint; dialog.show(); if (null != marker.getPosition()) { getSingleZhanInfo(String.valueOf(zhan_id), marker.getPosition()); } } else { LatLngBounds latLngBounds = builder.build(); aMap.animateCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 0)); } } private void getSingleZhanInfo(String zhan_id, final LatLng ll) { String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/zhan-info?zhan_id=" + zhan_id + "&version=" + MainApplication.current_code; // Log.e(TAG, "getSingleZhanInfo: url="+url ); 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: " + response); dialog.cancel(); String info = JsonUtils.getKeyResult(response, "info"); // String info = "JbCMZl5FRHmpKqIywO0ntFtBJfaZYHk7bQGy9WjREYixObR+49H+MAJTiHTKnvSQz73LDfLo4MQMAldzbOFyNkhapUrlWOF5Og7H8HmFX/0A1mLAIDGIXMepmpS45gYVdzn8xvGDh3JXdiNU1AAohz4R3WdpSIo5Pvt+RbsIqH+/Uuk3/mRrizGxZmWhQzzIpc9KMY/69vUAEaxTz8YQLgdbHWUE/wD1e79BiXKTRmrbqayVFd8tFDrM6pvovDE15wUomION2gKdHLCvA2Dg5loIiany/FVkB7tmQLu2SiiCgfHArwWqr/axUP9Vbu878PrJRxLYSW616iFSBFYJHVe1PIDTXA6g8mvxUnCCnfhUVoRJ5mn18hXo2EsTdqbLnp3UpOAXicoGWoP4ztXu/M2P0xA+MnPk7Wa4NunMhPVeKpmTsYXV2RzQaUQknwtEgSRvtTEX6HSUxPnrNESiQML5fLCNiWms2z5vp2GUSFYQTGKnCsqlw7HsAJCf0VBJAz6Ii46kr8NBtk3WwOfld5ZO/pIhTuS3Mg1HHlu9nR1Vqu6/UPJiu0zF1AfOUB1f1mSM3d1p2tsPSGKbugRIP7vWOQ57vgUYK3n3UUo51aCemgpy3eIxo9cCdtTEXU5O4A4FpyQEKP8uIiAp7dIUqvkCGfatTI/dJVJ70Sv5sCpXCfdYIRpiWVj63nt8p4KUnxF7x5KrMDiZY+ntQLXzufgIHa+pL6E/ToJ2lznXaMOaMSt0O2bWz++2qa2TvpOj7S9qsaJgtySs7Mwrk+Yg3UULyp8BkMK6lcRxBv4jz43pt84fPO4imm42SDr/H0X/88CmmyhzJtLExchpZQA1nqmTyWkfj9V0Z62s+9IAcw90bHm/J6x5vSY3K+N5chBR47VEt77tg6DKPTW2u9R+lDGEPluYvPjZ2i20qeDkUJ19U6vM+QnYF8Sa4AlzT3G9SJlqHGyXRyTn7WOLnvg6pSKSAsTp/lFAaeNHAvJtx1bSq+43vDlFbs6jXPQXcVvTZf6ALge/rLFItYA8muOwKj2DxFftshKFwkufxA/nTS19rJoDNvLtVbTfe6E3Za2ei7LCaWNV5UtrDJOSdEGzFKqroB59Ika0Ijdn1ZI2f54feYgnUYZHKDb8UUbGQlRWzwcYBv4PjDGVVKbSWUMkeDA0FB4t+X1Rfu28UnSJ2GShL8cotnm6vwD1Psy3NDAShfvCBVqSx6O6PqTic0KBQq2Ufjlx1OWKexE08qEWWUEyEvMOPkTx2t94zdxQZVCIfR1DIvHCklvBTh7zyfcLXQol/6AnoTBh6X+R8Hh1Ih8FLnlZfeB4bde8hHZbNS2GyQb8Hs4haZmeYyVdUYy3OuXIBFd1Ve5UzKv+AY1JipsKI/ha/h19Xozpvr86sQUYDhlpbKyYAVtrZhYvTFcKuj6Jl46KGkJMXv6GU1QpYvjxF8W156HfGv9uN35Q1bVVcHOXerM4e8DXqUvXTK6g5zMTPes0smYLlTn73CO1iuc4c2wDmEiTEk367qJf6VDefWPRZpkOsKZHxc06OTfw3tAuEK9X8mnVaVhb+6OHkPKtnD//5K/6VYYPcXaIoSAcFdkgcMkYe5vSKyw7TNfgSBSGNlxFrYPkhotshDoKt6FP/KTn9lFxQtl/BKG6if5wfp2hp7Ufn339wJh6SKd7ibtM38AS3HFHxvq7pC+wREAkhW4gyD8t7S3BZKsw+M50vhI3rmg9gebH4MJxC2iK5JDhPnHyw6fVz72pgluqD0cWpvy/3hFt+QxFfpbVnMhC6fvmspLpk/WZf3CKIb5T8TLoUOSMX7wBlTrl+oh6A0c/OdUpScoIv1dFGSN/7FXXnWLlMz4nkRcsN3ob6RT/QXqaE3cpo8HmR/6x9A+qNkMvVndDLBw3v/S4Fq6pr1DVsJpYAhwmgx461Z1pQTB+ORKDZOdiz+WAeHzNH5tD2Ers4VK8IWoK/FX1JABSC3Qxad3gUTAGc7Bpx4VZ8fdGzr6gfMeg8HT5WSeCkffepjLTQ0+Z4S+vjQ=="; Log.e(TAG, "onResponse: info=" + info); String info_decode = ""; try { info_decode = DES3S.decode(info); } catch (Exception e) { e.printStackTrace(); } Log.e(TAG, "onResponse: info_decode=" + info_decode); if (null != info_decode && !info_decode.equals("")) { showInfoWindow(info_decode, ll); } } }); } private void showInfoWindow(String info, final LatLng ll) { final String id = JsonUtils.getKeyResult(info, "id"); getCommentNum(id); zhanGrade(id); final String zhan_name = JsonUtils.getKeyResult(info, "zhan_name"); String stop_cost = JsonUtils.getKeyResult(info, "stop_cost"); String own_pay = JsonUtils.getKeyResult(info, "own_pay"); String charge_cost_way2 = JsonUtils.getKeyResult(info, "charge_cost_way2"); final String charge_cost_way = JsonUtils.getKeyResult(info, "charge_cost_way"); String other_cost = JsonUtils.getKeyResult(info, "other_cost"); String charge_cost = JsonUtils.getKeyResult(info, "charge_cost"); String total_num = JsonUtils.getKeyResult(info, "total_num"); String slow_num = JsonUtils.getKeyResult(info, "slow_num"); String fast_num = JsonUtils.getKeyResult(info, "fast_num"); String remind = JsonUtils.getKeyResult(info, "remind"); final String city = JsonUtils.getKeyResult(info, "city"); final String poi_jing = JsonUtils.getKeyResult(info, "poi_jing"); final String poi_wei = JsonUtils.getKeyResult(info, "poi_wei"); if (remind.equals("0") && !"1".equals(own_pay)) { iv_guzhang.setVisibility(View.GONE); } else { if (!remind.equals("0")) { iv_guzhang.setImageResource(R.drawable.icon_guzhang_window); } else { iv_guzhang.setImageResource(R.drawable.icon_is_cost); } iv_guzhang.setVisibility(View.VISIBLE); } windowName.setText(zhan_name); if (center != null) { String wei = poi_wei; String jing = poi_jing; int position_jing = jing.length() - jing.indexOf(".") - 1; int position_wei = wei.length() - wei.indexOf(".") - 1; LatLng latLng; if (position_jing > 13 || position_wei > 13) { latLng = new LatLng(Double.parseDouble(wei), Double.parseDouble(jing)); } else { double dwei = Double.parseDouble(wei); double djing = Double.parseDouble(jing); getGaode(djing, dwei); latLng = new LatLng(Double.parseDouble(gd_wei), Double.parseDouble(gd_jing)); } // OK double d = AMapUtils.calculateLineDistance(center, latLng); if ("0m".equals(Util.getDistance(d))) { windowDistance.setText("未知"); updateInfoWindow("未知距离"); } else { String text = Util.getDistance(d); windowDistance.setText(text); updateInfoWindow("距您 " + text); } } String acNum = null, dcNum = null, acableNum = null, dcableNum = null; if (null != JsonUtils.getKeyResult(info, "acNum")) { acNum = JsonUtils.getKeyResult(info, "acNum"); dcNum = JsonUtils.getKeyResult(info, "dcNum"); acableNum = JsonUtils.getKeyResult(info, "acableNum"); dcableNum = JsonUtils.getKeyResult(info, "dcableNum"); // Log.e("dcableNum", dcableNum); } if (null != acableNum && null != acNum && null != dcableNum && null != dcNum) { windowFastNum.setText(dcNum); windowFastAbleNum.setText(dcableNum); windowFastAble.setVisibility(View.VISIBLE); windowFastAbleNum.setVisibility(View.VISIBLE); windowSlowNum.setText(acNum); windowSlowAbleNum.setText(acableNum); windowSlowAble.setVisibility(View.VISIBLE); windowSlowAbleNum.setVisibility(View.VISIBLE); // paoSlow.setText("空闲" + acableNum + "/共" + acNum + "个"); // paoFast.setText("空闲" + dcableNum + "/共" + dcNum + "个"); } else { if (fast_num.equals("")) { windowFastNum.setText("0"); } else { windowFastNum.setText(fast_num); } windowFastAble.setVisibility(View.GONE); windowFastAbleNum.setVisibility(View.GONE); if (slow_num.equals("")) { windowSlowNum.setText("0"); } else { windowSlowNum.setText(slow_num); } windowSlowAble.setVisibility(View.GONE); windowSlowAbleNum.setVisibility(View.GONE); } //OK if (own_pay.equals("1")) { windowCost.setText("可使用本APP扫码支付"); } else { if (charge_cost_way2.equals("")) { windowCost.setText("暂无"); } else { windowCost.setText(charge_cost_way2); } } // windowZhanDetails.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class); // intent.putExtra("zhan_id", id); // intent.putExtra("poi_jing", poi_jing); // intent.putExtra("poi_wei", poi_wei); // startActivity(intent); // } // }); windowZhanDetails.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class); intent.putExtra("zhan_id", id); intent.putExtra("poi_jing", poi_jing); intent.putExtra("poi_wei", poi_wei); startActivity(intent); MainMapActivity.isR = true; HashMap<String, String> map = new HashMap<String, String>(); map.put("type", "详情"); MobclickAgent.onEvent(context, "0102", map); map.clear(); } }); windowLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class); intent.putExtra("zhan_id", id); intent.putExtra("poi_jing", poi_jing); intent.putExtra("poi_wei", poi_wei); startActivity(intent); MainMapActivity.isR = true; HashMap<String, String> map = new HashMap<String, String>(); map.put("type", "详情"); MobclickAgent.onEvent(context, "0102", map); map.clear(); } }); windowComments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class); intent.putExtra("zhan_id", id); intent.putExtra("poi_jing", poi_jing); intent.putExtra("poi_wei", poi_wei); MainApplication.details_flag = "3"; startActivity(intent); HashMap<String, String> map = new HashMap<String, String>(); map.put("type", "评论"); MobclickAgent.onEvent(context, "0102", map); map.clear(); } }); //站点广告 // Log.e(TAG, "showInfoWindow: MainApplication.list_addetail="+MainApplication.list_addetail.size() ); if (MainApplication.list_addetail != null) { Random random = new Random(); final int result = random.nextInt(MainApplication.list_addetail.size()); Picasso.with(MainApplication.context) .load("http://cdz.evcharge.cc/zhannew/uploadfile/" + MainApplication.list_addetail.get(result).getImg()) .into(windowAd); windowAd.setVisibility(View.VISIBLE); windowView.setVisibility(View.GONE); windowAd.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { MobclickAgent.onEvent(context, "0052"); if (MainApplication.list_addetail.get(result).getIs_dui().equals("1")) { long appTime11 = System.currentTimeMillis() / 1000; long updatetime1 = appTime11 - MainMapActivity.cha - 5; String token1 = String.valueOf(updatetime1); String encode_token = null; try { encode_token = DES3.encode(token1); } catch (Exception e) { e.printStackTrace(); } String replace = URLEncoder.encode(encode_token); Intent intent11 = new Intent(); intent11.setClass(getApplicationContext(), CreditActivity.class); intent11.putExtra("navColor", "#fcfcfc"); //配置导航条的背景颜色,请用#ffffff长格式。 intent11.putExtra("titleColor", "#222222"); //配置导航条标题的颜色,请用#ffffff长格式。 MainApplication.goods_type = "details"; MainApplication.current_url = MainApplication.list_addetail.get(result).getUrl(); // MainApplication.current_url = "http://www.duiba.com.cn/mobile/appItemDetail?appItemId=453087"; if (!MainApplication.isLogin()) { intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?token=" + replace + "&url=" + MainApplication.current_url); //配置自动登陆地址,每次需服务端动态生成。 } else { intent11.putExtra("url", "http://cdz.evcharge.cc/zhannew/basic/web/index.php/duiba/active?user_id=" + MainApplication.userId + "&token=" + replace + "&url=" + MainApplication.current_url); //配置自动登陆地址,每次需服务端动态生成。 } startActivity(intent11); overridePendingTransition(0, 0); CreditActivity.creditsListener = new CreditActivity.CreditsListener() { /** * 当点击分享按钮被点击 * @param shareUrl 分享的地址 * @param shareThumbnail 分享的缩略图 * @param shareTitle 分享的标题 * @param shareSubtitle 分享的副标题 */ public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) { //当分享按钮被点击时,会调用此处代码。在这里处理分享的业务逻辑。 ChargingShareBean chargingShareBean = new ChargingShareBean(); chargingShareBean.setIcon(shareThumbnail); chargingShareBean.setTitle(shareTitle); chargingShareBean.setUrl(shareUrl); chargingShareBean.setText(""); showSimpleBottomSheetGrid(chargingShareBean); } /** * 当点击“请先登录”按钮唤起登录时,会调用此处代码。 * 用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。 * @param webView 用于登录成功后返回到当前的webview刷新登录状态。 * @param currentUrl 当前页面的url */ public void onLoginClick(WebView webView, final String currentUrl) { //当未登录的用户点击去登录时,会调用此处代码。 //用户登录后,需要将CreditsActivity.IS_WAKEUP_LOGIN变量设置为true。 //为了用户登录后能回到未登录前的页面(currentUrl)。 //当用户登录成功后,需要重新请求一次服务端,带上currentUrl。 //用该方法中的webview变量加载请求链接。 //服务端收到请求后在生成免登录url时,将currentUrl放入redirect参数,通知客户端302跳转到新生成的免登录URL。 new android.app.AlertDialog.Builder(webView.getContext()) .setTitle("跳转登录") .setMessage("跳转到登录页面?") .setPositiveButton("是", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // MainApplication.current_url = currentUrl; MainApplication.current_url = currentUrl; context.startActivity(new Intent(getApplicationContext(), LoginActivity.class)); } }) .setNegativeButton("否", null) .show(); } /** * 当点击“复制”按钮时,触发该方法,回调获取到券码code * @param webView webview对象。 * @param code 复制的券码 */ public void onCopyCode(WebView webView, String code) { //当未登录的用户点击去登录时,会调用此处代码。 new android.app.AlertDialog.Builder(webView.getContext()) .setTitle("复制券码") .setMessage("已复制,券码为:" + code) .setPositiveButton("是", null) .setNegativeButton("否", null) .show(); } /** * 积分商城返回首页刷新积分时,触发该方法。 */ public void onLocalRefresh(WebView mWebView, String credits) { //String credits为积分商城返回的最新积分,不保证准确。 //触发更新本地积分,这里建议用ajax向自己服务器请求积分值,比较准确。 // Toast.makeText(getApplicationContext(), "触发本地刷新积分:" + credits, Toast.LENGTH_SHORT).show(); } }; } else { Intent intent145 = new Intent(getApplication(), MyWebViewActivity.class); String url = MainApplication.list_addetail.get(result).getUrl(); if (EmptyUtils.isNotEmpty(url)) { if (url.contains("?")) { url = MainApplication.list_addetail.get(result).getUrl() + "&cdzshareid=" + MainApplication.list_addetail.get(result).getId(); } else { url = MainApplication.list_addetail.get(result).getUrl() + "?cdzshareid=" + MainApplication.list_addetail.get(result).getId(); } // intent_text,intent_icon,intent_title,intent_url; intent145.putExtra("url", url); // intent145.putExtra("tag", "8"); // intent145.putExtra("intent_text", MainApplication.list_addetail.get(result).getContent()); // intent145.putExtra("intent_icon", MainApplication.list_addetail.get(result).getIcon()); // intent145.putExtra("intent_title", MainApplication.list_addetail.get(result).getTitle()); // intent145.putExtra("intent_url", MainApplication.list_addetail.get(result).getUrl()); startActivity(intent145); } } } }); } else { windowAd.setVisibility(View.GONE); windowView.setVisibility(View.VISIBLE); } //站点导航 final String finalRemind = remind; windowGo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { HashMap<String, String> mapp = new HashMap<String, String>(); mapp.put("type", "导航"); MobclickAgent.onEvent(context, "0102", mapp); mapp.clear(); if (finalRemind.equals("0")) { if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") && !isAvilible(getApplicationContext(), "com.autonavi.minimap")) { if (null == center) { ToastUtil.showToast(getApplicationContext(), "请检查您当前网络或定位权限是否开启", Toast.LENGTH_SHORT); } else { 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 { Toast.makeText(getApplication(), "没有定位到您的当前位置", Toast.LENGTH_SHORT) .show(); } } } else { new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder() .setMsg("站点充电桩均为离线或故障,可能无法正常充电,是否继续前往") .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(); } } }); // Log.e(TAG, "onResponse: id=" + id); Animation animation = AnimationUtils.loadAnimation(this, R.anim.in); animation.setDuration(500); windowLayout.startAnimation(animation); windowLayout.setVisibility(View.VISIBLE); } 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) { 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.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; } } } } } } }); } } cdzApp - Gogs: Go Git Service

充电桩app代码

1145873331@qq.com e1cf244fe0 remove Useless dependence 7 年之前
..
wrapper e1cf244fe0 remove Useless dependence 7 年之前
crypto-casino4811 - Gogs: Go Git Service

Obserwowani