fix
This commit is contained in:
@@ -76,7 +76,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import io.flutter.plugin.platform.PlatformView;
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
@@ -251,17 +250,33 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
View vSpace = new View(context);
|
||||
searchArea.addView(vSpace, new LinearLayout.LayoutParams(1, dp2px(12)));
|
||||
|
||||
AppCompatButton planBtn = new AppCompatButton(context);
|
||||
planBtn.setText("规划路线");
|
||||
planBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_path, 0, 0, 0);
|
||||
planBtn.setCompoundDrawablePadding(dp2px(4));
|
||||
planBtn.setGravity(Gravity.CENTER);
|
||||
planBtn.setPadding(dp2px(8), 0, dp2px(8), 0);
|
||||
planBtn.setTextColor(Color.WHITE);
|
||||
planBtn.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
planBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 99));
|
||||
planBtn.setOnClickListener(v -> calculateRouteBeforeNavi());
|
||||
searchArea.addView(planBtn, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48)));
|
||||
// 创建自定义按钮布局
|
||||
LinearLayout planBtnContainer = new LinearLayout(context);
|
||||
planBtnContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||
planBtnContainer.setGravity(Gravity.CENTER);
|
||||
planBtnContainer.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 99));
|
||||
planBtnContainer.setPadding(0, 0, 0, 0);
|
||||
|
||||
// 添加图标
|
||||
ImageView pathIcon = new ImageView(context);
|
||||
pathIcon.setImageResource(R.drawable.ic_path);
|
||||
pathIcon.setColorFilter(Color.WHITE);
|
||||
LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(dp2px(20), dp2px(20));
|
||||
iconParams.rightMargin = dp2px(6); // 图标和文字之间的间距
|
||||
planBtnContainer.addView(pathIcon, iconParams);
|
||||
|
||||
// 添加文字
|
||||
TextView planText = new TextView(context);
|
||||
planText.setText("规划路线");
|
||||
planText.setTextColor(Color.WHITE);
|
||||
planText.setTextSize(16);
|
||||
planText.setTypeface(Typeface.DEFAULT_BOLD);
|
||||
planText.setGravity(Gravity.CENTER);
|
||||
planBtnContainer.addView(planText);
|
||||
|
||||
// 设置点击事件
|
||||
planBtnContainer.setOnClickListener(v -> calculateRouteBeforeNavi());
|
||||
searchArea.addView(planBtnContainer, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48)));
|
||||
|
||||
bottomContainer.addView(searchArea);
|
||||
|
||||
@@ -559,7 +574,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
tvPrice.setText("加氢价格:" + hydrogenPrice);
|
||||
tvPhone.setText("联系方式:" + liaisonPhone);
|
||||
|
||||
isGetInputtips = false;
|
||||
|
||||
|
||||
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(endPoint, 13f));
|
||||
|
||||
@@ -727,13 +742,11 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
* 获取货车路线算法信息
|
||||
*/
|
||||
private void fetchTruckRouteAlgorithm(AMapLocation loc) {
|
||||
|
||||
showLoading();
|
||||
|
||||
if (plateNumber == null || plateNumber.isEmpty()) {
|
||||
Toast.makeText(mActivity,"请先绑定车辆后进行导航",Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading();
|
||||
try {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("longitude", String.valueOf(loc.getLongitude()));
|
||||
@@ -917,7 +930,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
// 简化逻辑,直接设置文本
|
||||
endInput.post(() -> {
|
||||
try {
|
||||
endInput.setText(district != null && !district.isEmpty() ? name + " " + district : name);
|
||||
endInput.setText(district != null && !district.isEmpty() ? (name + " " + district ): name);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to set text to endInput", e);
|
||||
}
|
||||
@@ -1142,6 +1155,9 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
||||
// 更新 UI 和 业务逻辑
|
||||
endName = marker.getTitle();
|
||||
isUserSelectedDestination = true; // 标识用户手动选择了目的地
|
||||
isGetInputtips = false;
|
||||
|
||||
endInput.setText("");
|
||||
|
||||
// 需要传入当前位置以便接口计算路线
|
||||
if (mlocationClient != null && mlocationClient.getLastKnownLocation() != null) {
|
||||
|
||||
Reference in New Issue
Block a user