use of net.osmand.plus.activities.LocalIndexHelper in project Osmand by osmandapp.
the class DownloadedRegionsLayer method initLayer.
@Override
public void initLayer(final OsmandMapTileView view) {
this.view = view;
app = view.getApplication();
rm = app.getResourceManager();
osmandRegions = rm.getOsmandRegions();
helper = new LocalIndexHelper(app);
paintDownloaded = getPaint(view.getResources().getColor(R.color.region_uptodate));
paintSelected = getPaint(view.getResources().getColor(R.color.region_selected));
paintBackuped = getPaint(view.getResources().getColor(R.color.region_backuped));
textPaint = new TextPaint();
final WindowManager wmgr = (WindowManager) view.getApplication().getSystemService(Context.WINDOW_SERVICE);
DisplayMetrics dm = new DisplayMetrics();
wmgr.getDefaultDisplay().getMetrics(dm);
textPaint.setStrokeWidth(21 * dm.scaledDensity);
textPaint.setAntiAlias(true);
textPaint.setTextAlign(Paint.Align.CENTER);
pathDownloaded = new Path();
pathSelected = new Path();
pathBackuped = new Path();
data = new MapLayerData<List<BinaryMapDataObject>>() {
@Override
public void layerOnPostExecute() {
view.refreshMap();
}
public boolean queriedBoxContains(final RotatedTileBox queriedData, final RotatedTileBox newBox) {
if (newBox.getZoom() < ZOOM_TO_SHOW_SELECTION) {
if (queriedData != null && queriedData.getZoom() < ZOOM_TO_SHOW_SELECTION) {
return queriedData.containsTileBox(newBox);
} else {
return false;
}
}
List<BinaryMapDataObject> queriedResults = getResults();
if (queriedData != null && queriedData.containsTileBox(newBox) && queriedData.getZoom() >= ZOOM_TO_SHOW_MAP_NAMES) {
if (queriedResults != null && (queriedResults.isEmpty() || Math.abs(queriedData.getZoom() - newBox.getZoom()) <= 1)) {
return true;
}
}
return false;
}
@Override
protected List<BinaryMapDataObject> calculateResult(RotatedTileBox tileBox) {
return queryData(tileBox);
}
};
}
use of net.osmand.plus.activities.LocalIndexHelper in project Osmand by osmandapp.
the class AppInitializer method checkLiveUpdatesAlerts.
private void checkLiveUpdatesAlerts() {
OsmandSettings settings = app.getSettings();
if (!settings.IS_LIVE_UPDATES_ON.get()) {
return;
}
LocalIndexHelper helper = new LocalIndexHelper(app);
List<LocalIndexInfo> fullMaps = helper.getLocalFullMaps(new AbstractLoadLocalIndexTask() {
@Override
public void loadFile(LocalIndexInfo... loaded) {
}
});
AlarmManager alarmMgr = (AlarmManager) app.getSystemService(Context.ALARM_SERVICE);
for (LocalIndexInfo fm : fullMaps) {
String fileName = fm.getFileName();
if (!preferenceLiveUpdatesOn(fileName, settings).get()) {
continue;
}
int updateFrequencyOrd = preferenceUpdateFrequency(fileName, settings).get();
LiveUpdatesHelper.UpdateFrequency updateFrequency = LiveUpdatesHelper.UpdateFrequency.values()[updateFrequencyOrd];
long lastCheck = preferenceLastCheck(fileName, settings).get();
if (System.currentTimeMillis() - lastCheck > updateFrequency.getTime() * 2) {
runLiveUpdate(app, fileName, false);
PendingIntent alarmIntent = getPendingIntent(app, fileName);
int timeOfDayOrd = preferenceTimeOfDayToUpdate(fileName, settings).get();
LiveUpdatesHelper.TimeOfDay timeOfDayToUpdate = LiveUpdatesHelper.TimeOfDay.values()[timeOfDayOrd];
setAlarmForPendingIntent(alarmIntent, alarmMgr, updateFrequency, timeOfDayToUpdate);
}
}
}
Aggregations