Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 片段动画使谷歌地图不断被称为“onCameraChange”_Android_Google Maps_Android Fragments_Coding Style_Solid Principles - Fatal编程技术网

Android 片段动画使谷歌地图不断被称为“onCameraChange”

Android 片段动画使谷歌地图不断被称为“onCameraChange”,android,google-maps,android-fragments,coding-style,solid-principles,Android,Google Maps,Android Fragments,Coding Style,Solid Principles,我的活动包含以下要素: 覆盖所有屏幕的谷歌地图。 动画和某些事件发生后出现的底部片段wifi、gps位置。。。 我已经定义了一个onCameraChange方法来从数据库中获取一些数据 map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition cameraPosition) {

我的活动包含以下要素:

覆盖所有屏幕的谷歌地图。 动画和某些事件发生后出现的底部片段wifi、gps位置。。。 我已经定义了一个onCameraChange方法来从数据库中获取一些数据

map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {

    @Override
    public void onCameraChange(CameraPosition cameraPosition) {
        SpotsMapActivity.cameraPosition = cameraPosition;

        mClusterManager.onCameraChange(cameraPosition);
        presenter.onMapViewUpdate(map.getCameraPosition().target, cameraPosition.zoom);
    }
});
问题是片段动画不断调用CameraChange方法。CameraPosition没有更改其值,始终具有相同的纬度/经度和缩放

我怎样才能避免这种不断的重新呼叫

编辑:

这是布局图:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        class="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.github.rahatarmanahmed.cpv.CircularProgressView xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/map_progress_view"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_centerInParent="true"
        android:visibility="gone"
        app:cpv_animAutostart="true"
        app:cpv_indeterminate="true"
        app:cpv_thickness="8px" />

    <include
        android:id="@+id/map_toolbar"
        layout="@layout/toolbar" />

    <FrameLayout
        android:id="@+id/map_status_banner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:visibility="gone"
        android:layout_marginTop="-20dp"/>

   <!-- <FrameLayout
        android:id="@+id/main_big_card"
        android:layout_width="match_parent"
        android:layout_height="@dimen/card_big_height"
        android:layout_alignParentBottom="true" /> -->

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/map_my_location_custom"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/map_status_banner"
        android:layout_alignParentRight="true"
        android:layout_alignWithParentIfMissing="true"
        android:layout_margin="10dp"
        android:src="@drawable/ic_my_location"
        app:borderWidth="0dp"
        app:fabSize="normal"
        app:backgroundTint="@color/white"/>

</RelativeLayout>
动画:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

    <translate
        android:fromXDelta="0"
        android:fromYDelta="1000"
        android:duration="1500"/>

</set>

你能发布关于片段动画的代码吗?不知道为什么它会调用SetOnCamerachenglistener。此外,您还可以使用temp变量检查位置是否相同,如果相同,请在使用侦听器方法执行其他操作之前返回。谢谢,我已经添加了主布局和动画。我想更改此presenter.onMapViewUpdatemap.getCameraPosition.target、cameraPosition.zoom;要查看presenter.onMapViewUpdatecameraPosition.target,请单击cameraPosition.zoom;可能有用