Skip to content

Commit

Permalink
feat: removed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kikoso committed Dec 10, 2024
1 parent 97ad505 commit ac246f2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 31 deletions.
3 changes: 3 additions & 0 deletions demo/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
<activity
android:name=".CustomAdvancedMarkerClusteringDemoActivity"
android:exported="true" />
<activity
android:name=".ClusteringDiffDemoActivity"
android:exported="true" />
<activity
android:name=".ZoomClusteringDemoActivity"
android:exported="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.google.maps.android.utils.demo;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Handler;
Expand All @@ -26,6 +27,7 @@
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
Expand Down Expand Up @@ -70,6 +72,7 @@ public void onMapReady(@NonNull GoogleMap map) {
* Draws profile photos inside markers (using IconGenerator).
* When there are multiple people in the cluster, draw multiple photos (using MultiDrawable).
*/
@SuppressLint("InflateParams")
private class PersonRenderer extends ClusterRendererMultipleItems<Person> {
private final IconGenerator mIconGenerator = new IconGenerator(getApplicationContext());
private final IconGenerator mClusterIconGenerator = new IconGenerator(getApplicationContext());
Expand All @@ -92,13 +95,6 @@ public PersonRenderer() {
mIconGenerator.setContentView(mImageView);
}

public void setUpdateMarker(Person person) {
Marker marker = getMarker(person);
if (marker != null) {
marker.setIcon(getItemIcon(person));
}
}

@Override
protected void onBeforeClusterItemRendered(@NonNull Person person, @NonNull MarkerOptions markerOptions) {
// Draw a single person - show their profile photo and set the info window to show their name
Expand Down Expand Up @@ -155,8 +151,10 @@ private BitmapDescriptor getClusterIcon(Cluster<Person> cluster) {
for (Person p : cluster.getItems()) {
// Draw 4 at most.
if (profilePhotos.size() == 4) break;
Drawable drawable = getResources().getDrawable(p.profilePhoto);
drawable.setBounds(0, 0, width, height);
Drawable drawable = ResourcesCompat.getDrawable(getBaseContext().getResources(), p.profilePhoto, null);
if (drawable != null) {
drawable.setBounds(0, 0, width, height);
}
profilePhotos.add(drawable);
}
MultiDrawable multiDrawable = new MultiDrawable(profilePhotos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected void onCreate(Bundle savedInstanceState) {
addDemo("Clustering", ClusteringDemoActivity.class);
addDemo("Advanced Markers Clustering Example", CustomAdvancedMarkerClusteringDemoActivity.class);
addDemo("Clustering: Custom Look", CustomMarkerClusteringDemoActivity.class);
addDemo("Clustering: Diff", ClusteringDiffDemoActivity.class);
addDemo("Clustering: 2K markers", BigClusteringDemoActivity.class);
addDemo("Clustering: 20K only visible markers", VisibleClusteringDemoActivity.class);
addDemo("Clustering: ViewModel", ClusteringViewModelDemoActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ public void diff(@Nullable Collection<T> add, @Nullable Collection<T> remove, @N
}

// Remove items
algorithm.removeItems(remove);
if (remove != null) {
algorithm.removeItems(remove);
}

// Modify items
if (modify != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,6 @@ public void run() {
if (shouldRenderAsCluster(c) && visibleBounds.contains(c.getPosition())) {
Point point = mSphericalMercatorProjection.toPoint(c.getPosition());
existingClustersOnScreen.add(point);
Log.d("ClusterTest","We added one point to the existingClustersOnScreen");
}
}
}
Expand All @@ -470,14 +469,11 @@ public void run() {
Point closest = findClosestCluster(existingClustersOnScreen, point);
if (closest != null) {
LatLng animateFrom = mSphericalMercatorProjection.toLatLng(closest);
Log.d("ClusterTest","We added one markerModifier");
markerModifier.add(true, new CreateMarkerTask(c, newMarkers, animateFrom));
} else {
Log.d("ALARM", "from not found");
markerModifier.add(true, new CreateMarkerTask(c, newMarkers, null));
}
} else {
Log.d("ALARM", "from not found2");
markerModifier.add(onScreen, new CreateMarkerTask(c, newMarkers, null));
}
}
Expand All @@ -498,7 +494,6 @@ public void run() {

if (shouldRenderAsCluster(c) && visibleBounds.contains(c.getPosition())) {
Point p = mSphericalMercatorProjection.toPoint(c.getPosition());
Log.d("ClusterTest","We are going to add a new cluster on the screen, located at " + c.getPosition().toString());
newClustersOnScreen.add(p);
}
}
Expand All @@ -514,14 +509,11 @@ public void run() {
final Point closest = findClosestCluster(newClustersOnScreen, point);
if (closest != null) {
LatLng animateTo = mSphericalMercatorProjection.toLatLng(closest);
Log.d("ClusterTest","We are going to remove an item from the screen (anim) located at " + marker.position.toString());
markerModifier.animateThenRemove(marker, marker.position, animateTo);
} else {
Log.d("ClusterTest","We are going to remove an item from the screen (no anim) located at " + marker.position.toString());
markerModifier.remove(true, marker.marker);
}
} else {
Log.d("ClusterTest","We are going to remove an item from the screen (no anim2) located at " + marker.position.toString());
markerModifier.remove(onScreen, marker.marker);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,11 @@ public DefaultClusterRenderer(Context context, GoogleMap map, ClusterManager<T>

@Override
public void onAdd() {
mClusterManager.getMarkerCollection().setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
return mItemClickListener != null && mItemClickListener.onClusterItemClick(mMarkerCache.get(marker));
}
});
mClusterManager.getMarkerCollection().setOnMarkerClickListener(marker -> mItemClickListener != null && mItemClickListener.onClusterItemClick(mMarkerCache.get(marker)));

mClusterManager.getMarkerCollection().setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(@NonNull Marker marker) {
if (mItemInfoWindowClickListener != null) {
mItemInfoWindowClickListener.onClusterItemInfoWindowClick(mMarkerCache.get(marker));
}
mClusterManager.getMarkerCollection().setOnInfoWindowClickListener(marker -> {
if (mItemInfoWindowClickListener != null) {
mItemInfoWindowClickListener.onClusterItemInfoWindowClick(mMarkerCache.get(marker));
}
});

Expand Down Expand Up @@ -1168,7 +1160,7 @@ public void removeOnAnimationComplete(MarkerManager markerManager) {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
if (to == null || from == null || marker == null) {
return;
return;
}

float fraction = valueAnimator.getAnimatedFraction();
Expand Down

0 comments on commit ac246f2

Please sign in to comment.