/** Restore visible state (generally after a call to pause). Appropriate for Activity.onResume. */ public void resume() { setWillNotDraw(false); updateViewport(); mTileCanvasViewGroup.updateTileSet(mDetailLevelManager.getCurrentDetailLevel()); requestRender(); requestLayout(); }
public TileView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mTileCanvasViewGroup = new TileCanvasViewGroup(context); addView(mTileCanvasViewGroup); mCompositePathView = new CompositePathView(context); addView(mCompositePathView); mScalingLayout = new ScalingLayout(context); addView(mScalingLayout); mMarkerLayout = new MarkerLayout(context); addView(mMarkerLayout); mCalloutLayout = new CalloutLayout(context); addView(mCalloutLayout); mDetailLevelManager.setDetailLevelChangeListener(this); mTileCanvasViewGroup.setTileRenderListener(this); addZoomPanListener(this); mRenderThrottleHandler = new RenderThrottleHandler(this); requestRender(); }
@Override public void onZoomBegin(float scale, Origination origin) { if (origin == null) { mTileCanvasViewGroup.suppressRender(); } mDetailLevelManager.setScale(scale); }
protected void updateViewport() { int left = getScrollX(); int top = getScrollY(); int right = left + getWidth(); int bottom = top + getHeight(); mDetailLevelManager.updateViewport(left, top, right, bottom); }
@Override public void onZoomEnd(float scale, Origination origin) { if (origin == null) { mTileCanvasViewGroup.resumeRender(); } mDetailLevelManager.setScale(scale); requestRender(); }
@Override public void onScaleChanged(float scale, float previous) { super.onScaleChanged(scale, previous); mDetailLevelManager.setScale(scale); mHotSpotManager.setScale(scale); mTileCanvasViewGroup.setScale(scale); mScalingLayout.setScale(scale); mCompositePathView.setScale(scale); mMarkerLayout.setScale(scale); mCalloutLayout.setScale(scale); }
/** * Allows the use of a custom {@link DetailLevelManager}. * <p> * For example, to change the logic of {@link DetailLevel} choice for a given scale, you * declare your own {@code DetailLevelMangerCustom} that extends {@link DetailLevelManager} : * <pre>{@code * private class DetailLevelManagerCustom extends DetailLevelManager{ * @literal @Override * public DetailLevel getDetailLevelForScale(){ * // your logic here * } * } * } * </pre> * Then you should use {@code TileView.setDetailLevelManager} before other method calls, especially * {@code TileView.setSize} and {@code TileView.addDetailLevel}. * </p> * * @param manager The DetailLevelManager instance used. */ public void setDetailLevelManager(DetailLevelManager manager) { mDetailLevelManager = manager; mDetailLevelManager.setDetailLevelChangeListener(this); }
/** * Recycles bitmap image files, prevents path drawing, and clears pending Handler messages, * appropriate for Activity.onPause. */ public void pause() { mRenderThrottleHandler.clear(); mDetailLevelManager.invalidateAll(); setWillNotDraw(true); }
/** * Pads the viewport by the number of pixels passed. e.g., setViewportPadding( 100 ) instructs the * TileView to interpret it's actual viewport offset by 100 pixels in each direction (top, left, * right, bottom), so more tiles will qualify for "visible" status when intersections are * calculated. * * @param padding The number of pixels to pad the viewport by */ public void setViewportPadding(int padding) { mDetailLevelManager.setViewportPadding(padding); }
/** * Register a tile set to be used for a particular detail level. Each tile set to be used must be * registered using this method, and at least one tile set must be registered for the TileView to * render any tiles. * * @param detailScale Scale at which the TileView should use the tiles in this set. * @param data An arbitrary object of any type that is passed to the (Adapter|Decoder) for each * tile on this level. * @param tileWidth Size of each tiled column. * @param tileHeight Size of each tiled row. */ public void addDetailLevel(float detailScale, Object data, int tileWidth, int tileHeight) { mDetailLevelManager.addDetailLevel(detailScale, data, tileWidth, tileHeight); }
/** * Defines the total size, in pixels, of the tile set at 100% scale. The TileView wills pan within * it's layout dimensions, with the content (scrollable) size defined by this method. * * @param width Total width of the tiled set. * @param height Total height of the tiled set. */ @Override public void setSize(int width, int height) { super.setSize(width, height); mDetailLevelManager.setSize(width, height); mCoordinateTranslater.setSize(width, height); }