Small changes

This commit is contained in:
Victor Shcherb 2014-11-29 13:21:48 +01:00
parent 52dd94adc7
commit a0800890f3
7 changed files with 54 additions and 28 deletions

View file

@ -7,12 +7,16 @@
android:background="@drawable/bg_cardui" android:background="@drawable/bg_cardui"
android:orientation="vertical" > android:orientation="vertical" >
<TextView <LinearLayout
android:id="@+id/search_for" android:layout_width="match_parent"
style="@style/DashboardSubHeader" android:layout_height="wrap_content">
android:layout_width="wrap_content" <TextView
android:layout_height="40dp" android:id="@+id/search_for"
android:text="@string/search_for" /> style="@style/DashboardSubHeader"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:text="@string/search_for" />
</LinearLayout>
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="error_avoid_specific_road">Nearest road was not found</string>
<string name="home_button">Home</string> <string name="home_button">Home</string>
<string name="osmo_use_https_descr">Use secure connection with server</string> <string name="osmo_use_https_descr">Use secure connection with server</string>
<string name="osmo_use_https">Use https</string> <string name="osmo_use_https">Use https</string>

View file

@ -42,35 +42,32 @@ public class CurrentPositionHelper {
ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, app.getResourceManager().getRoutingMapFiles()); ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, app.getResourceManager().getRoutingMapFiles());
} }
public synchronized RouteDataObject runUpdateInThread(double lat , double lon) { public synchronized RouteDataObject runUpdateInThread(double lat, double lon) throws IOException {
RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(false); RoutePlannerFrontEnd rp = new RoutePlannerFrontEnd(false);
try { if (ctx == null || am != app.getSettings().getApplicationMode()) {
if(ctx == null || am != app.getSettings().getApplicationMode()) { initCtx(app);
initCtx(app); if (ctx == null) {
if(ctx == null) {
return null;
}
}
RouteSegment sg = rp.findRouteSegment(lat, lon, ctx);
if(sg == null) {
return null; return null;
} }
return sg.getRoad(); }
} catch (IOException e) { RouteSegment sg = rp.findRouteSegment(lat, lon, ctx);
if (sg == null) {
return null; return null;
} }
return sg.getRoad();
} }
private void scheduleRouteSegmentFind(final Location loc){ private void scheduleRouteSegmentFind(final Location loc){
if(calculatingThread == Thread.currentThread()) { if(calculatingThread == Thread.currentThread()) {
lastFound = runUpdateInThread(loc.getLatitude(), loc.getLongitude()); lastFound = runUpdateInThreadCatch(loc.getLatitude(), loc.getLongitude());
} else if(calculatingThread == null && loc != null) { } else if(calculatingThread == null && loc != null) {
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
lastFound = runUpdateInThread(loc.getLatitude(), loc.getLongitude()); lastFound = runUpdateInThreadCatch(loc.getLatitude(), loc.getLongitude());
if (lastAskedLocation != loc) { if (lastAskedLocation != loc) {
// refresh and run new task if needed // refresh and run new task if needed
getLastKnownRouteSegment(lastAskedLocation); getLastKnownRouteSegment(lastAskedLocation);
@ -85,6 +82,15 @@ public class CurrentPositionHelper {
} }
protected RouteDataObject runUpdateInThreadCatch(double latitude, double longitude) {
try {
return runUpdateInThread(latitude, longitude);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private static double getOrthogonalDistance(RouteDataObject r, Location loc){ private static double getOrthogonalDistance(RouteDataObject r, Location loc){
double d = 1000; double d = 1000;
if (r.getPointsLength() > 0) { if (r.getPointsLength() > 0) {

View file

@ -216,7 +216,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
} }
public RouteDataObject findRoute(double lat , double lon) { public RouteDataObject findRoute(double lat , double lon) {
return currentPositionHelper.runUpdateInThread(lat, lon); return currentPositionHelper.runUpdateInThreadCatch(lat, lon);
} }
public void resumeAllUpdates() { public void resumeAllUpdates() {

View file

@ -1,18 +1,21 @@
package net.osmand.plus.dashboard; package net.osmand.plus.dashboard;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchActivity;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.search.SearchActivity;
/** /**
* Created by Denis on 24.11.2014. * Created by Denis on 24.11.2014.
@ -25,6 +28,7 @@ public class DashSearchFragment extends DashBaseFragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.dash_search_fragment, container, false); View view = getActivity().getLayoutInflater().inflate(R.layout.dash_search_fragment, container, false);
setupButtons(view); setupButtons(view);
// TODO cache typeface ?
Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Medium.ttf"); Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Medium.ttf");
((TextView) view.findViewById(R.id.search_for)).setTypeface(typeface); ((TextView) view.findViewById(R.id.search_for)).setTypeface(typeface);
return view; return view;
@ -39,6 +43,8 @@ public class DashSearchFragment extends DashBaseFragment {
private void setupButtons(View view){ private void setupButtons(View view){
final Activity activity = getActivity(); final Activity activity = getActivity();
final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization(); final OsmAndAppCustomization appCustomization = getMyApplication().getAppCustomization();
// EditText searchText = (EditText) view.findViewById(R.id.search_text);
// searchText.addTextChangedListener(textWatcher);
(view.findViewById(R.id.poi)).setOnClickListener(new View.OnClickListener() { (view.findViewById(R.id.poi)).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {

View file

@ -27,6 +27,7 @@ import android.widget.ArrayAdapter;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
public class AvoidSpecificRoads { public class AvoidSpecificRoads {
private List<RouteDataObject> missingRoads; private List<RouteDataObject> missingRoads;
@ -143,14 +144,23 @@ public class AvoidSpecificRoads {
} }
private void findRoad(final MapActivity activity, final LatLon loc) { private void findRoad(final MapActivity activity, final LatLon loc) {
new AsyncTask<LatLon, Void, RouteDataObject>() { new AsyncTask<LatLon, Void, RouteDataObject>() {
Exception e = null;
@Override @Override
protected RouteDataObject doInBackground(LatLon... params) { protected RouteDataObject doInBackground(LatLon... params) {
return app.getLocationProvider().findRoute(loc.getLatitude(), loc.getLongitude()); try {
return app.getLocationProvider().findRoute(loc.getLatitude(), loc.getLongitude());
} catch (Exception e) {
this.e = e;
e.printStackTrace();
return null;
}
} }
protected void onPostExecute(RouteDataObject result) { protected void onPostExecute(RouteDataObject result) {
if(result != null) { if(e != null) {
Toast.makeText(activity, R.string.error_avoid_specific_road, Toast.LENGTH_LONG).show();
} else if(result != null) {
getBuilder().addImpassableRoad(result); getBuilder().addImpassableRoad(result);
RoutingHelper rh = app.getRoutingHelper(); RoutingHelper rh = app.getRoutingHelper();
if(rh.isRouteCalculated() || rh.isRouteBeingCalculated()) { if(rh.isRouteCalculated() || rh.isRouteBeingCalculated()) {

View file

@ -6,7 +6,6 @@ import android.graphics.Canvas;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.View; import android.view.View;
public class OsmAndMapLayersView extends View { public class OsmAndMapLayersView extends View {