refactor: make MapView abstract, remove MapRenderCallback

This commit is contained in:
Hannes Janetzek
2013-07-26 00:56:17 +02:00
parent 3ab9751128
commit 136db862d2
5 changed files with 124 additions and 203 deletions

View File

@@ -1,23 +0,0 @@
/*
* Copyright 2013 Hannes Janetzek
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.view;
public interface MapRenderCallback {
void updateMap(boolean forceRender);
void renderMap();
int getWidth();
int getHeight();
}

View File

@@ -31,9 +31,8 @@ import org.oscim.theme.IRenderTheme;
import org.oscim.theme.InternalRenderTheme;
import org.oscim.theme.ThemeLoader;
import org.oscim.tilesource.TileSource;
import org.oscim.utils.GlUtils;
public class MapView {
public abstract class MapView {
private static final String TAG = MapView.class.getName();
@@ -43,10 +42,8 @@ public class MapView {
private final MapPosition mMapPosition;
private DebugSettings mDebugSettings;
private final MapRenderCallback mMapRenderCallback;
public MapView(MapRenderCallback mapRenderCallback) {
mMapRenderCallback = mapRenderCallback;
public MapView() {
mMapViewPosition = new MapViewPosition(this);
mMapPosition = new MapPosition();
@@ -111,11 +108,13 @@ public class MapView {
*
* @param forceRedraw pass true to render next frame
*/
public void updateMap(boolean forceRedraw) {
mMapRenderCallback.updateMap(forceRedraw);
}
public abstract void updateMap(boolean forceRedraw);
boolean mClearMap;
public abstract int getWidth();
public abstract int getHeight();
protected boolean mClearMap;
/**
* Request to clear all layers before rendering next frame
@@ -126,11 +125,9 @@ public class MapView {
/**
* Request to render a frame. Request will be handled on main
* thread.
* thread. Use this for animations.
*/
public void render() {
mMapRenderCallback.renderMap();
}
public abstract void render();
/**
* Do not call directly! This function is run on main-loop
@@ -200,28 +197,7 @@ public class MapView {
return mMapViewPosition.getViewBox();
}
public void onPause() {
// TODO Auto-generated method stub
}
public void onResume() {
// TODO Auto-generated method stub
}
public void onStop() {
// TODO Auto-generated method stub
}
public int getWidth() {
return mMapRenderCallback.getWidth();
}
public int getHeight() {
return mMapRenderCallback.getHeight();
}
}