linee 5 days ago
parent
commit
fc3d397b6b
37 changed files with 1753 additions and 2373 deletions
  1. 6 0
      build.gradle
  2. 2 3
      entry/build.gradle
  3. BIN
      entry/libs/mapslibrary-release.har
  4. 15 0
      entry/src/main/config.json
  5. 55 0
      entry/src/main/java/com/fujica/abk/model/response/Page.java
  6. 149 0
      entry/src/main/java/com/fujica/abk/model/response/ParkNearRes.java
  7. 0 235
      entry/src/main/java/com/fujica/abk/slice/CircleDemoSlice.java
  8. 0 92
      entry/src/main/java/com/fujica/abk/slice/CodeLayoutSlice.java
  9. 0 129
      entry/src/main/java/com/fujica/abk/slice/GestureDemoSlice.java
  10. 0 149
      entry/src/main/java/com/fujica/abk/slice/HuaweiMapOptionsDemoSlice.java
  11. 777 0
      entry/src/main/java/com/fujica/abk/slice/MainAbilitySlice copy.java
  12. 452 274
      entry/src/main/java/com/fujica/abk/slice/MainAbilitySlice.java
  13. 0 162
      entry/src/main/java/com/fujica/abk/slice/MapEventsDemoSlice.java
  14. 0 136
      entry/src/main/java/com/fujica/abk/slice/MapTypeDemoSlice.java
  15. 0 195
      entry/src/main/java/com/fujica/abk/slice/MapViewCameraDemoSlice.java
  16. 0 100
      entry/src/main/java/com/fujica/abk/slice/MapViewDemoSlice.java
  17. 0 222
      entry/src/main/java/com/fujica/abk/slice/MarkerDemoSlice.java
  18. 0 216
      entry/src/main/java/com/fujica/abk/slice/PolygonDemoSlice.java
  19. 0 190
      entry/src/main/java/com/fujica/abk/slice/PolylineDemoSlice.java
  20. 48 49
      entry/src/main/resources/base/layout/ability_main.xml
  21. 175 0
      entry/src/main/resources/base/layout/item_parking.xml
  22. 74 221
      entry/src/main/resources/base/layout/layout_find_parking.xml
  23. BIN
      entry/src/main/resources/base/media/fee.png
  24. BIN
      entry/src/main/resources/base/media/fee_1.png
  25. BIN
      entry/src/main/resources/base/media/location.png
  26. BIN
      entry/src/main/resources/base/media/logo_white.png
  27. BIN
      entry/src/main/resources/base/media/my.png
  28. BIN
      entry/src/main/resources/base/media/my_1.png
  29. BIN
      entry/src/main/resources/base/media/nav.png
  30. BIN
      entry/src/main/resources/base/media/park.png
  31. BIN
      entry/src/main/resources/base/media/park_1.png
  32. BIN
      entry/src/main/resources/base/media/pin_c.png
  33. BIN
      entry/src/main/resources/base/media/pin_dc.png
  34. BIN
      entry/src/main/resources/base/media/pin_h.png
  35. BIN
      entry/src/main/resources/base/media/pin_l.png
  36. BIN
      entry/src/main/resources/base/media/pin_zjd.png
  37. BIN
      entry/src/main/resources/base/media/search.png

+ 6 - 0
build.gradle

@@ -50,5 +50,11 @@ allprojects {
         maven {
             url 'https://developer.huawei.com/repo/'
         }
+
+        repositories {
+            flatDir {
+                dir './entry/libs'
+            }
+        }
     }
 }

+ 2 - 3
entry/build.gradle

@@ -31,9 +31,8 @@ ohos {
 
 dependencies {
     implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
-    // 华为地图 SDK 依赖
-    implementation 'com.huawei.hms:maps-harmony:6.4.0.300'
-    testImplementation 'junit:junit:4.13.1'
+    // 高德地图 SDK 依赖 - 显式指定har文件
+//    implementation files('libs/mapslibrary-release.har')
     ohosTestImplementation 'com.huawei.ohos.testkit:runner:2.0.0.400'
 
     implementation 'com.huawei.hms:hwid-ohos:6.5.0.300'

BIN
entry/libs/mapslibrary-release.har


+ 15 - 0
entry/src/main/config.json

@@ -60,6 +60,16 @@
           ],
           "when": "always"
         }
+      },
+      {
+        "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
+        "reason": "GET_BUNDLE_INFO_PRIVILEGED",
+        "usedScene": {
+          "ability": [
+            "com.fujica.abk.MainAbility"
+          ],
+          "when": "always"
+        }
       }
     ],
     "metaData":{
@@ -72,6 +82,11 @@
         {
           "name": "com.huawei.hms.client.appid",
           "value": "6917590990169282724"
+        },
+        {
+          "name": "com.amap.api.v2.apikey",
+          "value": "您的高德地图API Key",
+          "extra": ""
         }
       ]
     },

+ 55 - 0
entry/src/main/java/com/fujica/abk/model/response/Page.java

@@ -0,0 +1,55 @@
+package com.fujica.abk.model.response;
+
+import java.util.List;
+
+/**
+ * 分页响应数据
+ */
+public class Page<T> {
+    private Integer total;
+    private Integer pages;
+    private Integer current;
+    private Integer size;
+    private List<T> records;
+
+    public Integer getTotal() {
+        return total;
+    }
+
+    public void setTotal(Integer total) {
+        this.total = total;
+    }
+
+    public Integer getPages() {
+        return pages;
+    }
+
+    public void setPages(Integer pages) {
+        this.pages = pages;
+    }
+
+    public Integer getCurrent() {
+        return current;
+    }
+
+    public void setCurrent(Integer current) {
+        this.current = current;
+    }
+
+    public Integer getSize() {
+        return size;
+    }
+
+    public void setSize(Integer size) {
+        this.size = size;
+    }
+
+    public List<T> getRecords() {
+        return records;
+    }
+
+    public void setRecords(List<T> records) {
+        this.records = records;
+    }
+}
+

+ 149 - 0
entry/src/main/java/com/fujica/abk/model/response/ParkNearRes.java

@@ -0,0 +1,149 @@
+package com.fujica.abk.model.response;
+
+/**
+ * 附近停车场响应数据
+ */
+public class ParkNearRes {
+    private String parkId;
+    private String parkName;
+    /**
+     * 预约车位
+     */
+    private Integer isreserver;
+    /**
+     * 支持找车
+     */
+    private Integer isfindcar;
+    private Integer powerEnable;
+    private Double distance;
+    private String address;
+    private Integer totalPlace;
+    private Integer residuePlace;
+    private Double latitude;
+    private Double longitude;
+    private Integer onlinePayEnable;
+    private Integer invoiceEnable;
+    private Integer reductionEnable;
+    private String chargeInfo;
+
+    public String getParkId() {
+        return parkId;
+    }
+
+    public void setParkId(String parkId) {
+        this.parkId = parkId;
+    }
+
+    public String getParkName() {
+        return parkName;
+    }
+
+    public void setParkName(String parkName) {
+        this.parkName = parkName;
+    }
+
+    public Integer getIsreserver() {
+        return isreserver;
+    }
+
+    public void setIsreserver(Integer isreserver) {
+        this.isreserver = isreserver;
+    }
+
+    public Integer getIsfindcar() {
+        return isfindcar;
+    }
+
+    public void setIsfindcar(Integer isfindcar) {
+        this.isfindcar = isfindcar;
+    }
+
+    public Integer getPowerEnable() {
+        return powerEnable;
+    }
+
+    public void setPowerEnable(Integer powerEnable) {
+        this.powerEnable = powerEnable;
+    }
+
+    public Double getDistance() {
+        return distance;
+    }
+
+    public void setDistance(Double distance) {
+        this.distance = distance;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+
+    public Integer getTotalPlace() {
+        return totalPlace;
+    }
+
+    public void setTotalPlace(Integer totalPlace) {
+        this.totalPlace = totalPlace;
+    }
+
+    public Integer getResiduePlace() {
+        return residuePlace;
+    }
+
+    public void setResiduePlace(Integer residuePlace) {
+        this.residuePlace = residuePlace;
+    }
+
+    public Double getLatitude() {
+        return latitude;
+    }
+
+    public void setLatitude(Double latitude) {
+        this.latitude = latitude;
+    }
+
+    public Double getLongitude() {
+        return longitude;
+    }
+
+    public void setLongitude(Double longitude) {
+        this.longitude = longitude;
+    }
+
+    public Integer getOnlinePayEnable() {
+        return onlinePayEnable;
+    }
+
+    public void setOnlinePayEnable(Integer onlinePayEnable) {
+        this.onlinePayEnable = onlinePayEnable;
+    }
+
+    public Integer getInvoiceEnable() {
+        return invoiceEnable;
+    }
+
+    public void setInvoiceEnable(Integer invoiceEnable) {
+        this.invoiceEnable = invoiceEnable;
+    }
+
+    public Integer getReductionEnable() {
+        return reductionEnable;
+    }
+
+    public void setReductionEnable(Integer reductionEnable) {
+        this.reductionEnable = reductionEnable;
+    }
+
+    public String getChargeInfo() {
+        return chargeInfo;
+    }
+
+    public void setChargeInfo(String chargeInfo) {
+        this.chargeInfo = chargeInfo;
+    }
+}
+

+ 0 - 235
entry/src/main/java/com/fujica/abk/slice/CircleDemoSlice.java

@@ -1,235 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.fujica.abk.ResourceTable;
-import com.fujica.abk.utils.ScreenUtil;
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.CameraUpdateFactory;
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.CommonContext;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import com.huawei.hms.maps.harmony.model.Circle;
-import com.huawei.hms.maps.harmony.model.CircleOptions;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.Button;
-import ohos.agp.components.Component;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.LayoutScatter;
-import ohos.agp.components.element.ShapeElement;
-import ohos.agp.utils.Color;
-
-public class CircleDemoSlice extends AbilitySlice{
-    private HuaweiMap mHuaweiMap;
-
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    /**
-     * Declare a Circle object.
-     */
-    private Circle mCircle;
-
-    private boolean fillColorStatus = true;
-
-    private boolean strokeColorStatus = true;
-
-    /**
-     * the layout
-     */
-    private PositionLayout rootLayout;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        initPositionLayout();
-        initMapView();
-        addButtons();
-        super.setUIContent(this.rootLayout);
-    }
-
-    private void initPositionLayout() {
-        rootLayout = new PositionLayout(this);
-        this.rootLayout.setContentPosition(0, 0);
-        this.rootLayout.setWidth(ComponentContainer.LayoutConfig.MATCH_PARENT);
-        this.rootLayout.setHeight(ComponentContainer.LayoutConfig.MATCH_PARENT);
-
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-        this.rootLayout.setBackground(element);
-    }
-
-    private void initMapView() {
-        CommonContext.setContext(this);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this);
-        mMapView.onCreate();
-
-        // Obtain a HuaweiMap object.
-        mMapView.getMapAsync(new OnMapReadyCallback() {
-            @Override
-            public void onMapReady(HuaweiMap huaweiMap) {
-                mHuaweiMap = huaweiMap;
-
-                // If mHuaweiMap is null, the program stops running.
-                if (null == mHuaweiMap) {
-                    return;
-                }
-
-                if (null != mCircle) {
-                    mCircle.remove();
-                    mCircle = null;
-                }
-
-                mCircle = mHuaweiMap.addCircle(new CircleOptions()
-                        .center(new LatLng(48.893478, 2.334595))
-                        .radius(500)
-                        .fillColor(Color.GREEN.getValue()));
-
-                int strokeColor = Color.RED.getValue();
-                float strokeWidth = 15.0f;
-
-                // Set the edge color of a circle
-                mCircle.setStrokeColor(strokeColor);
-
-                // Sets the edge width of a circle
-                mCircle.setStrokeWidth(strokeWidth);
-
-                // move camera
-                mHuaweiMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.893478, 2.334595), 12));
-            }
-        });
-
-        this.rootLayout.addComponent(mMapView);
-    }
-
-    private void addButtons() {
-        int height = ScreenUtil.getScreenHeight(this);
-
-        Button buttonHollowCircle = createButton();
-        buttonHollowCircle.setText("HollowCircle");
-        buttonHollowCircle.setContentPosition(50, (float) height / 2 - 100);
-        this.rootLayout.addComponent(buttonHollowCircle);
-
-        Button buttonStrokeColor = createButton();
-        buttonStrokeColor.setText("StrokeColor");
-        buttonStrokeColor.setContentPosition(50, (float) height / 2);
-        this.rootLayout.addComponent(buttonStrokeColor);
-
-        Button buttonFillColor = createButton();
-        buttonFillColor.setText("FillColor");
-        buttonFillColor.setContentPosition(50, (float) height / 2 + 100);
-        this.rootLayout.addComponent(buttonFillColor);
-
-        buttonHollowCircle.setClickedListener(new Component.ClickedListener() {
-            @Override
-            public void onClick(Component component) {
-                // Set a hollow circle.
-                if (null != mCircle) {
-                    // Set the fill color of the circle to transparent.
-                    mCircle.setFillColor(Color.TRANSPARENT.getValue());
-                    // Set the stroke color of the circle.
-                    mCircle.setStrokeColor(Color.RED.getValue());
-                    // Set the stroke width of the circle.
-                    mCircle.setStrokeWidth(15.0f);
-                }
-            }
-        });
-
-        buttonStrokeColor.setClickedListener(new Component.ClickedListener() {
-            @Override
-            public void onClick(Component component) {
-                if (null == mCircle) {
-                    return;
-                }
-                if (strokeColorStatus) {
-                    // Set the stroke color of the circle (mCircle) to red.
-                    mCircle.setStrokeColor(Color.RED.getValue());
-                } else {
-                    // Set the stroke color of the circle (mCircle) to green.
-                    mCircle.setStrokeColor(Color.GREEN.getValue());
-                }
-                strokeColorStatus = !strokeColorStatus;
-            }
-        });
-
-        buttonFillColor.setClickedListener(new Component.ClickedListener() {
-            @Override
-            public void onClick(Component component) {
-                if (null == mCircle) {
-                    return;
-                }
-                if (fillColorStatus) {
-                    // Set the fill color of the circle (mCircle) to red.
-                    mCircle.setFillColor(Color.RED.getValue());
-                } else {
-                    // Set the fill color of the circle (mCircle) to green.
-                    mCircle.setFillColor(Color.GREEN.getValue());
-                }
-                fillColorStatus = !fillColorStatus;
-            }
-        });
-    }
-
-    /**
-     * Create button
-     *
-     * @return Button
-     */
-    private Button createButton() {
-        Component component = LayoutScatter.getInstance(getContext())
-                .parse(ResourceTable.Layout_button_layout, null, false);
-        return (Button) component;
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 0 - 92
entry/src/main/java/com/fujica/abk/slice/CodeLayoutSlice.java

@@ -1,92 +0,0 @@
-package com.fujica.abk.slice;
-
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.components.*;
-import ohos.agp.utils.TextAlignment;
-
-public class CodeLayoutSlice extends AbilitySlice {
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        
-        // 创建主布局 - 垂直方向布局
-        DirectionalLayout mainLayout = new DirectionalLayout(this);
-        mainLayout.setWidth(ComponentContainer.LayoutConfig.MATCH_PARENT);
-        mainLayout.setHeight(ComponentContainer.LayoutConfig.MATCH_PARENT);
-        mainLayout.setOrientation(Component.VERTICAL);
-        mainLayout.setPadding(32, 32, 32, 32);
-        
-        // 创建标题文本
-        Text titleText = new Text(this);
-        titleText.setText("代码布局页面");
-        titleText.setTextSize(30);
-        titleText.setTextAlignment(TextAlignment.CENTER);
-        DirectionalLayout.LayoutConfig titleConfig = new DirectionalLayout.LayoutConfig(
-            ComponentContainer.LayoutConfig.MATCH_PARENT,
-            ComponentContainer.LayoutConfig.MATCH_CONTENT
-        );
-        titleConfig.setMargins(0, 0, 0, 40);
-        titleText.setLayoutConfig(titleConfig);
-        mainLayout.addComponent(titleText);
-        
-        // 创建输入框
-        TextField textField = new TextField(this);
-        textField.setHint("请输入内容");
-        DirectionalLayout.LayoutConfig textFieldConfig = new DirectionalLayout.LayoutConfig(
-            ComponentContainer.LayoutConfig.MATCH_PARENT,
-            ComponentContainer.LayoutConfig.MATCH_CONTENT
-        );
-        textFieldConfig.setMargins(0, 0, 0, 30);
-        textField.setLayoutConfig(textFieldConfig);
-        mainLayout.addComponent(textField);
-        
-        // 创建复选框
-        Checkbox checkbox = new Checkbox(this);
-        checkbox.setText("选择项");
-        DirectionalLayout.LayoutConfig checkboxConfig = new DirectionalLayout.LayoutConfig(
-            ComponentContainer.LayoutConfig.MATCH_CONTENT,
-            ComponentContainer.LayoutConfig.MATCH_CONTENT
-        );
-        checkboxConfig.setMargins(0, 0, 0, 30);
-        checkbox.setLayoutConfig(checkboxConfig);
-        mainLayout.addComponent(checkbox);
-        
-        // 创建单选按钮
-        RadioButton radioButton = new RadioButton(this);
-        radioButton.setText("单选按钮");
-        DirectionalLayout.LayoutConfig radioConfig = new DirectionalLayout.LayoutConfig(
-            ComponentContainer.LayoutConfig.MATCH_CONTENT,
-            ComponentContainer.LayoutConfig.MATCH_CONTENT
-        );
-        radioConfig.setMargins(0, 0, 0, 30);
-        radioButton.setLayoutConfig(radioConfig);
-        mainLayout.addComponent(radioButton);
-        
-        // 创建滑块
-        Slider slider = new Slider(this);
-        slider.setMinValue(0);
-        slider.setMaxValue(100);
-        slider.setProgressValue(50);
-        DirectionalLayout.LayoutConfig sliderConfig = new DirectionalLayout.LayoutConfig(
-            ComponentContainer.LayoutConfig.MATCH_PARENT,
-            ComponentContainer.LayoutConfig.MATCH_CONTENT
-        );
-        slider.setLayoutConfig(sliderConfig);
-        mainLayout.addComponent(slider);
-        
-        // 设置布局
-        super.setUIContent(mainLayout);
-    }
-
-    @Override
-    public void onActive() {
-        super.onActive();
-    }
-
-    @Override
-    public void onForeground(Intent intent) {
-        super.onForeground(intent);
-    }
-}
-

+ 0 - 129
entry/src/main/java/com/fujica/abk/slice/GestureDemoSlice.java

@@ -1,129 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.OnMapClickListener;
-import com.huawei.hms.maps.harmony.CommonContext;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.element.ShapeElement;
-import ohos.agp.window.dialog.ToastDialog;
-
-public class GestureDemoSlice extends AbilitySlice {
-    private HuaweiMap mHuaweiMap;
-
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        CommonContext.setContext(this);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this);
-        mMapView.onCreate();
-
-        // Obtains the HuaweiMap object.
-        mMapView.getMapAsync(new OnMapReadyCallback() {
-            @Override
-            public void onMapReady(HuaweiMap huaweiMap) {
-                mHuaweiMap = huaweiMap;
-
-                // If mHuaweiMap is null, the program stops running.
-                if (null == mHuaweiMap) {
-                    return;
-                }
-
-                mHuaweiMap.setOnMapClickListener(new  OnMapClickListener() {
-                    @Override
-                    public void onMapClick(LatLng latLng) {
-                        new ToastDialog(CommonContext.getContext()).setText("onMapClick ").show();
-                    }
-                });
-
-                // Set whether to enable the compass.
-                mHuaweiMap.getUiSettings().setCompassEnabled(true);
-
-                // Set whether to enable the zoom controls.
-                mHuaweiMap.getUiSettings().setZoomControlsEnabled(true);
-
-                // Set whether to enable the zoom gestures.
-                mHuaweiMap.getUiSettings().setZoomGesturesEnabled(true);
-
-                // Set whether to enable the scroll gestures.
-                mHuaweiMap.getUiSettings().setScrollGesturesEnabled(true);
-
-                // Set whether to enable the tilt gestures.
-                mHuaweiMap.getUiSettings().setTiltGesturesEnabled(true);
-
-                // Set whether to enable the rotation gestures.
-                mHuaweiMap.getUiSettings().setRotateGesturesEnabled(true);
-            }
-        });
-
-        // Create a layout.
-        ComponentContainer.LayoutConfig config = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
-        PositionLayout myLayout = new PositionLayout(this);
-        myLayout.setLayoutConfig(config);
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-
-        // Load the MapView object.
-        myLayout.addComponent(mMapView);
-        super.setUIContent(myLayout);
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 0 - 149
entry/src/main/java/com/fujica/abk/slice/HuaweiMapOptionsDemoSlice.java

@@ -1,149 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.OnMapClickListener;
-import com.huawei.hms.maps.harmony.CommonContext;
-import com.huawei.hms.maps.harmony.HuaweiMapOptions;
-import com.huawei.hms.maps.harmony.model.LatLngBounds;
-import com.huawei.hms.maps.harmony.model.CameraPosition;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.element.ShapeElement;
-import ohos.agp.window.dialog.ToastDialog;
-
-public class HuaweiMapOptionsDemoSlice extends AbilitySlice {
-    private HuaweiMap mHuaweiMap;
-
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        CommonContext.setContext(this);
-
-        // Set initial camera attributes.
-        CameraPosition cameraPosition = new CameraPosition(new LatLng(48.893478, 2.334595), 3, 45, 20);
-
-        // Construct the target area of the camera.
-        LatLng southwest = new LatLng(47.893478, 3.334595);
-        LatLng northeast = new LatLng(49.893478, 1.334595);
-
-        LatLngBounds latLngBounds = new LatLngBounds(southwest, northeast);
-        HuaweiMapOptions options = new HuaweiMapOptions();
-        options
-                // Set camera attributes.
-                .camera(cameraPosition)
-                // Set whether to enable the zoom function. It is enabled by default.
-                .zoomControlsEnabled(false)
-                // Set whether to enable the compass. It is enabled by default.
-                .compassEnabled(true)
-                // Set whether to enable zoom gestures. They are enabled by default.
-                .zoomGesturesEnabled(true)
-                // Set whether to enable scroll gestures. They are enabled by default.
-                .scrollGesturesEnabled(true)
-                // Set whether to enable rotation gestures. They are enabled by default.
-                .rotateGesturesEnabled(false)
-                // Set whether to enable tilt gestures. They are enabled by default.
-                .tiltGesturesEnabled(true)
-                // Set whether to place the map view on the top of the map window. The default value is false.
-                .zOrderOnTop(true)
-                // Set whether to enable the lite mode for the map. It is disabled by default.
-                .liteMode(false)
-                // Set the preferred minimum zoom level.
-                .minZoomPreference(3)
-                // Set the preferred maximum zoom level.
-                .maxZoomPreference(13)
-                // Set an area to constrain the camera target so that the camera target does not move outside the bounds when a user scrolls the map camera.
-                .latLngBoundsForCameraTarget(latLngBounds);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this, options);
-        mMapView.onCreate();
-
-        // Obtains the HuaweiMap object.
-        mMapView.getMapAsync(new OnMapReadyCallback() {
-            @Override
-            public void onMapReady(HuaweiMap huaweiMap) {
-                mHuaweiMap = huaweiMap;
-
-                // If mHuaweiMap is null, the program stops running.
-                if (null == mHuaweiMap) {
-                    return;
-                }
-
-                mHuaweiMap.setOnMapClickListener(new  OnMapClickListener() {
-                    @Override
-                    public void onMapClick(LatLng latLng) {
-                        new ToastDialog(CommonContext.getContext()).setText("onMapClick ").show();
-                    }
-                });
-            }
-        });
-
-        // Create a layout.
-        ComponentContainer.LayoutConfig config = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
-        PositionLayout myLayout = new PositionLayout(this);
-        myLayout.setLayoutConfig(config);
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-
-        // Load the MapView object.
-        myLayout.addComponent(mMapView);
-        super.setUIContent(myLayout);
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 777 - 0
entry/src/main/java/com/fujica/abk/slice/MainAbilitySlice copy.java

@@ -0,0 +1,777 @@
+// package com.fujica.abk.slice;
+
+// import com.fujica.abk.ResourceTable;
+// import com.fujica.abk.api.cache;
+// import com.fujica.abk.utils.Log;
+// import com.fujica.abk.utils.Toast;
+// import com.fujica.abk.utils.api;
+// import com.huawei.hms.accountsdk.constant.CommonConstant;
+// import com.huawei.hms.accountsdk.exception.ApiException;
+// import com.huawei.hms.accountsdk.support.account.AccountAuthManager;
+// import com.huawei.hms.accountsdk.support.account.request.AccountAuthParams;
+// import com.huawei.hms.accountsdk.support.account.request.AccountAuthParamsHelper;
+// import com.huawei.hms.accountsdk.support.account.result.AuthAccount;
+// import com.huawei.hms.accountsdk.support.account.service.AccountAuthService;
+// import com.huawei.hms.accountsdk.support.account.tasks.OnFailureListener;
+// import com.huawei.hms.accountsdk.support.account.tasks.OnSuccessListener;
+// import com.huawei.hms.accountsdk.support.account.tasks.Task;
+// import com.huawei.hms.maps.harmony.*;
+// import com.huawei.hms.maps.harmony.model.CameraPosition;
+// import com.huawei.hms.maps.harmony.model.LatLng;
+// import com.huawei.hms.maps.harmony.model.Marker;
+// import com.huawei.hms.maps.harmony.model.MarkerOptions;
+// import ohos.aafwk.ability.AbilitySlice;
+// import ohos.aafwk.ability.DataAbilityHelper;
+// import ohos.aafwk.ability.IDataAbilityObserver;
+// import ohos.aafwk.content.Intent;
+// import ohos.account.AccountAbility;
+// import ohos.agp.colors.RgbColor;
+// import ohos.agp.colors.StateColor;
+// import ohos.agp.components.*;
+// import ohos.agp.components.element.ShapeElement;
+// import ohos.agp.utils.Color;
+// import ohos.agp.window.dialog.ToastDialog;
+// import ohos.agp.window.service.Window;
+// import ohos.agp.window.service.WindowManager;
+// import ohos.global.resource.NotExistException;
+// import ohos.global.resource.Resource;
+// import ohos.location.Location;
+// import ohos.location.Locator;
+// import ohos.location.LocatorCallback;
+// import ohos.location.RequestParam;
+// import ohos.sysappcomponents.settings.AppSettings;
+// import ohos.sysappcomponents.settings.SystemSettings;
+
+// import java.io.IOException;
+// import java.lang.reflect.Method;
+// import java.util.ArrayList;
+// import java.util.List;
+
+// public class MainAbilitySlice extends AbilitySlice {
+//     // PageSlider相关
+//     private PageSlider pageSlider;
+//     private PageSliderProvider pageSliderProvider;
+
+//     // 底部导航栏组件
+//     private DirectionalLayout navMy;
+//     private DirectionalLayout navFindParking;
+//     private DirectionalLayout navReserveParking;
+//     private DirectionalLayout navCurrentLocation;
+
+//     // 底部导航栏文字和图标
+//     private Text textMy;
+//     private Text textPark;
+//     private Text textFee;
+//     private Image iconPark;
+//     private Image iconPark1;
+//     private Image iconMy;
+//     private Image iconMy1;
+//     private Image iconFee;
+//     private Image iconFee1;
+
+//     // 当前选中的 tab
+//     private int currentTab = 1; // 0: 我的, 1: 找车位, 2: 预约停车
+
+//     // 定位相关
+//     private Locator locator;
+//     private LocatorCallback locatorCallback;
+//     private Location currentLocation; // 当前定位坐标
+
+//     // 地图相关 - 完全按照 MarkerDemo 的方式
+//     private HuaweiMap mHuaweiMap;
+//     /**
+//      * Declare a MapView object.
+//      */
+//     private MapView mMapView;
+//     /**
+//      * Declare a Marker object.
+//      */
+//     private Marker mMarker;
+//     /**
+//      * 当前位置标记
+//      */
+//     private Marker currentLocationMarker;
+//     DataAbilityHelper dataAbilityHelper;
+//     IDataAbilityObserver dataAbilityObserver;
+
+//     @Override
+//     public void onStart(Intent intent) {
+//         super.onStart(intent);
+
+//         cache.setToken(getContext(), "sdfdsfdsf11111111111");
+//         String token = cache.getToken(getContext());
+
+// //        api.http(getContext(), "http://www.baidu.com", "GET", null, null, null);
+
+//         api.http(getContext(), "/park/near/page?longitude=0&latitude=0", "GET", null, null, null);
+
+
+//         // 设置全屏显示
+//         setFullScreen();
+
+//         // 设置 CommonContext,华为地图需要 - 完全按照示例代码
+//         CommonContext.setContext(this);
+
+//         // 设置布局
+//         super.setUIContent(ResourceTable.Layout_ability_main);
+
+//         // 初始化组件
+//         initComponents();
+
+//         // 初始化地图 - 完全按照 MarkerDemo 的方式
+//         initMap();
+
+//         // 设置事件监听
+//         setupListeners();
+
+//         // 初始化定位
+//         initLocation();
+
+//         Button mBtnHuaweiIdSignIn = findComponentById(ResourceTable.Id_btn_hwid_sign_in);
+//         mBtnHuaweiIdSignIn.setClickedListener((Component c) -> {
+//             huaweiIdSignIn();
+//         });
+
+//         final String key = "car_license_plate_number";
+// //        final String key = SystemSettings.Date.TIME_FORMAT;
+
+//         dataAbilityHelper = DataAbilityHelper.creator(this);
+//         dataAbilityObserver = () -> {
+//             String timeFormat = SystemSettings.getValue(dataAbilityHelper, key);
+//             setTimeFormat(timeFormat);
+//         };
+//         dataAbilityHelper.registerObserver(SystemSettings.getUri(key), dataAbilityObserver);
+//         String timeFormat1 = SystemSettings.getValue(dataAbilityHelper, "car_license_plate_number");
+//         String timeFormat = SystemSettings.getValue(dataAbilityHelper, key);
+//     }
+
+//     void setTimeFormat(String timeFormat) {
+//         String timeStr = "12";
+//         if (timeStr.equals(timeFormat)) {
+//             // Display in 12-hour format
+//         } else {
+//             // Display in 24-hour format
+//         }
+//     }
+
+//     void huaweiIdSignIn() {
+//         AccountAuthService accountAuthService;
+//         // 1、配置登录请求参数AccountAuthParams,包括请求用户id(openid、unionid)、email、profile(昵称、头像)等。
+//         // 2、DEFAULT_AUTH_REQUEST_PARAM默认包含了id和profile(昵称、头像)的请求。
+//         // 3、如需要再获取用户邮箱,需要setEmail();
+//         // 4、如需要获取其他受限信息,如国家和地区,则需要先申请scope,再设置请求参数。
+//         AccountAuthParams accountAuthParams = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM)
+//                 .setEmail()
+//                 .createParams();
+//         try {
+//             accountAuthService = AccountAuthManager.getService(accountAuthParams);
+//         } catch (ApiException e) {
+//             // 处理初始化登录授权服务失败,status code标识了失败的原因,请参考API中的错误码参考了解详细错误原因
+//             e.getStatusCode();
+//             Toast.error(getContext(),"Init Huawei accountAuthService FAILED.");
+//             return;
+//         }
+//         Toast.info(getContext(),"Init Huawei accountAuthService SUCCESS");
+
+//         if (accountAuthService == null) {
+//             Toast.error(getContext(),"获取不到账号信息");
+//             return;
+//         }
+//         // 调用静默登录接口。
+//         // 如果华为系统帐号已经登录,并且已经授权,会登录成功;
+//         // 否则静默登录失败,需要在失败监听中,显式地调用前台登录授权接口,完成登录授权。
+//         Task<AuthAccount> taskSilentSignIn = accountAuthService.silentSignIn();
+// //        Task<AuthAccount> taskSilentSignIn = accountAuthService.silentSignIn();
+//         Toast.info(getContext(),"SilentSign START.");
+//         // 添加静默登录成功处理监听
+//         taskSilentSignIn.addOnSuccessListener(authAccount -> updateUI(authAccount));
+//         // 添加静默登录失败监听
+//         taskSilentSignIn.addOnFailureListener(e -> {
+//             if (e instanceof ApiException) {
+//                 ApiException apiException = (ApiException) e;
+//                 Toast.error(getContext(),"SilentSignIn FAILED, status code: " + apiException.getStatusCode() + ". Need to foreground sign in" + "\r\n" + apiException.getStatusMessage()
+//                         + "\r\n" + apiException.getMessage() + "\r\n" + apiException.getCause());
+
+//                 // 静默登录失败,显式地调用前台登录授权接口,完成登录授权。
+//                 Task<AuthAccount> taskSignIn = accountAuthService.signIn();
+//                 Toast.info(getContext(),"SignIn foreground START.");
+//                 if (taskSignIn == null) {
+//                     Toast.info(getContext(),"SignIn foreground task is null.");
+//                     return;
+//                 }
+//                 taskSignIn.addOnSuccessListener(new OnSuccessListener<AuthAccount>() {
+//                     @Override
+//                     public void onSuccess(AuthAccount result) {
+//                         Toast.info(getContext(),"SignIn foreground SUCCESS.");
+//                         updateUI(result);
+//                     }
+//                 });
+//                 taskSignIn.addOnFailureListener(new OnFailureListener() {
+//                     @Override
+//                     public void onFailure(Exception e) {
+//                         Toast.info(getContext(),"SignIn foreground FAILED.");
+//                         if (e instanceof ApiException) {
+//                             ApiException apiException = (ApiException) e;
+//                             // 登录失败,status code标识了失败的原因,请参考API中的错误码参考了解详细错误原因
+//                             apiException.getStatusCode();
+//                             Toast.info(getContext(),"SignIn foreground FAILED. status code: "
+//                                     + apiException.getStatusCode()
+//                                     + ".");
+//                             if (CommonConstant.RETCODE.SIGN_IN_CANCELLED == apiException.getStatusCode()) {
+//                                 Toast.info(getContext(),"Error message: User click CANCEL or Return, user cancel login in.");
+//                             }
+//                         }
+//                     }
+//                 });
+//             }
+//         });
+//     }
+
+//     private void updateUI(AuthAccount authAccount) {
+//         Toast.info(getContext(),authAccount.getOpenId() + " : " + authAccount.getUnionId());
+//     }
+
+
+//     /**
+//      * 设置全屏显示
+//      */
+//     private void setFullScreen() {
+//         try {
+//             Window window = getWindow();
+//             if (window != null) {
+//                 WindowManager.LayoutConfig layoutConfig = window.getLayoutConfig().orElse(null);
+//                 if (layoutConfig == null) {
+//                     layoutConfig = new WindowManager.LayoutConfig();
+//                 }
+//                 layoutConfig.type = WindowManager.LayoutConfig.MARK_FULL_SCREEN;
+//                 window.setLayoutConfig(layoutConfig);
+//             }
+//         } catch (Exception e) {
+//             Log.error("设置全屏失败: " + e.getMessage());
+//         }
+//     }
+
+//     /**
+//      * 初始化组件
+//      */
+//     private void initComponents() {
+//         // 初始化PageSlider
+//         pageSlider = (PageSlider) findComponentById(ResourceTable.Id_page_slider);
+//         if (pageSlider != null) {
+//             // 创建PageSliderProvider
+//             pageSliderProvider = new PageSliderProvider() {
+//                 private List<Component> pages = new ArrayList<>();
+
+//                 @Override
+//                 public int getCount() {
+//                     return 3; // 三个页面:我的、找车位、预约停车
+//                 }
+
+//                 @Override
+//                 public Object createPageInContainer(ComponentContainer componentContainer, int position) {
+//                     Component page = null;
+//                     try {
+//                         switch (position) {
+//                             case 0: // 我的
+//                                 page = LayoutScatter.getInstance(MainAbilitySlice.this)
+//                                         .parse(ResourceTable.Layout_layout_my, null, false);
+//                                 break;
+//                             case 1: // 找车位
+//                                 page = LayoutScatter.getInstance(MainAbilitySlice.this)
+//                                         .parse(ResourceTable.Layout_layout_find_parking, null, false);
+//                                 break;
+//                             case 2: // 预约停车
+//                                 page = LayoutScatter.getInstance(MainAbilitySlice.this)
+//                                         .parse(ResourceTable.Layout_layout_reserve_parking, null, false);
+//                                 break;
+//                         }
+//                         if (page != null) {
+//                             componentContainer.addComponent(page);
+//                             pages.add(page);
+//                         }
+//                     } catch (Exception e) {
+//                         Log.error("创建页面失败: " + e.getMessage());
+//                         e.printStackTrace();
+//                     }
+//                     return page;
+//                 }
+
+//                 @Override
+//                 public void destroyPageFromContainer(ComponentContainer componentContainer, int position, Object object) {
+//                     if (object instanceof Component) {
+//                         componentContainer.removeComponent((Component) object);
+//                         pages.remove(object);
+//                     }
+//                 }
+
+//                 @Override
+//                 public boolean isPageMatchToObject(Component component, Object object) {
+//                     return component == object;
+//                 }
+//             };
+
+//             pageSlider.setProvider(pageSliderProvider);
+//             // 默认显示找车位页面(索引1)
+//             pageSlider.setCurrentPage(1);
+
+//             // 添加页面切换监听
+//             pageSlider.addPageChangedListener(new PageSlider.PageChangedListener() {
+//                 @Override
+//                 public void onPageChosen(int index) {
+//                     // 页面切换完成
+//                     currentTab = index;
+//                     updateBottomNavState(index);
+//                     Log.info("切换到页面: " + index);
+//                 }
+
+//                 @Override
+//                 public void onPageSliding(int state, float v, int index) {
+
+//                 }
+
+//                 @Override
+//                 public void onPageSlideStateChanged(int state) {
+//                     // 滑动状态变化
+//                 }
+//             });
+//         }
+
+//         // 初始化底部导航栏
+//         initBottomNavigation();
+//     }
+
+//     /**
+//      * 初始化底部导航栏
+//      */
+//     private void initBottomNavigation() {
+//         navMy = findComponentById(ResourceTable.Id_nav_my);
+//         navFindParking = findComponentById(ResourceTable.Id_nav_find_parking);
+//         navReserveParking = findComponentById(ResourceTable.Id_nav_reserve_parking);
+//         navCurrentLocation = findComponentById(ResourceTable.Id_nav_current_location);
+
+//         textMy = findComponentById(ResourceTable.Id_text_my);
+//         textPark = findComponentById(ResourceTable.Id_text_park);
+//         textFee = findComponentById(ResourceTable.Id_text_fee);
+//         iconPark = findComponentById(ResourceTable.Id_icon_park);
+//         iconPark1 = findComponentById(ResourceTable.Id_icon_park_1);
+//         iconMy = findComponentById(ResourceTable.Id_icon_my);
+//         iconMy1 = findComponentById(ResourceTable.Id_icon_my_1);
+//         iconFee = findComponentById(ResourceTable.Id_icon_fee);
+//         iconFee1 = findComponentById(ResourceTable.Id_icon_fee_1);
+
+//         // 设置点击事件
+//         if (navMy != null) {
+//             navMy.setClickedListener(component -> switchToPage(0));
+//         }
+//         if (navFindParking != null) {
+//             navFindParking.setClickedListener(component -> switchToPage(1));
+//         }
+//         if (navReserveParking != null) {
+//             navReserveParking.setClickedListener(component -> switchToPage(2));
+//         }
+//         if (navCurrentLocation != null) {
+//             navCurrentLocation.setClickedListener(component -> {
+//                 Log.info("点击了当前位置按钮");
+//                 locateCurrentPosition();
+//             });
+//         }
+
+//         // 默认选中找车位
+//         updateBottomNavState(1);
+//     }
+
+//     /**
+//      * 切换到指定页面
+//      */
+//     private void switchToPage(int index) {
+//         if (pageSlider != null && index >= 0 && index < 3) {
+//             pageSlider.setCurrentPage(index);
+//         }
+//     }
+
+//     /**
+//      * 更新底部导航栏状态
+//      */
+//     private void updateBottomNavState(int index) {
+//         // 重置所有导航项样式
+//         Color grayColor = new Color(Color.getIntColor("#FF666666"));
+//         Color blueColor = new Color(Color.getIntColor("#FA6332"));
+
+//         if (textMy != null) {
+//             textMy.setTextColor(grayColor);
+//         }
+//         if (textPark != null) {
+//             textPark.setTextColor(grayColor);
+//         }
+//         if (textFee != null) {
+//             textFee.setTextColor(grayColor);
+//         }
+
+//         iconPark.setImageAndDecodeBounds(ResourceTable.Media_park);
+//         iconMy.setImageAndDecodeBounds(ResourceTable.Media_my);
+// //        iconReserveParking.setImageAndDecodeBounds(ResourceTable.Media_fee);
+
+//         // 设置选中状态
+//         switch (index) {
+//             case 0: // 我的
+//                 textMy.setTextColor(blueColor);
+//                 iconMy.setImageAndDecodeBounds(ResourceTable.Media_my_1);
+
+//                 iconMy.setVisibility(Component.HIDE);
+//                 iconMy1.setVisibility(Component.VISIBLE);
+//                 iconFee.setVisibility(Component.VISIBLE);
+//                 iconFee1.setVisibility(Component.HIDE);
+//                 iconPark.setVisibility(Component.VISIBLE);
+//                 iconPark1.setVisibility(Component.HIDE);
+//                 break;
+//             case 1: // 找车位
+//                 textPark.setTextColor(blueColor);
+//                 iconPark.setImageAndDecodeBounds(ResourceTable.Media_park_1);
+
+//                 iconMy.setVisibility(Component.VISIBLE);
+//                 iconMy1.setVisibility(Component.HIDE);
+//                 iconFee.setVisibility(Component.VISIBLE);
+//                 iconFee1.setVisibility(Component.HIDE);
+//                 iconPark.setVisibility(Component.HIDE);
+//                 iconPark1.setVisibility(Component.VISIBLE);
+//                 break;
+//             case 2: // 预约停车
+//                 textFee.setTextColor(blueColor);
+
+//                 iconMy.setVisibility(Component.VISIBLE);
+//                 iconMy1.setVisibility(Component.HIDE);
+//                 iconFee.setVisibility(Component.HIDE);
+//                 iconFee1.setVisibility(Component.VISIBLE);
+//                 iconPark.setVisibility(Component.VISIBLE);
+//                 iconPark1.setVisibility(Component.HIDE);
+//                 break;
+//         }
+//     }
+
+//     /**
+//      * 初始化地图 - 完全按照 MarkerDemo 的方式
+//      */
+//     private void initMap() {
+//         try {
+//             // Declaring and Initializing the HuaweiMapOptions Object - 完全按照 MarkerDemo
+//             HuaweiMapOptions huaweiMapOptions = new HuaweiMapOptions();
+
+//             // Initialize Camera Properties
+//             CameraPosition cameraPosition =
+//                     new CameraPosition(new LatLng(48.893478, 2.334595), 6, 0, 0);
+
+//             huaweiMapOptions
+//                     // Set Camera Properties
+//                     .camera(cameraPosition)
+//                     // Enables or disables the zoom function. By default, the zoom function is enabled.
+//                     .zoomControlsEnabled(false)
+//                     // Sets whether the compass is available. The compass is available by default.
+//                     .compassEnabled(true)
+//                     // Specifies whether the zoom gesture is available. By default, the zoom gesture is available.
+//                     .zoomGesturesEnabled(true)
+//                     // Specifies whether to enable the scrolling gesture. By default, the scrolling gesture is enabled.
+//                     .scrollGesturesEnabled(true)
+//                     // Specifies whether the rotation gesture is available. By default, the rotation gesture is available.
+//                     .rotateGesturesEnabled(false)
+//                     // Specifies whether the tilt gesture is available. By default, the tilt gesture is available.
+//                     .tiltGesturesEnabled(true)
+//                     // Sets whether the map is in lite mode. The default value is No.
+//                     .liteMode(false)
+//                     // Set Preference Minimum Zoom Level
+//                     .minZoomPreference(3)
+//                     // Set Preference Maximum Zoom Level
+//                     .maxZoomPreference(13);
+
+//             if (true) return;
+
+//             // Initialize MapView Object. - 完全按照 MarkerDemo
+//             mMapView = new MapView(this, huaweiMapOptions);
+//             mMapView.onCreate();
+
+
+//             // Obtains the HuaweiMap object. - 完全按照 MarkerDemo
+//             mMapView.getMapAsync(huaweiMap -> {
+//                 mHuaweiMap = huaweiMap;
+
+//                 // If mHuaweiMap is null, the program stops running. - 完全按照 MarkerDemo
+//                 if (null == mHuaweiMap) {
+//                     Log.error("mHuaweiMap 为 null");
+//                     return;
+//                 }
+
+//                 Log.info("地图已就绪,开始获取定位");
+
+//                 mHuaweiMap.setOnMapClickListener(new OnMapClickListener() {
+//                     @Override
+//                     public void onMapClick(LatLng latLng) {
+//                         new ToastDialog(CommonContext.getContext()).setText("onMapClick ").show();
+//                     }
+//                 });
+
+//                 // If mMarker is not null, remove it from the map and then set it to null. - 完全按照 MarkerDemo
+//                 if (null != mMarker) {
+//                     mMarker.remove();
+//                     mMarker = null;
+//                 }
+
+//                 // Add a marker to the map. - 完全按照 MarkerDemo
+//                 MarkerOptions options = new MarkerOptions()
+//                         .position(new LatLng(48.893478, 2.334595))
+//                         .title("Hello Huawei Map")
+//                         .snippet("This is a snippet!");
+//                 mMarker = mHuaweiMap.addMarker(options);
+
+//                 // Set the marker title. - 完全按照 MarkerDemo
+//                 if (mMarker != null) {
+//                     mMarker.setTitle("Marker title");
+//                 }
+
+//                 // Set whether the marker can be dragged. - 完全按照 MarkerDemo
+//                 if (mMarker != null) {
+//                     mMarker.setDraggable(true);
+//                 }
+
+//                 // Set the marker anchor point. - 完全按照 MarkerDemo
+//                 if (mMarker != null) {
+//                     mMarker.setMarkerAnchor(0.9F, 0.9F);
+//                 }
+
+//                 // Customizing the Marker Icon - 完全按照 MarkerDemo
+//                 addCustomMarker();
+
+//                 mHuaweiMap.setOnMarkerClickListener(new OnMarkerClickListener() {
+//                     @Override
+//                     public boolean onMarkerClick(Marker marker) {
+//                         new ToastDialog(CommonContext.getContext()).setText("onMarkerClick: " + marker.getTitle()).show();
+//                         return false;
+//                     }
+//                 });
+
+//                 mHuaweiMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
+//                     @Override
+//                     public void onInfoWindowClick(Marker marker) {
+//                         new ToastDialog(CommonContext.getContext()).setText("onInfoWindowClick:").show();
+//                     }
+//                 });
+
+//                 // 地图就绪后,自动获取当前位置
+//                 if (locator != null && locatorCallback != null) {
+//                     locateCurrentPosition();
+//                 }
+//             });
+
+// //            ComponentContainer.LayoutConfig config = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
+// //            PositionLayout myLayout = new PositionLayout(this);
+// //            myLayout.setLayoutConfig(config);
+
+//             PositionLayout myLayout = findComponentById(ResourceTable.Id_main_body);
+
+//             ShapeElement element = new ShapeElement();
+//             element.setShape(ShapeElement.RECTANGLE);
+//             element.setRgbColor(new RgbColor(255, 255, 255));
+
+//             // 加载MapView
+//             myLayout.addComponent(mMapView);
+//         } catch (Exception e) {
+//             Log.error("初始化地图失败: " + e.getMessage());
+//             e.printStackTrace();
+//         }
+//     }
+
+//     /**
+//      * addCustomMarker - 完全按照 MarkerDemo
+//      */
+//     private void addCustomMarker() {
+//         Resource resource = null;
+//         try {
+//             resource = getResourceManager().getResource(ResourceTable.Media_icon);
+//         } catch (IOException e) {
+//             e.printStackTrace();
+//         } catch (NotExistException e) {
+//             e.printStackTrace();
+//         }
+
+//         if (resource != null && mHuaweiMap != null) {
+//             mHuaweiMap.addMarker(new MarkerOptions()
+//                     .position(new LatLng(47.8333, 2.8333))
+//                     .icon(resource));
+//         }
+//     }
+
+//     /**
+//      * 设置事件监听
+//      */
+//     private void setupListeners() {
+//         // 事件监听已在initBottomNavigation中设置
+//     }
+
+//     /**
+//      * 初始化定位服务
+//      */
+//     private void initLocation() {
+//         try {
+//             locator = new Locator(this);
+//             locatorCallback = new LocatorCallback() {
+//                 @Override
+//                 public void onLocationReport(Location location) {
+//                     // 保存当前位置坐标
+//                     currentLocation = location;
+//                     double latitude = location.getLatitude();
+//                     double longitude = location.getLongitude();
+
+//                     Log.info("定位成功: " + latitude + ", " + longitude);
+
+//                     // 将坐标传递给地图
+//                     updateMapWithLocation(location);
+//                 }
+
+//                 @Override
+//                 public void onStatusChanged(int type) {
+//                     Log.info("定位状态变化: " + type);
+//                 }
+
+//                 @Override
+//                 public void onErrorReport(int errorCode) {
+//                     Log.error("定位错误: " + errorCode);
+//                     new ToastDialog(CommonContext.getContext())
+//                             .setText("定位失败,错误码: " + errorCode)
+//                             .show();
+//                 }
+//             };
+//         } catch (Exception e) {
+//             Log.error("初始化定位服务失败: " + e.getMessage());
+//         }
+//     }
+
+//     /**
+//      * 定位到当前位置
+//      */
+//     private void locateCurrentPosition() {
+//         if (locator == null || locatorCallback == null) {
+//             Log.error("定位服务未初始化");
+//             return;
+//         }
+
+//         try {
+//             // 请求定位
+//             RequestParam requestParam = new RequestParam(RequestParam.PRIORITY_ACCURACY, 0, 0);
+//             locator.startLocating(requestParam, locatorCallback);
+//             Log.info("开始定位...");
+//         } catch (Exception e) {
+//             Log.error("定位失败: " + e.getMessage());
+//         }
+//     }
+
+//     /**
+//      * 将定位坐标传递给地图并更新地图显示
+//      */
+//     private void updateMapWithLocation(Location location) {
+//         if (mHuaweiMap == null) {
+//             Log.warn("地图未初始化完成,等待地图就绪");
+//             return;
+//         }
+
+//         try {
+//             double latitude = location.getLatitude();
+//             double longitude = location.getLongitude();
+
+//             Log.info("更新地图位置: " + latitude + ", " + longitude);
+
+//             // 创建坐标点
+//             LatLng latLng = new LatLng(latitude, longitude);
+
+//             // 移除旧的当前位置标记
+//             if (currentLocationMarker != null) {
+//                 currentLocationMarker.remove();
+//                 currentLocationMarker = null;
+//             }
+
+//             // 在地图上添加当前位置标记
+//             MarkerOptions currentLocationOptions = new MarkerOptions()
+//                     .position(latLng)
+//                     .title("当前位置")
+//                     .snippet("纬度: " + latitude + ", 经度: " + longitude);
+//             currentLocationMarker = mHuaweiMap.addMarker(currentLocationOptions);
+
+//             // Method 8: Set the center point and zoom level of the camera. - 完全按照示例代码
+//             float zoom = 15.0f;
+//             CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, zoom);
+
+//             // move camera - 完全按照示例代码
+//             mHuaweiMap.moveCamera(cameraUpdate);
+
+//             Log.info("地图已更新到当前位置");
+
+//             // 显示提示
+//             new ToastDialog(CommonContext.getContext())
+//                     .setText("已定位到当前位置")
+//                     .show();
+
+//         } catch (Exception e) {
+//             Log.error("更新地图位置失败: " + e.getMessage());
+//             e.printStackTrace();
+//         }
+//     }
+
+//     /**
+//      * 移动地图到当前位置 - 完全按照 MapViewCameraDemo 的方式
+//      */
+//     private void moveToCurrentLocation(Location location) {
+//         updateMapWithLocation(location);
+//     }
+
+//     // 生命周期管理 - 完全按照示例代码 MapViewDemo.java 的方式
+//     @Override
+//     protected void onActive() {
+//         super.onActive();
+//         if (mMapView != null) {
+//             mMapView.onResume();
+//         }
+//     }
+
+//     @Override
+//     protected void onInactive() {
+//         super.onInactive();
+//         if (mMapView != null) {
+//             mMapView.onPause();
+//         }
+//     }
+
+//     @Override
+//     protected void onBackground() {
+//         super.onBackground();
+//         if (mMapView != null) {
+//             mMapView.onStop();
+//         }
+//     }
+
+//     @Override
+//     protected void onForeground(Intent intent) {
+//         super.onForeground(intent);
+//         if (mMapView != null) {
+//             mMapView.onStart();
+//         }
+//     }
+
+//     @Override
+//     protected void onStop() {
+//         super.onStop();
+//         // 停止定位
+//         if (locator != null && locatorCallback != null) {
+//             try {
+//                 locator.stopLocating(locatorCallback);
+//             } catch (Exception e) {
+//                 Log.error("停止定位失败: " + e.getMessage());
+//             }
+//         }
+//         // 销毁地图 - 完全按照示例代码
+//         if (mMapView != null) {
+//             mMapView.onDestroy();
+//         }
+
+//         if (dataAbilityHelper != null) {
+
+//         }
+//         dataAbilityHelper.unregisterObserver(SystemSettings.getUri(SystemSettings.Date.TIME_FORMAT), dataAbilityObserver);
+//     }
+// }

+ 452 - 274
entry/src/main/java/com/fujica/abk/slice/MainAbilitySlice.java

@@ -15,37 +15,30 @@ import com.huawei.hms.accountsdk.support.account.service.AccountAuthService;
 import com.huawei.hms.accountsdk.support.account.tasks.OnFailureListener;
 import com.huawei.hms.accountsdk.support.account.tasks.OnSuccessListener;
 import com.huawei.hms.accountsdk.support.account.tasks.Task;
-import com.huawei.hms.maps.harmony.*;
-import com.huawei.hms.maps.harmony.model.CameraPosition;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import com.huawei.hms.maps.harmony.model.Marker;
-import com.huawei.hms.maps.harmony.model.MarkerOptions;
 import ohos.aafwk.ability.AbilitySlice;
 import ohos.aafwk.ability.DataAbilityHelper;
 import ohos.aafwk.ability.IDataAbilityObserver;
 import ohos.aafwk.content.Intent;
-import ohos.account.AccountAbility;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.colors.StateColor;
 import ohos.agp.components.*;
 import ohos.agp.components.element.ShapeElement;
+import ohos.agp.colors.RgbColor;
 import ohos.agp.utils.Color;
 import ohos.agp.window.dialog.ToastDialog;
 import ohos.agp.window.service.Window;
 import ohos.agp.window.service.WindowManager;
-import ohos.global.resource.NotExistException;
-import ohos.global.resource.Resource;
 import ohos.location.Location;
 import ohos.location.Locator;
 import ohos.location.LocatorCallback;
 import ohos.location.RequestParam;
-import ohos.sysappcomponents.settings.AppSettings;
+import ohos.rpc.RemoteException;
 import ohos.sysappcomponents.settings.SystemSettings;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
+import ohos.utils.zson.ZSONObject;
+import com.fujica.abk.model.response.ParkNearRes;
+import com.fujica.abk.model.response.Page;
+import com.fujica.abk.utils.R;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CompletableFuture;
 
 public class MainAbilitySlice extends AbilitySlice {
     // PageSlider相关
@@ -77,27 +70,34 @@ public class MainAbilitySlice extends AbilitySlice {
     private LocatorCallback locatorCallback;
     private Location currentLocation; // 当前定位坐标
 
-    // 地图相关 - 完全按照 MarkerDemo 的方式
-    private HuaweiMap mHuaweiMap;
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-    /**
-     * Declare a Marker object.
-     */
-    private Marker mMarker;
-    /**
-     * 当前位置标记
-     */
-    private Marker currentLocationMarker;
+    // 找车位页面相关
+    private Component findParkingPage; // 找车位页面组件
+    private Text tabAll; // 全部车场标签
+    private Text tabRecommended; // 推荐车场标签
+    private Component tabAllUnderline; // 全部车场下划线
+    private Component tabRecommendedUnderline; // 推荐车场下划线
+    private Button btnDistanceSort; // 距离最近按钮
+    private ScrollView parkingListScroll; // 停车场列表滚动视图
+    private DirectionalLayout parkingListContainer; // 停车场列表容器
+    private int currentPage = 1; // 当前页码
+    private int pageSize = 10; // 每页数量
+    private boolean isLoading = false; // 是否正在加载
+    private boolean hasMore = true; // 是否还有更多数据
+    private int filterType = 2; // 筛选类型:2=全部,1=推荐
+    private List<ParkNearRes> parkingList = new ArrayList<>(); // 停车场列表数据
+
     DataAbilityHelper dataAbilityHelper;
     IDataAbilityObserver dataAbilityObserver;
 
     @Override
     public void onStart(Intent intent) {
         super.onStart(intent);
-
+        try {
+            //com.fujica.abk_BD8VI9k5bO0HeGAPnhTGeYX++mgKw87G8y+3RZ6nrb9evCePddojupXJN03auUKxTKn1qbFrYQAjFyGumpjsHzw=
+            String appId = getApplicationContext().getBundleManager().getBundleInfo(getBundleName(), 0).getAppId();
+            Log.info(appId);
+        } catch (RemoteException e) {
+        }
         cache.setToken(getContext(), "sdfdsfdsf11111111111");
         String token = cache.getToken(getContext());
 
@@ -105,22 +105,15 @@ public class MainAbilitySlice extends AbilitySlice {
 
         api.http(getContext(), "/park/near/page?longitude=0&latitude=0", "GET", null, null, null);
 
-
         // 设置全屏显示
         setFullScreen();
 
-        // 设置 CommonContext,华为地图需要 - 完全按照示例代码
-        CommonContext.setContext(this);
-
         // 设置布局
         super.setUIContent(ResourceTable.Layout_ability_main);
 
         // 初始化组件
         initComponents();
 
-        // 初始化地图 - 完全按照 MarkerDemo 的方式
-        initMap();
-
         // 设置事件监听
         setupListeners();
 
@@ -279,6 +272,18 @@ public class MainAbilitySlice extends AbilitySlice {
                             case 1: // 找车位
                                 page = LayoutScatter.getInstance(MainAbilitySlice.this)
                                         .parse(ResourceTable.Layout_layout_find_parking, null, false);
+                                findParkingPage = page;
+                                // 初始化找车位页面组件(延迟执行,确保页面已添加到容器)
+                                getUITaskDispatcher().asyncDispatch(() -> {
+                                    try {
+                                        Thread.sleep(100); // 等待页面渲染
+                                    } catch (InterruptedException e) {
+                                        e.printStackTrace();
+                                    }
+                                    initFindParkingPage();
+                                    // 默认加载数据
+                                    loadParkingData(true);
+                                });
                                 break;
                             case 2: // 预约停车
                                 page = LayoutScatter.getInstance(MainAbilitySlice.this)
@@ -322,6 +327,10 @@ public class MainAbilitySlice extends AbilitySlice {
                     currentTab = index;
                     updateBottomNavState(index);
                     Log.info("切换到页面: " + index);
+                    // 如果切换到找车位页面,加载数据
+                    if (index == 1 && findParkingPage != null) {
+                        loadParkingData(true);
+                    }
                 }
 
                 @Override
@@ -407,15 +416,10 @@ public class MainAbilitySlice extends AbilitySlice {
             textFee.setTextColor(grayColor);
         }
 
-        iconPark.setImageAndDecodeBounds(ResourceTable.Media_park);
-        iconMy.setImageAndDecodeBounds(ResourceTable.Media_my);
-//        iconReserveParking.setImageAndDecodeBounds(ResourceTable.Media_fee);
-
         // 设置选中状态
         switch (index) {
             case 0: // 我的
                 textMy.setTextColor(blueColor);
-                iconMy.setImageAndDecodeBounds(ResourceTable.Media_my_1);
 
                 iconMy.setVisibility(Component.HIDE);
                 iconMy1.setVisibility(Component.VISIBLE);
@@ -426,7 +430,6 @@ public class MainAbilitySlice extends AbilitySlice {
                 break;
             case 1: // 找车位
                 textPark.setTextColor(blueColor);
-                iconPark.setImageAndDecodeBounds(ResourceTable.Media_park_1);
 
                 iconMy.setVisibility(Component.VISIBLE);
                 iconMy1.setVisibility(Component.HIDE);
@@ -448,156 +451,6 @@ public class MainAbilitySlice extends AbilitySlice {
         }
     }
 
-    /**
-     * 初始化地图 - 完全按照 MarkerDemo 的方式
-     */
-    private void initMap() {
-        try {
-            // Declaring and Initializing the HuaweiMapOptions Object - 完全按照 MarkerDemo
-            HuaweiMapOptions huaweiMapOptions = new HuaweiMapOptions();
-
-            // Initialize Camera Properties
-            CameraPosition cameraPosition =
-                    new CameraPosition(new LatLng(48.893478, 2.334595), 6, 0, 0);
-
-            huaweiMapOptions
-                    // Set Camera Properties
-                    .camera(cameraPosition)
-                    // Enables or disables the zoom function. By default, the zoom function is enabled.
-                    .zoomControlsEnabled(false)
-                    // Sets whether the compass is available. The compass is available by default.
-                    .compassEnabled(true)
-                    // Specifies whether the zoom gesture is available. By default, the zoom gesture is available.
-                    .zoomGesturesEnabled(true)
-                    // Specifies whether to enable the scrolling gesture. By default, the scrolling gesture is enabled.
-                    .scrollGesturesEnabled(true)
-                    // Specifies whether the rotation gesture is available. By default, the rotation gesture is available.
-                    .rotateGesturesEnabled(false)
-                    // Specifies whether the tilt gesture is available. By default, the tilt gesture is available.
-                    .tiltGesturesEnabled(true)
-                    // Sets whether the map is in lite mode. The default value is No.
-                    .liteMode(false)
-                    // Set Preference Minimum Zoom Level
-                    .minZoomPreference(3)
-                    // Set Preference Maximum Zoom Level
-                    .maxZoomPreference(13);
-
-            if (true) return;
-
-            // Initialize MapView Object. - 完全按照 MarkerDemo
-            mMapView = new MapView(this, huaweiMapOptions);
-            mMapView.onCreate();
-
-
-            // Obtains the HuaweiMap object. - 完全按照 MarkerDemo
-            mMapView.getMapAsync(huaweiMap -> {
-                mHuaweiMap = huaweiMap;
-
-                // If mHuaweiMap is null, the program stops running. - 完全按照 MarkerDemo
-                if (null == mHuaweiMap) {
-                    Log.error("mHuaweiMap 为 null");
-                    return;
-                }
-
-                Log.info("地图已就绪,开始获取定位");
-
-                mHuaweiMap.setOnMapClickListener(new OnMapClickListener() {
-                    @Override
-                    public void onMapClick(LatLng latLng) {
-                        new ToastDialog(CommonContext.getContext()).setText("onMapClick ").show();
-                    }
-                });
-
-                // If mMarker is not null, remove it from the map and then set it to null. - 完全按照 MarkerDemo
-                if (null != mMarker) {
-                    mMarker.remove();
-                    mMarker = null;
-                }
-
-                // Add a marker to the map. - 完全按照 MarkerDemo
-                MarkerOptions options = new MarkerOptions()
-                        .position(new LatLng(48.893478, 2.334595))
-                        .title("Hello Huawei Map")
-                        .snippet("This is a snippet!");
-                mMarker = mHuaweiMap.addMarker(options);
-
-                // Set the marker title. - 完全按照 MarkerDemo
-                if (mMarker != null) {
-                    mMarker.setTitle("Marker title");
-                }
-
-                // Set whether the marker can be dragged. - 完全按照 MarkerDemo
-                if (mMarker != null) {
-                    mMarker.setDraggable(true);
-                }
-
-                // Set the marker anchor point. - 完全按照 MarkerDemo
-                if (mMarker != null) {
-                    mMarker.setMarkerAnchor(0.9F, 0.9F);
-                }
-
-                // Customizing the Marker Icon - 完全按照 MarkerDemo
-                addCustomMarker();
-
-                mHuaweiMap.setOnMarkerClickListener(new OnMarkerClickListener() {
-                    @Override
-                    public boolean onMarkerClick(Marker marker) {
-                        new ToastDialog(CommonContext.getContext()).setText("onMarkerClick: " + marker.getTitle()).show();
-                        return false;
-                    }
-                });
-
-                mHuaweiMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
-                    @Override
-                    public void onInfoWindowClick(Marker marker) {
-                        new ToastDialog(CommonContext.getContext()).setText("onInfoWindowClick:").show();
-                    }
-                });
-
-                // 地图就绪后,自动获取当前位置
-                if (locator != null && locatorCallback != null) {
-                    locateCurrentPosition();
-                }
-            });
-
-//            ComponentContainer.LayoutConfig config = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
-//            PositionLayout myLayout = new PositionLayout(this);
-//            myLayout.setLayoutConfig(config);
-
-            PositionLayout myLayout = findComponentById(ResourceTable.Id_main_body);
-
-            ShapeElement element = new ShapeElement();
-            element.setShape(ShapeElement.RECTANGLE);
-            element.setRgbColor(new RgbColor(255, 255, 255));
-
-            // 加载MapView
-            myLayout.addComponent(mMapView);
-        } catch (Exception e) {
-            Log.error("初始化地图失败: " + e.getMessage());
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * addCustomMarker - 完全按照 MarkerDemo
-     */
-    private void addCustomMarker() {
-        Resource resource = null;
-        try {
-            resource = getResourceManager().getResource(ResourceTable.Media_icon);
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (NotExistException e) {
-            e.printStackTrace();
-        }
-
-        if (resource != null && mHuaweiMap != null) {
-            mHuaweiMap.addMarker(new MarkerOptions()
-                    .position(new LatLng(47.8333, 2.8333))
-                    .icon(resource));
-        }
-    }
-
     /**
      * 设置事件监听
      */
@@ -620,9 +473,10 @@ public class MainAbilitySlice extends AbilitySlice {
                     double longitude = location.getLongitude();
 
                     Log.info("定位成功: " + latitude + ", " + longitude);
-
-                    // 将坐标传递给地图
-                    updateMapWithLocation(location);
+                    // 定位成功后,如果当前在找车位页面,重新加载数据
+                    if (currentTab == 1 && findParkingPage != null) {
+                        loadParkingData(true);
+                    }
                 }
 
                 @Override
@@ -633,7 +487,7 @@ public class MainAbilitySlice extends AbilitySlice {
                 @Override
                 public void onErrorReport(int errorCode) {
                     Log.error("定位错误: " + errorCode);
-                    new ToastDialog(CommonContext.getContext())
+                    new ToastDialog(getContext())
                             .setText("定位失败,错误码: " + errorCode)
                             .show();
                 }
@@ -662,116 +516,440 @@ public class MainAbilitySlice extends AbilitySlice {
         }
     }
 
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        // 停止定位
+        if (locator != null && locatorCallback != null) {
+            try {
+                locator.stopLocating(locatorCallback);
+            } catch (Exception e) {
+                Log.error("停止定位失败: " + e.getMessage());
+            }
+        }
+
+        if (dataAbilityHelper != null) {
+
+        }
+        dataAbilityHelper.unregisterObserver(SystemSettings.getUri(SystemSettings.Date.TIME_FORMAT), dataAbilityObserver);
+    }
+
     /**
-     * 将定位坐标传递给地图并更新地图显示
+     * 初始化找车位页面组件
      */
-    private void updateMapWithLocation(Location location) {
-        if (mHuaweiMap == null) {
-            Log.warn("地图未初始化完成,等待地图就绪");
+    private void initFindParkingPage() {
+        if (findParkingPage == null) {
             return;
         }
 
-        try {
-            double latitude = location.getLatitude();
-            double longitude = location.getLongitude();
+        // 获取组件
+        tabAll = (Text) findParkingPage.findComponentById(ResourceTable.Id_tab_all);
+        tabRecommended = (Text) findParkingPage.findComponentById(ResourceTable.Id_tab_recommended);
+        tabAllUnderline = findParkingPage.findComponentById(ResourceTable.Id_tab_all_underline);
+        tabRecommendedUnderline = findParkingPage.findComponentById(ResourceTable.Id_tab_recommended_underline);
+        btnDistanceSort = (Button) findParkingPage.findComponentById(ResourceTable.Id_btn_distance_sort);
+        parkingListScroll = (ScrollView) findParkingPage.findComponentById(ResourceTable.Id_parking_list_scroll);
+        parkingListContainer = (DirectionalLayout) findParkingPage.findComponentById(ResourceTable.Id_parking_list_container);
+
+        // 设置标签页点击事件
+        if (tabAll != null) {
+            tabAll.setClickedListener(component -> switchTab(2)); // 2=全部
+        }
+        if (tabRecommended != null) {
+            tabRecommended.setClickedListener(component -> switchTab(1)); // 1=推荐
+        }
 
-            Log.info("更新地图位置: " + latitude + ", " + longitude);
+        // 设置下拉框点击事件(这里用按钮模拟下拉框)
+        if (btnDistanceSort != null) {
+            btnDistanceSort.setClickedListener(component -> {
+                // 可以在这里显示下拉选择框,暂时保持"距离最近"
+                Log.info("点击了距离最近下拉框");
+            });
+        }
 
-            // 创建坐标点
-            LatLng latLng = new LatLng(latitude, longitude);
+        // 设置滚动监听,实现分页加载
+        if (parkingListScroll != null) {
+            parkingListScroll.setReboundEffect(false);
+            // 监听滚动到底部
+            parkingListScroll.addScrolledListener(new Component.ScrolledListener() {
+                @Override
+                public void onContentScrolled(Component component, int x, int y, int oldX, int oldY) {
+                    // 计算是否滚动到底部
+                    int scrollHeight = parkingListScroll.getScrollValue(1);
+                    int contentHeight = parkingListScroll.getEstimatedHeight();
+//                    int contentHeight = parkingListScroll.getContentHeight();
+                    int viewHeight = parkingListScroll.getHeight();
+                    
+                    if (scrollHeight + viewHeight >= contentHeight - 100 && !isLoading && hasMore) {
+                        // 加载下一页
+                        loadParkingData(false);
+                    }
+                }
+            });
+        }
 
-            // 移除旧的当前位置标记
-            if (currentLocationMarker != null) {
-                currentLocationMarker.remove();
-                currentLocationMarker = null;
+        // 默认选中全部车场
+        switchTab(2);
+    }
+
+    /**
+     * 切换标签页
+     */
+    private void switchTab(int filter) {
+        filterType = filter;
+        currentPage = 1;
+        hasMore = true;
+        parkingList.clear();
+        if (parkingListContainer != null) {
+            parkingListContainer.removeAllComponents();
+        }
+        
+        // 更新标签样式
+        Color selectedColor = new Color(Color.getIntColor("#FA6332"));
+        Color normalColor = new Color(Color.getIntColor("#FF666666"));
+        
+        if (tabAll != null) {
+            tabAll.setTextColor(filter == 2 ? selectedColor : normalColor);
+        }
+        if (tabRecommended != null) {
+            tabRecommended.setTextColor(filter == 1 ? selectedColor : normalColor);
+        }
+        
+        // 更新下划线显示
+        if (tabAllUnderline != null) {
+            tabAllUnderline.setVisibility(filter == 2 ? Component.VISIBLE : Component.HIDE);
+        }
+        if (tabRecommendedUnderline != null) {
+            tabRecommendedUnderline.setVisibility(filter == 1 ? Component.VISIBLE : Component.HIDE);
+        }
+        
+        // 加载数据
+        loadParkingData(true);
+    }
+
+    /**
+     * 加载停车场数据
+     */
+    private void loadParkingData(boolean isRefresh) {
+        if (isLoading) {
+            return;
+        }
+
+        if (isRefresh) {
+            currentPage = 1;
+            hasMore = true;
+            parkingList.clear();
+            if (parkingListContainer != null) {
+                parkingListContainer.removeAllComponents();
             }
+        }
 
-            // 在地图上添加当前位置标记
-            MarkerOptions currentLocationOptions = new MarkerOptions()
-                    .position(latLng)
-                    .title("当前位置")
-                    .snippet("纬度: " + latitude + ", 经度: " + longitude);
-            currentLocationMarker = mHuaweiMap.addMarker(currentLocationOptions);
+        if (!hasMore) {
+            return;
+        }
 
-            // Method 8: Set the center point and zoom level of the camera. - 完全按照示例代码
-            float zoom = 15.0f;
-            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, zoom);
+        isLoading = true;
 
-            // move camera - 完全按照示例代码
-            mHuaweiMap.moveCamera(cameraUpdate);
+        // 获取定位坐标
+        double latitude = 0;
+        double longitude = 0;
+        if (currentLocation != null) {
+            latitude = currentLocation.getLatitude();
+            longitude = currentLocation.getLongitude();
+        }
 
-            Log.info("地图已更新到当前位置");
+        // 构建请求URL
+        String url = String.format("/park/near/page?filter=%d&latitude=%f&longitude=%f&current=%d&size=%d",
+                filterType, latitude, longitude, currentPage, pageSize);
+
+        // 发送请求
+        CompletableFuture<R<Object>> future = api.http(getContext(), url, "GET", null, null, null);
+        future.thenAccept(response -> {
+            getUITaskDispatcher().asyncDispatch(() -> {
+                isLoading = false;
+                
+                if (response == null || !response.isSuccess()) {
+                    String errorMsg = response != null ? response.getMsg() : "请求失败";
+                    Log.error("加载停车场数据失败: " + errorMsg);
+                    return;
+                }
+
+                try {
+                    // 解析响应数据
+                    Object dataObj = response.getData();
+                    if (dataObj == null) {
+                        Log.error("响应数据为空");
+                        return;
+                    }
 
-            // 显示提示
-            new ToastDialog(CommonContext.getContext())
-                    .setText("已定位到当前位置")
-                    .show();
+                    // 将data转换为ZSONObject
+                    ZSONObject pageObj;
+                    if (dataObj instanceof ZSONObject) {
+                        pageObj = (ZSONObject) dataObj;
+                    } else {
+                        pageObj = ZSONObject.stringToZSON(dataObj.toString());
+                    }
+
+                    // 解析Page对象
+                    Page<ParkNearRes> page = parsePageData(pageObj);
+                    if (page == null || page.getRecords() == null) {
+                        Log.error("解析分页数据失败");
+                        return;
+                    }
+
+                    List<ParkNearRes> records = page.getRecords();
+                    if (records.isEmpty()) {
+                        hasMore = false;
+                        return;
+                    }
+
+                    // 添加到列表
+                    parkingList.addAll(records);
+                    
+                    // 渲染列表项
+                    for (ParkNearRes park : records) {
+                        addParkingItem(park);
+                    }
+
+                    // 更新分页信息
+                    if (page.getCurrent() != null && page.getPages() != null) {
+                        if (page.getCurrent() >= page.getPages()) {
+                            hasMore = false;
+                        } else {
+                            currentPage++;
+                        }
+                    } else {
+                        // 如果没有分页信息,根据返回数量判断
+                        if (records.size() < pageSize) {
+                            hasMore = false;
+                        } else {
+                            currentPage++;
+                        }
+                    }
+
+                } catch (Exception e) {
+                    Log.error("解析停车场数据失败: " + e.getMessage());
+                    e.printStackTrace();
+                }
+            });
+        });
+    }
 
+    /**
+     * 解析分页数据
+     */
+    private Page<ParkNearRes> parsePageData(ZSONObject pageObj) {
+        try {
+            Page<ParkNearRes> page = new Page<>();
+            
+            if (pageObj.containsKey("total")) {
+                page.setTotal(pageObj.getIntValue("total"));
+            }
+            if (pageObj.containsKey("pages")) {
+                page.setPages(pageObj.getIntValue("pages"));
+            }
+            if (pageObj.containsKey("current")) {
+                page.setCurrent(pageObj.getIntValue("current"));
+            }
+            if (pageObj.containsKey("size")) {
+                page.setSize(pageObj.getIntValue("size"));
+            }
+            if (pageObj.containsKey("records")) {
+                Object recordsObj = pageObj.get("records");
+                if (recordsObj instanceof List) {
+                    List<?> recordsList = (List<?>) recordsObj;
+                    List<ParkNearRes> parkList = new ArrayList<>();
+                    for (Object item : recordsList) {
+                        ParkNearRes park = parseParkData(item);
+                        if (park != null) {
+                            parkList.add(park);
+                        }
+                    }
+                    page.setRecords(parkList);
+                }
+            }
+            
+            return page;
         } catch (Exception e) {
-            Log.error("更新地图位置失败: " + e.getMessage());
-            e.printStackTrace();
+            Log.error("解析Page数据失败: " + e.getMessage());
+            return null;
         }
     }
 
     /**
-     * 移动地图到当前位置 - 完全按照 MapViewCameraDemo 的方式
+     * 解析停车场数据
      */
-    private void moveToCurrentLocation(Location location) {
-        updateMapWithLocation(location);
-    }
+    private ParkNearRes parseParkData(Object itemObj) {
+        try {
+            ZSONObject parkObj;
+            if (itemObj instanceof ZSONObject) {
+                parkObj = (ZSONObject) itemObj;
+            } else {
+                parkObj = ZSONObject.stringToZSON(itemObj.toString());
+            }
 
-    // 生命周期管理 - 完全按照示例代码 MapViewDemo.java 的方式
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
+            ParkNearRes park = new ParkNearRes();
+            if (parkObj.containsKey("parkId")) {
+                park.setParkId(parkObj.getString("parkId"));
+            }
+            if (parkObj.containsKey("parkName")) {
+                park.setParkName(parkObj.getString("parkName"));
+            }
+            if (parkObj.containsKey("isreserver")) {
+                park.setIsreserver(parkObj.getIntValue("isreserver"));
+            }
+            if (parkObj.containsKey("isfindcar")) {
+                park.setIsfindcar(parkObj.getIntValue("isfindcar"));
+            }
+            if (parkObj.containsKey("powerEnable")) {
+                park.setPowerEnable(parkObj.getIntValue("powerEnable"));
+            }
+            if (parkObj.containsKey("distance")) {
+                park.setDistance(parkObj.getDoubleValue("distance"));
+            }
+            if (parkObj.containsKey("address")) {
+                park.setAddress(parkObj.getString("address"));
+            }
+            if (parkObj.containsKey("totalPlace")) {
+                park.setTotalPlace(parkObj.getIntValue("totalPlace"));
+            }
+            if (parkObj.containsKey("residuePlace")) {
+                park.setResiduePlace(parkObj.getIntValue("residuePlace"));
+            }
+            if (parkObj.containsKey("latitude")) {
+                park.setLatitude(parkObj.getDoubleValue("latitude"));
+            }
+            if (parkObj.containsKey("longitude")) {
+                park.setLongitude(parkObj.getDoubleValue("longitude"));
+            }
+            if (parkObj.containsKey("onlinePayEnable")) {
+                park.setOnlinePayEnable(parkObj.getIntValue("onlinePayEnable"));
+            }
+            if (parkObj.containsKey("invoiceEnable")) {
+                park.setInvoiceEnable(parkObj.getIntValue("invoiceEnable"));
+            }
+            if (parkObj.containsKey("reductionEnable")) {
+                park.setReductionEnable(parkObj.getIntValue("reductionEnable"));
+            }
+            if (parkObj.containsKey("chargeInfo")) {
+                park.setChargeInfo(parkObj.getString("chargeInfo"));
+            }
 
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
+            return park;
+        } catch (Exception e) {
+            Log.error("解析ParkNearRes数据失败: " + e.getMessage());
+            return null;
         }
     }
 
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
+    /**
+     * 添加停车场列表项
+     */
+    private void addParkingItem(ParkNearRes park) {
+        if (parkingListContainer == null) {
+            return;
         }
-    }
 
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
+        try {
+            // 加载列表项布局
+            Component item = LayoutScatter.getInstance(this)
+                    .parse(ResourceTable.Layout_item_parking, null, false);
+
+            // 设置停车场名称
+            Text nameText = (Text) item.findComponentById(ResourceTable.Id_parking_name);
+            if (nameText != null && park.getParkName() != null) {
+                nameText.setText(park.getParkName());
+            }
 
-    @Override
-    protected void onStop() {
-        super.onStop();
-        // 停止定位
-        if (locator != null && locatorCallback != null) {
-            try {
-                locator.stopLocating(locatorCallback);
-            } catch (Exception e) {
-                Log.error("停止定位失败: " + e.getMessage());
+            // 设置距离和地址
+            Text addressText = (Text) item.findComponentById(ResourceTable.Id_parking_address);
+            if (addressText != null) {
+                String distanceStr = park.getDistance() != null ? 
+                    String.format("%.1fkm", park.getDistance() / 1000.0) : "0km";
+                String address = park.getAddress() != null ? park.getAddress() : "";
+                addressText.setText(distanceStr + " | " + address);
             }
-        }
-        // 销毁地图 - 完全按照示例代码
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
 
-        if (dataAbilityHelper != null) {
+            // 设置总车位
+            Text totalPlaceText = (Text) item.findComponentById(ResourceTable.Id_text_total_place);
+            if (totalPlaceText != null && park.getTotalPlace() != null) {
+                totalPlaceText.setText(String.valueOf(park.getTotalPlace()));
+            }
 
+            // 设置剩余车位
+            Text residuePlaceText = (Text) item.findComponentById(ResourceTable.Id_text_residue_place);
+            if (residuePlaceText != null && park.getResiduePlace() != null) {
+                residuePlaceText.setText(String.valueOf(park.getResiduePlace()));
+            }
+
+            // 设置免费时长(从chargeInfo中解析,这里简化处理)
+            Text freeDurationText = (Text) item.findComponentById(ResourceTable.Id_text_free_duration);
+            if (freeDurationText != null) {
+                // 这里可以根据chargeInfo解析免费时长,暂时显示"15分"
+                freeDurationText.setText("15分");
+            }
+
+            // 设置标签
+            DirectionalLayout tagsContainer = (DirectionalLayout) item.findComponentById(ResourceTable.Id_tags_container);
+            if (tagsContainer != null) {
+                tagsContainer.removeAllComponents();
+                
+                // 根据数据添加标签
+                // 商场、学校等标签需要根据业务逻辑判断,这里简化处理
+                // 可预约 - 浅蓝色(#4CAF50 或 #2196F3)
+                if (park.getIsreserver() != null && park.getIsreserver() == 1) {
+                    addTag(tagsContainer, "可预约", "#4CAF50");
+                }
+                // 可充电 - 浅蓝色
+                if (park.getPowerEnable() != null && park.getPowerEnable() == 1) {
+                    addTag(tagsContainer, "可充电", "#4CAF50");
+                }
+                // 优惠 - 红色
+                if (park.getReductionEnable() != null && park.getReductionEnable() == 1) {
+                    addTag(tagsContainer, "惠", "#FF0000");
+                }
+                // 商场、学校等标签 - 橙色(#FA6332,需要根据业务逻辑判断,这里暂时不添加)
+            }
+
+            // 设置导航按钮点击事件
+            Button navButton = (Button) item.findComponentById(ResourceTable.Id_btn_navigate);
+            if (navButton != null) {
+                navButton.setClickedListener(component -> {
+                    // 导航功能
+                    Log.info("导航到: " + park.getParkName());
+                    // TODO: 实现导航功能
+                });
+            }
+
+            // 添加到容器
+            parkingListContainer.addComponent(item);
+
+        } catch (Exception e) {
+            Log.error("添加停车场列表项失败: " + e.getMessage());
+            e.printStackTrace();
         }
-        dataAbilityHelper.unregisterObserver(SystemSettings.getUri(SystemSettings.Date.TIME_FORMAT), dataAbilityObserver);
+    }
+
+    /**
+     * 添加标签
+     */
+    private void addTag(DirectionalLayout container, String text, String bgColor) {
+        Text tag = new Text(getContext());
+        tag.setText(text);
+        tag.setTextSize(11);
+        tag.setTextColor(Color.WHITE);
+        tag.setPadding(8, 4, 8, 4);
+        
+        // 创建圆角背景(椭圆形)
+        ShapeElement background = new ShapeElement();
+        background.setShape(ShapeElement.RECTANGLE);
+        RgbColor rgbColor = new RgbColor(Color.getIntColor(bgColor));
+        background.setRgbColor(rgbColor);
+        background.setCornerRadius(12);
+        tag.setBackground(background);
+        
+        tag.setMarginLeft(4);
+        container.addComponent(tag);
     }
 }

+ 0 - 162
entry/src/main/java/com/fujica/abk/slice/MapEventsDemoSlice.java

@@ -1,162 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.OnMapClickListener;
-import com.huawei.hms.maps.harmony.OnCameraMoveStartedListener;
-import com.huawei.hms.maps.harmony.OnCameraMoveListener;
-import com.huawei.hms.maps.harmony.OnCameraIdleListener;
-import com.huawei.hms.maps.harmony.OnMapLoadedCallback;
-import com.huawei.hms.maps.harmony.OnMapLongClickListener;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import com.huawei.hms.maps.harmony.CommonContext;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.element.ShapeElement;
-import ohos.agp.window.dialog.ToastDialog;
-import ohos.hiviewdfx.HiLog;
-import ohos.hiviewdfx.HiLogLabel;
-
-public class MapEventsDemoSlice extends AbilitySlice implements OnMapReadyCallback {
-    private static final HiLogLabel LABEL = new HiLogLabel(HiLog.DEBUG, 0x011, "MapEventsDemo");
-
-    private HuaweiMap mHuaweiMap;
-
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        CommonContext.setContext(this);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this);
-        mMapView.onCreate();
-
-        // Obtains the HuaweiMap object.
-        mMapView.getMapAsync(this);
-
-        // Create a layout.
-        ComponentContainer.LayoutConfig config = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
-        PositionLayout myLayout = new PositionLayout(this);
-        myLayout.setLayoutConfig(config);
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-
-        // Load the MapView object.
-        myLayout.addComponent(mMapView);
-        super.setUIContent(myLayout);
-    }
-
-    @Override
-    public void onMapReady(HuaweiMap huaweiMap) {
-        mHuaweiMap = huaweiMap;
-
-        // If mHuaweiMap is null, the program stops running.
-        if (null == mHuaweiMap) {
-            return;
-        }
-
-        mHuaweiMap.setOnCameraMoveStartedListener(new OnCameraMoveStartedListener() {
-            @Override
-            public void onCameraMoveStarted(int i) {
-                HiLog.debug(LABEL, "onCameraMoveStarted.");
-            }
-        });
-
-        mHuaweiMap.setOnCameraMoveListener(new OnCameraMoveListener() {
-            @Override
-            public void onCameraMove() {
-                HiLog.debug(LABEL, "onCameraMove.");
-            }
-        });
-
-        mHuaweiMap.setOnCameraIdleListener(new OnCameraIdleListener() {
-            @Override
-            public void onCameraIdle() {
-                HiLog.debug(LABEL, "onCameraIdle.");
-            }
-        });
-
-        mHuaweiMap.setOnMapLoadedCallback(new OnMapLoadedCallback() {
-            @Override
-            public void onMapLoaded() {
-                new ToastDialog(CommonContext.getContext()).setText("onMapLoaded:").show();
-            }
-        });
-
-        mHuaweiMap.setOnMapClickListener(new OnMapClickListener() {
-            @Override
-            public void onMapClick(LatLng latLng) {
-                new ToastDialog(CommonContext.getContext()).setText("onMapClick:").show();
-            }
-        });
-
-        mHuaweiMap.setOnMapLongClickListener(new OnMapLongClickListener() {
-            @Override
-            public void onMapLongClick(LatLng latLng) {
-                new ToastDialog(CommonContext.getContext()).setText("onMapLongClick:").show();
-            }
-        });
-
-        // 设置最小偏好缩放级别,范围为[3,20]
-        mHuaweiMap.setMinZoomPreference(3);
-        // 设置最大偏好缩放级别,范围为[3,20]
-        mHuaweiMap.setMaxZoomPreference(14);
-        // 重置最大最小缩放级别
-        mHuaweiMap.resetMinMaxZoomPreference();
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 0 - 136
entry/src/main/java/com/fujica/abk/slice/MapTypeDemoSlice.java

@@ -1,136 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.HuaweiMapOptions;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.OnMapClickListener;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import com.huawei.hms.maps.harmony.CommonContext;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.element.ShapeElement;
-import ohos.agp.window.dialog.ToastDialog;
-import com.huawei.hms.maps.harmony.OnMapLongClickListener;
-
-public class MapTypeDemoSlice extends AbilitySlice {
-    private int longClickCounter = 0;
-
-    private HuaweiMap mHuaweiMap;
-
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        CommonContext.setContext(this);
-
-        // Declaring and Initializing the HuaweiMapOptions Object
-        HuaweiMapOptions huaweiMapOptions = new HuaweiMapOptions();
-
-        // Enable the lite mode map.
-        huaweiMapOptions.liteMode(true);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this, huaweiMapOptions);
-        mMapView.onCreate();
-
-        // Obtains the HuaweiMap object.
-        mMapView.getMapAsync(new OnMapReadyCallback() {
-            @Override
-            public void onMapReady(HuaweiMap huaweiMap) {
-                mHuaweiMap = huaweiMap;
-
-                // If mHuaweiMap is null, the program stops running.
-                if (null == mHuaweiMap) {
-                    return;
-                }
-
-                mHuaweiMap.setOnMapClickListener(new  OnMapClickListener() {
-                    @Override
-                    public void onMapClick(LatLng latLng) {
-                        new ToastDialog(CommonContext.getContext()).setText("onMapClick ").show();
-                    }
-                });
-
-                mHuaweiMap.setOnMapLongClickListener(new OnMapLongClickListener() {
-                    @Override
-                    public void onMapLongClick(LatLng latLng) {
-                        if (longClickCounter % 2 ==0 ) {
-                            mHuaweiMap.setMapType(HuaweiMap.MAP_TYPE_NONE);
-                            new ToastDialog(CommonContext.getContext()).setText("HuaweiMap.MAP_TYPE_NONE ").show();
-                            longClickCounter++;
-                        } else {
-                            mHuaweiMap.setMapType(HuaweiMap.MAP_TYPE_NORMAL);
-                            new ToastDialog(CommonContext.getContext()).setText("HuaweiMap.MAP_TYPE_NORMAL ").show();
-                            longClickCounter++;
-                        }
-                    }
-                });
-            }
-        });
-
-        // Create a layout.
-        ComponentContainer.LayoutConfig config = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
-        PositionLayout myLayout = new PositionLayout(this);
-        myLayout.setLayoutConfig(config);
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-
-        // Load the MapView object.
-        myLayout.addComponent(mMapView);
-        super.setUIContent(myLayout);
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 0 - 195
entry/src/main/java/com/fujica/abk/slice/MapViewCameraDemoSlice.java

@@ -1,195 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.CameraUpdate;
-import com.huawei.hms.maps.harmony.CameraUpdateFactory;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.OnMapClickListener;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import com.huawei.hms.maps.harmony.model.CameraPosition;
-import com.huawei.hms.maps.harmony.model.LatLngBounds;
-import com.huawei.hms.maps.harmony.model.Point;
-import com.huawei.hms.maps.harmony.OnMapLongClickListener;
-import com.huawei.hms.maps.harmony.CommonContext;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.element.ShapeElement;
-import ohos.agp.window.dialog.ToastDialog;
-
-public class MapViewCameraDemoSlice extends AbilitySlice {
-    private HuaweiMap mHuaweiMap;
-
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        CommonContext.setContext(this);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this);
-
-        // Creating a MapView
-        mMapView.onCreate();
-
-        // Obtains the HuaweiMap object.
-        mMapView.getMapAsync(new OnMapReadyCallback() {
-            @Override
-            public void onMapReady(HuaweiMap huaweiMap) {
-                mHuaweiMap = huaweiMap;
-
-                // If mHuaweiMap is null, the program stops running.
-                if (null == mHuaweiMap) {
-                    return;
-                }
-
-                mHuaweiMap.setOnMapClickListener(new OnMapClickListener() {
-                    @Override
-                    public void onMapClick(LatLng latLng) {
-                        new ToastDialog(CommonContext.getContext()).setText("onMapClick:").show();
-                    }
-                });
-
-                mHuaweiMap.setOnMapLongClickListener(new OnMapLongClickListener() {
-                    @Override
-                    public void onMapLongClick(LatLng latLng) {
-                        new ToastDialog(CommonContext.getContext()).setText("onMapLongClick:").show();
-                    }
-                });
-
-                // move camera
-                CameraUpdate cameraUpdate = buildCameraUpdate();
-                mHuaweiMap.moveCamera(cameraUpdate);
-
-                // Sets the minimum preferred zoom level. The value ranges from 3 to 20.
-                mHuaweiMap.setMinZoomPreference(3);
-                // Sets the maximum preferred zoom level. The value ranges from 3 to 20.
-                mHuaweiMap.setMaxZoomPreference(14);
-                // Reset maximum and minimum zoom levels
-                mHuaweiMap.resetMinMaxZoomPreference();
-            }
-        });
-
-        // Create a layout.
-        ComponentContainer.LayoutConfig config = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
-        PositionLayout myLayout = new PositionLayout(this);
-        myLayout.setLayoutConfig(config);
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-
-        // Load the MapView object.
-        myLayout.addComponent(mMapView);
-        super.setUIContent(myLayout);
-    }
-
-    /**
-     * new CameraUpdate
-     *
-     * @return CameraUpdate
-     */
-    private CameraUpdate buildCameraUpdate() {
-        // Method 1: Increase the camera zoom level by 1 and retain other attribute settings.
-        CameraUpdate cameraUpdate = CameraUpdateFactory.zoomIn();
-
-        // Method 2: Decrease the camera zoom level by 1 and retain other attribute settings.
-        CameraUpdate cameraUpdate1 = CameraUpdateFactory.zoomOut();
-
-        // Method 3: Set the camera zoom level to a specified value and retain other attribute settings.
-        float zoom = 8.0f;
-        CameraUpdate cameraUpdate2 = CameraUpdateFactory.zoomTo(zoom);
-
-        // Method 4: Increase or decrease the camera zoom level by a specified value.
-        float amount = 2.0f;
-        CameraUpdate cameraUpdate3 = CameraUpdateFactory.zoomBy(amount);
-
-        // Method 5: Move the camera to the specified center point and increase or decrease the camera zoom level
-        // by a specified value.
-        Point point = new Point(31, 118);
-        float amount2 = 2.0f;
-        CameraUpdate cameraUpdate4 = CameraUpdateFactory.zoomBy(amount2, point);
-
-        // Method 6: Set the latitude and longitude of the camera and retain other attribute settings.
-        LatLng latLng = new LatLng(31.5, 118.9);
-        CameraUpdate cameraUpdate5 = CameraUpdateFactory.newLatLng(latLng);
-
-        // Method 7: Set the visible region and padding.
-        int padding = 100;
-        LatLng latLng1 = new LatLng(31.5, 118.9);
-        LatLng latLng2 = new LatLng(32.5, 119.9);
-        LatLngBounds latLngBounds = new LatLngBounds(latLng1, latLng2);
-        CameraUpdate cameraUpdate6 = CameraUpdateFactory.newLatLngBounds(latLngBounds, padding);
-
-        // Method 8: Set the center point and zoom level of the camera.
-        float zoom2 = 0.0f;
-        LatLng latLng3 = new LatLng(32.5, 119.9);
-        CameraUpdate cameraUpdate7 = CameraUpdateFactory.newLatLngZoom(latLng3, zoom2);
-
-        // Method 9: Scroll the camera by specified number of pixels.
-        float x = 100.0f;
-        float y = 100.0f;
-        CameraUpdate cameraUpdate8 = CameraUpdateFactory.scrollBy(x, y);
-
-        // Method 10: Specify the camera position.
-        // Set the tilt.
-        float tilt = 2.2f;
-        // Set the bearing.
-        float bearing = 31.5f;
-        CameraPosition cameraPosition = new CameraPosition(latLng1, zoom, tilt, bearing);
-        CameraUpdate cameraUpdate9 = CameraUpdateFactory.newCameraPosition(cameraPosition);
-
-        return cameraUpdate9;
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 0 - 100
entry/src/main/java/com/fujica/abk/slice/MapViewDemoSlice.java

@@ -1,100 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.OnMapClickListener;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import com.huawei.hms.maps.harmony.CommonContext;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.element.ShapeElement;
-import ohos.agp.window.dialog.ToastDialog;
-
-public class MapViewDemoSlice extends AbilitySlice {
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        CommonContext.setContext(this);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this);
-
-        // Creating a MapView
-        mMapView.onCreate();
-
-        // Obtains the HuaweiMap object.
-        mMapView.getMapAsync(new OnMapReadyCallback() {
-            @Override
-            public void onMapReady(HuaweiMap huaweiMap) {
-                HuaweiMap mHuaweiMap = huaweiMap;
-                mHuaweiMap.setOnMapClickListener(latLng -> new ToastDialog(CommonContext.getContext()).setText("onMapClick ").show());
-            }
-        });
-
-        // Create a layout.
-        ComponentContainer.LayoutConfig config = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
-        PositionLayout myLayout = new PositionLayout(this);
-        myLayout.setLayoutConfig(config);
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-
-        // Load the MapView object.
-        myLayout.addComponent(mMapView);
-        super.setUIContent(myLayout);
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 0 - 222
entry/src/main/java/com/fujica/abk/slice/MarkerDemoSlice.java

@@ -1,222 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.fujica.abk.ResourceTable;
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.HuaweiMapOptions;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.OnMapClickListener;
-import com.huawei.hms.maps.harmony.OnInfoWindowClickListener;
-import com.huawei.hms.maps.harmony.OnMarkerClickListener;
-import com.huawei.hms.maps.harmony.model.CameraPosition;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import com.huawei.hms.maps.harmony.model.Marker;
-import com.huawei.hms.maps.harmony.model.MarkerOptions;
-import com.huawei.hms.maps.harmony.CommonContext;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.element.ShapeElement;
-import ohos.agp.window.dialog.ToastDialog;
-import ohos.global.resource.NotExistException;
-import ohos.global.resource.Resource;
-
-import java.io.IOException;
-
-public class MarkerDemoSlice extends AbilitySlice {
-    private HuaweiMap mHuaweiMap;
-
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    /**
-     * Declare a Polyline object.
-     */
-    private Marker mMarker;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        CommonContext.setContext(this);
-
-        // Declaring and Initializing the HuaweiMapOptions Object
-        HuaweiMapOptions huaweiMapOptions = new HuaweiMapOptions();
-
-        // Initialize Camera Properties
-        CameraPosition cameraPosition =
-                new CameraPosition(new LatLng(48.893478, 2.334595), 6, 0, 0);
-
-        huaweiMapOptions
-                // Set Camera Properties
-                .camera(cameraPosition)
-                // Enables or disables the zoom function. By default, the zoom function is enabled.
-                .zoomControlsEnabled(false)
-                // Sets whether the compass is available. The compass is available by default.
-                .compassEnabled(true)
-                // Specifies whether the zoom gesture is available. By default, the zoom gesture is available.
-                .zoomGesturesEnabled(true)
-                // Specifies whether to enable the scrolling gesture. By default, the scrolling gesture is enabled.
-                .scrollGesturesEnabled(true)
-                // Specifies whether the rotation gesture is available. By default, the rotation gesture is available.
-                .rotateGesturesEnabled(false)
-                // Specifies whether the tilt gesture is available. By default, the tilt gesture is available.
-                .tiltGesturesEnabled(true)
-                // Sets whether the map is in lite mode. The default value is No.
-                .liteMode(false)
-                // Set Preference Minimum Zoom Level
-                .minZoomPreference(3)
-                // Set Preference Maximum Zoom Level
-                .maxZoomPreference(13);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this, huaweiMapOptions);
-        mMapView.onCreate();
-
-        // Obtains the HuaweiMap object.
-        mMapView.getMapAsync(new OnMapReadyCallback() {
-            @Override
-            public void onMapReady(HuaweiMap huaweiMap) {
-                mHuaweiMap = huaweiMap;
-
-                // If mHuaweiMap is null, the program stops running.
-                if (null == mHuaweiMap) {
-                    return;
-                }
-
-                mHuaweiMap.setOnMapClickListener(new  OnMapClickListener() {
-                    @Override
-                    public void onMapClick(LatLng latLng) {
-                        new ToastDialog(CommonContext.getContext()).setText("onMapClick ").show();
-                    }
-                });
-
-                // If mMarker is not null, remove it from the map and then set it to null.
-                if (null != mMarker) {
-                    mMarker.remove();
-                    mMarker = null;
-                }
-
-                // Add a marker to the map.
-                MarkerOptions options = new MarkerOptions()
-                        .position(new LatLng(48.893478, 2.334595))
-                        .title("Hello Huawei Map")
-                        .snippet("This is a snippet!");
-                mMarker = mHuaweiMap.addMarker(options);
-
-                // Set the marker title.
-                if (mMarker != null) {
-                    mMarker.setTitle("Marker title");
-                }
-
-                // Set whether the marker can be dragged.
-                if (mMarker != null) {
-                    mMarker.setDraggable(true);
-                }
-
-                // Set the marker anchor point.
-                if (mMarker != null) {
-                    mMarker.setMarkerAnchor(0.9F, 0.9F);
-                }
-
-                // Customizing the Marker Icon
-                addCustomMarker();
-
-                mHuaweiMap.setOnMarkerClickListener(new OnMarkerClickListener() {
-                    @Override
-                    public boolean onMarkerClick(Marker marker) {
-                        new ToastDialog(CommonContext.getContext()).setText("onMarkerClick: " + marker.getTitle()).show();
-                        return false;
-                    }
-                });
-
-                mHuaweiMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
-                    @Override
-                    public void onInfoWindowClick(Marker marker) {
-                        new ToastDialog(CommonContext.getContext()).setText("onInfoWindowClick:").show();
-                    }
-                });
-            }
-        });
-
-        // Create a layout.
-        ComponentContainer.LayoutConfig config = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT);
-        PositionLayout myLayout = new PositionLayout(this);
-        myLayout.setLayoutConfig(config);
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-
-        // Load the MapView object.
-        myLayout.addComponent(mMapView);
-        super.setUIContent(myLayout);
-    }
-
-    /**
-     * addCustomMarker
-     */
-    private void addCustomMarker() {
-        Resource resource = null;
-        try {
-            resource = getResourceManager().getResource(ResourceTable.Media_icon);
-        } catch (IOException e) {
-            e.printStackTrace();
-        } catch (NotExistException e) {
-            e.printStackTrace();
-        }
-
-        if (resource != null) {
-            mHuaweiMap.addMarker(new MarkerOptions()
-                    .position(new LatLng(47.8333, 2.8333))
-                    .icon(resource));
-        }
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 0 - 216
entry/src/main/java/com/fujica/abk/slice/PolygonDemoSlice.java

@@ -1,216 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.fujica.abk.ResourceTable;
-import com.fujica.abk.utils.ScreenUtil;
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.CameraUpdateFactory;
-import com.huawei.hms.maps.harmony.CommonContext;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.Button;
-import ohos.agp.components.Component;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.LayoutScatter;
-import ohos.agp.components.element.ShapeElement;
-import com.huawei.hms.maps.harmony.model.Polygon;
-import com.huawei.hms.maps.harmony.model.PolygonOptions;
-import ohos.agp.utils.Color;
-
-public class PolygonDemoSlice extends AbilitySlice {
-    private HuaweiMap mHuaweiMap;
-
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    /**
-     * Declare a Polygon object.
-     */
-    private Polygon mPolygon;
-
-    private boolean fillColorStatus = true;
-
-    private boolean strokeColorStatus = true;
-
-    /**
-     * the layout
-     */
-    private PositionLayout rootLayout;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        initPositionLayout();
-        initMapView();
-        addButtons();
-        super.setUIContent(this.rootLayout);
-    }
-
-    private void initPositionLayout() {
-        rootLayout = new PositionLayout(this);
-        this.rootLayout.setContentPosition(0, 0);
-        this.rootLayout.setWidth(ComponentContainer.LayoutConfig.MATCH_PARENT);
-        this.rootLayout.setHeight(ComponentContainer.LayoutConfig.MATCH_PARENT);
-
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-        this.rootLayout.setBackground(element);
-    }
-
-    private void initMapView() {
-        CommonContext.setContext(this);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this);
-        mMapView.onCreate();
-
-        // Obtains the HuaweiMap object.
-        mMapView.getMapAsync(new OnMapReadyCallback() {
-            @Override
-            public void onMapReady(HuaweiMap huaweiMap) {
-                mHuaweiMap = huaweiMap;
-
-                // If mHuaweiMap is null, the program stops running.
-                if (null == mHuaweiMap) {
-                    return;
-                }
-
-                // If mPolygon is not null, remove it from the map and then set it to null.
-                if (null != mPolygon) {
-                    mPolygon.remove();
-                    mPolygon = null;
-                }
-
-                LatLng center = new LatLng(48.893478, 2.334595);
-                double halfHeight = 0.1;
-                double halfWidth = 0.1;
-
-                mPolygon = mHuaweiMap
-                        .addPolygon(new PolygonOptions().add(
-                                new LatLng(center.mLatitude - halfHeight, center.mLongitude - halfWidth),
-                                new LatLng(center.mLatitude - halfHeight, center.mLongitude + halfWidth),
-                                new LatLng(center.mLatitude + halfHeight, center.mLongitude + halfWidth),
-                                new LatLng(center.mLatitude + halfHeight, center.mLongitude - halfWidth))
-                                .fillColor(Color.GREEN.getValue())
-                                .strokeColor(Color.BLACK.getValue()));
-
-                // move camera
-                mHuaweiMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.893478, 2.334595), 8));
-            }
-        });
-
-        this.rootLayout.addComponent(mMapView);
-    }
-
-    private void addButtons() {
-        int height = ScreenUtil.getScreenHeight(this);
-
-        Button buttonStrokeColor = createButton();
-        buttonStrokeColor.setText("StrokeColor");
-        buttonStrokeColor.setContentPosition(50, (float) height / 2 - 100);
-        this.rootLayout.addComponent(buttonStrokeColor);
-
-        Button buttonFillColor = createButton();
-        buttonFillColor.setText("FillColor");
-        buttonFillColor.setContentPosition(50, (float) height / 2);
-        this.rootLayout.addComponent(buttonFillColor);
-
-
-        buttonStrokeColor.setClickedListener(new Component.ClickedListener() {
-            @Override
-            public void onClick(Component component) {
-                if (null == mPolygon) {
-                    return;
-                }
-                if (strokeColorStatus) {
-                    // Set the stroke color of the polygon (mPolygon) to red.
-                    mPolygon.setStrokeColor(Color.RED.getValue());
-                } else {
-                    // Set the stroke color of the polygon (mPolygon) to green.
-                    mPolygon.setStrokeColor(Color.GREEN.getValue());
-                }
-                strokeColorStatus = !strokeColorStatus;
-            }
-        });
-
-        buttonFillColor.setClickedListener(new Component.ClickedListener() {
-            @Override
-            public void onClick(Component component) {
-                if (null == mPolygon) {
-                    return;
-                }
-                if (fillColorStatus) {
-                    // Set the fill color of the polygon (mCircle) to red.
-                    mPolygon.setFillColor(Color.RED.getValue());
-                } else {
-                    // Set the fill color of the polygon (mPolygon) to green.
-                    mPolygon.setFillColor(Color.GREEN.getValue());
-                }
-                fillColorStatus = !fillColorStatus;
-            }
-        });
-    }
-
-    /**
-     * Create button
-     *
-     * @return Button
-     */
-    private Button createButton() {
-        Component component = LayoutScatter.getInstance(getContext())
-                .parse(ResourceTable.Layout_button_layout, null, false);
-        return (Button) component;
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 0 - 190
entry/src/main/java/com/fujica/abk/slice/PolylineDemoSlice.java

@@ -1,190 +0,0 @@
-/*
- * Copyright (c) Huawei Technologies Co., Ltd. 2008-2021. All rights reserved.
- */
-
-package com.fujica.abk.slice;
-
-import com.fujica.abk.ResourceTable;
-import com.fujica.abk.utils.ScreenUtil;
-import com.huawei.hms.maps.harmony.HuaweiMap;
-import com.huawei.hms.maps.harmony.MapView;
-import com.huawei.hms.maps.harmony.OnMapReadyCallback;
-import com.huawei.hms.maps.harmony.CameraUpdateFactory;
-import com.huawei.hms.maps.harmony.CommonContext;
-import com.huawei.hms.maps.harmony.model.LatLng;
-import ohos.aafwk.ability.AbilitySlice;
-import ohos.aafwk.content.Intent;
-import ohos.agp.colors.RgbColor;
-import ohos.agp.components.Button;
-import ohos.agp.components.Component;
-import ohos.agp.components.ComponentContainer;
-import ohos.agp.components.PositionLayout;
-import ohos.agp.components.LayoutScatter;
-import ohos.agp.components.element.ShapeElement;
-import com.huawei.hms.maps.harmony.model.Polyline;
-import com.huawei.hms.maps.harmony.model.PolylineOptions;
-import ohos.agp.utils.Color;
-
-public class PolylineDemoSlice extends AbilitySlice {
-    private HuaweiMap mHuaweiMap;
-
-    /**
-     * Declare a MapView object.
-     */
-    private MapView mMapView;
-
-    /**
-     * Declare a Polyline object.
-     */
-    private Polyline mPolyline;
-
-    private boolean strokeColorStatus = true;
-
-    /**
-     * the layout
-     */
-    private PositionLayout rootLayout;
-
-    @Override
-    public void onStart(Intent intent) {
-        super.onStart(intent);
-        initPositionLayout();
-        initMapView();
-        addButtons();
-        super.setUIContent(this.rootLayout);
-    }
-
-    private void initPositionLayout() {
-        rootLayout = new PositionLayout(this);
-        this.rootLayout.setContentPosition(0, 0);
-        this.rootLayout.setWidth(ComponentContainer.LayoutConfig.MATCH_PARENT);
-        this.rootLayout.setHeight(ComponentContainer.LayoutConfig.MATCH_PARENT);
-
-        ShapeElement element = new ShapeElement();
-        element.setShape(ShapeElement.RECTANGLE);
-        element.setRgbColor(new RgbColor(255, 255, 255));
-        this.rootLayout.setBackground(element);
-    }
-
-    private void initMapView() {
-        CommonContext.setContext(this);
-
-        // Initialize MapView Object.
-        mMapView = new MapView(this);
-        mMapView.onCreate();
-
-        // Obtains the HuaweiMap object.
-        mMapView.getMapAsync(new OnMapReadyCallback() {
-            @Override
-            public void onMapReady(HuaweiMap huaweiMap) {
-                mHuaweiMap = huaweiMap;
-
-                // If mHuaweiMap is null, the program stops running.
-                if (null == mHuaweiMap) {
-                    return;
-                }
-
-                // If mPolyline is not null, remove it from the map and then set it to null.
-                if (null != mPolyline) {
-                    mPolyline.remove();
-                    mPolyline = null;
-                }
-
-                // Add a polyline to a map.
-                mPolyline = mHuaweiMap.addPolyline(new PolylineOptions()
-                        // polyline coordinate
-                        .add(new LatLng(47.893478, 2.334595), new LatLng(48.993478, 3.434595),
-                                new LatLng(48.693478, 2.134595), new LatLng(48.793478, 2.334595))
-                        // Polyline Color
-                        .color(Color.BLUE.getValue())
-                        // Polyline Width
-                        .width(3));
-
-                // move camera
-                mHuaweiMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.893478, 2.334595), 6));
-            }
-        });
-
-        this.rootLayout.addComponent(mMapView);
-    }
-
-    private void addButtons() {
-        int height = ScreenUtil.getScreenHeight(this);
-
-        Button buttonStrokeColor = createButton();
-        buttonStrokeColor.setText("StrokeColor");
-        buttonStrokeColor.setContentPosition(50, (float) height / 2);
-        this.rootLayout.addComponent(buttonStrokeColor);
-
-        buttonStrokeColor.setClickedListener(new Component.ClickedListener() {
-            @Override
-            public void onClick(Component component) {
-                if (null == mPolyline) {
-                    return;
-                }
-                if (strokeColorStatus) {
-                    // Set the color of the polyline (mPolyline) to red.
-                    mPolyline.setColor(Color.RED.getValue());
-                } else {
-                    // Set the color of the polyline (mPolyline) to green.
-                    mPolyline.setColor(Color.GREEN.getValue());
-                }
-                // Set the width of the polyline (mPolyline) to 10 pixels.
-                mPolyline.setWidth(10);
-                strokeColorStatus = !strokeColorStatus;
-            }
-        });
-    }
-
-    /**
-     * Create button
-     *
-     * @return Button
-     */
-    private Button createButton() {
-        Component component = LayoutScatter.getInstance(getContext())
-                .parse(ResourceTable.Layout_button_layout, null, false);
-        return (Button) component;
-    }
-
-    @Override
-    protected void onActive() {
-        super.onActive();
-        if (mMapView != null) {
-            mMapView.onResume();
-        }
-    }
-
-    @Override
-    protected void onInactive() {
-        super.onInactive();
-        if (mMapView != null) {
-            mMapView.onPause();
-        }
-    }
-
-    @Override
-    protected void onBackground() {
-        super.onBackground();
-        if (mMapView != null) {
-            mMapView.onStop();
-        }
-    }
-
-    @Override
-    protected void onForeground(Intent intent) {
-        super.onForeground(intent);
-        if (mMapView != null) {
-            mMapView.onStart();
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-        if (mMapView != null) {
-            mMapView.onDestroy();
-        }
-    }
-}
-

+ 48 - 49
entry/src/main/resources/base/layout/ability_main.xml

@@ -14,7 +14,7 @@
 
     <!-- 主内容区域 - 垂直布局 -->
     <DirectionalLayout
-        ohos:margin="5vp"
+        ohos:margin="10vp"
         ohos:id="$+id:main_content"
         ohos:height="match_parent"
         ohos:width="400vp"
@@ -23,7 +23,7 @@
 
         <DirectionalLayout
             ohos:id="$+id:header_bar"
-            ohos:height="56vp"
+            ohos:height="40vp"
             ohos:width="match_parent"
             ohos:alignment="left"
             ohos:background_element="$graphic:container_top"
@@ -38,26 +38,23 @@
                 ohos:alignment="center"
                 ohos:orientation="horizontal">
 
-                <!-- P图标圆圈 -->
-                <Text
-                    ohos:id="$+id:icon_parking"
-                    ohos:height="22vp"
-                    ohos:width="22vp"
-                    ohos:background_element="$graphic:background_circle_16"
-                    ohos:end_margin="8vp"
-                    ohos:text="P"
-                    ohos:text_alignment="center"
-                    ohos:text_color="#FA6332"
-                    ohos:text_size="18fp"/>
+                <Image ohos:image_src="$media:logo_white"
+                       ohos:width="25vp"
+                       ohos:height="25vp"
+                       ohos:right_margin="10vp"
+                       ohos:scale_mode="stretch"
+                       ></Image>
 
                 <!-- 标题文字 -->
                 <Text
                     ohos:id="$+id:title_text"
                     ohos:height="match_content"
                     ohos:width="match_content"
-                    ohos:text="爱泊客 - 停车缴费"
+                    ohos:layout_alignment="vertical_center"
+                    ohos:text="爱泊客.停车缴费"
+                    ohos:text_weight="600"
                     ohos:text_color="#FFFFFFFF"
-                    ohos:text_size="18fp"/>
+                    ohos:text_size="14fp"/>
             </DirectionalLayout>
         </DirectionalLayout>
 
@@ -89,9 +86,10 @@
                 ohos:bottom_padding="8vp"
                 ohos:orientation="horizontal"
                 ohos:top_padding="8vp">
-                <!-- 我的 -->
+
+                <!-- 找车位 -->
                 <DirectionalLayout
-                    ohos:id="$+id:nav_my"
+                    ohos:id="$+id:nav_find_parking"
                     ohos:height="match_parent"
                     ohos:width="0vp"
                     ohos:alignment="center"
@@ -99,34 +97,34 @@
                     ohos:weight="1">
 
                     <Image
-                        ohos:id="$+id:icon_my"
+                        ohos:id="$+id:icon_park"
                         ohos:height="24vp"
                         ohos:width="24vp"
                         ohos:scale_mode="stretch"
                         ohos:bottom_margin="4vp"
-                        ohos:image_src="$media:my"/>
+                        ohos:visibility="hide"
+                        ohos:image_src="$media:park"/>
 
                     <Image
-                        ohos:id="$+id:icon_my_1"
+                        ohos:id="$+id:icon_park_1"
                         ohos:height="24vp"
                         ohos:width="24vp"
                         ohos:scale_mode="stretch"
                         ohos:bottom_margin="4vp"
-                        ohos:visibility="hide"
-                        ohos:image_src="$media:my_1"/>
+                        ohos:image_src="$media:park_1"/>
 
                     <Text
-                        ohos:id="$+id:text_my"
+                        ohos:id="$+id:text_park"
                         ohos:height="match_content"
                         ohos:width="match_content"
-                        ohos:text="我的"
-                        ohos:text_color="#FF666666"
+                        ohos:text="找车位"
+                        ohos:text_color="#FA6332"
                         ohos:text_size="12fp"/>
                 </DirectionalLayout>
 
-                <!-- 找车位 -->
+                <!-- 预约停车 -->
                 <DirectionalLayout
-                    ohos:id="$+id:nav_find_parking"
+                    ohos:id="$+id:nav_reserve_parking"
                     ohos:height="match_parent"
                     ohos:width="0vp"
                     ohos:alignment="center"
@@ -134,34 +132,34 @@
                     ohos:weight="1">
 
                     <Image
-                        ohos:id="$+id:icon_park"
+                        ohos:id="$+id:icon_fee"
+                        ohos:scale_mode="stretch"
                         ohos:height="24vp"
                         ohos:width="24vp"
-                        ohos:scale_mode="stretch"
                         ohos:bottom_margin="4vp"
-                        ohos:visibility="hide"
-                        ohos:image_src="$media:park"/>
-
+                        ohos:image_src="$media:fee"/>
                     <Image
-                        ohos:id="$+id:icon_park_1"
+                        ohos:id="$+id:icon_fee_1"
+                        ohos:scale_mode="stretch"
                         ohos:height="24vp"
                         ohos:width="24vp"
-                        ohos:scale_mode="stretch"
                         ohos:bottom_margin="4vp"
-                        ohos:image_src="$media:park_1"/>
+                        ohos:visibility="hide"
+                        ohos:image_src="$media:fee_1"/>
 
                     <Text
-                        ohos:id="$+id:text_park"
+                        ohos:id="$+id:text_fee"
                         ohos:height="match_content"
                         ohos:width="match_content"
-                        ohos:text="找车位"
-                        ohos:text_color="#FA6332"
+                        ohos:text="缴费记录"
+                        ohos:text_color="#FF666666"
                         ohos:text_size="12fp"/>
                 </DirectionalLayout>
 
-                <!-- 预约停车 -->
+
+                <!-- 我的 -->
                 <DirectionalLayout
-                    ohos:id="$+id:nav_reserve_parking"
+                    ohos:id="$+id:nav_my"
                     ohos:height="match_parent"
                     ohos:width="0vp"
                     ohos:alignment="center"
@@ -169,26 +167,27 @@
                     ohos:weight="1">
 
                     <Image
-                        ohos:id="$+id:icon_fee"
-                        ohos:scale_mode="stretch"
+                        ohos:id="$+id:icon_my"
                         ohos:height="24vp"
                         ohos:width="24vp"
+                        ohos:scale_mode="stretch"
                         ohos:bottom_margin="4vp"
-                        ohos:image_src="$media:fee"/>
+                        ohos:image_src="$media:my"/>
+
                     <Image
-                        ohos:id="$+id:icon_fee_1"
-                        ohos:scale_mode="stretch"
+                        ohos:id="$+id:icon_my_1"
                         ohos:height="24vp"
                         ohos:width="24vp"
+                        ohos:scale_mode="stretch"
                         ohos:bottom_margin="4vp"
                         ohos:visibility="hide"
-                        ohos:image_src="$media:fee_1"/>
+                        ohos:image_src="$media:my_1"/>
 
                     <Text
-                        ohos:id="$+id:text_fee"
+                        ohos:id="$+id:text_my"
                         ohos:height="match_content"
                         ohos:width="match_content"
-                        ohos:text="预约停车"
+                        ohos:text="我的"
                         ohos:text_color="#FF666666"
                         ohos:text_size="12fp"/>
                 </DirectionalLayout>
@@ -221,7 +220,7 @@
             </DirectionalLayout>
         </DirectionalLayout>
 
-        <Button ohos:width="match_parent" ohos:height="60vp" ohos:id="$+id:btn_hwid_sign_in" ohos:text="华为账号登录" ohos:layout_alignment="right|horizontal_center"  ></Button>
+        <Button ohos:width="match_parent" ohos:visibility="hide" ohos:height="60vp" ohos:id="$+id:btn_hwid_sign_in" ohos:text="华为账号登录" ohos:layout_alignment="right|horizontal_center"  ></Button>
     </DirectionalLayout>
 
 </StackLayout>

+ 175 - 0
entry/src/main/resources/base/layout/item_parking.xml

@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8"?>
+<DirectionalLayout
+    xmlns:ohos="http://schemas.huawei.com/res/ohos"
+    ohos:height="match_content"
+    ohos:width="match_parent"
+    ohos:orientation="horizontal"
+    ohos:padding="12vp"
+    ohos:bottom_margin="12vp"
+    ohos:background_element="#FFFFFFFF"
+    ohos:border_radius="8vp"
+    ohos:shadow="2">
+
+    <!-- 中间内容区域 -->
+    <DirectionalLayout
+        ohos:height="match_content"
+        ohos:width="0vp"
+        ohos:weight="1"
+        ohos:orientation="vertical">
+
+        <!-- 停车场名称和标签 -->
+        <DirectionalLayout
+            ohos:height="match_content"
+            ohos:width="match_parent"
+            ohos:orientation="horizontal"
+            ohos:bottom_margin="8vp"
+            ohos:alignment="center">
+
+            <Text
+                ohos:id="$+id:parking_name"
+                ohos:height="match_content"
+                ohos:width="0vp"
+                ohos:weight="1"
+                ohos:text="停车场名称"
+                ohos:text_color="#FF000000"
+                ohos:text_size="16fp"
+                ohos:text_weight="1"
+                ohos:end_margin="8vp"/>
+
+            <!-- 标签容器 -->
+            <DirectionalLayout
+                ohos:id="$+id:tags_container"
+                ohos:height="match_content"
+                ohos:width="match_content"
+                ohos:orientation="horizontal">
+            </DirectionalLayout>
+        </DirectionalLayout>
+
+        <!-- 距离和地址 -->
+        <Text
+            ohos:id="$+id:parking_address"
+            ohos:height="match_content"
+            ohos:width="match_parent"
+            ohos:text="0.8km | 地址信息"
+            ohos:text_color="#FF666666"
+            ohos:text_size="12fp"
+            ohos:bottom_margin="8vp"/>
+
+        <!-- 统计信息:总车位、剩余车位、免费时长 -->
+        <DirectionalLayout
+            ohos:height="match_content"
+            ohos:width="match_parent"
+            ohos:orientation="horizontal"
+            ohos:alignment="center">
+
+            <!-- 总车位 -->
+            <DirectionalLayout
+                ohos:height="match_content"
+                ohos:width="0vp"
+                ohos:weight="1"
+                ohos:orientation="vertical"
+                ohos:alignment="center">
+
+                <Text
+                    ohos:id="$+id:text_total_place"
+                    ohos:height="match_content"
+                    ohos:width="match_content"
+                    ohos:text="2000"
+                    ohos:text_color="#FF000000"
+                    ohos:text_size="14fp"
+                    ohos:text_weight="1"
+                    ohos:text_alignment="center"/>
+
+                <Text
+                    ohos:height="match_content"
+                    ohos:width="match_content"
+                    ohos:text="总车位"
+                    ohos:text_color="#FF666666"
+                    ohos:text_size="12fp"
+                    ohos:text_alignment="center"/>
+            </DirectionalLayout>
+
+            <!-- 剩余车位 -->
+            <DirectionalLayout
+                ohos:height="match_content"
+                ohos:width="0vp"
+                ohos:weight="1"
+                ohos:orientation="vertical"
+                ohos:alignment="center">
+
+                <Text
+                    ohos:id="$+id:text_residue_place"
+                    ohos:height="match_content"
+                    ohos:width="match_content"
+                    ohos:text="50"
+                    ohos:text_color="#FA6332"
+                    ohos:text_size="14fp"
+                    ohos:text_weight="1"
+                    ohos:text_alignment="center"/>
+
+                <Text
+                    ohos:height="match_content"
+                    ohos:width="match_content"
+                    ohos:text="剩余车位"
+                    ohos:text_color="#FF666666"
+                    ohos:text_size="12fp"
+                    ohos:text_alignment="center"/>
+            </DirectionalLayout>
+
+            <!-- 免费时长 -->
+            <DirectionalLayout
+                ohos:height="match_content"
+                ohos:width="0vp"
+                ohos:weight="1"
+                ohos:orientation="vertical"
+                ohos:alignment="center">
+
+                <Text
+                    ohos:id="$+id:text_free_duration"
+                    ohos:height="match_content"
+                    ohos:width="match_content"
+                    ohos:text="15分"
+                    ohos:text_color="#FF000000"
+                    ohos:text_size="14fp"
+                    ohos:text_weight="1"
+                    ohos:text_alignment="center"/>
+
+                <Text
+                    ohos:height="match_content"
+                    ohos:width="match_content"
+                    ohos:text="免费时长"
+                    ohos:text_color="#FF666666"
+                    ohos:text_size="12fp"
+                    ohos:text_alignment="center"/>
+            </DirectionalLayout>
+        </DirectionalLayout>
+    </DirectionalLayout>
+
+    <!-- 右侧导航按钮 -->
+    <DirectionalLayout
+        ohos:height="match_content"
+        ohos:width="match_content"
+        ohos:orientation="vertical"
+        ohos:alignment="center"
+        ohos:start_margin="8vp">
+
+        <Button
+            ohos:id="$+id:btn_navigate"
+            ohos:height="48vp"
+            ohos:width="48vp"
+            ohos:background_element="#FF0000"
+            ohos:border_radius="24vp"
+            ohos:image_src="$media:nav"
+            ohos:scale_mode="stretch"/>
+
+        <Text
+            ohos:height="match_content"
+            ohos:width="match_content"
+            ohos:text="导航"
+            ohos:text_color="#FF000000"
+            ohos:text_size="12fp"
+            ohos:text_alignment="center"
+            ohos:top_margin="4vp"/>
+    </DirectionalLayout>
+</DirectionalLayout>
+

+ 74 - 221
entry/src/main/resources/base/layout/layout_find_parking.xml

@@ -3,247 +3,100 @@
     xmlns:ohos="http://schemas.huawei.com/res/ohos"
     ohos:height="match_parent"
     ohos:width="match_parent"
-    ohos:orientation="vertical">
+    ohos:orientation="vertical"
+    ohos:background_element="#FFFFFFFF">
 
-
-    <!-- 停车场列表 -->
-    <ScrollView
-        ohos:id="$+id:parking_list_scroll"
-        ohos:height="0vp"
+    <!-- 顶部查询条件区域 -->
+    <DirectionalLayout
+        ohos:id="$+id:top_filter_bar"
+        ohos:height="match_content"
         ohos:width="match_parent"
-        ohos:weight="1"
-        ohos:background_element="#FFFFFFFF">
+        ohos:orientation="horizontal"
+        ohos:padding="16vp"
+        ohos:background_element="#FFFFFFFF"
+        ohos:bottom_margin="8vp">
 
+        <!-- 标签页:全部车场、推荐车场 -->
         <DirectionalLayout
-            ohos:id="$+id:parking_list_container"
             ohos:height="match_content"
-            ohos:width="match_parent"
-            ohos:orientation="vertical"
-            ohos:padding="16vp">
+            ohos:width="0vp"
+            ohos:weight="1"
+            ohos:orientation="horizontal"
+            ohos:alignment="center">
 
-            <!-- 停车场项1:尚美国际停车场 -->
             <DirectionalLayout
-                ohos:id="$+id:parking_item_1"
                 ohos:height="match_content"
-                ohos:width="match_parent"
-                ohos:orientation="horizontal"
-                ohos:padding="12vp"
-                ohos:bottom_margin="12vp"
-                ohos:background_element="#FFFFFFFF"
-                ohos:border_radius="8vp"
-                ohos:shadow="2">
-
-                <!-- 左侧编号圆圈 -->
+                ohos:width="match_content"
+                ohos:orientation="vertical"
+                ohos:end_margin="16vp">
                 <Text
-                    ohos:id="$+id:parking_number_1"
-                    ohos:height="32vp"
-                    ohos:width="32vp"
-                    ohos:background_element="#FF2196F3"
-                    ohos:text="18"
-                    ohos:text_color="#FFFFFFFF"
-                    ohos:text_size="14fp"
-                    ohos:text_alignment="center"
-                    ohos:border_radius="16vp"
-                    ohos:end_margin="12vp"/>
-
-                <!-- 中间内容区域 -->
-                <DirectionalLayout
+                    ohos:id="$+id:tab_all"
                     ohos:height="match_content"
-                    ohos:width="0vp"
-                    ohos:weight="1"
-                    ohos:orientation="vertical">
-
-                    <!-- 停车场名称 -->
-                    <Text
-                        ohos:id="$+id:parking_name_1"
-                        ohos:height="match_content"
-                        ohos:width="match_parent"
-                        ohos:text="尚美国际停车场"
-                        ohos:text_color="#FF000000"
-                        ohos:text_size="16fp"
-                        ohos:text_weight="1"
-                        ohos:bottom_margin="8vp"/>
-
-                    <!-- 距离和地址 -->
-                    <Text
-                        ohos:id="$+id:parking_address_1"
-                        ohos:height="match_content"
-                        ohos:width="match_parent"
-                        ohos:text="距您534米 | 桃源街道平山社区留仙大道4168号"
-                        ohos:text_color="#FF666666"
-                        ohos:text_size="12fp"
-                        ohos:bottom_margin="8vp"/>
-
-                    <!-- 余位和价格信息 -->
-                    <Text
-                        ohos:id="$+id:parking_info_1"
-                        ohos:height="match_content"
-                        ohos:width="match_parent"
-                        ohos:text="余位308 · 首小时10元 · 30分钟免费 · 封顶60元"
-                        ohos:text_color="#FF666666"
-                        ohos:text_size="12fp"
-                        ohos:bottom_margin="8vp"/>
-
-                    <!-- 推荐标签 -->
-                    <DirectionalLayout
-                        ohos:height="match_content"
-                        ohos:width="match_content"
-                        ohos:orientation="horizontal"
-                        ohos:alignment="center">
-
-                        <Text
-                            ohos:id="$+id:recommend_icon_1"
-                            ohos:height="16vp"
-                            ohos:width="16vp"
-                            ohos:text="👍"
-                            ohos:text_size="12fp"
-                            ohos:end_margin="4vp"/>
-
-                        <Text
-                            ohos:id="$+id:recommend_text_1"
-                            ohos:height="match_content"
-                            ohos:width="match_content"
-                            ohos:text="推荐车场"
-                            ohos:text_color="#FFFF9800"
-                            ohos:text_size="12fp"/>
-                    </DirectionalLayout>
-                </DirectionalLayout>
-
-                <!-- 右侧导航图标 -->
-                <Image
-                    ohos:id="$+id:navigation_icon_1"
-                    ohos:height="24vp"
-                    ohos:width="24vp"
-                    ohos:image_src="$media:icon"
-                    ohos:start_margin="8vp"
-                    ohos:layout_alignment="center"/>
+                    ohos:width="match_content"
+                    ohos:text="全部车场"
+                    ohos:text_size="16fp"
+                    ohos:text_color="#FA6332"
+                    ohos:text_weight="1"
+                    ohos:padding="8vp"/>
+                <Component
+                    ohos:id="$+id:tab_all_underline"
+                    ohos:height="2vp"
+                    ohos:width="match_parent"
+                    ohos:background_element="#FA6332"/>
             </DirectionalLayout>
 
-            <!-- 停车场项2:丽新花园停车场 -->
             <DirectionalLayout
-                ohos:id="$+id:parking_item_2"
                 ohos:height="match_content"
-                ohos:width="match_parent"
-                ohos:orientation="horizontal"
-                ohos:padding="12vp"
-                ohos:bottom_margin="12vp"
-                ohos:background_element="#FFFFFFFF"
-                ohos:border_radius="8vp"
-                ohos:shadow="2">
-
+                ohos:width="match_content"
+                ohos:orientation="vertical">
                 <Text
-                    ohos:id="$+id:parking_number_2"
-                    ohos:height="32vp"
-                    ohos:width="32vp"
-                    ohos:background_element="#FF2196F3"
-                    ohos:text="19"
-                    ohos:text_color="#FFFFFFFF"
-                    ohos:text_size="14fp"
-                    ohos:text_alignment="center"
-                    ohos:border_radius="16vp"
-                    ohos:end_margin="12vp"/>
-
-                <DirectionalLayout
+                    ohos:id="$+id:tab_recommended"
                     ohos:height="match_content"
-                    ohos:width="0vp"
-                    ohos:weight="1"
-                    ohos:orientation="vertical">
-
-                    <Text
-                        ohos:id="$+id:parking_name_2"
-                        ohos:height="match_content"
-                        ohos:width="match_parent"
-                        ohos:text="丽新花园停车场"
-                        ohos:text_color="#FF000000"
-                        ohos:text_size="16fp"
-                        ohos:text_weight="1"
-                        ohos:bottom_margin="8vp"/>
-
-                    <Text
-                        ohos:id="$+id:parking_address_2"
-                        ohos:height="match_content"
-                        ohos:width="match_parent"
-                        ohos:text="距您537米 | 沙河西路4011号丽新花园"
-                        ohos:text_color="#FF666666"
-                        ohos:text_size="12fp"
-                        ohos:bottom_margin="8vp"/>
-
-                    <Text
-                        ohos:id="$+id:parking_info_2"
-                        ohos:height="match_content"
-                        ohos:width="match_parent"
-                        ohos:text="余位76"
-                        ohos:text_color="#FF666666"
-                        ohos:text_size="12fp"/>
-                </DirectionalLayout>
-
-                <Image
-                    ohos:id="$+id:navigation_icon_2"
-                    ohos:height="24vp"
-                    ohos:width="24vp"
-                    ohos:image_src="$media:icon"
-                    ohos:start_margin="8vp"
-                    ohos:layout_alignment="center"/>
+                    ohos:width="match_content"
+                    ohos:text="推荐车场"
+                    ohos:text_size="16fp"
+                    ohos:text_color="#FF666666"
+                    ohos:text_weight="1"
+                    ohos:padding="8vp"/>
+                <Component
+                    ohos:id="$+id:tab_recommended_underline"
+                    ohos:height="2vp"
+                    ohos:width="match_parent"
+                    ohos:background_element="#00000000"
+                    ohos:visibility="hide"/>
             </DirectionalLayout>
+        </DirectionalLayout>
 
-            <!-- 停车场项3:众冠红花岭工业区商业... -->
-            <DirectionalLayout
-                ohos:id="$+id:parking_item_3"
-                ohos:height="match_content"
-                ohos:width="match_parent"
-                ohos:orientation="horizontal"
-                ohos:padding="12vp"
-                ohos:bottom_margin="12vp"
-                ohos:background_element="#FFFFFFFF"
-                ohos:border_radius="8vp"
-                ohos:shadow="2">
-
-                <Text
-                    ohos:id="$+id:parking_number_3"
-                    ohos:height="32vp"
-                    ohos:width="32vp"
-                    ohos:background_element="#FF2196F3"
-                    ohos:text="20"
-                    ohos:text_color="#FFFFFFFF"
-                    ohos:text_size="14fp"
-                    ohos:text_alignment="center"
-                    ohos:border_radius="16vp"
-                    ohos:end_margin="12vp"/>
-
-                <DirectionalLayout
-                    ohos:height="match_content"
-                    ohos:width="0vp"
-                    ohos:weight="1"
-                    ohos:orientation="vertical">
-
-                    <Text
-                        ohos:id="$+id:parking_name_3"
-                        ohos:height="match_content"
-                        ohos:width="match_parent"
-                        ohos:text="众冠红花岭工业区商业…"
-                        ohos:text_color="#FF000000"
-                        ohos:text_size="16fp"
-                        ohos:text_weight="1"
-                        ohos:bottom_margin="8vp"/>
+        <!-- 距离最近下拉框 -->
+        <Button
+            ohos:id="$+id:btn_distance_sort"
+            ohos:height="36vp"
+            ohos:width="match_content"
+            ohos:text="距离最近"
+            ohos:text_size="14fp"
+            ohos:text_color="#FF000000"
+            ohos:background_element="#F5F5F5"
+            ohos:left_padding="12vp"
+            ohos:right_padding="12vp"
+            ohos:top_padding="6vp"
+            ohos:bottom_padding="6vp"
+            ohos:border_radius="4vp"/>
+    </DirectionalLayout>
 
-                    <Text
-                        ohos:id="$+id:parking_address_3"
-                        ohos:height="match_content"
-                        ohos:width="match_parent"
-                        ohos:text="距您538米 | 留仙大道1213号西门"
-                        ohos:text_color="#FF666666"
-                        ohos:text_size="12fp"/>
-                </DirectionalLayout>
+    <!-- 停车场列表 -->
+    <ScrollView
+        ohos:id="$+id:parking_list_scroll"
+        ohos:height="0vp"
+        ohos:width="match_parent"
+        ohos:weight="1"
+        ohos:background_element="#FFFFFFFF">
 
-                <Image
-                    ohos:id="$+id:navigation_icon_3"
-                    ohos:height="24vp"
-                    ohos:width="24vp"
-                    ohos:image_src="$media:icon"
-                    ohos:start_margin="8vp"
-                    ohos:layout_alignment="center"/>
-            </DirectionalLayout>
+        <DirectionalLayout
+            ohos:id="$+id:parking_list_container"
+            ohos:height="match_content"
+            ohos:width="match_parent"
+            ohos:orientation="vertical"
+            ohos:padding="16vp">
         </DirectionalLayout>
     </ScrollView>
 </DirectionalLayout>
-

BIN
entry/src/main/resources/base/media/fee.png


BIN
entry/src/main/resources/base/media/fee_1.png


BIN
entry/src/main/resources/base/media/location.png


BIN
entry/src/main/resources/base/media/logo_white.png


BIN
entry/src/main/resources/base/media/my.png


BIN
entry/src/main/resources/base/media/my_1.png


BIN
entry/src/main/resources/base/media/nav.png


BIN
entry/src/main/resources/base/media/park.png


BIN
entry/src/main/resources/base/media/park_1.png


BIN
entry/src/main/resources/base/media/pin_c.png


BIN
entry/src/main/resources/base/media/pin_dc.png


BIN
entry/src/main/resources/base/media/pin_h.png


BIN
entry/src/main/resources/base/media/pin_l.png


BIN
entry/src/main/resources/base/media/pin_zjd.png


BIN
entry/src/main/resources/base/media/search.png