Skip to content

Commit

Permalink
Merge pull request #297 from peterLaurence/custom-DLManager
Browse files Browse the repository at this point in the history
Add the ability to use a custom DetailLevelManager (#293).
  • Loading branch information
moagrius committed Apr 25, 2016
2 parents a5802aa + d85b21f commit c3663ee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Javadocs are [here](http://moagrius.github.io/TileView/index.html?com/qozix/tile
###Installation
Gradle:
```
compile 'com.qozix:tileview:2.1.4'
compile 'com.qozix:tileview:2.1.5'
```

The library is hosted on jcenter, and is not currently available from maven.
Expand All @@ -54,7 +54,7 @@ A demo application, built in Android Studio, is available in the `demo` folder o
at the 2nd column from left and 3rd row from top.
1. Create a new application with a single activity ('Main').
1. Save the image tiles to your `assets` directory.
1. Add `compile 'com.qozix:tileview:2.1.4'` to your gradle dependencies.
1. Add `compile 'com.qozix:tileview:2.1.5'` to your gradle dependencies.
1. In the Main Activity, use this for `onCreate`:
```
@Override
Expand Down
4 changes: 2 additions & 2 deletions tileview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
defaultConfig {
minSdkVersion 11
targetSdkVersion 22
versionCode 29
versionName "2.1.4"
versionCode 30
versionName "2.1.5"
}
buildTypes {
release {
Expand Down
24 changes: 24 additions & 0 deletions tileview/src/main/java/com/qozix/tileview/TileView.java
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,30 @@ public void setShouldRenderWhilePanning( boolean shouldRender ) {
mTileCanvasViewGroup.setRenderBuffer( buffer );
}

/**
* 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;
}

@Override
protected void onLayout( boolean changed, int l, int t, int r, int b ) {
super.onLayout( changed, l, t, r, b );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

public class DetailLevelManager {

private LinkedList<DetailLevel> mDetailLevelLinkedList = new LinkedList<DetailLevel>();
protected LinkedList<DetailLevel> mDetailLevelLinkedList = new LinkedList<DetailLevel>();

private DetailLevelChangeListener mDetailLevelChangeListener;

private float mScale = 1;
protected float mScale = 1;

private int mBaseWidth;
private int mBaseHeight;
Expand Down Expand Up @@ -127,7 +127,7 @@ public DetailLevel getCurrentDetailLevel() {
return mCurrentDetailLevel;
}

private void update() {
protected void update() {
boolean detailLevelChanged = false;
if( !mDetailLevelLocked ) {
DetailLevel matchingLevel = getDetailLevelForScale();
Expand Down

0 comments on commit c3663ee

Please sign in to comment.