From d9e33f4c8137f1e47387b248066f2ebba871c38e Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 21 May 2012 01:22:53 +0200 Subject: [PATCH] Implement base plugin API --- OsmAnd/src/net/osmand/plus/OsmandApplication.java | 6 ++++++ OsmAnd/src/net/osmand/plus/OsmandPlugin.java | 7 +++++++ OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 8 +++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 133f899349..0e0d359336 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -92,6 +92,12 @@ public class OsmandApplication extends Application { if (LOG.isDebugEnabled()) { LOG.debug("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms"); } + timeToStart = System.currentTimeMillis(); + OsmandPlugin.initPlugins(this); + + if (LOG.isDebugEnabled()) { + LOG.debug("Time to init plugins " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms"); + } } @Override diff --git a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java index 357d8e85f7..037c574b6e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandPlugin.java +++ b/OsmAnd/src/net/osmand/plus/OsmandPlugin.java @@ -38,6 +38,13 @@ public abstract class OsmandPlugin { */ public abstract boolean init(OsmandApplication app); + + public static void initPlugins(OsmandApplication app) { + for (OsmandPlugin plugin : plugins) { + plugin.init(app); + } + } + /** * ???? */ diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index f1ac4b8b3d..b8cd5621f9 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -108,8 +108,8 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe /** Called when the activity is first created. */ private OsmandMapTileView mapView; - final private MapActivityActions mapActions = new MapActivityActions(this); - final private MapActivityLayers mapLayers = new MapActivityLayers(this); + private MapActivityActions mapActions; + private MapActivityLayers mapLayers; private NavigationInfo navigationInfo; private SavingTrackHelper savingTrackHelper; @@ -152,7 +152,9 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - settings = getMyApplication().getSettings(); + settings = getMyApplication().getSettings(); + mapActions = new MapActivityActions(this); + mapLayers = new MapActivityLayers(this); navigationInfo = new NavigationInfo(this); requestWindowFeature(Window.FEATURE_NO_TITLE); // Full screen is not used here