From a25d361ae9533ad256b5501818b2812005acd1c4 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Wed, 30 Oct 2013 11:28:03 +0100 Subject: [PATCH] Add constants for UI handler events --- OsmAnd/src/net/osmand/plus/OsmAndConstants.java | 16 ++++++++++++++++ .../net/osmand/plus/OsmAndLocationProvider.java | 9 ++++----- .../plus/ProgressDialogImplementation.java | 4 ++-- .../net/osmand/plus/activities/MapActivity.java | 5 +++-- .../search/SearchByNameAbstractActivity.java | 5 +++-- .../activities/search/SearchPOIActivity.java | 6 ++++-- .../osmand/plus/base/BasicProgressAsyncTask.java | 3 ++- .../plus/base/MapViewTrackingUtilities.java | 3 ++- .../net/osmand/plus/views/MapControlsLayer.java | 3 ++- .../net/osmand/plus/views/OsmandMapTileView.java | 5 +++-- 10 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/OsmAndConstants.java diff --git a/OsmAnd/src/net/osmand/plus/OsmAndConstants.java b/OsmAnd/src/net/osmand/plus/OsmAndConstants.java new file mode 100644 index 0000000000..21ca887c6f --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/OsmAndConstants.java @@ -0,0 +1,16 @@ +package net.osmand.plus; + +public interface OsmAndConstants { + + + public int UI_HANDLER_MAP_VIEW = 300; + + public int UI_HANDLER_MAP_CONTROLS = 400; + + public int UI_HANDLER_LOCATION_SERVICE = 500; + + public int UI_HANDLER_PROGRESS = 600; + + public int UI_HANDLER_SEARCH = 700; + +} diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 8926cda133..ee74270b79 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -9,7 +9,6 @@ import java.util.List; import net.osmand.GeoidAltitudeCorrection; import net.osmand.PlatformUtil; import net.osmand.access.NavigationInfo; -import net.osmand.binary.BinaryMapDataObject; import net.osmand.binary.RouteDataObject; import net.osmand.data.LatLon; import net.osmand.data.QuadPoint; @@ -44,11 +43,11 @@ public class OsmAndLocationProvider implements SensorEventListener { } private static final int INTERVAL_TO_CLEAR_SET_LOCATION = 30 * 1000; - private static final int LOST_LOCATION_MSG_ID = 53; - private static final int START_SIMULATE_LOCATION_MSG_ID = 54; - private static final int RUN_SIMULATE_LOCATION_MSG_ID = 55; + private static final int LOST_LOCATION_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 1; + private static final int START_SIMULATE_LOCATION_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 2; + private static final int RUN_SIMULATE_LOCATION_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 3; private static final long LOST_LOCATION_CHECK_DELAY = 18000; - private static final long START_LOCATION_SIMULATION_DELAY = 4000; + private static final long START_LOCATION_SIMULATION_DELAY = 3000; private static final float ACCURACY_FOR_GPX_AND_ROUTING = 50; diff --git a/OsmAnd/src/net/osmand/plus/ProgressDialogImplementation.java b/OsmAnd/src/net/osmand/plus/ProgressDialogImplementation.java index 417dffbf2f..301d2b7f83 100644 --- a/OsmAnd/src/net/osmand/plus/ProgressDialogImplementation.java +++ b/OsmAnd/src/net/osmand/plus/ProgressDialogImplementation.java @@ -10,8 +10,8 @@ import android.os.Message; public class ProgressDialogImplementation implements IProgress { - private static final int HANDLER_START_TASK = 0; - private static final int HADLER_UPDATE_PROGRESS = 1; + private static final int HANDLER_START_TASK = OsmAndConstants.UI_HANDLER_PROGRESS + 1; + private static final int HADLER_UPDATE_PROGRESS = OsmAndConstants.UI_HANDLER_PROGRESS + 2; private String taskName; private int progress; private int deltaProgress; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index bd0e992dd5..17e6fd9dae 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -19,6 +19,7 @@ import net.osmand.map.MapTileDownloader.DownloadRequest; import net.osmand.map.MapTileDownloader.IMapDownloaderCallback; import net.osmand.plus.ApplicationMode; import net.osmand.plus.BusyIndicator; +import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; @@ -68,8 +69,8 @@ import android.widget.Toast; public class MapActivity extends AccessibleActivity { - private static final int SHOW_POSITION_MSG_ID = 7; - private static final int LONG_KEYPRESS_MSG_ID = 28; + private static final int SHOW_POSITION_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 1; + private static final int LONG_KEYPRESS_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_VIEW + 2; private static final int LONG_KEYPRESS_DELAY = 500; private static MapViewTrackingUtilities mapViewTrackingUtilities; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java index 21484e6353..3572bebffe 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchByNameAbstractActivity.java @@ -15,6 +15,7 @@ import net.osmand.CollatorStringMatcher.StringMatcherMode; import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.data.MapObject; +import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; @@ -66,8 +67,8 @@ public abstract class SearchByNameAbstractActivity extends OsmandListActivity private EditText searchText; private AsyncTask initializeTask; - protected static final int MESSAGE_CLEAR_LIST = 1; - protected static final int MESSAGE_ADD_ENTITY = 2; + protected static final int MESSAGE_CLEAR_LIST = OsmAndConstants.UI_HANDLER_SEARCH + 2; + protected static final int MESSAGE_ADD_ENTITY = OsmAndConstants.UI_HANDLER_SEARCH + 3; protected static final String SEQUENTIAL_SEARCH = "SEQUENTIAL_SEARCH"; protected ProgressBar progress; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index 01d0f1faf9..c8bacb8718 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -28,6 +28,7 @@ import net.osmand.plus.NameFinderPoiFilter; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; +import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.PoiFilter; @@ -94,6 +95,7 @@ import com.actionbarsherlock.view.Window; */ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompassListener, OsmAndLocationListener { + private static final int COMPASS_REFRESH_MSG_ID = OsmAndConstants.UI_HANDLER_SEARCH + 3; public static final String AMENITY_FILTER = "net.osmand.amenity_filter"; //$NON-NLS-1$ public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT; //$NON-NLS-1$ public static final String SEARCH_LON = SearchActivity.SEARCH_LON; //$NON-NLS-1$ @@ -517,14 +519,14 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa @Override public void updateCompassValue(float value) { heading = value; - if(!uiHandler.hasMessages(5)){ + if(!uiHandler.hasMessages(COMPASS_REFRESH_MSG_ID)){ Message msg = Message.obtain(uiHandler, new Runnable(){ @Override public void run() { amenityAdapter.notifyDataSetChanged(); } }); - msg.what = 5; + msg.what = COMPASS_REFRESH_MSG_ID; uiHandler.sendMessageDelayed(msg, 100); } } diff --git a/OsmAnd/src/net/osmand/plus/base/BasicProgressAsyncTask.java b/OsmAnd/src/net/osmand/plus/base/BasicProgressAsyncTask.java index c470cbb0c5..77efe1527d 100644 --- a/OsmAnd/src/net/osmand/plus/base/BasicProgressAsyncTask.java +++ b/OsmAnd/src/net/osmand/plus/base/BasicProgressAsyncTask.java @@ -1,6 +1,7 @@ package net.osmand.plus.base; import net.osmand.IProgress; +import net.osmand.plus.OsmAndConstants; import net.osmand.plus.R; import android.content.Context; import android.os.AsyncTask; @@ -77,7 +78,7 @@ public abstract class BasicProgressAsyncTask extends A updateProgress(updateOnlyProgress); } }); - msg.what = 1; + msg.what = OsmAndConstants.UI_HANDLER_PROGRESS + 2; uiHandler.sendMessage(msg); } } diff --git a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java index e5af70da4b..411ea61e80 100644 --- a/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java +++ b/OsmAnd/src/net/osmand/plus/base/MapViewTrackingUtilities.java @@ -7,6 +7,7 @@ import net.osmand.map.IMapLocationListener; import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; +import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.AutoZoomMap; @@ -19,7 +20,7 @@ import android.content.Context; import android.view.WindowManager; public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLocationListener, OsmAndCompassListener { - private static final int AUTO_FOLLOW_MSG_ID = 8; + private static final int AUTO_FOLLOW_MSG_ID = OsmAndConstants.UI_HANDLER_LOCATION_SERVICE + 4; private long lastTimeAutoZooming = 0; private long lastTimeSensorMapRotation = 0; diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index b33caa8067..231aed7184 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -9,6 +9,7 @@ import net.londatiga.android.ActionItem; import net.londatiga.android.QuickAction; import net.osmand.data.RotatedTileBox; import net.osmand.plus.ApplicationMode; +import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings.CommonPreference; @@ -41,7 +42,7 @@ import android.widget.SeekBar; public class MapControlsLayer extends OsmandMapLayer { - private static final int SHOW_ZOOM_LEVEL_MSG_ID = 3; + private static final int SHOW_ZOOM_LEVEL_MSG_ID = OsmAndConstants.UI_HANDLER_MAP_CONTROLS + 1; private static final int SHOW_ZOOM_LEVEL_DELAY = 4000; diff --git a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java index 5be6f5dca1..f75d1a1e18 100644 --- a/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java +++ b/OsmAnd/src/net/osmand/plus/views/OsmandMapTileView.java @@ -16,6 +16,7 @@ import net.osmand.data.RotatedTileBox; import net.osmand.map.IMapLocationListener; import net.osmand.map.MapTileDownloader.DownloadRequest; import net.osmand.map.MapTileDownloader.IMapDownloaderCallback; +import net.osmand.plus.OsmAndConstants; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; @@ -53,8 +54,8 @@ import android.widget.Toast; public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCallback, Callback { - private static final int MAP_REFRESH_MESSAGE = 1; - private static final int BASE_REFRESH_MESSAGE = 2; + private static final int MAP_REFRESH_MESSAGE = OsmAndConstants.UI_HANDLER_MAP_VIEW + 4; + private static final int BASE_REFRESH_MESSAGE = OsmAndConstants.UI_HANDLER_MAP_VIEW + 3; protected final static int LOWEST_ZOOM_TO_ROTATE = 9; private boolean MEASURE_FPS = false; private FPSMeasurement main = new FPSMeasurement();