Skip to content

Commit

Permalink
Disabled viewport listener for non-preview charts **ViewportChangeLis…
Browse files Browse the repository at this point in the history
…tener** will be called only for preview charts!
  • Loading branch information
lecho committed Aug 2, 2014
1 parent 029db81 commit 2090176
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public class ChartCalculator {
protected float minViewportWidth;
protected float minViewportHeight;

private ViewportChangeListener viewportChangeListener = new DummyVieportChangeListener();
/**
* Warning! Viewport listener is disabled for all charts beside preview charts to avoid addidtional method calls
* during animations.
*/
protected ViewportChangeListener viewportChangeListener = new DummyVieportChangeListener();

/**
* Calculates available width and height. Should be called when chart dimensions or chart data change.
Expand Down Expand Up @@ -74,8 +78,6 @@ public void constrainViewport(float left, float top, float right, float bottom)
currentViewport.top = Math.max(maxViewport.top, top);
currentViewport.bottom = Math.max(Utils.nextUpF(top), Math.min(maxViewport.bottom, bottom));
currentViewport.right = Math.max(Utils.nextUpF(left), Math.min(maxViewport.right, right));

viewportChangeListener.onViewportChanged(currentViewport);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package lecho.lib.hellocharts;

import android.graphics.RectF;
import android.util.Log;

public class DummyVieportChangeListener implements ViewportChangeListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ public void setVisibleViewport(RectF visibleViewport) {
setMaxViewport(visibleViewport);
}

public void constrainViewport(float left, float top, float right, float bottom) {
super.constrainViewport(left, top, right, bottom);
viewportChangeListener.onViewportChanged(currentViewport);
}

}

0 comments on commit 2090176

Please sign in to comment.