add TouchListener Interface
This commit is contained in:
parent
ba9300da91
commit
c093fe3b0c
9
vtm/src/org/oscim/event/TouchListener.java
Normal file
9
vtm/src/org/oscim/event/TouchListener.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package org.oscim.event;
|
||||||
|
|
||||||
|
import org.oscim.core.MapPosition;
|
||||||
|
|
||||||
|
public interface TouchListener {
|
||||||
|
boolean onPress(MotionEvent e, MapPosition pos);
|
||||||
|
boolean onLongPress(MotionEvent e, MapPosition pos);
|
||||||
|
boolean onTap(MotionEvent e, MapPosition pos);
|
||||||
|
}
|
||||||
@ -18,12 +18,15 @@ package org.oscim.layers.marker;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.oscim.core.BoundingBox;
|
import org.oscim.core.BoundingBox;
|
||||||
|
import org.oscim.core.MapPosition;
|
||||||
import org.oscim.core.Point;
|
import org.oscim.core.Point;
|
||||||
import org.oscim.event.MotionEvent;
|
import org.oscim.event.MotionEvent;
|
||||||
|
import org.oscim.event.TouchListener;
|
||||||
import org.oscim.map.Map;
|
import org.oscim.map.Map;
|
||||||
import org.oscim.map.Viewport;
|
import org.oscim.map.Viewport;
|
||||||
|
|
||||||
public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<Item> {
|
public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<Item>
|
||||||
|
implements TouchListener {
|
||||||
//private static final String TAG = ItemizedIconOverlay.class.getName();
|
//private static final String TAG = ItemizedIconOverlay.class.getName();
|
||||||
|
|
||||||
protected final List<Item> mItemList;
|
protected final List<Item> mItemList;
|
||||||
@ -98,37 +101,37 @@ public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<It
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Each of these methods performs a item sensitive check. If the item is
|
* Each of these methods performs a item sensitive check. If the item is
|
||||||
// * located its corresponding method is called. The result of the call is
|
* located its corresponding method is called. The result of the call is
|
||||||
// * returned. Helper methods are provided so that child classes may more
|
* returned. Helper methods are provided so that child classes may more
|
||||||
// * easily override behavior without resorting to overriding the
|
* easily override behavior without resorting to overriding the
|
||||||
// * ItemGestureListener methods.
|
* ItemGestureListener methods.
|
||||||
// */
|
*/
|
||||||
// @Override
|
@Override
|
||||||
// public boolean onSingleTapUp(MotionEvent event) {
|
public boolean onTap(MotionEvent event, MapPosition pos) {
|
||||||
// return activateSelectedItems(event, mActiveItemSingleTap) || super.onSingleTapUp(event);
|
return activateSelectedItems(event, mActiveItemSingleTap);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// protected boolean onSingleTapUpHelper(int index, Item item) {
|
protected boolean onSingleTapUpHelper(int index, Item item) {
|
||||||
// return this.mOnItemGestureListener.onItemSingleTapUp(index, item);
|
return this.mOnItemGestureListener.onItemSingleTapUp(index, item);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// private final ActiveItem mActiveItemSingleTap = new ActiveItem() {
|
private final ActiveItem mActiveItemSingleTap = new ActiveItem() {
|
||||||
// @Override
|
@Override
|
||||||
// public boolean run(int index) {
|
public boolean run(int index) {
|
||||||
// final ItemizedIconLayer<Item> that = ItemizedIconLayer.this;
|
final ItemizedIconLayer<Item> that = ItemizedIconLayer.this;
|
||||||
// if (that.mOnItemGestureListener == null) {
|
if (that.mOnItemGestureListener == null) {
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// return onSingleTapUpHelper(index, that.mItemList.get(index));
|
return onSingleTapUpHelper(index, that.mItemList.get(index));
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public boolean onLongPress(MotionEvent event) {
|
public boolean onLongPress(MotionEvent event, MapPosition pos) {
|
||||||
// return activateSelectedItems(event, mActiveItemLongPress) || super.onLongPress(event);
|
return activateSelectedItems(event, mActiveItemLongPress);
|
||||||
// }
|
}
|
||||||
|
|
||||||
protected boolean onLongPressHelper(int index, Item item) {
|
protected boolean onLongPressHelper(int index, Item item) {
|
||||||
return this.mOnItemGestureListener.onItemLongPress(index, item);
|
return this.mOnItemGestureListener.onItemLongPress(index, item);
|
||||||
@ -145,11 +148,15 @@ public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<It
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPress(MotionEvent e, MapPosition pos) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a content sensitive action is performed the content item needs to be
|
* When a content sensitive action is performed the content item needs to be
|
||||||
* identified. This method does that and then performs the assigned task on
|
* identified. This method does that and then performs the assigned task on
|
||||||
* that item.
|
* that item.
|
||||||
*
|
|
||||||
* @param event
|
* @param event
|
||||||
* ...
|
* ...
|
||||||
* @param task
|
* @param task
|
||||||
@ -211,7 +218,6 @@ public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<It
|
|||||||
* When the item is touched one of these methods may be invoked depending on
|
* When the item is touched one of these methods may be invoked depending on
|
||||||
* the type of touch. Each of them returns true if the event was completely
|
* the type of touch. Each of them returns true if the event was completely
|
||||||
* handled.
|
* handled.
|
||||||
*
|
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* ....
|
* ....
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user