路径接口
This commit is contained in:
@@ -5,10 +5,13 @@ import android.content.Context;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.GradientDrawable;
|
import android.graphics.drawable.GradientDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
@@ -20,6 +23,7 @@ import android.widget.EditText;
|
|||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.amap.api.location.AMapLocation;
|
import com.amap.api.location.AMapLocation;
|
||||||
@@ -43,10 +47,7 @@ import com.amap.api.navi.AmapNaviPage;
|
|||||||
import com.amap.api.navi.AmapNaviParams;
|
import com.amap.api.navi.AmapNaviParams;
|
||||||
import com.amap.api.navi.AmapNaviType;
|
import com.amap.api.navi.AmapNaviType;
|
||||||
import com.amap.api.navi.AmapPageType;
|
import com.amap.api.navi.AmapPageType;
|
||||||
import com.amap.api.navi.INaviInfoCallback;
|
|
||||||
import com.amap.api.navi.enums.PathPlanningStrategy;
|
|
||||||
import com.amap.api.navi.model.AMapCarInfo;
|
import com.amap.api.navi.model.AMapCarInfo;
|
||||||
import com.amap.api.navi.model.AMapNaviLocation;
|
|
||||||
import com.amap.api.services.core.AMapException;
|
import com.amap.api.services.core.AMapException;
|
||||||
import com.amap.api.services.core.LatLonPoint;
|
import com.amap.api.services.core.LatLonPoint;
|
||||||
import com.amap.api.services.geocoder.GeocodeResult;
|
import com.amap.api.services.geocoder.GeocodeResult;
|
||||||
@@ -54,7 +55,11 @@ import com.amap.api.services.geocoder.GeocodeSearch;
|
|||||||
import com.amap.api.services.geocoder.RegeocodeAddress;
|
import com.amap.api.services.geocoder.RegeocodeAddress;
|
||||||
import com.amap.api.services.geocoder.RegeocodeQuery;
|
import com.amap.api.services.geocoder.RegeocodeQuery;
|
||||||
import com.amap.api.services.geocoder.RegeocodeResult;
|
import com.amap.api.services.geocoder.RegeocodeResult;
|
||||||
|
import com.amap.api.services.help.Inputtips;
|
||||||
|
import com.amap.api.services.help.InputtipsQuery;
|
||||||
|
import com.amap.api.services.help.Tip;
|
||||||
import com.amap.api.services.route.BusRouteResult;
|
import com.amap.api.services.route.BusRouteResult;
|
||||||
|
import com.amap.api.services.route.DrivePath;
|
||||||
import com.amap.api.services.route.DriveRouteResult;
|
import com.amap.api.services.route.DriveRouteResult;
|
||||||
import com.amap.api.services.route.RideRouteResult;
|
import com.amap.api.services.route.RideRouteResult;
|
||||||
import com.amap.api.services.route.RouteSearch;
|
import com.amap.api.services.route.RouteSearch;
|
||||||
@@ -78,33 +83,33 @@ import okhttp3.RequestBody;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 高德地图导航
|
* 高德地图导航 Native View - 底部精简交互优化版
|
||||||
*/
|
*/
|
||||||
public class NativeMapView implements PlatformView, LocationSource, AMapLocationListener,
|
public class NativeMapView implements PlatformView, LocationSource, AMapLocationListener,
|
||||||
GeocodeSearch.OnGeocodeSearchListener, RouteSearch.OnRouteSearchListener, AMap.OnMarkerClickListener {
|
GeocodeSearch.OnGeocodeSearchListener, RouteSearch.OnRouteSearchListener, AMap.OnMarkerClickListener, Inputtips.InputtipsListener {
|
||||||
|
|
||||||
private static final String TAG = "NativeMapView";
|
private static final String TAG = "NativeMapView";
|
||||||
private final FrameLayout container;
|
private final FrameLayout container;
|
||||||
|
|
||||||
// 地图相关
|
|
||||||
private MapView mapView;
|
private MapView mapView;
|
||||||
private AMap aMap;
|
private AMap aMap;
|
||||||
private OnLocationChangedListener mListener;
|
private OnLocationChangedListener mListener;
|
||||||
|
|
||||||
// 定位相关
|
|
||||||
private AMapLocationClient mlocationClient;
|
private AMapLocationClient mlocationClient;
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private Activity mActivity; // 保存Activity引用用于导航
|
private Activity mActivity;
|
||||||
private GeocodeSearch geocoderSearch;
|
private GeocodeSearch geocoderSearch;
|
||||||
private RouteSearch routeSearch;
|
private RouteSearch routeSearch;
|
||||||
private final OkHttpClient httpClient = new OkHttpClient();
|
private final OkHttpClient httpClient = new OkHttpClient();
|
||||||
|
|
||||||
// UI组件
|
// UI组件
|
||||||
private EditText startInput;
|
|
||||||
private EditText endInput;
|
private EditText endInput;
|
||||||
|
private LinearLayout searchArea; // 规划路线面板
|
||||||
|
private LinearLayout detailPanel; // 详情面板
|
||||||
|
private TextView tvStationName, tvStationAddr, tvRouteInfo;
|
||||||
|
|
||||||
private LatLng currentLatLng;
|
private LatLng currentLatLng;
|
||||||
private String startName = "我的位置";
|
private String startName = "我的位置";
|
||||||
private String endName = "目的地";
|
private String endName = "";
|
||||||
private LatLng startPoint;
|
private LatLng startPoint;
|
||||||
private LatLng endPoint;
|
private LatLng endPoint;
|
||||||
private boolean isFirstLocation = true;
|
private boolean isFirstLocation = true;
|
||||||
@@ -112,8 +117,6 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
|
|
||||||
public NativeMapView(Context context, int id, Object args) {
|
public NativeMapView(Context context, int id, Object args) {
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
|
|
||||||
// 尝试获取Activity引用
|
|
||||||
mActivity = getActivityFromContext(context);
|
mActivity = getActivityFromContext(context);
|
||||||
|
|
||||||
MapsInitializer.updatePrivacyShow(context, true, true);
|
MapsInitializer.updatePrivacyShow(context, true, true);
|
||||||
@@ -127,24 +130,17 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
mapView.onCreate(null);
|
mapView.onCreate(null);
|
||||||
aMap = mapView.getMap();
|
aMap = mapView.getMap();
|
||||||
|
|
||||||
container.addView(mapView, new FrameLayout.LayoutParams(
|
container.addView(mapView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
||||||
|
|
||||||
initServices(context);
|
initServices(context);
|
||||||
initOverlays(context);
|
initOverlays(context);
|
||||||
setupMapUi();
|
setupMapUi();
|
||||||
|
|
||||||
// 通知MainActivity
|
|
||||||
if (context instanceof MainActivity) {
|
if (context instanceof MainActivity) {
|
||||||
((MainActivity) context).setMapView(this);
|
((MainActivity) context).setMapView(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.d(TAG, "NativeMapView初始化完成");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化服务
|
|
||||||
*/
|
|
||||||
private void initServices(Context context) {
|
private void initServices(Context context) {
|
||||||
try {
|
try {
|
||||||
geocoderSearch = new GeocodeSearch(context);
|
geocoderSearch = new GeocodeSearch(context);
|
||||||
@@ -156,75 +152,209 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化覆盖层UI
|
|
||||||
*/
|
|
||||||
private void initOverlays(Context context) {
|
private void initOverlays(Context context) {
|
||||||
LinearLayout searchBox = new LinearLayout(context);
|
// --- 底部主容器 (包含两个互斥显示的面板) ---
|
||||||
searchBox.setOrientation(LinearLayout.VERTICAL);
|
LinearLayout bottomContainer = new LinearLayout(context);
|
||||||
searchBox.setBackground(getRoundedDrawable(Color.WHITE, 12));
|
bottomContainer.setOrientation(LinearLayout.VERTICAL);
|
||||||
searchBox.setElevation(dp2px(8));
|
bottomContainer.setGravity(Gravity.BOTTOM);
|
||||||
int p = dp2px(15);
|
|
||||||
searchBox.setPadding(p, p, p, p);
|
|
||||||
searchBox.setClickable(true);
|
|
||||||
searchBox.setFocusable(true);
|
|
||||||
|
|
||||||
startInput = createInput(context, "起点: 正在定位...");
|
// 1. 详情面板 (用于显示加氢站详细信息,初始隐藏)
|
||||||
searchBox.addView(startInput);
|
detailPanel = createDetailPanel(context);
|
||||||
|
detailPanel.setVisibility(View.GONE);
|
||||||
|
bottomContainer.addView(detailPanel);
|
||||||
|
|
||||||
|
// 2. 搜索规划面板 (初始显示)
|
||||||
|
searchArea = new LinearLayout(context);
|
||||||
|
searchArea.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
searchArea.setBackground(getRoundedDrawable(Color.WHITE, 16));
|
||||||
|
searchArea.setElevation(dp2px(10));
|
||||||
|
int p = dp2px(15);
|
||||||
|
searchArea.setPadding(p, p, p, p);
|
||||||
|
|
||||||
|
endInput = new EditText(context);
|
||||||
|
endInput.setHint("请输入目的地,不输入则自动匹配推荐加氢站");
|
||||||
|
endInput.setTextSize(13);
|
||||||
|
endInput.setHintTextColor(Color.LTGRAY);
|
||||||
|
endInput.setPadding(dp2px(12), dp2px(12), dp2px(12), dp2px(12));
|
||||||
|
endInput.setBackground(getRoundedDrawable(Color.parseColor("#F8F8F8"), 8));
|
||||||
|
endInput.setSingleLine(true);
|
||||||
|
endInput.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
|
||||||
|
endInput.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||||
|
@Override public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||||
|
if (s.length() > 1) {
|
||||||
|
InputtipsQuery query = new InputtipsQuery(s.toString(), "");
|
||||||
|
query.setCityLimit(true);
|
||||||
|
Inputtips inputtips = new Inputtips(mContext, query);
|
||||||
|
inputtips.setInputtipsListener(NativeMapView.this);
|
||||||
|
inputtips.requestInputtipsAsyn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override public void afterTextChanged(Editable s) {}
|
||||||
|
});
|
||||||
|
searchArea.addView(endInput);
|
||||||
|
|
||||||
View vSpace = new View(context);
|
View vSpace = new View(context);
|
||||||
searchBox.addView(vSpace, new LinearLayout.LayoutParams(1, dp2px(10)));
|
searchArea.addView(vSpace, new LinearLayout.LayoutParams(1, dp2px(12)));
|
||||||
|
|
||||||
LinearLayout endRow = new LinearLayout(context);
|
Button planBtn = new Button(context);
|
||||||
endRow.setOrientation(LinearLayout.HORIZONTAL);
|
planBtn.setText("规划路线");
|
||||||
endRow.setGravity(Gravity.CENTER_VERTICAL);
|
planBtn.setTextColor(Color.WHITE);
|
||||||
|
planBtn.setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
|
planBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 10));
|
||||||
|
planBtn.setOnClickListener(v -> calculateRouteBeforeNavi());
|
||||||
|
searchArea.addView(planBtn, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48)));
|
||||||
|
|
||||||
endInput = createInput(context, "终点: 请输入目的地");
|
bottomContainer.addView(searchArea);
|
||||||
endRow.addView(endInput, new LinearLayout.LayoutParams(0, dp2px(42), 1f));
|
|
||||||
|
|
||||||
Button routeBtn = new Button(context);
|
// 设置统一的底部间距
|
||||||
routeBtn.setText("路径规划");
|
FrameLayout.LayoutParams bottomParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
routeBtn.setTextColor(Color.WHITE);
|
bottomParams.gravity = Gravity.BOTTOM;
|
||||||
routeBtn.setAllCaps(false);
|
bottomParams.setMargins(dp2px(12), 0, dp2px(12), dp2px(65));
|
||||||
routeBtn.setTextSize(14);
|
container.addView(bottomContainer, bottomParams);
|
||||||
routeBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 6));
|
|
||||||
routeBtn.setOnClickListener(v -> startRouteSearch());
|
|
||||||
endRow.addView(routeBtn, new LinearLayout.LayoutParams(dp2px(90), dp2px(42)));
|
|
||||||
|
|
||||||
searchBox.addView(endRow);
|
|
||||||
|
|
||||||
FrameLayout.LayoutParams searchParams = new FrameLayout.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
||||||
searchParams.setMargins(dp2px(15), dp2px(50), dp2px(15), 0);
|
|
||||||
container.addView(searchBox, searchParams);
|
|
||||||
|
|
||||||
|
// --- 右下角定位按钮 ---
|
||||||
ImageButton locBtn = new ImageButton(context);
|
ImageButton locBtn = new ImageButton(context);
|
||||||
locBtn.setImageResource(android.R.drawable.ic_menu_mylocation);
|
locBtn.setImageResource(android.R.drawable.ic_menu_mylocation);
|
||||||
locBtn.setBackground(getRoundedDrawable(Color.WHITE, 30));
|
locBtn.setBackground(getRoundedDrawable(Color.WHITE, 25));
|
||||||
locBtn.setElevation(dp2px(4));
|
locBtn.setElevation(dp2px(4));
|
||||||
locBtn.setOnClickListener(v -> {
|
locBtn.setOnClickListener(v -> {
|
||||||
if (currentLatLng != null) {
|
if (currentLatLng != null) aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 15f));
|
||||||
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 15f));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
FrameLayout.LayoutParams locParams = new FrameLayout.LayoutParams(dp2px(50), dp2px(50));
|
FrameLayout.LayoutParams locParams = new FrameLayout.LayoutParams(dp2px(44), dp2px(44));
|
||||||
locParams.setMargins(0, 0, dp2px(20), dp2px(120));
|
locParams.setMargins(0, 0, dp2px(15), dp2px(250)); // 调高一点,避开底部的面板
|
||||||
locParams.gravity = Gravity.BOTTOM | Gravity.END;
|
locParams.gravity = Gravity.BOTTOM | Gravity.END;
|
||||||
container.addView(locBtn, locParams);
|
container.addView(locBtn, locParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EditText createInput(Context context, String hint) {
|
private LinearLayout createDetailPanel(Context context) {
|
||||||
EditText et = new EditText(context);
|
LinearLayout panel = new LinearLayout(context);
|
||||||
et.setHint(hint);
|
panel.setOrientation(LinearLayout.VERTICAL);
|
||||||
et.setTextSize(14f);
|
panel.setBackground(getRoundedDrawable(Color.WHITE, 16));
|
||||||
et.setTextColor(Color.BLACK);
|
panel.setPadding(dp2px(20), dp2px(20), dp2px(20), dp2px(20));
|
||||||
et.setPadding(dp2px(12), dp2px(10), dp2px(12), dp2px(10));
|
panel.setElevation(dp2px(12));
|
||||||
et.setBackground(getRoundedDrawable(Color.parseColor("#F5F5F5"), 6));
|
|
||||||
et.setSingleLine(true);
|
tvStationName = new TextView(context);
|
||||||
et.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
tvStationName.setTextSize(18);
|
||||||
et.setFocusable(true);
|
tvStationName.setTextColor(Color.BLACK);
|
||||||
et.setFocusableInTouchMode(true);
|
tvStationName.setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
return et;
|
panel.addView(tvStationName);
|
||||||
|
|
||||||
|
tvStationAddr = new TextView(context);
|
||||||
|
tvStationAddr.setTextSize(13);
|
||||||
|
tvStationAddr.setPadding(0, dp2px(4), 0, dp2px(10));
|
||||||
|
tvStationAddr.setTextColor(Color.GRAY);
|
||||||
|
panel.addView(tvStationAddr);
|
||||||
|
|
||||||
|
tvRouteInfo = new TextView(context);
|
||||||
|
tvRouteInfo.setTextSize(14);
|
||||||
|
tvRouteInfo.setTextColor(Color.parseColor("#333333"));
|
||||||
|
panel.addView(tvRouteInfo);
|
||||||
|
|
||||||
|
Button startNaviBtn = new Button(context);
|
||||||
|
startNaviBtn.setText("开始导航");
|
||||||
|
startNaviBtn.setTextColor(Color.WHITE);
|
||||||
|
startNaviBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 10));
|
||||||
|
startNaviBtn.setOnClickListener(v -> startRouteSearch());
|
||||||
|
|
||||||
|
LinearLayout.LayoutParams btnParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48));
|
||||||
|
btnParams.topMargin = dp2px(15);
|
||||||
|
panel.addView(startNaviBtn, btnParams);
|
||||||
|
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void calculateRouteBeforeNavi() {
|
||||||
|
if (startPoint == null) {
|
||||||
|
Toast.makeText(mContext, "正在定位...", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (endPoint == null) {
|
||||||
|
Toast.makeText(mContext, "请先选择目的地", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 开始规划前隐藏输入框面板
|
||||||
|
searchArea.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
RouteSearch.FromAndTo fromAndTo = new RouteSearch.FromAndTo(
|
||||||
|
new LatLonPoint(startPoint.latitude, startPoint.longitude),
|
||||||
|
new LatLonPoint(endPoint.latitude, endPoint.longitude));
|
||||||
|
RouteSearch.DriveRouteQuery query = new RouteSearch.DriveRouteQuery(fromAndTo, RouteSearch.DRIVING_SINGLE_DEFAULT, null, null, "");
|
||||||
|
routeSearch.calculateDriveRouteAsyn(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGetInputtips(List<Tip> tipList, int rCode) {
|
||||||
|
if (rCode == 1000 && tipList != null && !tipList.isEmpty()) {
|
||||||
|
Tip tip = tipList.get(0);
|
||||||
|
if (tip.getPoint() != null) {
|
||||||
|
endPoint = new LatLng(tip.getPoint().getLatitude(), tip.getPoint().getLongitude());
|
||||||
|
endName = tip.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDriveRouteSearched(DriveRouteResult result, int rCode) {
|
||||||
|
if (rCode == AMapException.CODE_AMAP_SUCCESS && result != null && !result.getPaths().isEmpty()) {
|
||||||
|
DrivePath path = result.getPaths().get(0);
|
||||||
|
|
||||||
|
// 规划成功,显示详情面板
|
||||||
|
detailPanel.setVisibility(View.VISIBLE);
|
||||||
|
tvStationName.setText(endName);
|
||||||
|
tvStationAddr.setText(endInput.getText().toString());
|
||||||
|
|
||||||
|
String info = String.format("预计时间:%d分钟 | 行驶里程:%.1f公里 | 预计路费:%.0f元",
|
||||||
|
path.getDuration() / 60, path.getDistance() / 1000f, path.getTolls());
|
||||||
|
tvRouteInfo.setText(info);
|
||||||
|
|
||||||
|
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(endPoint, 13f));
|
||||||
|
} else {
|
||||||
|
// 规划失败回退面板
|
||||||
|
searchArea.setVisibility(View.VISIBLE);
|
||||||
|
Toast.makeText(mContext, "路径规划失败: " + rCode, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startRouteSearch() {
|
||||||
|
if (mActivity == null || startPoint == null || endPoint == null) return;
|
||||||
|
|
||||||
|
Poi start = new Poi(startName, startPoint, "");
|
||||||
|
Poi end = new Poi(endName, endPoint, "");
|
||||||
|
AmapNaviParams params = new AmapNaviParams(start, null, end, AmapNaviType.DRIVER, AmapPageType.ROUTE);
|
||||||
|
|
||||||
|
try {
|
||||||
|
AMapNavi mAMapNavi = AMapNavi.getInstance(mContext);
|
||||||
|
AMapCarInfo carInfo = new AMapCarInfo();
|
||||||
|
carInfo.setCarNumber("沪AGK2267");
|
||||||
|
carInfo.setCarType("1");
|
||||||
|
mAMapNavi.setCarInfo(carInfo);
|
||||||
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
|
|
||||||
|
AmapNaviPage.getInstance().showRouteActivity(mActivity, params, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupMapUi() {
|
||||||
|
aMap.setLocationSource(this);
|
||||||
|
aMap.setMyLocationEnabled(true);
|
||||||
|
aMap.setOnMarkerClickListener(this);
|
||||||
|
|
||||||
|
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
||||||
|
try {
|
||||||
|
Bitmap carBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.car);
|
||||||
|
if (carBitmap != null) {
|
||||||
|
Bitmap scaledBitmap = Bitmap.createScaledBitmap(carBitmap, dp2px(30), dp2px(30), true);
|
||||||
|
myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap));
|
||||||
|
}
|
||||||
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
|
|
||||||
|
myLocationStyle.anchor(0.5f, 0.5f);
|
||||||
|
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
||||||
|
aMap.setMyLocationStyle(myLocationStyle);
|
||||||
|
aMap.getUiSettings().setZoomControlsEnabled(false);
|
||||||
|
aMap.getUiSettings().setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GradientDrawable getRoundedDrawable(int color, int radiusDp) {
|
private GradientDrawable getRoundedDrawable(int color, int radiusDp) {
|
||||||
@@ -239,55 +369,9 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, mContext.getResources().getDisplayMetrics());
|
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, mContext.getResources().getDisplayMetrics());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupMapUi() {
|
@Override public void activate(OnLocationChangedListener listener) { mListener = listener; startLocation(); }
|
||||||
aMap.setLocationSource(this);
|
@Override public void deactivate() { mListener = null; if (mlocationClient != null) mlocationClient.stopLocation(); }
|
||||||
aMap.setMyLocationEnabled(true);
|
|
||||||
aMap.setOnMarkerClickListener(this);
|
|
||||||
|
|
||||||
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
|
||||||
|
|
||||||
// --- 放大定位图标 ---
|
|
||||||
try {
|
|
||||||
Bitmap carBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.car);
|
|
||||||
if (carBitmap != null) {
|
|
||||||
// 放大到 80dp
|
|
||||||
int iconSize = dp2px(25);
|
|
||||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(carBitmap, iconSize, iconSize, true);
|
|
||||||
myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "设置大图标失败", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
myLocationStyle.anchor(0.5f, 0.5f);
|
|
||||||
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
|
||||||
myLocationStyle.showMyLocation(true);
|
|
||||||
myLocationStyle.strokeColor(Color.TRANSPARENT);
|
|
||||||
myLocationStyle.radiusFillColor(Color.TRANSPARENT);
|
|
||||||
aMap.setMyLocationStyle(myLocationStyle);
|
|
||||||
|
|
||||||
aMap.getUiSettings().setZoomControlsEnabled(true);
|
|
||||||
aMap.getUiSettings().setScaleControlsEnabled(true);
|
|
||||||
aMap.getUiSettings().setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== LocationSource 接口实现 ====================
|
|
||||||
@Override
|
|
||||||
public void activate(OnLocationChangedListener listener) {
|
|
||||||
mListener = listener;
|
|
||||||
startLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deactivate() {
|
|
||||||
mListener = null;
|
|
||||||
if (mlocationClient != null) {
|
|
||||||
mlocationClient.stopLocation();
|
|
||||||
mlocationClient.onDestroy();
|
|
||||||
}
|
|
||||||
mlocationClient = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startLocation() {
|
public void startLocation() {
|
||||||
if (mlocationClient == null) {
|
if (mlocationClient == null) {
|
||||||
try {
|
try {
|
||||||
@@ -297,135 +381,49 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
|
option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
|
||||||
mlocationClient.setLocationOption(option);
|
mlocationClient.setLocationOption(option);
|
||||||
mlocationClient.startLocation();
|
mlocationClient.startLocation();
|
||||||
Log.d(TAG, "定位启动成功");
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "定位启动失败", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged(AMapLocation loc) {
|
public void onLocationChanged(AMapLocation loc) {
|
||||||
if (loc != null) {
|
if (loc != null && loc.getErrorCode() == 0) {
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onLocationChanged(loc);
|
|
||||||
}
|
|
||||||
currentLatLng = new LatLng(loc.getLatitude(), loc.getLongitude());
|
currentLatLng = new LatLng(loc.getLatitude(), loc.getLongitude());
|
||||||
|
if (mListener != null) mListener.onLocationChanged(loc);
|
||||||
if (loc.getErrorCode() == 0) {
|
if (isFirstLocation) {
|
||||||
if (isFirstLocation) {
|
isFirstLocation = false;
|
||||||
isFirstLocation = false;
|
startPoint = currentLatLng;
|
||||||
startPoint = currentLatLng;
|
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 14f));
|
||||||
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 14f));
|
getAddressByLatlng(currentLatLng);
|
||||||
getAddressByLatlng(currentLatLng);
|
fetchRecommendStation(loc);
|
||||||
fetchRecommendStation(loc);
|
fetchNearbyStations(loc);
|
||||||
fetchNearbyStations(loc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 逆地理编码 ====================
|
|
||||||
private void getAddressByLatlng(LatLng latLng) {
|
private void getAddressByLatlng(LatLng latLng) {
|
||||||
LatLonPoint point = new LatLonPoint(latLng.latitude, latLng.longitude);
|
geocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(latLng.latitude, latLng.longitude), 200, GeocodeSearch.AMAP));
|
||||||
RegeocodeQuery query = new RegeocodeQuery(point, 200, GeocodeSearch.AMAP);
|
|
||||||
geocoderSearch.getFromLocationAsyn(query);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
|
public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
|
||||||
if (rCode == AMapException.CODE_AMAP_SUCCESS && result != null && result.getRegeocodeAddress() != null) {
|
if (rCode == 1000 && result != null) {
|
||||||
RegeocodeAddress addr = result.getRegeocodeAddress();
|
RegeocodeAddress addr = result.getRegeocodeAddress();
|
||||||
String fullAddr = addr.getFormatAddress();
|
startName = addr.getStreetNumber() != null ? addr.getStreetNumber().getStreet() : addr.getDistrict();
|
||||||
|
|
||||||
// 优化地址显示逻辑
|
|
||||||
startName = formatAddress(fullAddr,result);
|
|
||||||
|
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
|
||||||
startInput.setText(startName);
|
|
||||||
startInput.setSelection(startName.length()); // 光标移到末尾
|
|
||||||
});
|
|
||||||
|
|
||||||
Log.d(TAG, "逆地理编码成功: " + startName);
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "逆地理编码失败: code=" + rCode + ", result=" + (result != null ? "null" : "has data"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 格式化地址显示,移除重复的前缀并限制长度
|
|
||||||
*/
|
|
||||||
private String formatAddress(String fullAddress,RegeocodeResult result) {
|
|
||||||
if (fullAddress == null || fullAddress.isEmpty()) {
|
|
||||||
return "未知地点";
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取各级地址信息
|
|
||||||
String province = null;
|
|
||||||
String city = null;
|
|
||||||
String district = null;
|
|
||||||
String township = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (result.getRegeocodeAddress() != null) {
|
|
||||||
RegeocodeAddress addr = result.getRegeocodeAddress();
|
|
||||||
province = addr.getProvince();
|
|
||||||
city = addr.getCity();
|
|
||||||
district = addr.getDistrict();
|
|
||||||
township = addr.getTownship();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "获取地址信息失败", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
String formattedAddr = fullAddress;
|
|
||||||
|
|
||||||
// 按优先级移除重复前缀(省、市、区、乡)
|
|
||||||
String[] prefixes = {province, city, district, township};
|
|
||||||
for (String prefix : prefixes) {
|
|
||||||
if (prefix != null && !prefix.isEmpty() && formattedAddr.startsWith(prefix)) {
|
|
||||||
formattedAddr = formattedAddr.substring(prefix.length());
|
|
||||||
Log.d(TAG, "移除前缀: " + prefix + " -> " + formattedAddr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 限制地址长度并添加省略号
|
|
||||||
if (formattedAddr.length() > 25) {
|
|
||||||
formattedAddr = formattedAddr.substring(0, 25) + "...";
|
|
||||||
Log.d(TAG, "地址长度截断: " + formattedAddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return formattedAddr;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGeocodeSearched(GeocodeResult result, int rCode) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== API请求 ====================
|
|
||||||
|
|
||||||
private void fetchRecommendStation(AMapLocation loc) {
|
private void fetchRecommendStation(AMapLocation loc) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("province", loc.getProvince() != null ? loc.getProvince() : "");
|
json.put("province", loc.getProvince());
|
||||||
json.put("city", loc.getCity() != null && !loc.getCity().isEmpty() ? loc.getCity() : "");
|
json.put("city", loc.getCity().isEmpty() ? loc.getProvince() : loc.getCity());
|
||||||
json.put("district", loc.getDistrict() != null ? loc.getDistrict() : "");
|
json.put("longitude", loc.getLongitude());
|
||||||
json.put("longitude", String.valueOf(loc.getLongitude()));
|
json.put("latitude", loc.getLatitude());
|
||||||
json.put("latitude", String.valueOf(loc.getLatitude()));
|
|
||||||
|
|
||||||
RequestBody body = RequestBody.create(json.toString(), MediaType.parse("application/json; charset=utf-8"));
|
httpClient.newCall(new Request.Builder().url("https://beta-esg.api.lnh2e.com/appointment/station/getStationInfoByArea").post(RequestBody.create(json.toString(), MediaType.parse("application/json"))).build()).enqueue(new Callback() {
|
||||||
Request request = new Request.Builder()
|
@Override public void onFailure(@NonNull Call call, @NonNull IOException e) {}
|
||||||
.url("https://beta-esg.api.lnh2e.com/appointment/station/getStationInfoByArea")
|
@Override public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
||||||
.post(body)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
httpClient.newCall(request).enqueue(new Callback() {
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
try {
|
try {
|
||||||
JSONObject res = new JSONObject(response.body().string());
|
JSONObject res = new JSONObject(response.body().string());
|
||||||
@@ -439,68 +437,43 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
markStation(endPoint, endName, true);
|
markStation(endPoint, endName, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchNearbyStations(AMapLocation loc) {
|
private void fetchNearbyStations(AMapLocation loc) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("longitude", String.valueOf(loc.getLongitude()));
|
json.put("longitude", loc.getLongitude());
|
||||||
json.put("latitude", String.valueOf(loc.getLatitude()));
|
json.put("latitude", loc.getLatitude());
|
||||||
|
|
||||||
RequestBody body = RequestBody.create(json.toString(), MediaType.parse("application/json; charset=utf-8"));
|
httpClient.newCall(new Request.Builder().url("https://beta-esg.api.lnh2e.com/appointment/station/getNearbyHydrogenStationsByLocation").post(RequestBody.create(json.toString(), MediaType.parse("application/json"))).build()).enqueue(new Callback() {
|
||||||
Request request = new Request.Builder()
|
@Override public void onFailure(@NonNull Call call, @NonNull IOException e) {}
|
||||||
.url("https://beta-esg.api.lnh2e.com/appointment/station/getNearbyHydrogenStationsByLocation")
|
@Override public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
||||||
.post(body)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
httpClient.newCall(request).enqueue(new Callback() {
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
|
||||||
if (response.isSuccessful() && response.body() != null) {
|
if (response.isSuccessful() && response.body() != null) {
|
||||||
try {
|
try {
|
||||||
JSONObject res = new JSONObject(response.body().string());
|
JSONObject res = new JSONObject(response.body().string());
|
||||||
if (res.getInt("code") == 0 && !res.isNull("data")) {
|
JSONArray array = res.getJSONArray("data");
|
||||||
JSONArray array = res.getJSONArray("data");
|
new Handler(Looper.getMainLooper()).post(() -> {
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
for (int i = 0; i < array.length(); i++) {
|
||||||
for (int i = 0; i < array.length(); i++) {
|
try {
|
||||||
try {
|
JSONObject item = array.getJSONObject(i);
|
||||||
JSONObject item = array.getJSONObject(i);
|
markStation(new LatLng(item.getDouble("latitude"), item.getDouble("longitude")), item.getString("name"), false);
|
||||||
markStation(new LatLng(item.getDouble("latitude"), item.getDouble("longitude")),
|
} catch (Exception ignored) {}
|
||||||
item.getString("name"), false);
|
}
|
||||||
} catch (Exception ignored) {
|
});
|
||||||
}
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) { e.printStackTrace(); }
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markStation(LatLng latLng, String name, boolean isRecommend) {
|
private void markStation(LatLng latLng, String name, boolean isRecommend) {
|
||||||
MarkerOptions opt = new MarkerOptions()
|
Marker m = aMap.addMarker(new MarkerOptions().position(latLng).title(name).icon(BitmapDescriptorFactory.defaultMarker(isRecommend ? BitmapDescriptorFactory.HUE_RED : BitmapDescriptorFactory.HUE_GREEN)));
|
||||||
.position(latLng).title(name)
|
|
||||||
.icon(BitmapDescriptorFactory.defaultMarker(isRecommend ? BitmapDescriptorFactory.HUE_RED : BitmapDescriptorFactory.HUE_GREEN));
|
|
||||||
Marker m = aMap.addMarker(opt);
|
|
||||||
m.setObject(latLng);
|
m.setObject(latLng);
|
||||||
stationMarkers.add(m);
|
stationMarkers.add(m);
|
||||||
}
|
}
|
||||||
@@ -511,185 +484,28 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
endPoint = (LatLng) marker.getObject();
|
endPoint = (LatLng) marker.getObject();
|
||||||
endName = marker.getTitle();
|
endName = marker.getTitle();
|
||||||
endInput.setText(endName);
|
endInput.setText(endName);
|
||||||
startRouteSearch();
|
calculateRouteBeforeNavi();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== 路径规划 ====================
|
@Override public void onGeocodeSearched(GeocodeResult r, int c) {}
|
||||||
|
@Override public void onBusRouteSearched(BusRouteResult r, int c) {}
|
||||||
private void startRouteSearch() {
|
@Override public void onWalkRouteSearched(WalkRouteResult r, int c) {}
|
||||||
if (startPoint == null || endPoint == null) {
|
@Override public void onRideRouteSearched(RideRouteResult r, int c) {}
|
||||||
Toast.makeText(mContext, "正在定位中,请稍后...", Toast.LENGTH_SHORT).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Poi start = new Poi(startName, startPoint, "");
|
|
||||||
Poi end = new Poi(endName, endPoint, "");
|
|
||||||
|
|
||||||
AmapNaviParams params = new AmapNaviParams(start, null, end, AmapNaviType.DRIVER, AmapPageType.ROUTE);
|
|
||||||
|
|
||||||
try {
|
|
||||||
AMapNavi mAMapNavi = AMapNavi.getInstance(mContext);
|
|
||||||
AMapCarInfo carInfo = new AMapCarInfo();
|
|
||||||
carInfo.setCarNumber("沪AGK2267");
|
|
||||||
carInfo.setCarType("1");
|
|
||||||
carInfo.setVehicleAxis("6");
|
|
||||||
carInfo.setVehicleHeight("3.32");
|
|
||||||
carInfo.setVehicleLength("6.9");
|
|
||||||
carInfo.setVehicleWidth("2.26");
|
|
||||||
carInfo.setVehicleSize("2");
|
|
||||||
carInfo.setVehicleLoad("4.5");
|
|
||||||
carInfo.setVehicleWeight("4.5");
|
|
||||||
carInfo.setRestriction(true);
|
|
||||||
carInfo.setVehicleLoadSwitch(true);
|
|
||||||
mAMapNavi.setCarInfo(carInfo);
|
|
||||||
} catch (com.amap.api.maps.AMapException e) {
|
|
||||||
Log.e(TAG, "设置车辆信息失败", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
params.setRouteStrategy(PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT);
|
|
||||||
|
|
||||||
if (mActivity != null) {
|
|
||||||
AmapNaviPage.getInstance().showRouteActivity(mActivity, params, new INaviInfoCallback() {
|
|
||||||
@Override
|
|
||||||
public void onInitNaviFailure() {
|
|
||||||
Log.e(TAG, "导航初始化失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGetNavigationText(String s) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLocationChange(AMapNaviLocation location) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onArriveDestination(boolean b) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartNavi(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCalculateRouteSuccess(int[] ints) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCalculateRouteFailure(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStopSpeaking() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onReCalculateRoute(int i) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onArrivedWayPoint(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onExitPage(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStrategyChanged(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMapTypeChanged(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNaviDirectionChanged(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDayAndNightModeChanged(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBroadcastModeChanged(int i) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScaleAutoChanged(boolean b) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getCustomNaviBottomView() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getCustomNaviView() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getCustomMiddleView() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDriveRouteSearched(DriveRouteResult result, int rCode) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBusRouteSearched(BusRouteResult r, int c) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWalkRouteSearched(WalkRouteResult r, int c) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRideRouteSearched(RideRouteResult r, int c) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private Activity getActivityFromContext(Context context) {
|
private Activity getActivityFromContext(Context context) {
|
||||||
if (context instanceof Activity)
|
if (context instanceof Activity) return (Activity) context;
|
||||||
return (Activity) context;
|
if (context instanceof android.content.ContextWrapper) return getActivityFromContext(((android.content.ContextWrapper) context).getBaseContext());
|
||||||
if (context instanceof android.content.ContextWrapper) {
|
|
||||||
Context base = ((android.content.ContextWrapper) context).getBaseContext();
|
|
||||||
if (base instanceof Activity)
|
|
||||||
return (Activity) base;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onResume() {
|
public void onResume() { mapView.onResume(); }
|
||||||
mapView.onResume();
|
public void onPause() { mapView.onPause(); }
|
||||||
}
|
public void onSaveInstanceState(Bundle out) { mapView.onSaveInstanceState(out); }
|
||||||
|
@Override public View getView() { return container; }
|
||||||
public void onPause() {
|
@Override public void dispose() {
|
||||||
mapView.onPause();
|
if (mlocationClient != null) { mlocationClient.stopLocation(); mlocationClient.onDestroy(); }
|
||||||
}
|
|
||||||
|
|
||||||
public void onSaveInstanceState(Bundle out) {
|
|
||||||
mapView.onSaveInstanceState(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView() {
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
if (mlocationClient != null) {
|
|
||||||
mlocationClient.stopLocation();
|
|
||||||
mlocationClient.onDestroy();
|
|
||||||
}
|
|
||||||
mapView.onDestroy();
|
mapView.onDestroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ PODS:
|
|||||||
- OrderedSet (6.0.3)
|
- OrderedSet (6.0.3)
|
||||||
- package_info_plus (0.4.5):
|
- package_info_plus (0.4.5):
|
||||||
- Flutter
|
- Flutter
|
||||||
|
- path_provider_foundation (0.0.1):
|
||||||
|
- Flutter
|
||||||
|
- FlutterMacOS
|
||||||
- permission_handler_apple (9.3.0):
|
- permission_handler_apple (9.3.0):
|
||||||
- Flutter
|
- Flutter
|
||||||
- shared_preferences_foundation (0.0.1):
|
- shared_preferences_foundation (0.0.1):
|
||||||
@@ -70,6 +73,7 @@ DEPENDENCIES:
|
|||||||
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
|
||||||
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/darwin`)
|
- mobile_scanner (from `.symlinks/plugins/mobile_scanner/darwin`)
|
||||||
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
|
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
|
||||||
|
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
|
||||||
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
|
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
|
||||||
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
|
||||||
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
|
||||||
@@ -114,6 +118,8 @@ EXTERNAL SOURCES:
|
|||||||
:path: ".symlinks/plugins/mobile_scanner/darwin"
|
:path: ".symlinks/plugins/mobile_scanner/darwin"
|
||||||
package_info_plus:
|
package_info_plus:
|
||||||
:path: ".symlinks/plugins/package_info_plus/ios"
|
:path: ".symlinks/plugins/package_info_plus/ios"
|
||||||
|
path_provider_foundation:
|
||||||
|
:path: ".symlinks/plugins/path_provider_foundation/darwin"
|
||||||
permission_handler_apple:
|
permission_handler_apple:
|
||||||
:path: ".symlinks/plugins/permission_handler_apple/ios"
|
:path: ".symlinks/plugins/permission_handler_apple/ios"
|
||||||
shared_preferences_foundation:
|
shared_preferences_foundation:
|
||||||
@@ -125,28 +131,29 @@ SPEC CHECKSUMS:
|
|||||||
AlicloudELS: fbf821383330465a5af84a033f36f263ae46ca41
|
AlicloudELS: fbf821383330465a5af84a033f36f263ae46ca41
|
||||||
AlicloudPush: 52cbf38ffc20c07f039cbc72d5738745fd986215
|
AlicloudPush: 52cbf38ffc20c07f039cbc72d5738745fd986215
|
||||||
AlicloudUTDID: 5d2f22d50e11eecd38f30bc7a48c71925ea90976
|
AlicloudUTDID: 5d2f22d50e11eecd38f30bc7a48c71925ea90976
|
||||||
aliyun_push_flutter: ab0bf7112ef3797f506770a7a9f47f004635a9f6
|
aliyun_push_flutter: 0fc2f048a08687ef256c0cfdd72dd7a550ef3347
|
||||||
AMapFoundation-NO-IDFA: 6ce0ef596d4eb8d934ff498e56747b6de1247b05
|
AMapFoundation-NO-IDFA: 6ce0ef596d4eb8d934ff498e56747b6de1247b05
|
||||||
AMapLocation-NO-IDFA: 590fd42af0c8ea9eac26978348221bbc16be4ef9
|
AMapLocation-NO-IDFA: 590fd42af0c8ea9eac26978348221bbc16be4ef9
|
||||||
AMapNavi-NO-IDFA: 22edfa7d6a81d75c91756e31b6c26b7746152233
|
AMapNavi-NO-IDFA: 22edfa7d6a81d75c91756e31b6c26b7746152233
|
||||||
AMapNavIOSSDK: 0cd6ec22ab6b6aba268028a5b580e18bb8066f7e
|
AMapNavIOSSDK: ca325c9ac3378daea6a6be4bd8c34fe48d3ac896
|
||||||
AMapSearch-NO-IDFA: 53b2193244be8f07f3be0a4d5161200236960587
|
AMapSearch-NO-IDFA: 53b2193244be8f07f3be0a4d5161200236960587
|
||||||
connectivity_plus: 2a701ffec2c0ae28a48cf7540e279787e77c447d
|
connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
|
||||||
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
|
device_info_plus: 71ffc6ab7634ade6267c7a93088ed7e4f74e5896
|
||||||
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
||||||
flutter_inappwebview_ios: 6f63631e2c62a7c350263b13fa5427aedefe81d4
|
flutter_inappwebview_ios: b89ba3482b96fb25e00c967aae065701b66e9b99
|
||||||
flutter_native_splash: df59bb2e1421aa0282cb2e95618af4dcb0c56c29
|
flutter_native_splash: c32d145d68aeda5502d5f543ee38c192065986cf
|
||||||
flutter_pdfview: 2e4d13ffb774858562ffbdfdb61b40744b191adc
|
flutter_pdfview: 32bf27bda6fd85b9dd2c09628a824df5081246cf
|
||||||
geolocator_apple: 66b711889fd333205763b83c9dcf0a57a28c7afd
|
geolocator_apple: ab36aa0e8b7d7a2d7639b3b4e48308394e8cef5e
|
||||||
image_picker_ios: 4f2f91b01abdb52842a8e277617df877e40f905b
|
image_picker_ios: e0ece4aa2a75771a7de3fa735d26d90817041326
|
||||||
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
|
Masonry: 678fab65091a9290e40e2832a55e7ab731aad201
|
||||||
MJExtension: e97d164cb411aa9795cf576093a1fa208b4a8dd8
|
MJExtension: e97d164cb411aa9795cf576093a1fa208b4a8dd8
|
||||||
mobile_scanner: 77265f3dc8d580810e91849d4a0811a90467ed5e
|
mobile_scanner: 9157936403f5a0644ca3779a38ff8404c5434a93
|
||||||
OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94
|
OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94
|
||||||
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
|
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
|
||||||
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
|
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
|
||||||
shared_preferences_foundation: 5086985c1d43c5ba4d5e69a4e8083a389e2909e6
|
permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d
|
||||||
url_launcher_ios: bb13df5870e8c4234ca12609d04010a21be43dfa
|
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
|
||||||
|
url_launcher_ios: 7a95fa5b60cc718a708b8f2966718e93db0cef1b
|
||||||
|
|
||||||
PODFILE CHECKSUM: 97188da9dab9d4b3372eb4c16e872fbd555fdbea
|
PODFILE CHECKSUM: 97188da9dab9d4b3372eb4c16e872fbd555fdbea
|
||||||
|
|
||||||
|
|||||||
@@ -477,8 +477,7 @@
|
|||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CODE_SIGN_STYLE = Manual;
|
|
||||||
CURRENT_PROJECT_VERSION = 4;
|
CURRENT_PROJECT_VERSION = 4;
|
||||||
DEVELOPMENT_TEAM = 2228B9MS38;
|
DEVELOPMENT_TEAM = 2228B9MS38;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
@@ -742,8 +741,7 @@
|
|||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CODE_SIGN_STYLE = Manual;
|
|
||||||
CURRENT_PROJECT_VERSION = 4;
|
CURRENT_PROJECT_VERSION = 4;
|
||||||
DEVELOPMENT_TEAM = 2228B9MS38;
|
DEVELOPMENT_TEAM = 2228B9MS38;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
@@ -844,8 +842,7 @@
|
|||||||
CLANG_ENABLE_MODULES = YES;
|
CLANG_ENABLE_MODULES = YES;
|
||||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CODE_SIGN_STYLE = Manual;
|
|
||||||
CURRENT_PROJECT_VERSION = 4;
|
CURRENT_PROJECT_VERSION = 4;
|
||||||
DEVELOPMENT_TEAM = 2228B9MS38;
|
DEVELOPMENT_TEAM = 2228B9MS38;
|
||||||
ENABLE_BITCODE = NO;
|
ENABLE_BITCODE = NO;
|
||||||
|
|||||||
@@ -61,6 +61,7 @@
|
|||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
debugDocumentVersioning = "YES"
|
debugDocumentVersioning = "YES"
|
||||||
debugServiceExtension = "internal"
|
debugServiceExtension = "internal"
|
||||||
|
enableGPUFrameCaptureMode = "3"
|
||||||
enableGPUValidationMode = "1"
|
enableGPUValidationMode = "1"
|
||||||
allowLocationSimulation = "YES">
|
allowLocationSimulation = "YES">
|
||||||
<BuildableProductRunnable
|
<BuildableProductRunnable
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Flutter
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
///
|
///
|
||||||
let kAMapKey = "key";
|
let kAMapKey = "3ac08e5e14df9d7a52e98d40e21a0189";
|
||||||
|
|
||||||
|
|
||||||
@main
|
@main
|
||||||
|
|||||||
@@ -4,5 +4,9 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>aps-environment</key>
|
<key>aps-environment</key>
|
||||||
<string>development</string>
|
<string>development</string>
|
||||||
|
<key>com.apple.developer.background-tasks.continued-processing.gpu</key>
|
||||||
|
<true/>
|
||||||
|
<key>com.apple.developer.location.push</key>
|
||||||
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class AppTheme {
|
|||||||
|
|
||||||
//http://192.168.110.222:8080/
|
//http://192.168.110.222:8080/
|
||||||
//http://192.168.110.44:8080/
|
//http://192.168.110.44:8080/
|
||||||
static String test_service_url = "http://47.101.201.13:8443/api/";
|
static String test_service_url = "https://beta-esg.api.lnh2e.com/";
|
||||||
static const String release_service_url = "";
|
static const String release_service_url = "";
|
||||||
|
|
||||||
//加氢站相关查询
|
//加氢站相关查询
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ void main() async {
|
|||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
WidgetsBinding widgetsBinding = await init(
|
WidgetsBinding widgetsBinding = await init(
|
||||||
isDebug: false,
|
isDebug: true,
|
||||||
logTag: '小羚羚',
|
logTag: '小羚羚',
|
||||||
supportedLocales: [const Locale('zh', 'CN')],
|
supportedLocales: [const Locale('zh', 'CN')],
|
||||||
);
|
);
|
||||||
@@ -34,7 +34,7 @@ void main() async {
|
|||||||
// 设计稿尺寸 单位:dp
|
// 设计稿尺寸 单位:dp
|
||||||
designSize: const Size(390, 844),
|
designSize: const Size(390, 844),
|
||||||
// Getx Log
|
// Getx Log
|
||||||
enableLog: false,
|
enableLog: true,
|
||||||
// 默认的跳转动画
|
// 默认的跳转动画
|
||||||
defaultTransition: Transition.rightToLeft,
|
defaultTransition: Transition.rightToLeft,
|
||||||
// 主题模式
|
// 主题模式
|
||||||
@@ -77,7 +77,7 @@ void initHttpSet() {
|
|||||||
return null;
|
return null;
|
||||||
} else if (baseModel.code == 401) {
|
} else if (baseModel.code == 401) {
|
||||||
await StorageService.to.clearLoginInfo();
|
await StorageService.to.clearLoginInfo();
|
||||||
// Get.offAll(() => const LoginPage());
|
Get.offAll(() => const LoginPage());
|
||||||
return baseModel.message;
|
return baseModel.message;
|
||||||
} else {
|
} else {
|
||||||
return (baseModel.error.toString()).isEmpty
|
return (baseModel.error.toString()).isEmpty
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:getx_scaffold/getx_scaffold.dart';
|
import 'package:getx_scaffold/getx_scaffold.dart';
|
||||||
import 'package:ln_jq_app/common/login_util.dart';
|
import 'package:ln_jq_app/common/login_util.dart';
|
||||||
import 'package:ln_jq_app/pages/c_page/base_widgets/NativePageIOS.dart';
|
import 'package:ln_jq_app/pages/c_page/base_widgets/NativePageIOS.dart';
|
||||||
import 'package:ln_jq_app/pages/c_page/car_info/view.dart';
|
import 'package:ln_jq_app/pages/c_page/car_info/view.dart';
|
||||||
import 'package:ln_jq_app/pages/c_page/map/view.dart';
|
|
||||||
import 'package:ln_jq_app/pages/c_page/mine/view.dart';
|
import 'package:ln_jq_app/pages/c_page/mine/view.dart';
|
||||||
import 'package:ln_jq_app/pages/c_page/reservation/view.dart';
|
import 'package:ln_jq_app/pages/c_page/reservation/view.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ class HomeController extends GetxController with BaseControllerMixin {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 未登录,直接去登录页
|
// 未登录,直接去登录页
|
||||||
return BaseWidgetsPage();
|
return LoginPage();
|
||||||
// return LoginPage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user