forked from organicmaps/organicmaps-tmp
Implemented routing recommendations on Android
This commit is contained in:
parent
0299da3c99
commit
c24cfb1cf2
3 changed files with 51 additions and 0 deletions
|
@ -642,6 +642,14 @@ void CallRouteProgressListener(shared_ptr<jobject> listener, float progress)
|
|||
env->CallVoidMethod(*listener, methodId, progress);
|
||||
}
|
||||
|
||||
void CallRouteRecommendationListener(shared_ptr<jobject> listener,
|
||||
RoutingManager::Recommendation recommendation)
|
||||
{
|
||||
JNIEnv * env = jni::GetEnv();
|
||||
jmethodID const methodId = jni::GetMethodID(env, *listener, "onRecommend", "(I)V");
|
||||
env->CallVoidMethod(*listener, methodId, static_cast<int>(recommendation));
|
||||
}
|
||||
|
||||
/// @name JNI EXPORTS
|
||||
//@{
|
||||
JNIEXPORT jstring JNICALL
|
||||
|
@ -1130,6 +1138,15 @@ Java_com_mapswithme_maps_Framework_nativeSetRouteProgressListener(JNIEnv * env,
|
|||
bind(&CallRouteProgressListener, jni::make_global_ref(listener), _1));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetRoutingRecommendationListener(JNIEnv * env, jclass,
|
||||
jobject listener)
|
||||
{
|
||||
CHECK(g_framework, ("Framework isn't created yet!"));
|
||||
frm()->GetRoutingManager().SetRouteRecommendationListener(
|
||||
bind(&CallRouteRecommendationListener, jni::make_global_ref(listener), _1));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeDeactivatePopup(JNIEnv * env, jclass)
|
||||
{
|
||||
|
|
|
@ -70,6 +70,12 @@ public class Framework
|
|||
public static final int LOCAL_ADS_EVENT_CLICKED_PHONE = 2;
|
||||
public static final int LOCAL_ADS_EVENT_CLICKED_WEBSITE = 3;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({ROUTE_REBUILD_AFTER_POINTS_LOADING})
|
||||
public @interface RouteRecommendationType {}
|
||||
|
||||
public static final int ROUTE_REBUILD_AFTER_POINTS_LOADING = 0;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface MapObjectListener
|
||||
{
|
||||
|
@ -90,6 +96,12 @@ public class Framework
|
|||
void onRouteBuildingProgress(float progress);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface RoutingRecommendationListener
|
||||
{
|
||||
void onRecommend(@RouteRecommendationType int recommendation);
|
||||
}
|
||||
|
||||
public static class Params3dMode
|
||||
{
|
||||
public boolean enabled;
|
||||
|
@ -251,6 +263,8 @@ public class Framework
|
|||
|
||||
public static native void nativeSetRouteProgressListener(RoutingProgressListener listener);
|
||||
|
||||
public static native void nativeSetRoutingRecommendationListener(RoutingRecommendationListener listener);
|
||||
|
||||
public static native void nativeShowCountry(String countryId, boolean zoomToDownloadButton);
|
||||
|
||||
public static native void nativeSetMapStyle(int mapStyle);
|
||||
|
|
|
@ -164,6 +164,25 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
}
|
||||
};
|
||||
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
private final Framework.RoutingRecommendationListener mRoutingRecommendationListener =
|
||||
new Framework.RoutingRecommendationListener()
|
||||
{
|
||||
@Override
|
||||
public void onRecommend(@Framework.RouteRecommendationType final int recommendation)
|
||||
{
|
||||
UiThread.run(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (recommendation == Framework.ROUTE_REBUILD_AFTER_POINTS_LOADING)
|
||||
setStartPoint(LocationHelper.INSTANCE.getMyPosition());
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
public static RoutingController get()
|
||||
{
|
||||
return sInstance;
|
||||
|
@ -258,6 +277,7 @@ public class RoutingController implements TaxiManager.TaxiListener
|
|||
|
||||
Framework.nativeSetRoutingListener(mRoutingListener);
|
||||
Framework.nativeSetRouteProgressListener(mRoutingProgressListener);
|
||||
Framework.nativeSetRoutingRecommendationListener(mRoutingRecommendationListener);
|
||||
TaxiManager.INSTANCE.setTaxiListener(this);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue