forked from organicmaps/organicmaps
[android] Fixed crash with RoutingController attaching listeners before framework is initialized.
This commit is contained in:
parent
c36ce46bb3
commit
39bac02dc3
3 changed files with 15 additions and 11 deletions
|
@ -826,12 +826,14 @@ Java_com_mapswithme_maps_Framework_nativeShowCountry(JNIEnv * env, jclass, jstri
|
|||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetRoutingListener(JNIEnv * env, jclass, jobject listener)
|
||||
{
|
||||
CHECK(g_framework, ("Framework isn't created yet!"));
|
||||
frm()->SetRouteBuildingListener(bind(&CallRoutingListener, jni::make_global_ref(listener), _1, _2));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetRouteProgressListener(JNIEnv * env, jclass, jobject listener)
|
||||
{
|
||||
CHECK(g_framework, ("Framework isn't created yet!"));
|
||||
frm()->SetRouteProgressListener(bind(&CallRouteProgressListener, jni::make_global_ref(listener), _1));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.mapswithme.maps.downloader.CountryItem;
|
|||
import com.mapswithme.maps.downloader.MapManager;
|
||||
import com.mapswithme.maps.editor.Editor;
|
||||
import com.mapswithme.maps.location.TrackRecorder;
|
||||
import com.mapswithme.maps.routing.RoutingController;
|
||||
import com.mapswithme.maps.sound.TtsPlayer;
|
||||
import com.mapswithme.util.Config;
|
||||
import com.mapswithme.util.Constants;
|
||||
|
@ -131,6 +132,7 @@ public class MwmApplication extends Application
|
|||
BookmarkManager.nativeLoadBookmarks();
|
||||
TtsPlayer.INSTANCE.init(this);
|
||||
ThemeSwitcher.restart();
|
||||
RoutingController.get().initialize();
|
||||
mIsFrameworkInitialized = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,11 @@ public class RoutingController
|
|||
}
|
||||
};
|
||||
|
||||
public static RoutingController get()
|
||||
{
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private void processRoutingEvent()
|
||||
{
|
||||
if (!mContainsCachedResult ||
|
||||
|
@ -164,17 +169,6 @@ public class RoutingController
|
|||
fragment.show(mContainer.getActivity().getSupportFragmentManager(), RoutingErrorDialogFragment.class.getSimpleName());
|
||||
}
|
||||
|
||||
private RoutingController()
|
||||
{
|
||||
Framework.nativeSetRoutingListener(mRoutingListener);
|
||||
Framework.nativeSetRouteProgressListener(mRoutingProgressListener);
|
||||
}
|
||||
|
||||
public static RoutingController get()
|
||||
{
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private void setState(State newState)
|
||||
{
|
||||
Log.d(TAG, "[S] State: " + mState + " -> " + newState + ", BuildState: " + mBuildState);
|
||||
|
@ -217,6 +211,12 @@ public class RoutingController
|
|||
mContainer = container;
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
Framework.nativeSetRoutingListener(mRoutingListener);
|
||||
Framework.nativeSetRouteProgressListener(mRoutingProgressListener);
|
||||
}
|
||||
|
||||
public void detach()
|
||||
{
|
||||
mContainer = null;
|
||||
|
|
Loading…
Add table
Reference in a new issue