find bookmark on map

This commit is contained in:
AlexeiVitenko 2012-12-07 21:37:34 +03:00 committed by Alex Zolotarev
parent 825cd10706
commit db7bbde8d1
3 changed files with 43 additions and 20 deletions

View file

@ -38,4 +38,20 @@ extern "C"
{
frm()->GetBmCategory(cat)->DeleteBookmark(bmk);
}
JNIEXPORT jintArray JNICALL
Java_com_mapswithme_maps_bookmarks_data_BookmarkManager_nGetBookmark(JNIEnv * env, jobject thiz, jint x, jint y)
{
BookmarkAndCategory bac = frm()->GetBookmark(m2::PointD(x, y));
jintArray result;
result = env->NewIntArray(2);
if (result == NULL) {
return NULL; /* out of memory error thrown */
}
int fill[2];
fill[0] = bac.first;
fill[1] = bac.second;
env->SetIntArrayRegion(result, 0, 2, fill);
return result;
}
}

View file

@ -10,6 +10,7 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.graphics.Point;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
@ -23,7 +24,11 @@ import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.mapswithme.maps.bookmarks.BookmarkActivity;
import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
import com.mapswithme.maps.bookmarks.data.Bookmark;
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
import com.mapswithme.maps.bookmarks.data.ParcelablePoint;
import com.mapswithme.maps.location.LocationService;
import com.mapswithme.maps.settings.UnitLocale;
import com.mapswithme.util.ConnectionState;
@ -48,9 +53,9 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
}
private interface OnClickListenter
{
{
void onClick(int x, int y);
}
}
private native int addOnLongClickListener(Object l);
private native void removeOnLongClickListener(int h);
@ -562,11 +567,20 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
@Override
public void onClick(int x, int y)
{
handleOnBookmarkClick(x, y);
}
});
//m_timer = new VideoTimer();
}
private void handleOnBookmarkClick(int x, int y)
{
ParcelablePoint b = BookmarkManager.getPinManager(this).findBookmark(new Point(x, y));
if (b != null)
{
startActivity(new Intent(this, BookmarkActivity.class).putExtra(BookmarkActivity.PIN, b));
}
}
@Override
public void onDestroy()
{

View file

@ -38,24 +38,6 @@ public class BookmarkManager
return sManager;
}
public List<BookmarkCategory> getPinSets()
{
return mPinSets;
}
public int getPinId(Bookmark pin)
{
return mPins.indexOf(pin);
}
/*
public Bookmark createNewBookmark()
{
Bookmark p;
// mPins.add(p = new Bookmark("", mIcons.get(R.drawable.placemark_red)));
return p;
}*/
private void refreshList()
{
for (int i = 0; i < 10; i++)
@ -132,6 +114,17 @@ public class BookmarkManager
}
}
public ParcelablePoint findBookmark(Point p)
{
int [] bookmark = nGetBookmark(p.x, p.y);
if (bookmark[0]>=0 && bookmark[1]>=0)
{
return new ParcelablePoint(bookmark[0], bookmark[1]);
}
else
return null;
}
private native int[] nGetBookmark(int x, int y);
public Bookmark getBookmark(int cat, int bmk)