Itapox
Itapox

Reputation: 691

Can i import and edit code from one external library ? (e.g. google-maps-utils)

I´m using google-maps-utils (only marker clustering) and the code is read-only.

dependencies {
    compile 'com.google.maps.android:android-maps-utils:0.5+'
}

I want to comment 3 lines in ClusterManager.java

    /**
     * Might re-cluster.
     */
    @Override
    public void onCameraIdle() {
        if (mRenderer instanceof GoogleMap.OnCameraIdleListener) {
            ((GoogleMap.OnCameraIdleListener) mRenderer).onCameraIdle();
        }

        // Don't re-compute clusters if the map has just been panned/tilted/rotated.
        CameraPosition position = mMap.getCameraPosition();
//        if (mPreviousCameraPosition != null && mPreviousCameraPosition.zoom == position.zoom) {
//            return;
//        }
        mPreviousCameraPosition = mMap.getCameraPosition();

        cluster();
    }
  1. Can i import this code to my app and edit these lines ?
  2. If yes, how can i do that ? (step by step)

I'm trying to import the modules but I'm doing something wrong.

Upvotes: 1

Views: 45

Answers (1)

Pali
Pali

Reputation: 1347

If this is a high level class which you will use directly you can simply extend this class and override the method:

public class MyClusterManager<T extends ClusterItem> extends ClusterManager<T> {
  @Override
  public void onCameraIdle() {
    if (mRenderer instanceof GoogleMap.OnCameraIdleListener) {
      ((GoogleMap.OnCameraIdleListener) mRenderer).onCameraIdle();
    }
    CameraPosition position = mMap.getCameraPosition();
    mPreviousCameraPosition = mMap.getCameraPosition();
    cluster();
  }
}

and then:

ClusterManager<MyClusterItem> clusterManager = new MyClusterManager<MyClusterItem>();
// do something with your own clusterManager ...

Upvotes: 1

Related Questions