|
package com.electric.chargingpile.activity;
import android.Manifest;
import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.FileProvider;
import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationClientOption.AMapLocationMode;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.maps.AMap;
import com.amap.api.maps.AMapUtils;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.LocationSource;
import com.amap.api.maps.MapView;
import com.amap.api.maps.UiSettings;
import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.LatLngBounds;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.MyLocationStyle;
import com.amap.api.services.weather.LocalDayWeatherForecast;
import com.amap.api.services.weather.LocalWeatherForecast;
import com.amap.api.services.weather.LocalWeatherForecastResult;
import com.amap.api.services.weather.LocalWeatherLive;
import com.amap.api.services.weather.LocalWeatherLiveResult;
import com.amap.api.services.weather.WeatherSearch;
import com.amap.api.services.weather.WeatherSearchQuery;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.EmptyUtils;
import com.blankj.utilcode.util.LogUtils;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.electric.chargingpile.R;
import com.electric.chargingpile.application.MainApplication;
import com.electric.chargingpile.base.BaseEvent;
import com.electric.chargingpile.cluster.ClusterClickListener;
import com.electric.chargingpile.cluster.ClusterItem;
import com.electric.chargingpile.cluster.ClusterOverlay;
import com.electric.chargingpile.cluster.ClusterRender;
import com.electric.chargingpile.cluster.RegionItem;
import com.electric.chargingpile.constant.BaseConstants;
import com.electric.chargingpile.constant.UrlConstants;
import com.electric.chargingpile.data.Adin;
import com.electric.chargingpile.data.ChargingShareBean;
import com.electric.chargingpile.data.City;
import com.electric.chargingpile.data.DataRefresh;
import com.electric.chargingpile.data.FindData;
import com.electric.chargingpile.data.PileData;
import com.electric.chargingpile.data.UpdateZhanDataBean;
import com.electric.chargingpile.data.Zhan;
import com.electric.chargingpile.data.ZhanDB;
import com.electric.chargingpile.data.zhan_list;
import com.electric.chargingpile.gen.DaoMaster;
import com.electric.chargingpile.gen.DaoSession;
import com.electric.chargingpile.gen.zhan_listDao;
import com.electric.chargingpile.manager.ProfileManager;
import com.electric.chargingpile.util.BarColorUtil;
import com.electric.chargingpile.util.DES3;
import com.electric.chargingpile.util.DES3S;
import com.electric.chargingpile.util.DensityUtil;
import com.electric.chargingpile.util.EventBusUtil;
import com.electric.chargingpile.util.JsonUtils;
import com.electric.chargingpile.util.LoadingDialog;
import com.electric.chargingpile.util.Md5Util;
import com.electric.chargingpile.util.OkHttpUtil;
import com.electric.chargingpile.util.SharedPreferencesUtil;
import com.electric.chargingpile.util.ToastUtil;
import com.electric.chargingpile.util.Util;
import com.electric.chargingpile.util.ZhanDBHelper;
import com.electric.chargingpile.view.AlertDialogTwo;
import com.electric.chargingpile.view.AlertDialogUpdate;
import com.electric.chargingpile.view.SlideAdView;
import com.electric.chargingpile.view.UpdateDialog;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.zxing.client.android.constant.ChargingConstants;
import com.qmuiteam.qmui.widget.dialog.QMUIBottomSheet;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.picasso.Picasso;
import com.umeng.analytics.MobclickAgent;
import com.zhy.autolayout.AutoLayout;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.FileCallBack;
import com.zhy.http.okhttp.callback.StringCallback;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.tencent.qq.QQ;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.moments.WechatMoments;
import okhttp3.Call;
import pub.devrel.easypermissions.AfterPermissionGranted;
import pub.devrel.easypermissions.AppSettingsDialog;
import pub.devrel.easypermissions.EasyPermissions;
public class MainMapActivity extends Activity implements LocationSource, AMapLocationListener,
View.OnClickListener, AMap.OnMapLoadedListener, AMap.OnCameraChangeListener, AMap.OnMapClickListener,
ClusterRender, ClusterClickListener, WeatherSearch.OnWeatherSearchListener, EasyPermissions.PermissionCallbacks,
AMap.OnMarkerClickListener, AMap.InfoWindowAdapter, AMap.OnInfoWindowClickListener {
private static final String TAG = "MainMapActivity";
public static String screen_jing = "", screen_wei = "";
public static String location_city = "";
public static String re_move = "true";
List<LatLng> list_ll = new ArrayList<>();
private LinearLayout ll_recommend;
private WeatherSearchQuery mquery;
private WeatherSearchQuery mquery1;
private WeatherSearch mweathersearch;
private WeatherSearch mweathersearch1;
private RelativeLayout window_ll_zhan;
public static MainMapActivity m;
public static MainMapActivity mainMapActivity;
private int clusterRadius = 80;
private ClusterOverlay mClusterOverlay;
private Map<Integer, Drawable> mBackDrawAbles = new HashMap<Integer, Drawable>();
private IntentFilter intentFilter;
private NetworkChangeReceiver networkChangeReceiver;
private List<zhan_list> zhan_lists;
private MapView mapView;
public static String back = "";
private static AMap aMap;
private AlertDialogUpdate alterDialog;
public static boolean tag = false;
public static String condition;
public static int level;
private UiSettings mUiSettings;
private OnLocationChangedListener mListener;
private AMapLocationClient mlocationClient;
private AMapLocationClientOption mLocationOption;
private Marker currentClickedMarker;
private Marker detailMarker;
public static boolean onResumeRefresh = false;
public static boolean search_back = false;
private ImageView iv_guzhang, iVpoint;
private boolean clickMarker = false;
public static LatLng center = null;
private static boolean firstOpen = true;
private static boolean firstCheck = true;
public static long cha;
String gd_jing, gd_wei, bg_jing, bg_wei;
private String is_dui = "";
private final int SEARCH_CODE = 1;
static String token = "";
private String Token = "";
public static int have_message = 0;
public static int have_pinglun = 0;
public static int msg_num = 0;
public static int num1 = 0, num2 = 0;
public static int zhuang_no = 0;
public static int city_no = 0;
private static int count = 1;
private static int have_order = 0;
private static float minZoomLevel;
private static float maxZoomLevel;
public static RelativeLayout rl_tuijian_tip;
public static boolean detailsBack = false;
private int city_able = 0;
private Socket socket;
private int time_out = 0;
private Marker search_marker;
public static Marker recommend_marker_one, recommend_marker_two, recommend_marker_three;
private double bd_lon, bd_lat, bd_jing, bd_wei;
private LoadingDialog loadingDialog;
Context context;
public static boolean moveRefresh = true;
public static LinearLayout ll_map_control;
private List<String> stringTid = new ArrayList<String>();
public static List<Zhan> list = new ArrayList<Zhan>();
public static List<Zhan> listt = new ArrayList<Zhan>();
public static List<Zhan> list1 = new ArrayList<Zhan>();
public static List<Zhan> list2 = new ArrayList<Zhan>();
public static List<Zhan> list3 = new ArrayList<Zhan>();
public static List<ZhanDB> list_db = new ArrayList<ZhanDB>();
public static List<City> cityList = new ArrayList<City>();
private int yindaoye = 0;
MarkerOptions ooyes = null;
MarkerOptions oogift = null;
MarkerOptions oocity = null;
MarkerOptions oono = null;
MarkerOptions oo = null;
MarkerOptions oote = null;
private Marker mMarkerYes;
private Marker mMarkerNo;
private Marker mMarkerTe;
private Marker mMarkerTed;
private Marker mMarkerGift;
private Marker mMarkerCity;
private Marker keep = null;
private int sortTye = 1;
private SlideAdView sav;
private static TextView userLogin;
private float mPosX;
private float mCurPosX;
private float mPosY;
private float mCurPosY;
private TextView tv_msg_num;
BitmapDescriptor bdyes = BitmapDescriptorFactory.fromResource(R.drawable.icon_sgreen);
BitmapDescriptor bdgift = BitmapDescriptorFactory.fromResource(R.drawable.icon_sgift);
BitmapDescriptor bdno = BitmapDescriptorFactory.fromResource(R.drawable.icon_sorange);
BitmapDescriptor bigno = BitmapDescriptorFactory.fromResource(R.drawable.icon_borange);
BitmapDescriptor bigyes = BitmapDescriptorFactory.fromResource(R.drawable.icon_bgreen);
BitmapDescriptor biggift = BitmapDescriptorFactory.fromResource(R.drawable.icon_bgift);
public static boolean canRefreshthree = true;
public static boolean canRefreshtwo = true;
private boolean gestureguide;
private TextView mTvMarkerViewNum;
private TextView mTvMarkerViewNumAppB;
private TextView mTvMarkerViewNumAppS;
private ImageView mIvMarkerBg;
private ImageView mIvMarkerAppS;
private ImageView mIvMarkerAppB;
private TextView mTvMarkerViewNum1;
private ImageView mIvMarkerBg1;
private ImageView mIvMarkerBgYes;
private TextView mTvMarkerViewNumcity;
private ImageView mIvMarkerBgcity;
private ImageView iv_tuijian_close;
private ImageView iv_tuijian_tip_close;
private String againPoint = "";
private LoadingDialog dialog;
private LinearLayout tab_qa;
public static boolean isR = false;
private boolean isListShow = false;
private View mMarkerView;
private View mMarkerView1;
private View mMarkerViewAppS;
private View mMarkerViewAppB;
private View mMarkerViewYes;
private View mMarkerViewcity;
public static float now_zoom = 0;
private TextView tv_tishi, paoName, paoName1, paoAddress, paoCostWay, paoDaohang, paoDistance,
paoFast, paoSlow, paoAlter, paoTotal, tingche, fuwu, dian, tv_grade, tv_shaixuan, tv_recommend_tip,
tv_daohang, tvOne, tvTwo, tv_num, tvThree, tv_sortDistance, tv_sortStarLevel, iv_list, tv_sortFreeTime;
public static TextView tv_atCity;
public static RelativeLayout paoRl;
public static LinearLayout rl_control;
private RelativeLayout rela, ll_comment, rl_ad, rl_grade, rl_search, ll_paoxiang, rl_charging_notice;
private RelativeLayout tv_notice, tv_citynotice, rl_mapList, ll_tab_find;
private LinearLayout ll_paogo, ll_title, ll_open, tab_me, tab_screen;
public static LinearLayout ll_tuijian, ll_top_right;
private PopupWindow popupWindow;
private View popupWindowView;
private Button cancleButton;
private ListView lvZhan;
private ZhanAdapter adapter;
private long exitTime = 0;
private ImageView iv_clear;
private ImageView iv_sceen;
private ImageView iv_refresh, iv_route;
private ImageView iv_our;
private ImageView iv_tuijian;
private static ImageView inBtn;
private static ImageView outBtn;
private ImageView paopaoAd;
private ImageView iv_example;
private ImageView iv_clear_address;
private ImageView iv_bg_example;
private String now_versionCode, now_versionName, app_version, title;
private String login_meg = "";
private ImageView iv_yindaoye, iv_grade, iv_roadCondition, iv_find, iv_main, iv_screening;
private TextView tv_search, tv_main, tv_tuijian_feedback;
public static String comments_num;
private zhan_listDao zhan_listDao;
public static zhan_list current_chargePoint;
public static Marker nMarker;
private boolean paoShow = false;
private TextView windowName, windowGrade, windowCost, window_tv_fast_free_num, window_tv_fast_free_label, window_tv_fast_total_num,
window_tv_slow_free_label, window_tv_slow_free_num, window_tv_slow_total_num, windowCommentNum, windowDistance, stopCost;
private RelativeLayout windowGo, windowZhanDetails, windowComments;
private ImageView windowAd, windowGradeImg;
public static RelativeLayout windowLayout;
public static int question_unread = 0;
public static int comment_unread = 0;
public static int system_unread = 0;
public static int total_unread = 0;
public static boolean isStatusBack = false;
private static final int RC_CAMERA_PERM = 123;
private static final int RC_SAVE_PERM = 124;
private String adfloatUrl = "";
private UpdateDialog updateDialog;
//标识,用于判断是否只显示一次定位信息和用户重新定位
private boolean isFirstLoc = true;
private Handler myHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 0x01:
Bundle data = msg.getData();
String format = data.getString("format");
String f = data.getString("progress");
String s = f.substring(0, f.indexOf("."));
LogUtils.e(s);
updateDialog.updateMsg("当前已下载:" + format);
updateDialog.updateProgress(Integer.parseInt(s));
break;
}
}
};
private Handler hand = new Handler() {
public void handleMessage(android.os.Message msg) {
SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
switch (msg.what) {
//获取站点评论数
case 1:
try {
JSONObject jsonObject = new JSONObject(msg.obj.toString());
String comment_num = jsonObject.getString("rtnMsg");
comments_num = comment_num;
windowCommentNum.setText("评论(" + comment_num + ")");
// tv_num.setText("(" + comment_num + ")");
} catch (JSONException e) {
e.printStackTrace();
}
break;
//获取版本号及首页广告
case 2:
try {
String data = JsonUtils.getKeyResult(msg.obj.toString(), "data");
if (!data.equals("")) {
// 二手车广告
String adfloat = JsonUtils.getKeyResult(data, "ad_float");
if (adfloat != null && !adfloat.equals("")) {
List<Adin> listAdfloat = JsonUtils.parseToObjectList(adfloat, Adin.class);
if (listAdfloat.size() > 0) {
loadAdfloatImg(listAdfloat.get(0));
}
}
String adin = JsonUtils.getKeyResult(data, "adin");
if (null != adin) {
List<Adin> listAdin = JsonUtils.parseToObjectList(adin, Adin.class);
System.out.print("size:" + listAdin.size());
if (listAdin.size() > 0) {
sav.initData(listAdin);
rl_ad.setVisibility(View.VISIBLE);
for (Adin item : listAdin) {
if (item.getAdvertiser().equals("1")) {
loadDmpData();
break;
}
}
}
}
String version = JsonUtils.getKeyResult(data, "version");
com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray(version);
if (jsonArray != null) {
com.alibaba.fastjson.JSONObject version1 = jsonArray.getJSONObject(0);
String android = JsonUtils.getKeyResult(version1.toJSONString(), "android");
title = JsonUtils.getKeyResult(version1.toJSONString(), "title");
login_meg = JsonUtils.getKeyResult(version1.toJSONString(), "login_meg");
title = title.replace("\\n", "\n");
now_versionCode = JsonUtils.getKeyResult(android, "versionCode");
now_versionName = JsonUtils.getKeyResult(android, "versionName");
String[] key = now_versionName.split("\\.");
if (key.length - 1 > 2) {
dialogup_other();
} else {
dialogup();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
//获取站点数据
case 3:
try {
stringTid.clear();
if (socket != null) {
if (socket.isInputShutdown()) {
stringTid.clear();
}
}
String rtnCode = JsonUtils.getKeyResult(msg.obj.toString(), "rtnCode");
if (rtnCode.equals("03")) {
if (time_out < 3) {
ete("{\"fun\":\"timer\"}");
clickMarker = false;
// SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
// sharedPreferencesUtil.setFileName("CurrentMarkerInfo");
// sharedPreferencesUtil.clearData();
time_out++;
}
} else {
time_out = 0;
try {
String date = JsonUtils.getKeyResult(msg.obj.toString(), "data");
// Log.d("678543", date);
System.out.print("678543" + date);
// Log.e("ete1", "执行");
List<Zhan> mZhan = JsonUtils.parseToObjectList(date, Zhan.class);
System.out.print("222:" + mZhan.size());
// Log.e(TAG, "handleMessage: " + mZhan.size());
for (int i = 0; i < mZhan.size(); i++) {
Zhan aZhan = mZhan.get(i);
// System.err.println(aZhan.getZhan_name());
}
list.clear();
listt.clear();
list1.clear();
list2.clear();
list3.clear();
// aMap.clear();
if (mZhan != null && mZhan.size() > 0) {
list.addAll(mZhan);
listt.addAll(mZhan);
if (center != null) {
for (int i = 0; i < list.size(); i++) {
String wei = list.get(i).getPoi_wei().trim();
String jing = list.get(i).getPoi_jing().trim();
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));
}
double d = AMapUtils.calculateLineDistance(center, ll);
list.get(i).setDistance(Util.getDistance(d));
// if (mZhan.get(i).getSupplier().equals("特来电")) {
// stringTid.add(mZhan.get(i).getTid());
// getDetailThread(mZhan.get(i).getTid());
//// Log.e("Tid", mZhan.get(i).getTid());
// }
}
}
} else {
// showTextToast("没有合适的充电桩");
if (center != null) {
BitmapDescriptor point = BitmapDescriptorFactory
.fromResource(R.drawable.point_icon);
MarkerOptions oo = new MarkerOptions().position(center)
.anchor(0.5f, 0.5f).zIndex(7).icon(point)
.draggable(true);
aMap.addMarker(oo);
}
}
lvZhan.setAdapter(adapter);
lvZhan.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
MainApplication.details_flag = "2";
Intent intent = new Intent(getApplication(), NewZhanDetailsActivity.class);
intent.putExtra("zhan_id", list.get(position).getZhan_id());
startActivity(intent);
}
});
if (list.size() > 0) {
if (sortTye == 1) {
list = Util.getSortList(listt);
} else if (sortTye == 2) {
list = Util.getSortPFList(listt);
} else if (sortTye == 3) {
list = Util.getSortFTList(listt);
}
if (MainApplication.isMap == false) {
tv_tishi.setVisibility(View.GONE);
}
} else {
if (MainApplication.isMap == false) {
tv_tishi.setVisibility(View.VISIBLE);
}
}
adapter.notifyDataSetChanged();
} catch (Exception e) {
BitmapDescriptor point = BitmapDescriptorFactory
.fromResource(R.drawable.point_icon);
if (center != null) {
oo = new MarkerOptions().position(center).
anchor(0.5f, 0.5f).zIndex(7)
.draggable(true).icon(point);
aMap.addMarker(oo);
}
// Toast.makeText(getActivity(), "该范围内没有充电桩", Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
e.printStackTrace();
}
break;
//城市站点数量
case 4:
try {
// JSONObject jsonObj = new JSONObject(msg.obj.toString());
// String data = jsonObj.getString("data");
// String time = jsonObj.getString("time");
// String pic = jsonObj.getString("pic");
// Log.i("data-----",data);
//// Log.i("pic------",pic);
// String zhan_data = DES3.decode(data);
// Log.i("zhan_data-----",zhan_data);
//
//// Log.d("appTime---", DateUtils.getCurrentDate());
//
// long phpTime = Long.parseLong(time);
//
// Log.i("phpTime(long)---", phpTime+"");
// long appTime1 = System.currentTimeMillis()/1000;
// Log.i("appTime(long)---", appTime1+"");
// cha = appTime1 - phpTime;
// SharedPreferences mySharedPreferences= MainFragment.getSharedPreferences("userName",
// Activity.MODE_PRIVATE);
// SharedPreferences.Editor editor = mySharedPreferences.edit();
// editor.putInt("cha", cha);
// editor.commit();
// Log.d("cha(long)---", cha + "");
try {
String date = JsonUtils.getKeyResult(msg.obj.toString(), "data");
// Log.e("data", date);
Gson g = new Gson();
List<City> ll = g.fromJson(date, new TypeToken<List<City>>() {
}.getType());
stringTid.clear();
cityList.clear();
aMap.clear();
if (ll != null && ll.size() > 0) {
cityList.addAll(ll);
if (center != null) {
for (int i = 0; i < cityList.size(); i++) {
double dwei = Double.parseDouble(list.get(i).getPoi_wei());
double djing = Double.parseDouble(list.get(i).getPoi_jing());
LatLng lll = new LatLng(dwei, djing);
}
}
} else {
if (center != null) {
BitmapDescriptor point = BitmapDescriptorFactory
.fromResource(R.drawable.point_icon);
oo = new MarkerOptions().position(center)
.anchor(0.5f, 0.5f).zIndex(7).icon(point)
.draggable(false);
aMap.addMarker(oo);
}
}
// listt = list;
// if (list.size() > 0) {
// dialog.show();
// list = Util.getSortList(listt);
// list1 = list;
// dialog.cancel();
// }
// adapter.notifyDataSetChanged();
} catch (Exception e) {
BitmapDescriptor point = BitmapDescriptorFactory
.fromResource(R.drawable.point_icon);
oo = new MarkerOptions().position(center).
anchor(0.5f, 0.5f).zIndex(7)
.draggable(true).icon(point);
aMap.addMarker(oo);
// Toast.makeText(getActivity(),"该范围内没有充电桩",Toast.LENGTH_SHORT).show();
}
} catch (Exception e) {
e.printStackTrace();
}
break;
default:
break;
}
}
};
private View infoWindow;
private String zhanInfo;
private TextView windowChargeRecordCnt;
private View windowChargeRecordCntLine;
private TextView windowZongjia;
private LinearLayout windowZongjiaLayout;
private ImageView windowRedPaperBag;
private TextView windowLabelPublic;
private TextView windowLabelGround;
private TextView windowLabelFreePark;
private ConstraintLayout windowChat;
private LatLng markerPosition;
private ImageView second_hand_car;
private LinearLayout private_telephone;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AutoLayout.getInstance().auto(this);
setContentView(R.layout.activity_main_map);
BarColorUtil.initStatusBarColor(MainMapActivity.this);
m = this;
// mquery = new WeatherSearchQuery("北京", WeatherSearchQuery.WEATHER_TYPE_FORECAST);
// mweathersearch=new WeatherSearch(this);
// mweathersearch.setOnWeatherSearchListener(this);
// mweathersearch.setQuery(mquery);
// mweathersearch.searchWeatherAsyn(); //异步搜索
//
// mquery1 = new WeatherSearchQuery("北京", WeatherSearchQuery.WEATHER_TYPE_LIVE);
// mweathersearch1=new WeatherSearch(this);
// mweathersearch1.setOnWeatherSearchListener(this);
// mweathersearch1.setQuery(mquery1);
// mweathersearch1.searchWeatherAsyn(); //异步搜索
mainMapActivity = MainMapActivity.this;
intentFilter = new IntentFilter();
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
networkChangeReceiver = new NetworkChangeReceiver();
registerReceiver(networkChangeReceiver, intentFilter);
EventBusUtil.register(this);
if (MainApplication.ad_link.equals("1")) {
againPoint = "1";
is_dui = getIntent().getStringExtra("is_dui");
// Log.e("is_dui===", is_dui);
String url1 = getIntent().getStringExtra("shareUrl"); // web address
// Log.e("z222", url1);
if (is_dui.equals("0")) {
Intent intent2 = new Intent(getApplication(), HomeWebActivity.class);
// intent2.putExtra("shareUrl",url1);
intent2.putExtra("shareUrl", url1);
intent2.putExtra("shareTitle", getIntent().getStringExtra("shareTitle"));
intent2.putExtra("shareIcon", getIntent().getStringExtra("shareIcon"));
intent2.putExtra("shareContent", getIntent().getStringExtra("shareContent"));
intent2.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent2);
MainApplication.ad_link = "";
overridePendingTransition(0, 0);
} else {
long appTime11 = System.currentTimeMillis() / 1000;
// Log.e("sfv_url===", getIntent().getStringExtra("shareUrl"));
// Log.i("appTime(long)---", appTime11 + "");
long updatetime1 = appTime11 - MainMapActivity.cha - 5;
// Log.i("updatetime(long)---", updatetime1 + "");
// Log.i("cha---", MainMapActivity.cha + "");
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);
// startActivity(new Intent(getApplication(), ShopActivity.class));
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 = getIntent().getStringExtra("shareUrl");
// 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);
MainApplication.ad_link = "";
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();
}
};
}
// finish();
}
context = this;
gestureguide = ProfileManager.getInstance().getGestureguide(getApplicationContext());
// //开启logcat输出,方便debug,发布时请关闭
// XGPushConfig.enableDebug(this, false);
// XGPushManager.registerPush(context);
//
// Context context = getApplicationContext();
// Intent service = new Intent(context, XGPushService.class);
// context.startService(service);
dialog = new LoadingDialog(this);
dialog.setCanceledOnTouchOutside(false);
setUserData();
setlogin();
mMarkerView = LayoutInflater.from(this).inflate(R.layout.view_custom_marker, null);
mMarkerView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mMarkerViewYes = LayoutInflater.from(this).inflate(R.layout.view_custom_yes, null);
mMarkerViewYes.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mMarkerView1 = LayoutInflater.from(this).inflate(R.layout.view_custom_marker1, null);
mMarkerView1.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mMarkerViewcity = LayoutInflater.from(this).inflate(R.layout.view_custom_markercity, null);
mMarkerViewcity.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mMarkerViewAppS = LayoutInflater.from(this).inflate(R.layout.view_custom_marker_apps, null);
mMarkerViewAppS.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mMarkerViewAppB = LayoutInflater.from(this).inflate(R.layout.view_custom_marker_appb, null);
mMarkerViewAppB.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
initViews();
getRecyclerViewData();
File databasePath = getDatabasePath("zhan_list");
if (databasePath.exists()) {
eteinit("{\"fun\":\"timer\"}");
try {
getZhanData();
} catch (Exception e) {
e.printStackTrace();
}
} else {
LogUtils.e("不存在");
try {
initDataBase();
} catch (IOException e) {
e.printStackTrace();
}
}
showUi(MainApplication.isMap);
if (MainApplication.haveActivity == true) {
List<Adin> listAdin = JsonUtils.parseToObjectList("[" + MainApplication.ad_major + "]", Adin.class);
// System.out.print("size:" + listAdin.size());
if (listAdin.size() > 0) {
sav.initData(listAdin);
rl_ad.setVisibility(View.VISIBLE);
}
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (login_meg.equals("")) {
login_meg = "我知道你关注我很久了,快来注册登录吧,登录后可以在特来电、聚电科技充电桩扫码充电";
}
if (MainApplication.count == 2 || MainApplication.count == 24 || MainApplication.count == 44 || MainApplication.count == 64 || MainApplication.count == 84 || MainApplication.count == 104) {
if (MainApplication.isIgnore == true) {
new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
.setMsg(login_meg)
.setPositiveButton("去登录", new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(intent);
}
}).setNegativeButton("忽略", new View.OnClickListener() {
@Override
public void onClick(View v) {
MainApplication.isIgnore = false;
}
}).show();
MobclickAgent.onEvent(context, "0041");
}
}
}
}, 2000);
}
private void initViews() {
rl_charging_notice = (RelativeLayout) findViewById(R.id.rl_charging_notice);
rl_charging_notice.setOnClickListener(this);
tab_qa = (LinearLayout) findViewById(R.id.tab_qa);
tab_qa.setOnClickListener(this);
iv_guzhang = (ImageView) findViewById(R.id.iv_guzhang);
windowName = (TextView) findViewById(R.id.window_tv_zhan_name);
stopCost = findViewById(R.id.window_tv_stop_cost);
windowGrade = (TextView) findViewById(R.id.window_tv_zhan_grade);
windowCost = (TextView) findViewById(R.id.window_tv_zhan_cost);
private_telephone = findViewById(R.id.private_telephone);
window_tv_fast_free_num = (TextView) findViewById(R.id.window_tv_fast_free_num);
window_tv_fast_free_label = findViewById(R.id.window_tv_fast_free_label);
window_tv_fast_total_num = findViewById(R.id.window_tv_fast_total_num);
window_tv_slow_free_label = findViewById(R.id.window_tv_slow_free_label);
window_tv_slow_free_num = findViewById(R.id.window_tv_slow_free_num);
window_tv_slow_total_num = findViewById(R.id.window_tv_slow_total_num);
windowCommentNum = (TextView) findViewById(R.id.window_tv_comment_num);
// windowDistance = (TextView) findViewById(R.id.window_tv_zhan_distance);
windowChargeRecordCnt = findViewById(R.id.window_tv_charge_record_cnt);
windowChargeRecordCntLine = findViewById(R.id.window_tv_charge_record_cnt_line);
windowZongjia = findViewById(R.id.window_tv_zongjia);
windowZongjiaLayout = findViewById(R.id.window_tv_zongjia_layout);
windowRedPaperBag = findViewById(R.id.iv_red_paper_bag);
windowLabelPublic = findViewById(R.id.iv_label_public);
windowLabelGround = findViewById(R.id.iv_label_ground);
windowLabelFreePark = findViewById(R.id.iv_label_free_park);
// windowChat = findViewById(R.id.iv_chat);
windowGo = (RelativeLayout) findViewById(R.id.window_rl_go);
windowZhanDetails = (RelativeLayout) findViewById(R.id.window_rl_zhan_details);
windowComments = (RelativeLayout) findViewById(R.id.window_rl_comment);
windowAd = (ImageView) findViewById(R.id.window_iv_ad);
windowGradeImg = (ImageView) findViewById(R.id.window_iv_zhan_grade);
iv_tuijian_close = (ImageView) findViewById(R.id.iv_tuijian_close);
iv_tuijian_tip_close = (ImageView) findViewById(R.id.iv_tuijian_tip_close);
iv_tuijian_close.setOnClickListener(this);
iv_tuijian_tip_close.setOnClickListener(this);
ll_recommend = (LinearLayout) findViewById(R.id.ll_recommend);
tv_recommend_tip = (TextView) findViewById(R.id.tv_recommend_tip);
tv_tuijian_feedback = (TextView) findViewById(R.id.tv_tuijian_feedback);
tv_tuijian_feedback.setOnClickListener(this);
ll_map_control = (LinearLayout) findViewById(R.id.ll_map_control);
windowLayout = (RelativeLayout) findViewById(R.id.window_ll_zhan);
ll_top_right = (LinearLayout) findViewById(R.id.ll_top_right);
iv_tuijian = (ImageView) findViewById(R.id.iv_tuijian);
iv_route = (ImageView) findViewById(R.id.iv_route);
second_hand_car = findViewById(R.id.second_hand_car);
iv_tuijian.setOnClickListener(this);
iv_route.setOnClickListener(this);
second_hand_car.setOnClickListener(this);
iVpoint = findViewById(R.id.iv_point);
window_ll_zhan = (RelativeLayout) findViewById(R.id.window_ll_zhan);
tv_search = (TextView) findViewById(R.id.tv_search);
tv_msg_num = (TextView) findViewById(R.id.tv_msg_num);
tv_shaixuan = (TextView) findViewById(R.id.tv_shaixuan);
tv_shaixuan.setOnClickListener(this);
iv_example = (ImageView) findViewById(R.id.iv_example);
iv_example.setOnClickListener(this);
iv_clear_address = (ImageView) findViewById(R.id.iv_clear_address);
iv_clear_address.setOnClickListener(this);
ll_tuijian = (LinearLayout) findViewById(R.id.ll_tuijian);
ll_tuijian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e(TAG, "onClick: 333");
}
});
ll_tuijian.setOnTouchListener(new View.OnTouchListener() {
float mCurPosX, mCurPosY, mPosX, mPosY;
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_UP:
mCurPosX = event.getX();
mCurPosY = event.getY();
Log.e(TAG, "onTouch: 111");
break;
case MotionEvent.ACTION_DOWN:
mPosX = event.getX();
mPosY = event.getY();
Log.e(TAG, "onTouch: 222");
break;
case MotionEvent.ACTION_MOVE:
if (mCurPosY - mPosY > 0
&& (Math.abs(mCurPosY - mPosY) > 25)) {
Log.e(TAG, "onTouch: 向下滑動");
//向下滑動
} else if (mCurPosY - mPosY < 0
&& (Math.abs(mCurPosY - mPosY) > 25)) {
Log.e(TAG, "onTouch: 向上滑动");
//向上滑动
}
Log.e(TAG, "onTouch: qqqq");
break;
}
return false;
}
});
// add by hyg 气泡红包图标点击操作
windowRedPaperBag.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent_example = new Intent(getApplicationContext(), ExampleActivity.class);
intent_example.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent_example);
overridePendingTransition(0, 0);
}
});
tv_sortDistance = (TextView) findViewById(R.id.tv_sortDistance);
tv_sortDistance.setOnClickListener(this);
tv_sortStarLevel = (TextView) findViewById(R.id.tv_sortStarLevel);
tv_sortStarLevel.setOnClickListener(this);
tv_sortFreeTime = (TextView) findViewById(R.id.tv_sortFreeTime);
tv_sortFreeTime.setOnClickListener(this);
rl_mapList = (RelativeLayout) findViewById(R.id.rl_mapList);
iv_roadCondition = (ImageView) findViewById(R.id.iv_roadCondition);
iv_roadCondition.setOnClickListener(this);
iv_yindaoye = (ImageView) findViewById(R.id.iv_yindaoye);
iv_yindaoye.setOnClickListener(this);
rl_grade = (RelativeLayout) findViewById(R.id.rl_grade);
iv_grade = (ImageView) findViewById(R.id.iv_grade);
tv_grade = (TextView) findViewById(R.id.tv_grade);
userLogin = (TextView) findViewById(R.id.tv_userLogin);
mTvMarkerViewNum = (TextView) mMarkerView.findViewById(R.id.tv_num);
mTvMarkerViewNumAppS = (TextView) mMarkerViewAppS.findViewById(R.id.tv_num);
mTvMarkerViewNumAppB = (TextView) mMarkerViewAppB.findViewById(R.id.tv_num);
mIvMarkerBg = (ImageView) mMarkerView.findViewById(R.id.iv_icon);
mIvMarkerAppS = (ImageView) mMarkerViewAppS.findViewById(R.id.iv_icon);
mIvMarkerAppB = (ImageView) mMarkerViewAppB.findViewById(R.id.iv_icon);
mTvMarkerViewNum1 = (TextView) mMarkerView1.findViewById(R.id.tv_num);
mIvMarkerBg1 = (ImageView) mMarkerView1.findViewById(R.id.iv_icon);
mIvMarkerBgYes = (ImageView) mMarkerViewYes.findViewById(R.id.iv_icon);
mIvMarkerBgcity = (ImageView) mMarkerViewcity.findViewById(R.id.iv_icon);
mTvMarkerViewNumcity = (TextView) mMarkerViewcity.findViewById(R.id.tv_num);
//用户中心图标
iv_our = (ImageView) findViewById(R.id.iv_our);
//首页广告
rl_ad = (RelativeLayout) findViewById(R.id.rl_ad);
//首页广告pager
sav = (SlideAdView) findViewById(R.id.imageView8);
//首页广告关闭按钮
iv_clear = (ImageView) findViewById(R.id.iv_clear);
iv_clear.setOnClickListener(this);
tv_citynotice = (RelativeLayout) findViewById(R.id.tv_citynotice);
tv_citynotice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tv_citynotice.setVisibility(View.GONE);
tv_notice.setVisibility(View.GONE);
city_no = 1;
}
});
ll_tab_find = (RelativeLayout) findViewById(R.id.ll_tab_find);
ll_tab_find.setOnClickListener(this);
tab_screen = (LinearLayout) findViewById(R.id.tab_screening);
tab_screen.setOnClickListener(this);
tab_me = (LinearLayout) findViewById(R.id.tab_me);
tab_me.setOnClickListener(this);
// if (firstOpen == true) {
// getVersion();
//// eteinit("{\"fun\":\"timer\"}");
// getMessage();
//// clickMarker = false;
// firstOpen = false;
// }
// getMessage();
inBtn = (ImageView) findViewById(R.id.zoomin);
inBtn.setOnClickListener(this);
outBtn = (ImageView) findViewById(R.id.zoomout);
outBtn.setOnClickListener(this);
//站点地图列表切换按钮
iv_list = (TextView) findViewById(R.id.iv_list);
iv_list.setOnClickListener(this);
SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
//站点列表
lvZhan = (ListView) findViewById(R.id.lv_zhan_list);
adapter = new ZhanAdapter();
//条件筛选按钮
iv_sceen = (ImageView) findViewById(R.id.tv_person);
iv_sceen.setOnClickListener(this);
rl_control = (LinearLayout) findViewById(R.id.rl_control);
tv_tishi = (TextView) findViewById(R.id.tv_tishi);
//切换城市按钮
tv_atCity = (TextView) findViewById(R.id.tv_switch_city);
tv_atCity.setOnClickListener(this);
ll_open = (LinearLayout) findViewById(R.id.ll_open);
//显示该站点评论数量
tv_num = (TextView) findViewById(R.id.tv_num);
//定位按钮
iv_refresh = (ImageView) findViewById(R.id.iv_point_again);
iv_refresh.setOnClickListener(this);
paoRl = (RelativeLayout) findViewById(R.id.rela_paopao);
paoName = (TextView) findViewById(R.id.window_tv_zhan_name);
paoName.setFocusable(true);
paoAddress = (TextView) findViewById(R.id.tv_address);
paoCostWay = (TextView) findViewById(R.id.window_tv_zhan_cost);
paoDaohang = (TextView) findViewById(R.id.detail_daohang);
// paoDistance = (TextView) findViewById(R.id.window_tv_zhan_distance);
paoFast = (TextView) findViewById(R.id.tv_fastNum);
paoSlow = (TextView) findViewById(R.id.tv_slowNum);
paoAlter = (TextView) findViewById(R.id.tv_detail_alter);
paoTotal = (TextView) findViewById(R.id.tv_totalNum);
paopaoAd = (ImageView) findViewById(R.id.window_iv_ad);
tv_daohang = (TextView) findViewById(R.id.tv_daohang);
rela = (RelativeLayout) findViewById(R.id.rela);
ll_comment = (RelativeLayout) findViewById(R.id.window_rl_comment);
ll_paoxiang = (RelativeLayout) findViewById(R.id.window_rl_go);
rl_tuijian_tip = (RelativeLayout) findViewById(R.id.rl_tuijian_tip);
rl_tuijian_tip.setOnClickListener(this);
ll_paogo = (LinearLayout) findViewById(R.id.ll_paogo);
tingche = (TextView) findViewById(R.id.tv_park);
fuwu = (TextView) findViewById(R.id.tv_service);
dian = (TextView) findViewById(R.id.tv_charge);
rl_search = (RelativeLayout) findViewById(R.id.rl_search);
rl_search.setOnClickListener(this);
// tv_detail_alter.setOnClickListener(this);
ll_title = (LinearLayout) findViewById(R.id.ll_title);
if (aMap == null) {
aMap = mapView.getMap();
Util.setMapCustomStyleFile(aMap, getApplicationContext());
maxZoomLevel = aMap.getMaxZoomLevel();
minZoomLevel = aMap.getMinZoomLevel();
MyLocationStyle myLocationStyle = new MyLocationStyle();
myLocationStyle.myLocationIcon(BitmapDescriptorFactory
.fromResource(R.drawable.point_icon));// 设置小蓝点的图标
myLocationStyle.strokeColor(getResources().getColor(R.color.transparent));
myLocationStyle.radiusFillColor(getResources().getColor(R.color.transparent));
aMap.setMyLocationStyle(myLocationStyle);
mUiSettings = aMap.getUiSettings();
setUpMap();
}
iv_find = (ImageView) findViewById(R.id.iv_find);
iv_main = (ImageView) findViewById(R.id.iv_main);
iv_screening = (ImageView) findViewById(R.id.iv_screening);
tv_main = (TextView) findViewById(R.id.tv_main);
if (MainApplication.festival_time.equals("1")) {
iv_screening.setImageResource(R.drawable.icon_cj2);
iv_main.setImageResource(R.drawable.icon_cj1);
iv_find.setImageResource(R.drawable.icon_cj3);
tv_main.setTextColor(getResources().getColor(R.color.jieri));
iv_list.setTextColor(getResources().getColor(R.color.white));
ll_title.setBackgroundResource(R.color.jieri);
tv_atCity.setTextColor(getResources().getColor(R.color.white));
Drawable nav_up = getResources().getDrawable(R.drawable.iocn_down_white);
nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
tv_atCity.setCompoundDrawables(null, null, nav_up, null);
} else if (MainApplication.festival_time.equals("2")) {
iv_screening.setImageResource(R.drawable.icon_yx2);
iv_main.setImageResource(R.drawable.icon_yx1);
iv_find.setImageResource(R.drawable.icon_yx3);
tv_main.setTextColor(getResources().getColor(R.color.jieri));
iv_list.setTextColor(getResources().getColor(R.color.white));
ll_title.setBackgroundResource(R.color.jieri);
tv_atCity.setTextColor(getResources().getColor(R.color.white));
Drawable nav_up = getResources().getDrawable(R.drawable.iocn_down_white);
nav_up.setBounds(0, 0, nav_up.getMinimumWidth(), nav_up.getMinimumHeight());
tv_atCity.setCompoundDrawables(null, null, nav_up, null);
}
}
private void loadAdfloatImg(Adin adin) {
adfloatUrl = adin.getUrl();
Glide.with(this).load(MainApplication.url + "/zhannew/uploadfile/" + adin.getIcon()).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
second_hand_car.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
second_hand_car.setVisibility(View.VISIBLE);
return false;
}
}).into(second_hand_car);
}
/**
* 设置一些amap的属性
*/
private void setUpMap() {
// aMap.setOnMarkerClickListener(this);// 设置点击marker事件监听器
aMap.setOnCameraChangeListener(this);
aMap.setLocationSource(this);// 设置定位监听
aMap.setOnMapClickListener(this);
aMap.setOnMarkerClickListener(this);
aMap.setInfoWindowAdapter(this);
aMap.setOnInfoWindowClickListener(this);
aMap.setOnMapLoadedListener(this);// 设置amap加载成功事件监听器
aMap.getUiSettings().setMyLocationButtonEnabled(false);// 设置默认定位按钮是否显示
aMap.getUiSettings().setZoomControlsEnabled(false);// 设置默认缩放按钮是否显示
aMap.getUiSettings().setScaleControlsEnabled(true);// 设置比例尺是否显示
aMap.getUiSettings().setRotateGesturesEnabled(false);// 设置地图是否旋转
// aMap.getUiSettings().setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_CENTER);
aMap.setTrafficEnabled(true);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
/**
* 方法必须重写
*/
@Override
protected void onResume() {
super.onResume();
String search_address = ProfileManager.getInstance().getSearchAddress(this);
if (search_address.equals("")) {
tv_search.setText("请输入地址/关键字");
iv_clear_address.setVisibility(View.INVISIBLE);
} else {
tv_search.setText(search_address);
iv_clear_address.setVisibility(View.VISIBLE);
}
String from = getIntent().getStringExtra("from");
if ("search_from_activity".equals(from)) {
searchAll();
}
if (FindActivity.haveFindMessage == true) {
iVpoint.setVisibility(View.VISIBLE);
} else {
iVpoint.setVisibility(View.GONE);
}
saveTask();
if (MainApplication.haveActivity == false) {
if (MainApplication.isLogin() && MainApplication.isAppStart == true) {
userChargingCheck();
} else {
rl_charging_notice.setVisibility(View.GONE);
}
getMessageNum();
}
if (onResumeRefresh == true) {
try {
getZhanData();
} catch (Exception e) {
e.printStackTrace();
}
onResumeRefresh = false;
}
if (ProfileManager.getInstance().getRoadCondition(getApplicationContext()) == false) {
iv_roadCondition.setImageResource(R.drawable.icon_wulukuang_main);
aMap.setTrafficEnabled(false);
} else {
iv_roadCondition.setImageResource(R.drawable.icon_youlukuang_main);
aMap.setTrafficEnabled(true);
}
mapView.onResume();
if (againPoint.equals("1") && back.equals("1")) {
if (!isFirstLoc) {
isFirstLoc = true;
mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
aMap.setLocationSource(this);// 设置定位监听
aMap.setMyLocationEnabled(true);// 是否可触发定位并显示定位层
aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
mlocationClient.startLocation();
}
againPoint = "";
back = "";
}
detailsBack = false;
changeButton();
}
private void searchAll() {
if ("请输入地址/关键字".equals(tv_search.getText().toString())) {
if (search_marker != null) {
search_marker.remove();
}
return;
}
double jing = Double.valueOf(getIntent().getStringExtra("jing"));
double wei = Double.valueOf(getIntent().getStringExtra("wei"));
MainApplication.search_jing = jing;
MainApplication.search_wei = wei;
final LatLng screenCity = new LatLng(wei, jing);
aMap = mapView.getMap();
Util.setMapCustomStyleFile(aMap, getApplicationContext());
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(screenCity, 14.0f));
}
}, 500);
if (search_marker != null) {
search_marker.remove();
}
if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
LatLng latLng = new LatLng(MainApplication.search_wei, MainApplication.search_jing);
search_marker = aMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.icon_search_address))));
search_marker.setPeriod(8);
}
ete("{\"fun\":\"timer\"}");
}
/**
* 方法必须重写
*/
@Override
protected void onPause() {
super.onPause();
mapView.onPause();
// Log.e("onPause", "onPause");
deactivate();
}
/**
* 方法必须重写
*/
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
// Log.e("onSaveInstanceState", "onSaveInstanceState");
}
/**
* 方法必须重写
*/
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(networkChangeReceiver);
if (mClusterOverlay != null) {
mClusterOverlay.onDestroy();
}
mapView.onDestroy();
EventBusUtil.unregister(this);
// Log.e("onDestroy", "onDestroy");
if (null != mlocationClient) {
mlocationClient.onDestroy();
}
OkHttpUtils.getInstance().cancelTag(MainMapActivity.this);
SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
sharedPreferencesUtil.setFileName("CurrentMarkerInfo");
sharedPreferencesUtil.clearData();
}
@Override
public void activate(OnLocationChangedListener listener) {
mListener = listener;
if (mlocationClient == null) {
mlocationClient = new AMapLocationClient(this);
mLocationOption = new AMapLocationClientOption();
//设置定位监听
mlocationClient.setLocationListener(this);
//设置为高精度定位模式
mLocationOption.setLocationMode(AMapLocationMode.Battery_Saving);
// mLocationOption.setGpsFirst(true);
// mLocationOption.setOnceLocation(true);
mLocationOption.setInterval(1500);
//设置是否强制刷新WIFI,默认为强制刷新
// mLocationOption.setWifiActiveScan(true);
//设置定位参数
mlocationClient.setLocationOption(mLocationOption);
// 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
// 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求
// 在定位结束后,在合适的生命周期调用onDestroy()方法
// 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除
// 设置是否只定位一次,默认为false
mLocationOption.setOnceLocation(false);
//设置是否强制刷新WIFI,默认为强制刷新
//mLocationOption.setWifiActiveScan(false);
mLocationOption.setWifiScan(true);
mlocationClient.startLocation();
}
}
@Override
public void deactivate() {
mListener = null;
if (mlocationClient != null) {
mlocationClient.stopLocation();
mlocationClient.onDestroy();
}
mlocationClient = null;
}
@Override
public void onLocationChanged(AMapLocation amapLocation) {
if (mListener != null && amapLocation != null) {
if (amapLocation != null && amapLocation.getErrorCode() == 0) {
try {
MainApplication.atCity = amapLocation.getCity().substring(0, amapLocation.getCity().length() - 1);
location_city = MainApplication.atCity;
tv_atCity.setText(MainApplication.atCity);
} catch (NullPointerException e) {
e.printStackTrace();
}
ProfileManager.getInstance().setAtCity(getApplicationContext(), MainApplication.atCity);
center = new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude());
MainApplication.center = center;
ete("{\"fun\":\"timer\"}");
mlocationClient.stopLocation();
if (MainApplication.haveActivity == false) {
getBaidu(amapLocation.getLongitude(), amapLocation.getLatitude());
String uid;
if (MainApplication.isLogin()) {
uid = MainApplication.userId;
} else {
uid = "";
}
String url = "{\"fun\":\"dingwei\",\"poi_jing\":" + "\"" + String.format("%.6f", bd_lon) +
"\"" + ",\"poi_wei\":" + "\"" + String.format("%.6f", bd_lat) + "\"" + ",\"imei\":"
+ "\"" + "android_" + Util.getUdid() + "\"" + ",\"timer\":" + "\"" + Token
+ "\"" + ",\"registration_id\":" + "\"" + MainApplication.getInstance().getPushID() + "\""
+ ",\"userid\":" + "\"" + uid + "\"" + "}";
eteLocation(url);
}
if (isFirstLoc) {
//设置缩放级别
//将地图移动到定位点
aMap.moveCamera(CameraUpdateFactory.changeLatLng(center));
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
}
}, 2000);
//点击定位按钮 能够将地图的中心移动到定位点
mListener.onLocationChanged(amapLocation);
isFirstLoc = false;
}
} else {
String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
// Log.e("AmapErr", errText);
// mLocationErrText.setVisibility(View.VISIBLE);
Toast.makeText(this, errText, Toast.LENGTH_SHORT).show();
}
}
}
//地图缩放方法
public static void controlZoomShow() {
if (aMap != null) {
float zoom = aMap.getCameraPosition().zoom;
Log.e(TAG, "controlZoomShow: " + zoom);
try {
if (zoom >= maxZoomLevel) {
inBtn.setImageResource(R.drawable.icon_zoom_in_no);
inBtn.setEnabled(false);
// Toast.makeText(getApplication(), "已放大到最大级别", Toast.LENGTH_SHORT)
// .show();
return;
} else {
inBtn.setImageResource(R.drawable.icon_zoom_in_yes);
inBtn.setEnabled(true);
}
if (zoom <= minZoomLevel) {
outBtn.setImageResource(R.drawable.icon_zoom_out_no);
outBtn.setEnabled(false);
// Toast.makeText(getApplication(), "已缩小到最小级别", Toast.LENGTH_SHORT)
// .show();
return;
} else {
outBtn.setImageResource(R.drawable.icon_zoom_out_yes);
outBtn.setEnabled(true);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public void eteinit(final String params) {
// LogUtils.e("11111");
new Thread(new Runnable() {
@Override
public void run() {
try {
String host = "";
if (MainApplication.url.contains("cdz.evcharge.cc")) {
host = "cdz.evcharge.cc";
} else {
host = "59.110.68.162";
}
socket = new Socket(host, 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();
token = msg;
int time = (int) (System.currentTimeMillis() / 1000);
cha = time - Integer.parseInt(msg);
Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty");
ete2("{\"fun\":\"init\",\"timer\":" + "\"" + Token + "\"" + "}");
MainApplication.uptime = ProfileManager.getInstance().getDataUptime(getApplicationContext());
newUpdataZhanData(Token, MainApplication.uptime);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void newUpdataZhanData(String token, String uptime) {
String url = MainApplication.url + ":9080/update_db";
OkHttpUtils.get().url(url)
.addParams("timer", token)
.addParams("uptime", uptime)
.build().execute(new StringCallback() {
@Override
public void onError(Call call, Exception e) {
e.printStackTrace();
}
@Override
public void onResponse(String response) {
String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
if ("0".equals(rtnCode)) {
String data = JsonUtils.getKeyResult(response, "data");
if (EmptyUtils.isNotEmpty(data)) {
final List<UpdateZhanDataBean> list = JsonUtils.parseToObjectList(data, UpdateZhanDataBean.class);
if (list.size() > 0) {
new Thread(new Runnable() {
@Override
public void run() {
dealUpdateData(list);
}
}).start();
}
}
}
}
});
}
private void dealUpdateData(List<UpdateZhanDataBean> list) {
String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
String uptime = "";
try {
SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
db.beginTransaction();//开始事务
try {
for (int i = 0; i < list.size(); i++) {
UpdateZhanDataBean bean = list.get(i);
ContentValues cv = new ContentValues();
cv.put("id", bean.getId());
cv.put("status", bean.getStatus());
cv.put("poi_jing", bean.getPoi_jing());
cv.put("poi_wei", bean.getPoi_wei());
cv.put("total_num", bean.getTotal_num());
cv.put("fast_num", bean.getFast_num());
cv.put("slow_num", bean.getSlow_num());
cv.put("charge_cost_way", bean.getCharge_cost_way());
cv.put("city", bean.getCity());
cv.put("belong_attribute", bean.getBelong_attribute());
cv.put("suit_car", bean.getSuit_car());
cv.put("own_pay", bean.getOwn_pay());
cv.put("supplier", bean.getSupplier());
cv.put("stop_cost", bean.getStop_cost());
cv.put("zhuang_num", bean.getZhuang_num());
long mub = db.replace("zhan_list", null, cv);
if (mub > 0) {
uptime = bean.getUptime();
// LogUtils.e("添加成功: id = " + bean.getId() + ", uptime = " + ProfileManager.getInstance().getDataUptime(getApplicationContext()));
} else {
// LogUtils.e("添加失败---" + bean.getId());
}
}
db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务
} catch (Exception e) {
e.printStackTrace();
} finally {
db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务
}
db.close();
} catch (Exception e) {
e.printStackTrace();
}
if (!"".equals(uptime)) {
ProfileManager.getInstance().setDataUptime(getApplicationContext(), uptime);
}
}
public void ete(final String params) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String host = "";
if (MainApplication.url.contains("cdz.evcharge.cc")) {
host = "cdz.evcharge.cc";
} else {
host = "59.110.68.162";
}
socket = new Socket(host, 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();
token = msg;
// Log.e("msg===", msg);
int time = (int) (System.currentTimeMillis() / 1000);
cha = time - Integer.parseInt(msg);
Token = getMD5(String.valueOf((System.currentTimeMillis() / 1000 - cha) / 10) + "qwerty");
// Log.e("Token===", System.currentTimeMillis() / 1000 - cha + "");
// Point p1 = new Point(0, 0);
// LatLng locLeftTop = mapView.getMap().getProjection().fromScreenLocation(p1);
// Point p2 = new Point(MainApplication.mScreenWidth, mapView
// .getHeight());
// LatLng llRightBottom = mapView.getMap().getProjection()
// .fromScreenLocation(p2);
// System.out.print("qazwsx:"+url);
if (MainApplication.userTpye == "") {
MainApplication.userTpye = "1";
}
// getBaidu(locLeftTop.longitude - 0.01, locLeftTop.latitude + 0.01);
// getBaidu1(llRightBottom.longitude + 0.01, llRightBottom.latitude - 0.01);
// String own_pay = "";
// if (MainApplication.support.equals("true")) {
// own_pay = "1";
// } else {
// own_pay = "";
// }
String llon, llat, rlon, rlat;
if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
llon = String.valueOf(MainApplication.search_jing - 0.047414454728858857);
llat = String.valueOf(MainApplication.search_wei + 0.047414454728858857);
rlon = String.valueOf(MainApplication.search_jing + 0.047414454728858857);
rlat = String.valueOf(MainApplication.search_wei - 0.041842459916509256);
} else {
llon = String.valueOf(center.longitude - 0.047414454728858857);
llat = String.valueOf(center.latitude + 0.047414454728858857);
rlon = String.valueOf(center.longitude + 0.047414454728858857);
rlat = String.valueOf(center.latitude - 0.041842459916509256);
}
// Log.e("ggg", llon);
HashMap<String, String> map = new HashMap<String, String>();
map.put("fun", "zhangetlist");
map.put("poi_lux", llon);
map.put("poi_luy", llat);
map.put("poi_rdx", rlon);
map.put("poi_rdy", rlat);
map.put("suit_car2", MainApplication.userTpye);
map.put("status", MainApplication.mapStatus);
map.put("charge_cost_way", "");
map.put("belong_attribute", MainApplication.shuxing);
map.put("speed", MainApplication.sudu);
map.put("timer", Token);
map.put("supplier", MainApplication.costWay);
map.put("stop_free", MainApplication.mianStop);
int hotel, expressway, jingdian;
if (MainApplication.selecthotel.equals("true")) {
MainApplication.selecthotel = "true";
ProfileManager.getInstance().setSelecthotel(MainMapActivity.this, "true");
hotel = 1;
} else {
MainApplication.selecthotel = "false";
ProfileManager.getInstance().setSelecthotel(MainMapActivity.this, "false");
hotel = 0;
;
}
if (MainApplication.selectexpressway.equals("true")) {
MainApplication.selectexpressway = "true";
ProfileManager.getInstance().setSelectExpressway(MainMapActivity.this, "true");
expressway = 2;
} else {
MainApplication.selectexpressway = "false";
ProfileManager.getInstance().setSelectExpressway(MainMapActivity.this, "false");
expressway = 0;
;
}
if (MainApplication.selectjingdian.equals("true")) {
MainApplication.selectjingdian = "true";
ProfileManager.getInstance().setKeySelectjingdian(MainMapActivity.this, "true");
jingdian = 4;
} else {
MainApplication.selectjingdian = "false";
ProfileManager.getInstance().setKeySelectjingdian(MainMapActivity.this, "false");
jingdian = 0;
;
}
int total = hotel + expressway + jingdian;
String num;
if (total == 0) {
num = "";
} else {
num = String.valueOf(total);
}
map.put("zhuang_num", num);
if (ProfileManager.getInstance().getSupport(getApplicationContext()).equals("true")) {
map.put("own_pay", "1");
} else {
map.put("own_pay", "");
}
String socket_string = JsonUtils.mapToJson(map);
// Log.e("socket_string", socket_string);
// String url = "{\"fun\":\"zhangetlist\",\"poi_lux\":" + "\"" + bd_lon + "\"" + ",\"poi_luy\":" + "\"" + bd_lat + "\"" + ",\"poi_rdx\":" + "\"" + bd_jing + "\"" + ",\"poi_rdy\":" + "\"" + bd_wei + "\"" + ",\"suit_car2\":" + "\"" + MainApplication.userTpye + "\"" + ",\"status\":" + "\"" + MainApplication.mapStatus + "\"" + ",\"charge_cost_way\":" + "\"" + "\"" + ",\"belong_attribute\":" + "\"" + MainApplication.shuxing + "\"" + ",\"speed\":" + "\"" + MainApplication.sudu + "\"" + ",\"timer\":" + "\"" + Token + "\"" + ",\"supplier\":" + "\"" + MainApplication.costWay + "\"" + "}";
// String url = "{\"fun\":\"zhangetlist\",\"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 + "\"" + ",\"belong_attribute\":" + "\"" + MainApplication.shuxing + "\"" + ",\"speed\":" + "\"" + MainApplication.sudu + "\"" + ",\"timer\":" + "\"" + Token + "\"" + "}";
// Log.d("wwwww", url);
ete1(socket_string);
// Log.e("ete", "执行");
} catch (Exception e) {
}
}
}).start();
}
private void changeButton() {
if (MainApplication.userTpye.equals("5") && MainApplication.mapStatus.equals("4") && MainApplication.shuxing.equals("") && MainApplication.sudu.equals("0") && MainApplication.costWay.equals("") && MainApplication.mianStop.equals("")) {
iv_sceen.setImageResource(R.drawable.icon_screen_main);
} else {
iv_sceen.setImageResource(R.drawable.icon_screen_main_selected);
}
}
public void updateZhanData(final String params) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String host = "";
if (MainApplication.url.contains("cdz.evcharge.cc")) {
host = "cdz.evcharge.cc";
} else {
host = "59.110.68.162";
}
socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
socket.setReceiveBufferSize(1000000000);
// 向服务器发送消息
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();
if (null != msg) {
Log.d("msg=====update", msg);
String maxid = JsonUtils.getKeyResult(msg, "maxid");
Log.e(TAG, "run: max_id=" + maxid);
if (null != maxid && Integer.parseInt(maxid) > Integer.parseInt(MainApplication.logid)) {
MainApplication.logid = maxid;
ProfileManager.getInstance().setLogid(getApplicationContext(), maxid);
String data = JsonUtils.getKeyResult(msg, "data");
Log.e("updateZhanData===data", data);
Gson g = new Gson();
if (null != data) {
Log.e(TAG, "run: 有更新");
String add = JsonUtils.getKeyResult(data, "add");
if (null != add) {
if (!add.equals("")) {
List<DataRefresh> list_add = g.fromJson(add, new TypeToken<List<DataRefresh>>() {
}.getType());
Log.e("list_add===", list_add.size() + "");
addData(list_add);
} else {
// Log.e("updateZhanData===", "add_null");
}
}
String up = JsonUtils.getKeyResult(data, "up");
// Log.e("updateZhanData===up", up);
if (null != up) {
List<DataRefresh> list_up = g.fromJson(up, new TypeToken<List<DataRefresh>>() {
}.getType());
Log.e("list_up===", list_up.size() + "");
upData(list_up);
} else {
// Log.e("updateZhanData===", "up_null");
}
String del = JsonUtils.getKeyResult(data, "del");
if (del != null) {
List<DataRefresh> list_del = g.fromJson(del, new TypeToken<List<DataRefresh>>() {
}.getType());
Log.e("list_del===", list_del.size() + "");
if (null != del || list_del.size() > 0) {
delData(list_del);
} else {
// Log.e("updateZhanData===", "del_null");
}
}
} else {
// Log.e("updateZhanData===", "data == null");
}
} else {
// Log.e(TAG, "run: 没有更新");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void eteLocation(final String params) {
new Thread(new Runnable() {
@Override
public void run() {
try {
// 创建Socket
// socket = new Socket("192.168.1.110",54321);
// if (mapView.getMap().getMapStatus().zoom < 9.5f) {
// socket.close();
// stringTid.clear();
// } else
{
String host = "";
if (MainApplication.url.contains("cdz.evcharge.cc")) {
host = "cdz.evcharge.cc";
} else {
host = "59.110.68.162";
}
socket = new Socket(host, 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 = 5;
hand.sendMessage(mes);
}
// if (msg != null) {
// // mTextView.setText(msg);
// } else {
// // mTextView.setText("数据错误!");
// }
// System.err.println("msg:"+msg);
// String t1 = String.valueOf(new Date().getTime()/1000);
// System.err.println(t1);
// 关闭流
out.close();
br.close();
// 关闭Socket
socket.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
public void ete1(final String params) {
new Thread(new Runnable() {
@Override
public void run() {
try {
// 创建Socket
// socket = new Socket("192.168.1.110",54321);
// if (mapView.getMap().getMapStatus().zoom < 9.5f) {
// socket.close();
// stringTid.clear();
// } else
{
String host = "";
if (MainApplication.url.contains("cdz.evcharge.cc")) {
host = "cdz.evcharge.cc";
} else {
host = "59.110.68.162";
}
socket = new Socket(host, 9503); // IP:10.14.114.127,端口54321
socket.setReceiveBufferSize(99999); // 接收缓冲大小
socket.setSendBufferSize(99999);
// 向服务器发送消息
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 = 3;
hand.sendMessage(mes);
}
out.close();
br.close();
// 关闭Socket
socket.close();
}
} catch (Exception e) {
}
}
}).start();
}
public void ete2(final String params) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String host = "";
if (MainApplication.url.contains("cdz.evcharge.cc")) {
host = "cdz.evcharge.cc";
} else {
host = "59.110.68.162";
}
socket = new Socket(host, 9503);
// 向服务器发送消息
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();
if (msg != null) {
Message mes = new Message();
mes.obj = msg;
mes.what = 2;
hand.sendMessage(mes);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void getCommentNum(final String zhan_id) {
new Thread(new Runnable() {
@Override
public void run() {
Request request = new Request.Builder().url(MainApplication.url + "/zhannew/basic/web/index.php/tpappcomments/getcont?zhanid=" + zhan_id).build();
Response response = null;
try {
response = OkHttpUtil.execute(request);
if (response.code() == 200) {
String json = "";
try {
json = response.body().string();
Message msg = new Message();
msg.obj = json;
msg.what = 1;
hand.sendMessage(msg);
} catch (Exception e) {
e.printStackTrace();
Message msg = new Message();
msg.what = 2;
hand.sendMessage(msg);
}
}
} catch (Exception e) {
e.printStackTrace();
Message msg = new Message();
msg.what = 2;
hand.sendMessage(msg);
}
}
}).start();
}
public static String getMD5(String content) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(content.getBytes());
return getHashString(digest);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private static String getHashString(MessageDigest digest) {
StringBuilder builder = new StringBuilder();
for (byte b : digest.digest()) {
builder.append(Integer.toHexString((b >> 4) & 0xf));
builder.append(Integer.toHexString(b & 0xf));
}
return builder.toString().toLowerCase();
}
private Bitmap getMarkerBmpYes(int i) {
if (i == 1) {
mIvMarkerBgYes.setImageResource(R.drawable.icon_sgreen);
} else if (i == 2) {
mIvMarkerBgYes.setImageResource(R.drawable.icon_bgreen);
} else if (i == 3) {
mIvMarkerBgYes.setImageResource(R.drawable.icon_sorange);
} else if (i == 4) {
mIvMarkerBgYes.setImageResource(R.drawable.icon_borange);
} else if (i == 5) {
mIvMarkerBgYes.setImageResource(R.drawable.icon_sgift);
} else if (i == 6) {
mIvMarkerBgYes.setImageResource(R.drawable.icon_bgift);
} else if (i == 7) {
mIvMarkerBgYes.setImageResource(R.drawable.icon_sblue);
} else if (i == 8) {
mIvMarkerBgYes.setImageResource(R.drawable.icon_bblue);
}
Bitmap bmp = getBitmapFromView(mMarkerViewYes);
return bmp;
}
private Bitmap getMarkerBmp(int num) {
mIvMarkerBg.setImageResource(R.drawable.icon_konglog1105);
if (num > 10) {
mTvMarkerViewNum.setText(Integer.toString(num));
} else {
mTvMarkerViewNum.setText(Integer.toString(num));
}
Bitmap bmp = getBitmapFromView(mMarkerView);
return bmp;
}
private Bitmap getMarkerApps(int num) {
mIvMarkerAppS.setImageResource(R.drawable.icon_sapp);
if (num > 10) {
mTvMarkerViewNumAppS.setText(Integer.toString(num));
} else {
mTvMarkerViewNumAppS.setText(Integer.toString(num));
}
Bitmap bmp = getBitmapFromView(mMarkerViewAppS);
return bmp;
}
private Bitmap getMarkerAppb(int num) {
mIvMarkerAppB.setImageResource(R.drawable.icon_bapp);
if (num > 10) {
mTvMarkerViewNumAppB.setText(Integer.toString(num));
} else {
mTvMarkerViewNumAppB.setText(Integer.toString(num));
}
Bitmap bmp = getBitmapFromView(mMarkerViewAppB);
return bmp;
}
private Bitmap getMarkerBmp1(int num) {
mIvMarkerBg1.setImageResource(R.drawable.icon_konglogb);
if (num > 10) {
mTvMarkerViewNum1.setText(Integer.toString(num));
} else {
mTvMarkerViewNum1.setText(Integer.toString(num));
}
Bitmap bmp = getBitmapFromView(mMarkerView1);
return bmp;
}
private Bitmap getMarkerBmpCity(String num) {
String no = num;
mIvMarkerBgcity.setImageResource(R.drawable.icon_cityno);
mTvMarkerViewNumcity.setText(no);
Bitmap bmp = getBitmapFromView(mMarkerViewcity);
return bmp;
}
public static Bitmap getBitmapFromView(View view) {
view.destroyDrawingCache();
view.measure(View.MeasureSpec.makeMeasureSpec(0,
View.MeasureSpec.UNSPECIFIED), View.MeasureSpec
.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.setDrawingCacheEnabled(true);
Bitmap tmp = view.getDrawingCache();
Bitmap bitmap = tmp.copy(Bitmap.Config.ARGB_8888, false);
tmp.recycle();
return bitmap;
}
@Override
public void onClick(View v) {
SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
switch (v.getId()) {
case R.id.iv_tuijian:
if (null != center) {
MobclickAgent.onEvent(getApplicationContext(), "0111");
Intent i = new Intent(getApplicationContext(), RecommendZhanActivity.class);
i.putExtra("center_jing", String.valueOf(center.longitude));
i.putExtra("center_wei", String.valueOf(center.latitude));
startActivity(i);
} else {
ToastUtil.showToast(getApplicationContext(), "没有获取到您当前的位置,请检查网络或定位权限", Toast.LENGTH_SHORT);
}
MobclickAgent.onEvent(context, "0068");
break;
case R.id.iv_clear_address:
tv_search.setText("请输入地址/关键字");
iv_clear_address.setVisibility(View.INVISIBLE);
ProfileManager.getInstance().setSearchAddress(this, "");
MainApplication.search_jing = 0.0;
MainApplication.search_wei = 0.0;
ete("{\"fun\":\"timer\"}");
if (search_marker != null) {
search_marker.remove();
}
break;
case R.id.iv_example:
MobclickAgent.onEvent(getApplicationContext(), "0114");
Intent intent_example = new Intent(getApplicationContext(), ExampleActivity.class);
intent_example.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent_example);
overridePendingTransition(0, 0);
break;
case R.id.iv_bg_example:
break;
case R.id.tv_sortDistance:
MobclickAgent.onEvent(getApplicationContext(), "0057");
sortTye = 1;
tv_sortDistance.setTextColor(getResources().getColor(R.color.lvse));
tv_sortDistance.setBackgroundResource(R.drawable.bg_lv);
tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
if (list1.size() > 0) {
list.clear();
list.addAll(list1);
adapter.notifyDataSetChanged();
} else {
list.clear();
list = Util.getSortList(listt);
adapter.notifyDataSetChanged();
}
break;
case R.id.tv_sortStarLevel:
MobclickAgent.onEvent(getApplicationContext(), "0058");
sortTye = 2;
tv_sortDistance.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortDistance.setBackgroundColor(getResources().getColor(R.color.white));
tv_sortStarLevel.setTextColor(getResources().getColor(R.color.lvse));
tv_sortStarLevel.setBackgroundResource(R.drawable.bg_lv);
tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
if (list2.size() > 0) {
list.clear();
list.addAll(list2);
adapter.notifyDataSetChanged();
} else {
list.clear();
list = Util.getSortPFList(listt);
adapter.notifyDataSetChanged();
}
break;
case R.id.tv_sortFreeTime:
MobclickAgent.onEvent(getApplicationContext(), "0059");
sortTye = 3;
tv_sortDistance.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortDistance.setBackgroundColor(getResources().getColor(R.color.white));
tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
tv_sortFreeTime.setTextColor(getResources().getColor(R.color.lvse));
tv_sortFreeTime.setBackgroundResource(R.drawable.bg_lv);
if (list3.size() > 0) {
list.clear();
list.addAll(list3);
adapter.notifyDataSetChanged();
} else {
list.clear();
list = Util.getSortFTList(listt);
adapter.notifyDataSetChanged();
}
break;
case R.id.iv_route:
startActivity(new Intent(getApplication(), RoutePlanShowAddressActivity.class));
MobclickAgent.onEvent(getApplicationContext(), "0112");
break;
case R.id.second_hand_car:
Intent adfloatIntent = new Intent(this, MyWebViewActivity.class);
adfloatIntent.putExtra("url", adfloatUrl);
startActivity(adfloatIntent);
break;
case R.id.iv_roadCondition:
MobclickAgent.onEvent(getApplicationContext(), "0113");
if (ProfileManager.getInstance().getRoadCondition(getApplicationContext()) == false) {
iv_roadCondition.setImageResource(R.drawable.icon_youlukuang_main);
ProfileManager.getInstance().setRoadCondition(this, true);
aMap.setTrafficEnabled(true);
ToastUtil.showToast(this, "实时路况已打开", Toast.LENGTH_SHORT);
MobclickAgent.onEvent(getApplicationContext(), "0066");
} else {
iv_roadCondition.setImageResource(R.drawable.icon_wulukuang_main);
ProfileManager.getInstance().setRoadCondition(this, false);
aMap.setTrafficEnabled(false);
ToastUtil.showToast(this, "实时路况已关闭", Toast.LENGTH_SHORT);
MobclickAgent.onEvent(getApplicationContext(), "0067");
}
break;
case R.id.zoomin:
aMap.moveCamera(CameraUpdateFactory.zoomIn());
controlZoomShow();
break;
case R.id.zoomout:
aMap.moveCamera(CameraUpdateFactory.zoomOut());
controlZoomShow();
break;
//地图&列表切换按钮
case R.id.iv_list:
sharedPreferencesUtil.putBoolean("cdz_recommend_more_detail", true);
String jing, wei;
if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
Log.e(TAG, "onClick: 有搜索");
jing = String.valueOf(MainApplication.search_jing);
wei = String.valueOf(MainApplication.search_wei);
} else {
Log.e(TAG, "onClick: 当前位置");
if (null == center) {
ToastUtil.showToast(getApplicationContext(), "请确认当前定位是否可用", Toast.LENGTH_SHORT);
break;
} else {
jing = String.valueOf(center.longitude);
wei = String.valueOf(center.latitude);
}
}
if (null != jing && null != wei) {
MobclickAgent.onEvent(getApplicationContext(), "1135");
Intent intent = new Intent(getApplicationContext(), RecommendChargingStationActivity.class);
intent.putExtra("center_jing", jing);
intent.putExtra("center_wei", wei);
startActivity(intent);
}
break;
//定位刷新按钮
case R.id.iv_point_again:
if (!isFirstLoc) {
isFirstLoc = true;
mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
aMap.setLocationSource(this);// 设置定位监听
aMap.setMyLocationEnabled(true);// 是否可触发定位并显示定位层
aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
mlocationClient.startLocation();
}
windowLayout.setVisibility(View.GONE);
rl_control.setVisibility(View.VISIBLE);
ll_open.setVisibility(View.GONE);
break;
//条件筛选按钮
case R.id.tv_person:
windowLayout.setVisibility(View.GONE);
rl_control.setVisibility(View.VISIBLE);
if (nMarker != null) {
nMarker.hideInfoWindow();
MarkerOptions markerOptionss = new MarkerOptions();
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(current_chargePoint.getSupplier())) {
nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
} else {
nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
}
}
}
}
Intent intent = new Intent(getApplication(), NewScreenActivity.class);
startActivity(intent);
MobclickAgent.onEvent(getApplicationContext(), "0110");
break;
case R.id.tv_shaixuan:
isListShow = true;
windowLayout.setVisibility(View.GONE);
if (null != current_chargePoint) {
resetMarker();
}
MobclickAgent.onEvent(getApplicationContext(), "0110");
Intent intentt = new Intent(getApplication(), NewScreenActivity.class);
startActivity(intentt);
break;
case R.id.tv_switch_city:
if (isListShow == false) {
windowLayout.setVisibility(View.GONE);
rl_control.setVisibility(View.VISIBLE);
}
if (null != current_chargePoint) {
resetMarker();
}
MobclickAgent.onEvent(getApplicationContext(), "0107");
startActivity(new Intent(getApplicationContext(), NewSelectCityActivity.class));
if (ll_tuijian.getVisibility() == View.VISIBLE) {
ll_tuijian.setVisibility(View.GONE);
rl_tuijian_tip.setVisibility(View.VISIBLE);
ll_top_right.setVisibility(View.VISIBLE);
ll_map_control.setVisibility(View.VISIBLE);
}
break;
case R.id.tab_screening:
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (!MainApplication.isLogin()) {
startActivity(new Intent(getApplication(), LoginActivity.class));
} else if (!cameraTask()) {
EasyPermissions.requestPermissions(
this,
"该功能需要开启摄像头权限,是否前往开启?",
RC_CAMERA_PERM,
Manifest.permission.CAMERA);
} else {
Intent iintent = new Intent(getApplicationContext(), com.google.zxing.client.android.CaptureActivity.class);
iintent.putExtra("url", MainApplication.url);
iintent.putExtra("user_id", MainApplication.userId);
iintent.putExtra("user_password", MainApplication.userPassword);
iintent.putExtra("user_phone", ProfileManager.getInstance().getUsername(getApplicationContext()));
LogUtils.e(ProfileManager.getInstance().getUsername(getApplicationContext()));
iintent.putExtra("cha", MainMapActivity.cha);
iintent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(iintent);
overridePendingTransition(0, 0);
if (count == 1) {
MobclickAgent.onEvent(getApplicationContext(), "0104");
count = 2;
}
}
break;
//发现界面tab
case R.id.ll_tab_find:
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Intent intent1 = new Intent(getApplication(), FindActivity.class);
intent1.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent1);
overridePendingTransition(0, 0);
if (count == 1) {
MobclickAgent.onEvent(getApplicationContext(), "0105");
count = 2;
}
break;
case R.id.tab_qa:
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Intent i = new Intent(getApplication(), ChatActivity.class);//聊聊页面
i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(i);
overridePendingTransition(0, 0);
if (count == 1) {
MobclickAgent.onEvent(getApplicationContext(), "0999");
count = 2;
}
break;
//用户中心tab
case R.id.tab_me:
if (socket != null) {
try {
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Intent intent2 = new Intent(getApplication(), UserCenterActivity.class);
intent2.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent2);
if (sav.getVisibility() == View.VISIBLE) {
sav.setVisibility(View.GONE);
}
overridePendingTransition(0, 0);
if (count == 1) {
MobclickAgent.onEvent(getApplicationContext(), "0106");
count = 2;
}
break;
case R.id.iv_clear:
rl_ad.setVisibility(View.GONE);
break;
case R.id.rl_search:
if (isListShow == false) {
windowLayout.setVisibility(View.GONE);
rl_control.setVisibility(View.VISIBLE);
}
if (null != current_chargePoint) {
resetMarker();
}
MobclickAgent.onEvent(getApplicationContext(), "0108");
startActivityForResult(new Intent(getApplication(), SearchActivity.class), SEARCH_CODE);
if (ll_tuijian.getVisibility() == View.VISIBLE) {
ll_tuijian.setVisibility(View.GONE);
rl_tuijian_tip.setVisibility(View.VISIBLE);
ll_top_right.setVisibility(View.VISIBLE);
ll_map_control.setVisibility(View.VISIBLE);
}
break;
default:
break;
}
}
public void showMap() {
if (MainApplication.isMap) {
if (list.size() == 0) {
ete("{\"fun\":\"timer\"}");
}
MainApplication.isMap = false;
//显示列表站点
lvZhan.setVisibility(View.VISIBLE);
isListShow = true;
if (list.size() > 0) {
rl_mapList.setVisibility(View.VISIBLE);
tv_tishi.setVisibility(View.GONE);
} else if (list.size() == 0) {
rl_mapList.setVisibility(View.VISIBLE);
tv_tishi.setVisibility(View.VISIBLE);
}
iv_sceen.setVisibility(View.GONE);
iv_example.setVisibility(View.GONE);
if (windowLayout.getVisibility() == View.VISIBLE) {
paoShow = true;
windowLayout.setVisibility(View.GONE);
} else {
rl_control.setVisibility(View.GONE);
}
iv_roadCondition.setVisibility(View.GONE);
MobclickAgent.onEvent(getApplicationContext(), "0063");
} else {
//显示地图站点
MainApplication.isMap = true;
lvZhan.setVisibility(View.GONE);
rl_mapList.setVisibility(View.GONE);
tv_tishi.setVisibility(View.GONE);
if (paoShow == true && isListShow == false) {
windowLayout.setVisibility(View.VISIBLE);
rl_control.setVisibility(View.GONE);
paoShow = false;
} else {
rl_control.setVisibility(View.VISIBLE);
}
isListShow = false;
iv_sceen.setVisibility(View.VISIBLE);
iv_example.setVisibility(View.VISIBLE);
sortTye = 1;
tv_sortDistance.setTextColor(getResources().getColor(R.color.lvse));
tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortDistance.setBackgroundResource(R.drawable.bg_lv);
tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
iv_roadCondition.setVisibility(View.VISIBLE);
}
}
private void showUi(boolean status) {
if (status == true) {
lvZhan.setVisibility(View.GONE);
rl_mapList.setVisibility(View.GONE);
tv_tishi.setVisibility(View.GONE);
rl_control.setVisibility(View.VISIBLE);
iv_sceen.setVisibility(View.VISIBLE);
sortTye = 1;
tv_sortDistance.setTextColor(getResources().getColor(R.color.lvse));
tv_sortStarLevel.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortFreeTime.setTextColor(getResources().getColor(R.color.ui_62));
tv_sortDistance.setBackgroundResource(R.drawable.bg_lv);
tv_sortStarLevel.setBackgroundColor(getResources().getColor(R.color.white));
tv_sortFreeTime.setBackgroundColor(getResources().getColor(R.color.white));
iv_roadCondition.setVisibility(View.VISIBLE);
iv_example.setVisibility(View.VISIBLE);
} else {
lvZhan.setVisibility(View.VISIBLE);
if (list.size() > 0) {
rl_mapList.setVisibility(View.VISIBLE);
tv_tishi.setVisibility(View.GONE);
} else if (list.size() == 0) {
rl_mapList.setVisibility(View.VISIBLE);
tv_tishi.setVisibility(View.VISIBLE);
}
rl_control.setVisibility(View.GONE);
iv_sceen.setVisibility(View.GONE);
if (windowLayout.getVisibility() == View.VISIBLE) {
windowLayout.setVisibility(View.GONE);
rl_control.setVisibility(View.VISIBLE);
ll_open.setVisibility(View.GONE);
}
iv_roadCondition.setVisibility(View.GONE);
iv_example.setVisibility(View.GONE);
}
}
@Override
public void onMapLoaded() {
aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
// 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);
aMap.moveCamera(CameraUpdateFactory.zoomTo(14));
}
@Override
public void onCameraChange(CameraPosition cameraPosition) {
}
@Override
public void onCameraChangeFinish(CameraPosition cameraPosition) {
}
@Override
public void onMapClick(LatLng latLng) {
float zoom = aMap.getCameraPosition().zoom;
aMap.moveCamera(CameraUpdateFactory.zoomTo(zoom));
Animation animation = AnimationUtils.loadAnimation(this, R.anim.out);
animation.setDuration(500);
windowLayout.startAnimation(animation);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
windowLayout.setVisibility(View.GONE);
}
}, 500);
SharedPreferencesUtil sharedPreferencesUtil1 = new SharedPreferencesUtil(getApplication());
sharedPreferencesUtil1.setFileName("CurrentMarkerInfo");
sharedPreferencesUtil1.clearData();
rl_control.setVisibility(View.VISIBLE);
ll_open.setVisibility(View.GONE);
}
@Override
public void onWeatherLiveSearched(LocalWeatherLiveResult weatherLiveResult, int rCode) {
if (rCode == 1000) {
if (weatherLiveResult != null & weatherLiveResult.getLiveResult() != null) {
LocalWeatherLive weatherlive = weatherLiveResult.getLiveResult();
} else {
}
} else {
ToastUtil.showToast(MainMapActivity.this, rCode + "", Toast.LENGTH_SHORT);
}
}
@Override
public void onWeatherForecastSearched(LocalWeatherForecastResult localWeatherForecastResult, int i) {
if (i == 1000) {
if (localWeatherForecastResult != null & localWeatherForecastResult.getForecastResult() != null) {
LocalWeatherForecast weatherlive = localWeatherForecastResult.getForecastResult();
Log.e(TAG, "onWeatherLiveSearched: " + "-------" + weatherlive.getCity() + "-------" + weatherlive.getAdCode()
+ "-------" + weatherlive.getWeatherForecast() + "-------" + weatherlive.getProvince() + "-------" + weatherlive.getReportTime());
List<LocalDayWeatherForecast> list = weatherlive.getWeatherForecast();
list.get(0).getDate();
for (int a = 0; a < list.size(); a++) {
Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getDate());
Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getDayTemp());
Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getDayWeather());
Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getNightTemp());
Log.e(TAG, "onWeatherForecastSearched: " + list.get(a).getNightWeather());
}
} else {
}
} else {
}
}
@Override
public void onPermissionsGranted(int requestCode, List<String> perms) {
if (requestCode == RC_CAMERA_PERM) {
Intent iintent = new Intent(getApplicationContext(), com.google.zxing.client.android.CaptureActivity.class);
iintent.putExtra("url", MainApplication.url);
iintent.putExtra("user_id", MainApplication.userId);
iintent.putExtra("user_password", MainApplication.userPassword);
iintent.putExtra("user_phone", MainApplication.userPhone);
iintent.putExtra("cha", MainMapActivity.cha);
iintent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(iintent);
overridePendingTransition(0, 0);
}
}
@Override
public void onPermissionsDenied(int requestCode, List<String> perms) {
for (String s : perms) {
LogUtils.e(s);
}
if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
new AppSettingsDialog.Builder(MainMapActivity.this).build().show();
// TODO add by hyg20200525
// new AppSettingsDialog.Builder(MainMapActivity.this,
// "该功能需要开启摄像头权限,是否前往开启?").build().show();
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
}
private boolean hasCameraPermission() {
return EasyPermissions.hasPermissions(this, Manifest.permission.CAMERA);
}
private boolean isPermissionOK() {
return EasyPermissions.hasPermissions(this,
Manifest.permission.CAMERA,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
);
}
@AfterPermissionGranted(RC_SAVE_PERM)
public boolean saveTask() {
if (isPermissionOK()) {
// Have permission, do the thing!
// Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
return true;
} else {
// Ask for one permission
// EasyPermissions.requestPermissions(
// this,
// "该功能需要开启摄像头权限,是否前往开启?",
// RC_CAMERA_PERM,
// Manifest.permission.CAMERA);
return false;
}
}
@AfterPermissionGranted(RC_CAMERA_PERM)
public boolean cameraTask() {
if (hasCameraPermission()) {
// Have permission, do the thing!
// Toast.makeText(this, "TODO: Camera things", Toast.LENGTH_LONG).show();
return true;
} else {
// Ask for one permission
// EasyPermissions.requestPermissions(
// this,
// "该功能需要开启摄像头权限,是否前往开启?",
// RC_CAMERA_PERM,
// Manifest.permission.CAMERA);
return false;
}
}
@Override
public boolean onMarkerClick(Marker marker) {
return false;
}
/**
* 监听自定义infowindow窗口的infowindow时间回调
* add by hyg
*
* @param marker
* @return
*/
@Override
public View getInfoWindow(Marker marker) {
if (infoWindow == null) {
infoWindow = getLayoutInflater().inflate(R.layout.custom_info_window, null);
}
return infoWindow;
}
@Override
public View getInfoContents(Marker marker) {
return null;
}
/**
* 自定义infowindow窗口
* 如果想修改自定义Infow中内容,请通过view找到它并修改
*/
public void updateInfoWindow(String text) {
if (nMarker == null) {
return;
}
if (infoWindow == null) {
return;
}
infoWindow.findViewById(R.id.infoWindowNavigate).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MobclickAgent.onEvent(getApplicationContext(), "1120");
infoViewNavigate();
}
});
TextView distance = infoWindow.findViewById(R.id.distance);
distance.setText(text);
}
/**
* 点击自定义气泡,进行导航操作
* add by hyg
*
* @param marker
*/
@Override
public void onInfoWindowClick(Marker marker) {
}
public class ZhanAdapter extends BaseAdapter {
@Override
public int getCount() {
if (list.size() > 30) {
return 30;
} else {
return list.size();
}
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder = null;
if (convertView == null) {
convertView = LayoutInflater.from(getApplication()).inflate(
R.layout.item_zhandian, null);
viewHolder = new ViewHolder();
viewHolder.item_zhan_name = (TextView) convertView.findViewById(R.id.item_zhan_name);
viewHolder.item_zhan_go = (TextView) convertView.findViewById(R.id.item_zhan_go);
viewHolder.item_zhan_distance = (TextView) convertView.findViewById(R.id.item_zhan_distance);
viewHolder.item_zhan_cost = (TextView) convertView.findViewById(R.id.item_zhan_cost);
viewHolder.item_fast_num = (TextView) convertView.findViewById(R.id.item_fast_num);
viewHolder.item_fastable = (TextView) convertView.findViewById(R.id.item_fastable);
viewHolder.item_fastable_num = (TextView) convertView.findViewById(R.id.item_fastable_num);
viewHolder.item_slowable = (TextView) convertView.findViewById(R.id.item_slowable);
viewHolder.item_slowable_num = (TextView) convertView.findViewById(R.id.item_slowable_num);
viewHolder.item_slow_num = (TextView) convertView.findViewById(R.id.item_slow_num);
viewHolder.item_grade_pic = (ImageView) convertView.findViewById(R.id.item_grade_pic);
viewHolder.item_layout = (LinearLayout) convertView.findViewById(R.id.item_layout);
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
}
if (list.size() > 0) {
viewHolder.item_zhan_name.setText(list.get(position).getZhan_name());
if (list.get(position).getStar_level().equals("") || list.get(position).getStar_level().equals("0")) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_0xing);
} else {
String star_level = list.get(position).getStar_level().toString();
double d;
d = Double.parseDouble(star_level);
String grade = String.format("%.1f", d);
if (d > 0 && d < 1) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_05xing);
} else if (d >= 1 && d < 1.5) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_1xing);
} else if (d >= 1.5 && d < 2) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_15xing);
} else if (d >= 2 && d < 2.5) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_2xing);
} else if (d >= 2.5 && d < 3) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_25xing);
} else if (d >= 3 && d < 3.5) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_3xing);
} else if (d >= 3.5 && d < 4) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_35xing);
} else if (d >= 4 && d < 4.5) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_4xing);
} else if (d >= 4.5 && d < 5) {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_45xing);
} else {
viewHolder.item_grade_pic.setImageResource(R.drawable.icon_5xing);
}
}
if (list.get(position).getOwn_pay().equals("1")) {
viewHolder.item_zhan_cost.setText("可使用本APP扫码支付");
} else {
if (list.get(position).getCharge_cost_way2().equals("")) {
viewHolder.item_zhan_cost.setText("暂无");
} else {
if (list.get(position).getCharge_cost_way2().equals("微信支付")) {
viewHolder.item_zhan_cost.setText(list.get(position).getCharge_cost_way2());
} else {
viewHolder.item_zhan_cost.setText(list.get(position).getCharge_cost_way2() + "支付");
}
}
}
String fast = list.get(position).getFast_num();
String slow = list.get(position).getSlow_num();
String acNum = null, dcNum = null, acableNum = null, dcableNum = null;
acNum = list.get(position).getAcNum();
dcNum = list.get(position).getDcNum();
acableNum = list.get(position).getAcableNum();
dcableNum = list.get(position).getDcableNum();
if (null != acableNum && null != acNum
&& null != dcableNum && null != dcNum && !acableNum.equals("")
&& !acNum.equals("") && !dcableNum.equals("") && !dcNum.equals("")) {
viewHolder.item_fast_num.setText(dcNum);
viewHolder.item_fastable_num.setText(dcableNum);
viewHolder.item_fastable.setVisibility(View.VISIBLE);
viewHolder.item_fastable_num.setVisibility(View.VISIBLE);
viewHolder.item_slow_num.setText(acNum);
viewHolder.item_slowable_num.setText(acableNum);
viewHolder.item_slowable.setVisibility(View.VISIBLE);
viewHolder.item_slowable_num.setVisibility(View.VISIBLE);
} else {
viewHolder.item_fast_num.setText(fast);
viewHolder.item_fastable.setVisibility(View.GONE);
viewHolder.item_fastable_num.setVisibility(View.GONE);
viewHolder.item_slow_num.setText(slow);
viewHolder.item_slowable.setVisibility(View.GONE);
viewHolder.item_slowable_num.setVisibility(View.GONE);
}
if ("0m".equals(list.get(position).getDistance())) {
viewHolder.item_zhan_distance.setText("未知");
} else {
viewHolder.item_zhan_distance.setText(list.get(position).getDistance());
}
viewHolder.item_zhan_go.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MobclickAgent.onEvent(getApplicationContext(), "0060");
if (!isAvilible(getApplicationContext(), "com.baidu.BaiduMap") &&
!isAvilible(getApplicationContext(), "com.autonavi.minimap")) {
getGaode(Double.parseDouble(list.get(position).getPoi_jing()), Double.parseDouble(list.get(position).getPoi_wei()));
Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
intent.putExtra("start_jing", center.longitude + "");
intent.putExtra("start_wei", center.latitude + "");
intent.putExtra("stop_jing", gd_jing + "");
intent.putExtra("stop_wei", gd_wei + "");
startActivity(intent);
detailsBack = true;
HashMap<String, String> map = new HashMap<String, String>();
map.put("Name", list.get(position).getZhan_name());
map.put("CostWay", list.get(position).getCharge_cost_way());
map.put("City", list.get(position).getCity());
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) {
getGaode(Double.parseDouble(list.get(position).getPoi_jing()), Double.parseDouble(list.get(position).getPoi_wei()));
Intent intent = new Intent(getApplication(), BasicNaviActivity.class);
intent.putExtra("start_jing", center.longitude + "");
intent.putExtra("start_wei", center.latitude + "");
intent.putExtra("stop_jing", gd_jing + "");
intent.putExtra("stop_wei", gd_wei + "");
startActivity(intent);
detailsBack = true;
popupWindow.dismiss();
HashMap<String, String> map = new HashMap<String, String>();
map.put("Name", list.get(position).getZhan_name());
map.put("CostWay", list.get(position).getCharge_cost_way());
map.put("City", list.get(position).getCity());
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;
// try {
//// intent = Intent.getIntent("intent://map/direction?origin=latlng:"+center.latitude+","+center.longitude+"&destination=latlng:"+ll.latitude+","+ll.longitude+"|name:"+finalMarkerInfo.getZhan_name()+"&mode=driving®ion=&src=充电桩#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end");
// } catch (URISyntaxException e) {
// e.printStackTrace();
// }
double dwei = Double.parseDouble(list.get(position).getPoi_wei());
double djing = Double.parseDouble(list.get(position).getPoi_jing());
getBaidu(center.longitude, center.latitude);
try {
String s = "intent://map/direction?" +
"origin=" + bd_lat + "," + bd_lon + "&" +
"destination=" + dwei + "," + djing +
"&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", list.get(position).getZhan_name());
map.put("CostWay", list.get(position).getCharge_cost_way());
map.put("City", list.get(position).getCity());
MobclickAgent.onEvent(context, "0031", map);
map.clear();
} catch (URISyntaxException e) {
e.printStackTrace();
}
startActivity(intent);
// if (MainFragment.center != null) {
// double dwei = Double.parseDouble(zhan.getPoi_wei());
// double djing = Double.parseDouble(zhan.getPoi_jing());
// LatLng ll = new LatLng(dwei, djing);
//
// startNavi(MainFragment.center, ll);
//
// }
// startNavi(center, ll);
popupWindow.dismiss();
}
});
tvTwo = (TextView) popupWindowView.findViewById(R.id.tvTwo);
tvTwo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
// getBeginGaode(center.longitude, center.latitude);
getGaode(Double.parseDouble(list.get(position).getPoi_jing()), Double.parseDouble(list.get(position).getPoi_wei()));
Intent intent4 = new Intent("android.intent.action.VIEW",
android.net.Uri.parse("androidamap://route?sourceApplication=amap&slat=" + center.latitude + "&slon=" + center.longitude + "&sname=我的位置&dlat=" + gd_wei + "&dlon=" + gd_jing + "&dname=" + list.get(position).getZhan_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", list.get(position).getZhan_name());
map.put("CostWay", list.get(position).getCharge_cost_way());
map.put("City", list.get(position).getCity());
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();
}
}
}
});
}
return convertView;
}
class ViewHolder {
TextView item_zhan_name, item_zhan_go, item_zhan_distance, item_zhan_cost, item_fast_num, item_fastable, item_fastable_num,
item_slowable, item_slowable_num, item_slow_num;
ImageView item_grade_pic;
LinearLayout item_layout;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
// 判断气泡弹窗视图是否已经隐藏
if (windowLayout.getVisibility() == View.VISIBLE) {
Animation animation = AnimationUtils.loadAnimation(this, R.anim.out);
animation.setDuration(500);
windowLayout.startAnimation(animation);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
windowLayout.setVisibility(View.GONE);
rl_control.setVisibility(View.VISIBLE);
}
}, 500);
return false;
}
if ((System.currentTimeMillis() - exitTime) > 2000) {
Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
exitTime = System.currentTimeMillis();
} else {
// ActivityManagerApplication.destoryActivity("MainMapActivity");
if (MainMapActivity.mainMapActivity != null) {
MainMapActivity.mainMapActivity.finish();
}
SharedPreferences mySharedPreferences = getSharedPreferences("showdialog",
Activity.MODE_PRIVATE);
SharedPreferences.Editor editor1 = mySharedPreferences.edit();
editor1.clear();
ProfileManager.getInstance().setSearchAddress(this, "");
ActivityUtils.finishAllActivities();
// finish();
android.os.Process.killProcess(android.os.Process.myPid());
}
}
return true;
// return super.onKeyDown(keyCode, event);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (isListShow == false) {
windowLayout.setVisibility(View.GONE);
rl_control.setVisibility(View.VISIBLE);
}
if (requestCode == SEARCH_CODE && resultCode == 101) {
double jing = Double.valueOf(data.getStringExtra("jing"));
double wei = Double.valueOf(data.getStringExtra("wei"));
MainApplication.search_jing = jing;
MainApplication.search_wei = wei;
final LatLng screenCity = new LatLng(wei, jing);
aMap = mapView.getMap();
Util.setMapCustomStyleFile(aMap, getApplicationContext());
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(screenCity, 14.0f));
}
}, 500);
if (search_marker != null) {
search_marker.remove();
}
if (MainApplication.search_jing != 0.0 && MainApplication.search_wei != 0.0) {
LatLng latLng = new LatLng(MainApplication.search_wei, MainApplication.search_jing);
search_marker = aMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.icon_search_address))));
search_marker.setPeriod(8);
}
ete("{\"fun\":\"timer\"}");
} else if (requestCode == SEARCH_CODE && resultCode == 102) {
double jing = Double.valueOf(data.getStringExtra("jing"));
double wei = Double.valueOf(data.getStringExtra("wei"));
final LatLng screenCity = new LatLng(wei, jing);
aMap = mapView.getMap();
Util.setMapCustomStyleFile(aMap, getApplicationContext());
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(screenCity, 14.0f));
}
}, 500);
}
}
private void dialogup() {
int code = Integer.parseInt(now_versionCode);
if (code - getVersionCode(getApplication()) > 0) {
new AlertDialogUpdate(MainMapActivity.this).builder()
.setTitle("更新提示 " + now_versionName)
.setMsg(title.trim())
.setPositiveButton("更新", new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse("http://cdz.evcharge.cc/app/app.apk");
intent.setData(content_url);
startActivity(intent);
}
}).setNegativeButton("忽略", new View.OnClickListener() {
@Override
public void onClick(View v) {
}
}).show();
}
}
private void showProgressWindow() {
updateDialog = new UpdateDialog(MainMapActivity.this);
updateDialog.builder().setMsg("").setCancelable(false).show();
}
private void dialogup_other() {
int code = Integer.parseInt(now_versionCode);
if (code - getVersionCode(getApplication()) > 0) {
alterDialog = new AlertDialogUpdate(MainMapActivity.this);
alterDialog.builder()
.setTitle("更新提示 " + now_versionName)
.setMsg(title.trim())
.setPositiveButton("更新", new View.OnClickListener() {
@Override
public void onClick(View v) {
showProgressWindow();
ToastUtil.showToast(getApplicationContext(), "正在下载中", Toast.LENGTH_SHORT);
OkHttpUtils.get().url("http://cdz.evcharge.cc/app/app.apk").build()
.execute(new FileCallBack(Environment.getExternalStorageDirectory().getAbsolutePath(), "cdz_install") {
@Override
public void inProgress(final float progress, long total) {
NumberFormat numberFormat = NumberFormat.getInstance();
// 设置精确到小数点后2位
numberFormat.setMaximumFractionDigits(2);
String format = numberFormat.format(progress * 100);
Message message = new Message();
message.what = 0x01;
Bundle bundle = new Bundle();
bundle.putString("format", format + "%");
LogUtils.e("当前:" + format);
if (!format.contains(".")) {
bundle.putString("progress", format + ".");
} else {
bundle.putString("progress", format);
}
message.setData(bundle);
myHandler.sendMessage(message);
}
@Override
public void onError(Call call, Exception e) {
// LogUtils.e(e.getMessage());
}
@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(), "");
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 {
String host = "";
if (MainApplication.url.contains("cdz.evcharge.cc")) {
host = "cdz.evcharge.cc";
} else {
host = "59.110.68.162";
}
socket = new Socket(host, 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 {
String host = "";
if (MainApplication.url.contains("cdz.evcharge.cc")) {
host = "cdz.evcharge.cc";
} else {
host = "59.110.68.162";
}
socket = new Socket(host, 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);
gg_lat = z * Math.sin(theta);
bg_wei = String.valueOf(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);
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";
} 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";
}
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);
}
cursor.close();
db.endTransaction();
db.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private void delData(List<DataRefresh> list_del) {
String dbPath = "/data/user/0/com.electric.chargingpile/databases/zhan_list";
try {
SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
db.beginTransaction();//开始事务
try {
for (int i = 0; i < list_del.size(); i++) {
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();//由事务的标志决定是提交事务,还是回滚事务
}
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";
try {
SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
db.beginTransaction();//开始事务
try {
for (int i = 0; i < list_add.size(); i++) {
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, "添加成功");
} else {
Log.e(TAG, "添加失败---" + list_add.get(i).getId());
}
}
db.setTransactionSuccessful();//调用此方法会在执行到endTransaction() 时提交当前事务,如果不调用此方法会回滚事务
} finally {
db.endTransaction();//由事务的标志决定是提交事务,还是回滚事务
}
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";
try {
SQLiteDatabase db = SQLiteDatabase.openDatabase(dbPath, null, SQLiteDatabase.OPEN_READWRITE);
db.beginTransaction();//开始事务
try {
for (int i = 0; i < list_up.size(); i++) {
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();//由事务的标志决定是提交事务,还是回滚事务
}
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();
}
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 daoMaster = new DaoMaster(SQLiteDatabase.openOrCreateDatabase(getDatabasePath("zhan_list"), null));
DaoSession mDaoSession = daoMaster.newSession();
zhan_listDao = mDaoSession.getZhan_listDao();
zhan_lists = zhan_listDao.queryRaw("where status = ? " + MainApplication.sql, new String[]{"4"});
if (onResumeRefresh == true) {
ToastUtil.showToast(getApplicationContext(), "共" + zhan_lists.size() + "个符合条件的站点", Toast.LENGTH_SHORT);
}
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();
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);
markerPosition = clusterItem.getPosition();
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;
zhanInfo = null;
// 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 clickMarkAndMove(int adHeight) {
if (markerPosition == null) {
return;
}
float zoom = aMap.getCameraPosition().zoom;
int width = mapView.getMeasuredWidth();
int height = mapView.getMeasuredHeight();
if (height > 1122) {
Point point = aMap.getProjection().toScreenLocation(markerPosition);
int y = point.y - (height - 1122) - DensityUtil.dip2px(getApplicationContext(), adHeight);
aMap.moveCamera(CameraUpdateFactory.scrollBy(point.x - width / 2, y));
} else {
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(markerPosition, zoom));
}
}
private void getSingleZhanInfo(String zhan_id, final LatLng ll) {
String url = MainApplication.url + "/zhannew/basic/web/index.php/zhanlist/zhan-info2?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) {
zhanInfo = info;
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"); // 1:可支付
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");
String charge_record_cnt = JsonUtils.getKeyResult(info, "charge_record_cnt");
String zongjia = JsonUtils.getKeyResult(info, "zongjia");
String belong_attribute = JsonUtils.getKeyResult(info, "belong_attribute");
String park_location = JsonUtils.getKeyResult(info, "park_location");
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");
final String fenshi_is = JsonUtils.getKeyResult(info, "fenshi_is");
final String telephone = JsonUtils.getKeyResult(info, "telephone");
TextView fenshi_info_textview = findViewById(R.id.fenshi_info_textview);
fenshi_info_textview.setText("");
if ("1".equals(fenshi_is)) {
final String fenshi_info = JsonUtils.getKeyResult(info, "fenshi_info");
ArrayList<PileData.FenshiInfoBean> fenshiList = (ArrayList<PileData.FenshiInfoBean>) JsonUtils.parseToObjectList(fenshi_info, PileData.FenshiInfoBean.class);
if (fenshiList.size() == 1) {
fenshi_info_textview.setText("全天价格统一");
} else {
Calendar calendar = Calendar.getInstance();
int hours = calendar.get(Calendar.HOUR_OF_DAY);
int minutes = calendar.get(Calendar.MINUTE);
int totalMinutes = hours * 60 + minutes;
for (PileData.FenshiInfoBean bean : fenshiList) {
if (bean.getStartTotalMinutes() > totalMinutes) {
double service_free = 0;
double charge_free = 0;
try {
service_free = Double.valueOf(bean.getService_free());
charge_free = Double.valueOf(bean.getCharge_free());
} catch (Exception e) {
e.printStackTrace();
}
fenshi_info_textview.setText(String.format("%s开始 %.2f元/度", bean.getStart(), service_free + charge_free));
break;
}
}
}
} else {
double totalPrice = 0;
try {
totalPrice = Double.valueOf(zongjia);
} catch (Exception e) {
e.printStackTrace();
}
if (totalPrice != 0) {
fenshi_info_textview.setText("全天价格统一");
}
}
if (belong_attribute != null && belong_attribute.contains("私人")) {
private_telephone.setVisibility(View.VISIBLE);
private_telephone.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
.setMsg(zhan_name + " " + telephone)
.setPositiveButton("呼叫", new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction("android.intent.action.CALL");
intent.addCategory("android.intent.category.DEFAULT");
intent.setData(Uri.parse("tel:" + telephone));
startActivity(intent);
}
}).setNegativeButton("取消", new View.OnClickListener() {
@Override
public void onClick(View v) {
}
}).show();
}
});
} else {
private_telephone.setVisibility(View.GONE);
}
// remind 0 正常 2 休息中 other 故障
// own_pay 1 可支付
// 显示顺序 故障>可支付>休息中
if (remind.equals("0")) {
if ("1".equals(own_pay)) {
iv_guzhang.setVisibility(View.VISIBLE);
iv_guzhang.setImageResource(R.drawable.icon_is_cost);
} else {
iv_guzhang.setVisibility(View.GONE);
}
} else if (remind.equals("2")) {
iv_guzhang.setVisibility(View.VISIBLE);
iv_guzhang.setImageResource(R.drawable.icon_rest);
} else {
iv_guzhang.setVisibility(View.VISIBLE);
iv_guzhang.setImageResource(R.drawable.icon_guzhang_window);
}
windowName.setText(zhan_name);
if (stop_cost != null && !stop_cost.equals("")) {
stopCost.setVisibility(View.VISIBLE);
stopCost.setText("停车费:" + stop_cost);
} else {
stopCost.setVisibility(View.GONE);
}
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);
}
}
if (charge_record_cnt != null) {
int count = Integer.parseInt(charge_record_cnt);
// 成功充电次数
if (count == 0) {
windowChargeRecordCnt.setText("");
windowChargeRecordCntLine.setVisibility(View.GONE);
} else {
windowChargeRecordCntLine.setVisibility(View.VISIBLE);
if (count < 1000) {
windowChargeRecordCnt.setText(count + "次充电");
} else if (count < 10000) {
windowChargeRecordCnt.setText(count / 1000 + "k+次充电");
} else {
windowChargeRecordCnt.setText(count / 10000 + "w+次充电");
}
}
} else {
windowChargeRecordCnt.setText("");
windowChargeRecordCntLine.setVisibility(View.GONE);
}
if (zongjia != null) {
double zongjiaValue = Double.parseDouble(zongjia);
if (zongjiaValue == 0) {
windowZongjiaLayout.setVisibility(View.GONE);
} else {
windowZongjiaLayout.setVisibility(View.VISIBLE);
windowZongjia.setText(String.format("%.2f", zongjiaValue));
}
} else {
windowZongjiaLayout.setVisibility(View.GONE);
}
// 气泡红包显示
windowRedPaperBag.setVisibility("1".equals(own_pay) ? View.VISIBLE : View.GONE);
windowLabelPublic.setText(belong_attribute);
windowLabelGround.setText("0".equals(park_location) ? "地下" : "地上");
windowLabelFreePark.setVisibility(stop_cost.contains("免费") ? View.VISIBLE : View.GONE);
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) { // 有桩状态
window_tv_fast_free_num.setText(dcableNum); // 快充空闲桩数量
window_tv_fast_total_num.setText("/" + dcNum); // 快充桩总数
window_tv_fast_free_label.setVisibility(View.VISIBLE);
window_tv_fast_total_num.setVisibility(View.VISIBLE);
window_tv_slow_free_num.setText(acableNum); // 慢充空闲桩数量
window_tv_slow_total_num.setText("/" + acNum);
window_tv_slow_free_label.setVisibility(View.VISIBLE);
window_tv_slow_total_num.setVisibility(View.VISIBLE);
} else { // 没有桩状态
if (fast_num.equals("")) {
window_tv_fast_free_num.setText("0");
} else {
window_tv_fast_free_num.setText(fast_num);
}
window_tv_fast_free_label.setVisibility(View.GONE);
window_tv_fast_total_num.setVisibility(View.GONE);
if (slow_num.equals("")) {
window_tv_slow_free_num.setText("0");
} else {
window_tv_slow_free_num.setText(slow_num);
}
window_tv_slow_free_label.setVisibility(View.GONE);
window_tv_slow_total_num.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);
MainMapActivity.isR = true;
HashMap<String, String> map = new HashMap<String, String>();
map.put("type", "详情");
MobclickAgent.onEvent(context, "0102", map);
map.clear();
}
});
windowLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
switch (motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
mPosX = motionEvent.getX();
mPosY = motionEvent.getY();
mCurPosX = 0;
mCurPosY = 0;
break;
case MotionEvent.ACTION_MOVE:
mCurPosX = motionEvent.getX();
mCurPosY = motionEvent.getY();
break;
case MotionEvent.ACTION_UP:
if (mCurPosY != 0 && mCurPosY > mPosY && Math.abs(mCurPosY - mPosY) > 25) { // 向下滑动
// 取消气泡选中状态
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(current_chargePoint.getSupplier())) {
nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker2));
} else {
nMarker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.icon_newmarker3));
}
}
}
}
// 隐藏气泡弹窗视图
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.out);
animation.setDuration(500);
windowLayout.startAnimation(animation);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
windowLayout.setVisibility(View.GONE);
rl_control.setVisibility(View.VISIBLE);
}
}, 500);
} else if (mCurPosY != 0 && mCurPosY < mPosY && Math.abs(mCurPosY - mPosY) > 25) { // 向上活动
System.out.println("up");
} else if (mCurPosX != 0 && mCurPosX > mPosX && Math.abs(mCurPosX - mPosX) > 25) { // 向右滑动
System.out.println("right");
} else if (mCurPosX != 0 && mCurPosX < mPosX && Math.abs(mCurPosX - mPosX) > 25) { // 向左滑动
System.out.println("left");
} else { // 点击事件
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();
}
break;
}
return true;
}
});
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);
clickMarkAndMove(0);
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();
}
// url = "http://192.168.1.104:8000/";
// url = "https://www.d1ev.com/special/t/application.html?s=JUU1JUE1JTg3JUU3JTkxJTlFJUU1JUIwJThGJUU4JTlBJTgyJUU4JTlBJTgxLCVFNiVBQyVBNyVFNiU4QiU4OVIxLCVFNSU4QyU5NyVFNiVCMSVCREVDMw==";
// 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);
clickMarkAndMove(65);
}
//站点导航
final String finalRemind = remind;
windowGo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
infoViewNavigate();
}
});
Animation animation = AnimationUtils.loadAnimation(this, R.anim.in);
animation.setDuration(500);
windowLayout.startAnimation(animation);
windowLayout.setVisibility(View.VISIBLE);
SharedPreferencesUtil sharedPreferencesUtil = new SharedPreferencesUtil(getApplication());
boolean showedExampleActivity = sharedPreferencesUtil.hasKey("cdz_showed_example_activity");
if (!showedExampleActivity) {
Intent pIntent = new Intent(getApplicationContext(), ExampleActivity.class);
pIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(pIntent);
overridePendingTransition(0, 0);
}
}
/**
* 点击气泡进行导航
* add by hyg
*/
private void infoViewNavigate() {
if (zhanInfo == null) {
return;
}
if (nMarker == null) {
return;
}
final LatLng ll = nMarker.getPosition();
final String id = JsonUtils.getKeyResult(zhanInfo, "id");
final String zhan_name = JsonUtils.getKeyResult(zhanInfo, "zhan_name");
String stop_cost = JsonUtils.getKeyResult(zhanInfo, "stop_cost");
String own_pay = JsonUtils.getKeyResult(zhanInfo, "own_pay");
String charge_cost_way2 = JsonUtils.getKeyResult(zhanInfo, "charge_cost_way2");
final String charge_cost_way = JsonUtils.getKeyResult(zhanInfo, "charge_cost_way");
String other_cost = JsonUtils.getKeyResult(zhanInfo, "other_cost");
String charge_cost = JsonUtils.getKeyResult(zhanInfo, "charge_cost");
String total_num = JsonUtils.getKeyResult(zhanInfo, "total_num");
String slow_num = JsonUtils.getKeyResult(zhanInfo, "slow_num");
String fast_num = JsonUtils.getKeyResult(zhanInfo, "fast_num");
String remind = JsonUtils.getKeyResult(zhanInfo, "remind"); // remind 0 正常 2 休息中 other 故障
final String city = JsonUtils.getKeyResult(zhanInfo, "city");
final String poi_jing = JsonUtils.getKeyResult(zhanInfo, "poi_jing");
final String poi_wei = JsonUtils.getKeyResult(zhanInfo, "poi_wei");
String belongAttribute = JsonUtils.getKeyResult(zhanInfo, "belong_attribute");
HashMap<String, String> mapp = new HashMap<String, String>();
mapp.put("type", "导航");
MobclickAgent.onEvent(context, "0102", mapp);
mapp.clear();
if (remind.equals("0")) { // 正常显示导航
if (belongAttribute.contains("私人")) {
new com.electric.chargingpile.view.AlertDialog(MainMapActivity.this).builder()
.setMsg("该站为私人站点,建议\n先联系桩主后再前往")
.setPositiveButton("继续", new View.OnClickListener() {
@Override
public void onClick(View v) {
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 + "");
intent.putExtra("stop_wei", 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) {
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";
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);
} else {
Toast.makeText(getApplication(), "没有定位到您的当前位置", Toast.LENGTH_SHORT).show();
}
}
}
}).setNegativeButton("取消", new View.OnClickListener() {
@Override
public void onClick(View v) {
}
}).show();
} else {
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 + "");
intent.putExtra("stop_wei", 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) {
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";
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);
} else {
Toast.makeText(getApplication(), "没有定位到您的当前位置", Toast.LENGTH_SHORT).show();
}
}
}
} else if (remind.equals("2")) {
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 + "");
intent.putExtra("stop_wei", 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) {
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";
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);
} 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) {
}
});
}
}
|