Startup of application

This commit is contained in:
Victor Shcherb 2015-03-06 19:37:54 +01:00
parent 65b91119ed
commit 5e7a5374d2
30 changed files with 158 additions and 147 deletions

View file

@ -28,10 +28,8 @@ import org.apache.commons.logging.Log;
public class NativeLibrary {
protected final boolean newLibrary;
public NativeLibrary(boolean newLibrary) {
this.newLibrary = newLibrary;
public NativeLibrary() {
}
public static class RenderingGenerationResult {
@ -112,12 +110,7 @@ public class NativeLibrary {
}
public boolean initMapFile(String filePath) {
if(newLibrary) {
// TODO
return initBinaryMapFile(filePath);
} else {
return initBinaryMapFile(filePath);
}
return initBinaryMapFile(filePath);
}
public boolean initCacheMapFile(String filePath) {

View file

@ -1,37 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="@+id/dashboard"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#70000000"
android:visibility="gone">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dashboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#70000000"
android:orientation="vertical"
android:visibility="gone" >
<LinearLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_gravity="end"
android:layout_height="match_parent">
<include
android:id="@+id/init_progress"
layout="@layout/application_loading"
android:visibility="gone" />
<include android:id="@+id/init_progress"
layout="@layout/application_loading"/>
<net.osmand.plus.dashboard.NotifyingScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_scroll"
android:layout_width="360dp"
android:layout_gravity="start"
android:layout_height="match_parent"
android:fadeScrollbars="true" >
<net.osmand.plus.dashboard.NotifyingScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="360dp"
android:layout_height="match_parent"
android:id="@+id/main_scroll"
android:fadeScrollbars="true">
<LinearLayout
android:id="@+id/content"
android:paddingTop="@dimen/dashboard_map_top_padding"
android:paddingBottom="@dimen/dashboard_map_bottom_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</net.osmand.plus.dashboard.NotifyingScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</net.osmand.plus.dashboard.NotifyingScrollView>
</FrameLayout>

View file

@ -2,23 +2,26 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/loading"
android:layout_width="fill_parent"
android:layout_height="@dimen/dashMapHeight"
android:gravity="center_vertical|center_horizontal"
android:layout_height="wrap_content"
android:layout_gravity="top|end"
android:gravity="end"
android:paddingTop="5dp"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="30dp"/>
<TextView
android:id="@+id/ProgressMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="3"
android:textColor="@color/icon_color_light"
android:maxLines="1"
android:layout_gravity="center_vertical"
android:textColor="@color/dashboard_divider_light"
android:text="@string/loading_data"
android:layout_marginRight="5dp"
android:textSize="@dimen/dashProgressTextSize"/>
</LinearLayout>

View file

@ -5,6 +5,7 @@
android:layout_height="wrap_content"
android:background="?attr/expandable_list_item_background"
android:minHeight="@dimen/dashListItemHeight"
android:focusable="yes"
android:orientation="vertical">
<View
@ -18,7 +19,6 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check_local_index"
android:layout_width="wrap_content"

View file

@ -12,6 +12,6 @@
android:scaleType="centerCrop"
android:src="@drawable/background"
android:layout_width="match_parent"
android:layout_height="@dimen/dashMapHeight"
android:layout_height="260dp"
android:visibility="gone"/>
</RelativeLayout>

View file

@ -5,6 +5,7 @@
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="?attr/expandable_list_item_background"
android:layout_height="wrap_content"
android:orientation="vertical">

View file

@ -1,40 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:id="@+id/dashboard"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#70000000"
android:visibility="gone">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dashboard"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#70000000"
android:orientation="vertical"
android:visibility="gone" >
<RelativeLayout android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:layout_height="match_parent">
<include
android:id="@+id/init_progress"
layout="@layout/application_loading"
android:visibility="gone" />
<include android:layout_height="@dimen/dashMapHeight"
android:layout_width="@dimen/dashboard_map_width"
android:id="@+id/init_progress"
android:visibility="gone"
layout="@layout/application_loading"/>
<net.osmand.plus.dashboard.NotifyingScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadeScrollbars="true" >
<net.osmand.plus.dashboard.NotifyingScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="@dimen/dashboard_map_width"
android:layout_height="match_parent"
android:id="@+id/main_scroll"
android:fadeScrollbars="true">
<LinearLayout
android:id="@+id/content"
android:paddingTop="@dimen/dashboard_map_top_padding"
android:paddingBottom="@dimen/dashboard_map_bottom_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</net.osmand.plus.dashboard.NotifyingScrollView>
</RelativeLayout>
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/dashboard_map_bottom_padding"
android:paddingTop="@dimen/dashboard_map_top_padding" />
</net.osmand.plus.dashboard.NotifyingScrollView>
</FrameLayout>

View file

@ -38,7 +38,7 @@
android:layout_gravity="center_vertical|start"
android:layout_marginBottom="9dp"
android:layout_marginTop="9dp"
android:background="@null"
android:background="?attr/expandable_list_item_background"
android:drawableLeft="?attr/ic_action_settings"
android:drawablePadding="10dp"
android:drawableStart="?attr/ic_action_settings"

View file

@ -3,6 +3,7 @@
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:background="?attr/expandable_list_item_background"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

View file

@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="?attr/expandable_list_item_background"
android:orientation="vertical">
<LinearLayout

View file

@ -2,9 +2,11 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="?attr/expandable_list_item_background"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:orientation="horizontal">
android:paddingRight="@dimen/list_content_padding">
<TextView
android:id="@+id/distance_label"

View file

@ -3,11 +3,11 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/expandable_list_item_background"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"
android:paddingBottom="5dp"
android:paddingLeft="@dimen/list_content_padding"
android:paddingTop="5dp">
android:paddingRight="@dimen/list_content_padding">
<ImageView
android:id="@+id/icon"

View file

@ -5,6 +5,7 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:background="?attr/expandable_list_item_background"
android:orientation="horizontal"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding">

View file

@ -5,10 +5,9 @@
android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"
android:background="?attr/expandable_list_item_background"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:paddingBottom="5dp"
android:paddingTop="5dp">
android:paddingRight="@dimen/list_content_padding">
<ImageView
android:id="@+id/folder_icon"

View file

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"

View file

@ -1,6 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="dashboard_map_top_padding">0dp</dimen>
<dimen name="dashboard_map_bottom_padding">0dp</dimen>
<dimen name="dashMapHeight">125dp</dimen>
</resources>

View file

@ -9,7 +9,6 @@
<dimen name="dashFavIconSize">42dp</dimen>
<dimen name="dashFavIconMargin">18dp</dimen>
<dimen name="dashFavDirectionSize">15dp</dimen>
<dimen name="dashMapHeight">375dp</dimen>
<dimen name="dashMapMargin">3dp</dimen>
<dimen name="dashProgressTextSize">27sp</dimen>
<dimen name="dashNoteIconSize">42dp</dimen>
@ -21,7 +20,6 @@
<dimen name="dashPadding">9dp</dimen>
<dimen name="dashAboutTextSize">30sp</dimen>
<dimen name="dashCardMargin">6dp</dimen>
<dimen name="dash_parking_height">60dp</dimen>
<!-- TextSizes -->
<dimen name="showAllButtonTextSize">16sp</dimen>

View file

@ -9,7 +9,6 @@
<dimen name="dashFavIconSize">28dp</dimen>
<dimen name="dashFavIconMargin">12dp</dimen>
<dimen name="dashFavDirectionSize">10dp</dimen>
<dimen name="dashMapHeight">250dp</dimen>
<dimen name="dashNoteIconSize">28dp</dimen>
<dimen name="dashPluginPadding">4dp</dimen>
<dimen name="dashPluginMargin">8dp</dimen>
@ -43,8 +42,7 @@
<dimen name="gpx_small_icon_margin">3dp</dimen>
<dimen name="gpx_small_text_margin">14dp</dimen>
<dimen name="gpx_text_top_margin">6dp</dimen>
<dimen name="dashboard_map_width">360dp</dimen>
<dimen name="dashboard_map_top_padding">@dimen/dashMapHeight</dimen>
<dimen name="dashboard_map_top_padding">240dp</dimen>
<dimen name="dashboard_map_bottom_padding">90dp</dimen>
<!-- TextSizes -->
@ -53,6 +51,6 @@
<dimen name="download_descr_text_size">12sp</dimen>
<dimen name="subHeaderTextSize">14sp</dimen>
<dimen name="dashFavNameTextSize">16sp</dimen>
<dimen name="dashProgressTextSize">18sp</dimen>
<dimen name="dashProgressTextSize">14sp</dimen>
<dimen name="dashParkingTextSize">24sp</dimen>
</resources>

View file

@ -71,10 +71,10 @@ public class MapRendererContext implements RendererRegistry.IRendererLoadedEvent
*/
public void setMapRendererView(MapRendererView mapRendererView) {
boolean update = (this.mapRendererView != mapRendererView);
this.mapRendererView = mapRendererView;
if (!update) {
return;
}
this.mapRendererView = mapRendererView;
if (mapRendererView != null) {
applyCurrentContextToView();
}
@ -341,4 +341,6 @@ public class MapRendererContext implements RendererRegistry.IRendererLoadedEvent
Log.w(TAG, "Failed to add style from byte array");
}
}
}

View file

@ -79,7 +79,10 @@ public class AppInitializer implements IProgress {
private List<AppInitializeListener> listeners = new ArrayList<AppInitializer.AppInitializeListener>();
public enum InitEvents {
FAVORITES_INITIALIZED, NATIVE_INITIALIZED, TASK_CHANGED, MAPS_INITIALIZED, POI_TYPES_INITIALIZED, ASSETS_COPIED, INIT_RENDERERS, RESTORE_BACKUPS, INDEX_REGION_BOUNDARIES, SAVE_GPX_TRACKS, LOAD_GPX_TRACKS;
FAVORITES_INITIALIZED, NATIVE_INITIALIZED,
NATIVE_OPEN_GLINITIALIZED,
TASK_CHANGED, MAPS_INITIALIZED, POI_TYPES_INITIALIZED, ASSETS_COPIED, INIT_RENDERERS,
RESTORE_BACKUPS, INDEX_REGION_BOUNDARIES, SAVE_GPX_TRACKS, LOAD_GPX_TRACKS;
}
public interface AppInitializeListener {
@ -143,9 +146,9 @@ public class AppInitializer implements IProgress {
final File file = app.getAppPath(OsmandApplication.EXCEPTION_PATH);
if (file.exists() && file.length() > 0) {
if (size != file.length() && !firstTime) {
activity.getPreferences(Context.MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
return true;
}
activity.getPreferences(Context.MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, file.length()).commit();
} else {
if (size > 0) {
activity.getPreferences(Context.MODE_WORLD_WRITEABLE).edit().putLong(EXCEPTION_FILE_SIZE, 0).commit();
@ -373,13 +376,18 @@ public class AppInitializer implements IProgress {
private void startApplicationBackground() {
try {
startBgTime = System.currentTimeMillis();
initNativeCore();
notifyEvent(InitEvents.NATIVE_INITIALIZED);
app.resourceManager.reloadIndexesOnStart(this, warnings);
initPoiTypes();
notifyEvent(InitEvents.POI_TYPES_INITIALIZED);
app.favorites.loadFavorites();
notifyEvent(InitEvents.FAVORITES_INITIALIZED);
app.resourceManager.reloadIndexesOnStart(this, warnings);
app.resourceManager.initRenderers(this);
notifyEvent(InitEvents.INIT_RENDERERS);
// native depends on renderers
initNativeCore();
notifyEvent(InitEvents.NATIVE_INITIALIZED);
initPoiTypes();
notifyEvent(InitEvents.POI_TYPES_INITIALIZED);
indexRegionsBoundaries(false);
notifyEvent(InitEvents.INDEX_REGION_BOUNDARIES);
app.selectedGpxHelper.loadGPXTracks(this);

View file

@ -149,12 +149,17 @@ public class MapActivity extends AccessibleActivity {
dashboardOnMap.setDashboardVisibility(true);
findViewById(R.id.init_progress).setVisibility(View.VISIBLE);
initListener = new AppInitializeListener() {
boolean openGlSetup = false;
@Override
public void onProgress(AppInitializer init, InitEvents event) {
String tn = init.getCurrentInitTaskName();
if (tn != null) {
((TextView) findViewById(R.id.ProgressMessage)).setText(tn);
}
if(event == InitEvents.NATIVE_INITIALIZED) {
setupOpenGLView();
openGlSetup = true;
}
if(event == InitEvents.MAPS_INITIALIZED) {
mapView.refreshMap(true);
}
@ -163,29 +168,22 @@ public class MapActivity extends AccessibleActivity {
@Override
public void onFinish(AppInitializer init) {
applicationInitialized();
if(!openGlSetup) {
setupOpenGLView();
}
mapView.refreshMap();
}
};
getMyApplication().checkApplicationIsBeingInitialized(this, initListener);
} else {
setupOpenGLView();
}
parseLaunchIntentLocation();
if (settings.USE_OPENGL_RENDER.get() && NativeCoreContext.isInit()) {
ViewStub stub = (ViewStub) findViewById(R.id.atlasMapRendererViewStub);
atlasMapRendererView = (AtlasMapRendererView) stub.inflate();
OsmAndMapLayersView ml = (OsmAndMapLayersView) findViewById(R.id.MapLayersView);
ml.setVisibility(View.VISIBLE);
atlasMapRendererView.setAzimuth(0);
atlasMapRendererView.setElevationAngle(90);
NativeCoreContext.getMapRendererContext().setMapRendererView(atlasMapRendererView);
mapView = ml.getMapView();
mapView.setMapRender(atlasMapRendererView);
} else {
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) findViewById(R.id.MapView);
surf.setVisibility(View.VISIBLE);
mapView = surf.getMapView();
}
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) findViewById(R.id.MapView);
surf.setVisibility(View.VISIBLE);
mapView = surf.getMapView();
mapView.setTrackBallDelegate(new OsmandMapTileView.OnTrackBallListener() {
@Override
@ -249,6 +247,22 @@ public class MapActivity extends AccessibleActivity {
findViewById(R.id.init_progress).setVisibility(View.GONE);
findViewById(R.id.ParentLayout).invalidate();
}
private void setupOpenGLView() {
if (settings.USE_OPENGL_RENDER.get() && NativeCoreContext.isInit()) {
ViewStub stub = (ViewStub) findViewById(R.id.atlasMapRendererViewStub);
atlasMapRendererView = (AtlasMapRendererView) stub.inflate();
OsmAndMapLayersView ml = (OsmAndMapLayersView) findViewById(R.id.MapLayersView);
ml.setVisibility(View.VISIBLE);
atlasMapRendererView.setAzimuth(0);
atlasMapRendererView.setElevationAngle(90);
NativeCoreContext.getMapRendererContext().setMapRendererView(atlasMapRendererView);
mapView = ml.getMapView();
mapView.setMapRender(atlasMapRendererView);
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) findViewById(R.id.MapView);
surf.setVisibility(View.GONE);
}
}
public void addLockView(FrameLayout lockView) {
this.lockView = lockView;
@ -730,6 +744,9 @@ public class MapActivity extends AccessibleActivity {
}
public void updateMapSettings() {
if(app.isApplicationInitializing()) {
return;
}
// update vector renderer
new AsyncTask<Void, Void, Void>() {

View file

@ -28,6 +28,7 @@ public class PluginActivity extends OsmandActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
Intent intent = getIntent();

View file

@ -24,6 +24,7 @@ public class PluginsActivity extends OsmandListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
((OsmandApplication) getApplication()).applyTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.plugins);
getSupportActionBar().setTitle(R.string.plugins_screen);

View file

@ -162,13 +162,11 @@ public class DashPluginsFragment extends DashBaseFragment {
CompoundButton enableDisableButton =
(CompoundButton)view.findViewById(R.id.plugin_enable_disable);
enableDisableButton.setOnCheckedChangeListener(enableDisableListener);
Button getButton = (Button)view.findViewById(R.id.get_plugin);
getButton.setOnClickListener(getListener);
enableDisableButton.setOnCheckedChangeListener(null);
updatePluginState(view);
enableDisableButton.setOnCheckedChangeListener(enableDisableListener);
container.addView(view);
}
}

View file

@ -136,7 +136,8 @@ public class DashboardOnMap {
private void addDashboardFragments() {
FragmentManager manager = ma.getSupportFragmentManager();
FragmentTransaction fragmentTransaction = manager.beginTransaction();
if (manager.findFragmentByTag(DashErrorFragment.TAG) == null && ma.getMyApplication().getAppInitializer().checkPreviousRunsForExceptions(ma)) {
if (manager.findFragmentByTag(DashErrorFragment.TAG) == null &&
ma.getMyApplication().getAppInitializer().checkPreviousRunsForExceptions(ma)) {
DashErrorFragment errorFragment = new DashErrorFragment();
fragmentTransaction.add(R.id.content, errorFragment, DashErrorFragment.TAG);
}

View file

@ -75,6 +75,9 @@ public class OsMoPlugin extends OsmandPlugin implements MonitoringInfoControlSer
@Override
public boolean init(final OsmandApplication app, Activity activity) {
if(true) {
throw new IllegalStateException("Don't enable !!!");
}
if (service == null) {
service = new OsMoService(app, this);
tracker = new OsMoTracker(service, app.getSettings().OSMO_SAVE_TRACK_INTERVAL,

View file

@ -131,14 +131,6 @@ public class MapRenderRepositories {
}
files.put(file.getAbsolutePath(), reader);
NativeOsmandLibrary nativeLib = NativeOsmandLibrary.getLoadedLibrary();
if (nativeLib != null) {
if (!nativeLib.initMapFile(file.getAbsolutePath())) {
log.error("Initializing native db " + file.getAbsolutePath() + " failed!"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} else {
nativeFiles.add(file.getAbsolutePath());
}
}
}
public RotatedTileBox getBitmapLocation() {

View file

@ -17,8 +17,8 @@ public class NativeOsmandLibrary extends NativeLibrary {
private static NativeOsmandLibrary library;
private static Boolean isNativeSupported = null;
public NativeOsmandLibrary(boolean newLibrary) {
super(newLibrary);
public NativeOsmandLibrary() {
super();
}
public static NativeOsmandLibrary getLoadedLibrary(){
@ -47,7 +47,7 @@ public class NativeOsmandLibrary extends NativeLibrary {
log.debug("Loading native libraries..."); //$NON-NLS-1$
System.loadLibrary("osmand");
log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$
library = new NativeOsmandLibrary(false);
library = new NativeOsmandLibrary();
log.debug("Initializing rendering rules storage..."); //$NON-NLS-1$
NativeOsmandLibrary.initRenderingRulesStorage(storage);
isNativeSupported = true;

View file

@ -410,8 +410,6 @@ public class ResourceManager {
// check we have some assets to copy to sdcard
warnings.addAll(checkAssets(progress));
progress.notifyEvent(InitEvents.ASSETS_COPIED);
initRenderers(progress);
progress.notifyEvent(InitEvents.INIT_RENDERERS);
reloadIndexes(progress, warnings);
progress.notifyEvent(InitEvents.MAPS_INITIALIZED);
return warnings;
@ -549,7 +547,7 @@ public class ResourceManager {
Algorithms.closeStream(is);
}
private void initRenderers(IProgress progress) {
public void initRenderers(IProgress progress) {
File file = context.getAppPath(IndexConstants.RENDERERS_DIR);
file.mkdirs();
Map<String, File> externalRenderers = new LinkedHashMap<String, File>();
@ -604,10 +602,7 @@ public class ResourceManager {
if (indCache.exists()) {
try {
cachedOsmandIndexes.readFromFile(indCache, CachedOsmandIndexes.VERSION);
NativeOsmandLibrary nativeLib = NativeOsmandLibrary.getLoadedLibrary();
if (nativeLib != null) {
nativeLib.initCacheMapFile(indCache.getAbsolutePath());
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
@ -688,8 +683,19 @@ public class ResourceManager {
log.error("Index file could not be written", e);
}
}
initMapBoundariesCacheNative();
return warnings;
}
public void initMapBoundariesCacheNative() {
File indCache = context.getAppPath(INDEXES_CACHE);
if (indCache.exists()) {
NativeOsmandLibrary nativeLib = NativeOsmandLibrary.getLoadedLibrary();
if (nativeLib != null) {
nativeLib.initCacheMapFile(indCache.getAbsolutePath());
}
}
}
////////////////////////////////////////////// Working with amenities ////////////////////////////////////////////////
public boolean checkNameFilter(Amenity object, String filterByName) {

View file

@ -15,6 +15,8 @@ import net.osmand.core.jni.MapStylesCollection;
import net.osmand.core.jni.ObfsCollection;
import net.osmand.core.jni.QIODeviceLogSink;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.srtmplugin.SRTMPlugin;
/**
* Created by Denis on 01.10.2014.
@ -50,7 +52,7 @@ public class NativeCoreContext {
File directory = app.getAppPath("");
Logger.get().addLogSink(QIODeviceLogSink.createFileLogSink(
directory.getAbsolutePath() + "osmandcore.log"));
directory.getAbsolutePath() + "/osmandcore.log"));
WindowManager mgr = (WindowManager)app.getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
@ -58,6 +60,9 @@ public class NativeCoreContext {
ObfsCollection obfsCollection = new ObfsCollection();
obfsCollection.addDirectory(directory.getAbsolutePath(), false);
if(OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) != null) {
obfsCollection.addDirectory(app.getAppPath(IndexConstants.SRTM_INDEX_DIR).getAbsolutePath(), false);
}
mapRendererContext = new MapRendererContext(app, dm.density);
mapRendererContext.setupObfMap(new MapStylesCollection(), obfsCollection);