This commit is contained in:
Victor Shcherb 2020-11-11 23:49:20 +01:00
parent e9be0b7327
commit befffb6511
2 changed files with 29 additions and 20 deletions

View file

@ -85,6 +85,7 @@ import java.util.Map;
import java.util.Random;
import btools.routingapp.BRouterServiceConnection;
import btools.routingapp.IBRouterService;
import static net.osmand.plus.AppVersionUpgradeOnInit.LAST_APP_VERSION;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
@ -422,13 +423,9 @@ public class AppInitializer implements IProgress {
osmandSettings.APPLICATION_MODE.set(osmandSettings.DEFAULT_APPLICATION_MODE.get());
}
startTime = System.currentTimeMillis();
try {
app.bRouterServiceConnection = startupInit(BRouterServiceConnection.connect(app), BRouterServiceConnection.class);
} catch (Exception e) {
e.printStackTrace();
}
getLazyRoutingConfig();
app.applyTheme(app);
startupInit(app.reconnectToBRouter(), IBRouterService.class);
app.inAppPurchaseHelper = startupInit(new InAppPurchaseHelperImpl(app), InAppPurchaseHelperImpl.class);
app.poiTypes = startupInit(MapPoiTypes.getDefaultNoInit(), MapPoiTypes.class);
app.transportRoutingHelper = startupInit(new TransportRoutingHelper(app), TransportRoutingHelper.class);

View file

@ -109,17 +109,16 @@ public class OsmandApplication extends MultiDexApplication {
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(OsmandApplication.class);
final AppInitializer appInitializer = new AppInitializer(this);
OsmandSettings osmandSettings = null;
Handler uiHandler;
OsmandSettings osmandSettings;
OsmAndAppCustomization appCustomization;
NavigationService navigationService;
DownloadService downloadService;
OsmandAidlApi aidlApi;
private final SQLiteAPI sqliteAPI = new SQLiteAPIImpl(this);
private final OsmAndTaskManager taskManager = new OsmAndTaskManager(this);
private final UiUtilities iconsCache = new UiUtilities(this);
Handler uiHandler;
NavigationService navigationService;
DownloadService downloadService;
OsmandAidlApi aidlApi;
// start variables
ResourceManager resourceManager;
@ -157,10 +156,8 @@ public class OsmandApplication extends MultiDexApplication {
QuickActionRegistry quickActionRegistry;
private Resources localizedResources;
private Map<String, Builder> customRoutingConfigs = new ConcurrentHashMap<>();
private Locale preferredLocale = null;
private Locale preferredLocale;
private Locale defaultLocale;
private File externalStorageDirectory;
private boolean externalStorageDirectoryReadOnly;
@ -591,8 +588,7 @@ public class OsmandApplication extends MultiDexApplication {
while (getNavigationService() != null) {
try {
Thread.sleep(100);
}
catch (InterruptedException e) {
} catch (InterruptedException e) {
}
}
@ -783,11 +779,27 @@ public class OsmandApplication extends MultiDexApplication {
c.setTheme(themeResId);
}
public IBRouterService getBRouterService() {
if(bRouterServiceConnection == null) {
IBRouterService reconnectToBRouter() {
try {
bRouterServiceConnection = BRouterServiceConnection.connect(this);
if (bRouterServiceConnection != null) {
return bRouterServiceConnection.getBrouterService();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
return bRouterServiceConnection.getBrouterService();
public IBRouterService getBRouterService() {
if (bRouterServiceConnection == null) {
return null;
}
IBRouterService s = bRouterServiceConnection.getBrouterService();
if (s != null && !s.asBinder().isBinderAlive()) {
s = reconnectToBRouter();
}
return s;
}
public void setLanguage(Context context) {