Back to project page clusterkraf.
The source code is released under:
Apache License
If you think the Android project clusterkraf listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.twotoasters.clusterkraf; //from w w w . j a v a 2 s . c om import java.lang.ref.WeakReference; import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener; import com.google.android.gms.maps.model.CameraPosition; /** * An OnCameraChangeListener that calls back to its host only when appropriate */ class ClusteringOnCameraChangeListener implements OnCameraChangeListener { private final Options options; private final WeakReference<Host> hostRef; private long dirty = 0; public ClusteringOnCameraChangeListener(Host host, Options options) { this.hostRef = new WeakReference<Host>(host); this.options = options; } @Override public void onCameraChange(CameraPosition newPosition) { long now = System.currentTimeMillis(); long notDirtyAfter = now - options.getClusteringOnCameraChangeListenerDirtyLifetimeMillis(); if (dirty < notDirtyAfter) { Host host = hostRef.get(); if (host != null) { dirty = now; host.onClusteringCameraChange(); } } } public void setDirty(long when) { this.dirty = when; } interface Host { void onClusteringCameraChange(); } }