forked from organicmaps/organicmaps
[android] Codereview fixes.
This commit is contained in:
parent
f378221f40
commit
6d9ee3a798
5 changed files with 40 additions and 31 deletions
|
@ -30,11 +30,17 @@ namespace jni
|
|||
}
|
||||
|
||||
jstring ToJavaString(JNIEnv * env, char const * s);
|
||||
|
||||
inline jstring ToJavaString(JNIEnv * env, string const & s)
|
||||
{
|
||||
return ToJavaString(env, s.c_str());
|
||||
}
|
||||
|
||||
inline jstring ToJavaString(string const & s)
|
||||
{
|
||||
return ToJavaString(GetEnv(), s.c_str());
|
||||
}
|
||||
|
||||
string DescribeException();
|
||||
|
||||
shared_ptr<jobject> make_global_ref(jobject obj);
|
||||
|
|
|
@ -590,15 +590,15 @@ namespace android
|
|||
m2::PointD pxPivot;
|
||||
BookmarkAndCategory bmAndCat;
|
||||
|
||||
m_apiPointActive = NativeFramework()->GetMapApiPoint(pt, m_activePoint);
|
||||
bool const apiPointActivated = NativeFramework()->GetMapApiPoint(pt, m_activePoint);
|
||||
if (m_apiPointActivatedListener)
|
||||
m_apiPointActivatedListener(m_apiPointActive, m_activePoint.m_lat,
|
||||
m_apiPointActivatedListener(apiPointActivated, m_activePoint.m_lat,
|
||||
m_activePoint.m_lon,
|
||||
m_activePoint.m_title,
|
||||
m_activePoint.m_url);
|
||||
|
||||
|
||||
if (m_apiPointActive)
|
||||
if (apiPointActivated)
|
||||
{
|
||||
m2::PointD pivot(MercatorBounds::LonToX(m_activePoint.m_lon),
|
||||
MercatorBounds::LatToY(m_activePoint.m_lat));
|
||||
|
@ -790,8 +790,11 @@ namespace android
|
|||
m_doLoadState = false;
|
||||
|
||||
url_api::Request request;
|
||||
// if we have only one point
|
||||
// and import is successful
|
||||
// => show balloon
|
||||
if (m_work.SetViewportByURL(url, request)
|
||||
&& !request.m_points.size() == 1)
|
||||
&& request.m_points.size() == 1)
|
||||
{
|
||||
|
||||
//we need it only for one-point-call
|
||||
|
@ -833,15 +836,15 @@ extern "C"
|
|||
|
||||
void CallOnApiPointActivatedListener(shared_ptr<jobject> obj, bool activated, double lat, double lon, string name, string id)
|
||||
{
|
||||
jmethodID methodID = jni::GetJavaMethodID(jni::GetEnv(), *obj.get(),
|
||||
"onApiPointActivated",
|
||||
"(ZDDLjava/lang/String;Ljava/lang/String;)V");
|
||||
if (methodID != 0)
|
||||
{
|
||||
jstring j_name = jni::ToJavaString(jni::GetEnv(), name);
|
||||
jstring j_id = jni::ToJavaString(jni::GetEnv(), id);
|
||||
jni::GetEnv()->CallVoidMethod(*obj.get(), methodID, activated, lat, lon, j_name, j_id);
|
||||
}
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
const jmethodID methodID = jni::GetJavaMethodID(jniEnv,
|
||||
*obj.get(),
|
||||
"onApiPointActivated",
|
||||
"(ZDDLjava/lang/String;Ljava/lang/String;)V");
|
||||
|
||||
jstring j_name = jni::ToJavaString(name);
|
||||
jstring j_id = jni::ToJavaString(id);
|
||||
jniEnv->CallVoidMethod(*obj.get(), methodID, activated, lat, lon, j_name, j_id);
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
|
@ -858,12 +861,13 @@ extern "C"
|
|||
g_framework->SetViewportByUrl(jni::ToNativeString(url));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetApiPointActivatedListener(JNIEnv * env, jobject thiz, jobject l)
|
||||
{
|
||||
g_framework->AddApiPointActivatedListener(bind(&CallOnApiPointActivatedListener, jni::make_global_ref(l), _1, _2, _3, _4, _5));
|
||||
}
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetApiPointActivatedListener(JNIEnv * env, jobject thiz, jobject l)
|
||||
{
|
||||
g_framework->AddApiPointActivatedListener(
|
||||
bind(&CallOnApiPointActivatedListener, jni::make_global_ref(l),
|
||||
_1, _2, _3, _4, _5));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeRemoveApiPointActivatedListener(JNIEnv * env, jobject thiz)
|
||||
|
|
|
@ -41,9 +41,8 @@ namespace android
|
|||
int m_mask;
|
||||
|
||||
bool m_doLoadState;
|
||||
bool m_apiPointActive;
|
||||
url_scheme::ApiPoint m_activePoint;
|
||||
//Api point
|
||||
url_scheme::ApiPoint m_activePoint;
|
||||
typedef function<void (bool, double, double, string, string)> TOnApiPointActivatedListener;
|
||||
TOnApiPointActivatedListener m_apiPointActivatedListener;
|
||||
|
||||
|
@ -81,8 +80,6 @@ namespace android
|
|||
void CreateBookmarkBalloon();
|
||||
BookmarkBalloon * GetBookmarkBalloon();
|
||||
void OnPositionClicked(m2::PointD const & point);
|
||||
|
||||
/// @todo used to keep track of current position for "my_position" balloon
|
||||
bool m_doUpdateBalloonPositionFromLocation;
|
||||
|
||||
string m_searchQuery;
|
||||
|
|
|
@ -682,21 +682,22 @@ public class DownloadResourcesActivity extends MapsWithMeBaseActivity
|
|||
@Override
|
||||
public boolean processIntent(Intent intent)
|
||||
{
|
||||
//TODO get url and pass to core asynchronously
|
||||
final String apiUrl = intent.getStringExtra(Const.EXTRA_URL);
|
||||
if (apiUrl != null)
|
||||
{
|
||||
// We do not want to wait until parsing finish
|
||||
new Thread() {
|
||||
new Thread()
|
||||
{
|
||||
@Override
|
||||
public void run() { Framework.passApiUrl(apiUrl); };
|
||||
}.start();
|
||||
//TODO add synchronization for non-UI thread call
|
||||
final MWMRequest request = MWMRequest.extractFromIntent(intent, getApplicationContext());
|
||||
MWMRequest.setCurrentRequest(request);
|
||||
getMwmApplication().getAppStateManager().transitionTo(SuppotedState.API_REQUEST);
|
||||
return true;
|
||||
}
|
||||
final MWMRequest request = MWMRequest.extractFromIntent(intent, getApplicationContext());
|
||||
MWMRequest.setCurrentRequest(request);
|
||||
getMwmApplication().getAppStateManager().transitionTo(SuppotedState.API_REQUEST);
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ public class Framework
|
|||
return nativeGetNameAndAddress4Point(pixelX, pixelY);
|
||||
}
|
||||
|
||||
public static void passApiUrl(String url) {
|
||||
public static void passApiUrl(String url)
|
||||
{
|
||||
nativePassApiUrl(url);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue