[android] Minor fixes.

This commit is contained in:
vng 2012-11-22 13:52:14 +03:00 committed by Alex Zolotarev
parent dc21bffc67
commit 0f7ff1ad69
2 changed files with 16 additions and 17 deletions

View file

@ -185,14 +185,14 @@ Java_com_mapswithme_maps_SearchActivity_nativeFinishSearch(JNIEnv * env, jobject
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_SearchActivity_nativeRunSearch(
JNIEnv * env, jobject thiz,
jstring s, jstring lang, jdouble lat, jdouble lon, jint mode, jint queryID)
jstring s, jstring lang, jdouble lat, jdouble lon, jint flags, jint queryID)
{
search::SearchParams params;
params.m_query = jni::ToNativeString(env, s);
params.SetInputLanguage(jni::ToNativeString(env, lang));
if (mode % 2 == 0) params.SetForceSearch(true);
if (mode >= 2) params.SetPosition(lat, lon);
if ((flags & 1) == 0) params.SetForceSearch(true);
if ((flags & 2) != 0) params.SetPosition(lat, lon);
return SearchAdapter::Instance().RunSearch(env, params, queryID);
}
@ -206,7 +206,7 @@ Java_com_mapswithme_maps_SearchActivity_nativeShowItem(JNIEnv * env, jobject thi
JNIEXPORT jobject JNICALL
Java_com_mapswithme_maps_SearchActivity_nativeGetResult(
JNIEnv * env, jobject thiz, jint position, jint queryID,
jdouble lat, jdouble lon, jint mode, jdouble north)
jdouble lat, jdouble lon, jboolean hasPosition, jdouble north)
{
search::Result const * res = SearchAdapter::Instance().GetResult(position, queryID);
if (res == 0) return 0;
@ -223,7 +223,7 @@ Java_com_mapswithme_maps_SearchActivity_nativeGetResult(
string distance;
double azimut = -1.0;
if (mode >= 2)
if (hasPosition)
{
if (!g_framework->NativeFramework()->GetDistanceAndAzimut(
res->GetFeatureCenter(), lat, lon, north, distance, azimut))

View file

@ -291,7 +291,7 @@ public class SearchActivity extends ListActivity implements LocationService.List
super.onResume();
// Reset current mode flag - start first search.
m_mode = 0;
m_flags = 0;
m_north = -1.0;
m_location.startUpdate(this);
@ -335,17 +335,16 @@ public class SearchActivity extends ListActivity implements LocationService.List
private double m_lon;
private double m_north = -1.0;
/// It's should be equal to search::SearchParams::ModeT
/// Possible values:\n
/// m_mode % 2 == 0 - first search query;\n
/// m_mode >= 2 - position exists;\n
int m_mode = 0;
/// This constants should be equal with
/// Java_com_mapswithme_maps_SearchActivity_nativeRunSearch routine.
private static final int NOT_FIRST_QUERY = 1;
private static final int HAS_POSITION = 2;
private int m_flags = 0;
@Override
public void onLocationUpdated(long time, double lat, double lon, float accuracy)
{
if (m_mode < 2)
m_mode += 2;
m_flags |= HAS_POSITION;
m_lat = lat;
m_lon = lon;
@ -439,14 +438,14 @@ public class SearchActivity extends ListActivity implements LocationService.List
final String s = getSearchString();
final int id = m_queryID + QUERY_STEP;
if (nativeRunSearch(s, lang, m_lat, m_lon, m_mode, id))
if (nativeRunSearch(s, lang, m_lat, m_lon, m_flags, id))
{
// store current query
m_queryID = id;
//Log.d(TAG, "Current search query id =" + m_queryID);
// mark that it's not the first query already
if (m_mode % 2 == 0) ++m_mode;
m_flags |= NOT_FIRST_QUERY;
// set toolbar visible only for empty search string
LinearLayout bar = getSearchToolbar();
@ -459,14 +458,14 @@ public class SearchActivity extends ListActivity implements LocationService.List
public SearchAdapter.SearchResult getResult(int position, int queryID)
{
return nativeGetResult(position, queryID, m_lat, m_lon, m_mode, m_north);
return nativeGetResult(position, queryID, m_lat, m_lon, (m_flags & HAS_POSITION) != 0, m_north);
}
private native void nativeInitSearch();
private native void nativeFinishSearch();
private static native SearchAdapter.SearchResult
nativeGetResult(int position, int queryID, double lat, double lon, int mode, double north);
nativeGetResult(int position, int queryID, double lat, double lon, boolean mode, double north);
private native boolean nativeRunSearch(String s, String lang,
double lat, double lon, int mode, int queryID);