Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the camera position event to the listener #39

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void onCameraChange(CameraPosition newPosition) {
Host host = hostRef.get();
if (host != null) {
dirty = now;
host.onClusteringCameraChange();
host.onClusteringCameraChange(newPosition);
}
}
}
Expand All @@ -38,7 +38,7 @@ public void setDirty(long when) {
}

interface Host {
void onClusteringCameraChange();
void onClusteringCameraChange(CameraPosition newPosition);
}

}
9 changes: 7 additions & 2 deletions library/src/com/twotoasters/clusterkraf/Clusterkraf.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener;
import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener;
import com.google.android.gms.maps.Projection;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

Expand Down Expand Up @@ -281,7 +282,7 @@ private InnerCallbackListener(Clusterkraf clusterkraf) {
private final ClusteringOnCameraChangeListener clusteringOnCameraChangeListener;

@Override
public void onClusteringCameraChange() {
public void onClusteringCameraChange(CameraPosition newPosition) {
Clusterkraf clusterkraf = clusterkrafRef.get();
if (clusterkraf != null) {
if (clusterkraf.clusteringTaskHost != null) {
Expand All @@ -294,6 +295,10 @@ public void onClusteringCameraChange() {
}
clusterkraf.transitionsAnimation.cancel();
clusterkraf.updateClustersAndTransition();

if(clusterkraf.options.getProcessingListener() != null) {
clusterkraf.options.getProcessingListener().onCameraChanged(newPosition);
}
}
}

Expand Down Expand Up @@ -590,8 +595,8 @@ public void executeTask(Projection projection) {

public interface ProcessingListener {
void onClusteringStarted();

void onClusteringFinished();
void onCameraChanged(CameraPosition pos);
}

}