Fix NoSuchMethodError, possible npe and improve ui
This commit is contained in:
parent
16fde2606e
commit
79f23d96ca
11 changed files with 110 additions and 74 deletions
|
@ -37,7 +37,7 @@ public class TransportRoutePlanner {
|
|||
for(TransportRouteSegment s : endStops) {
|
||||
endSegments.put(s.getId(), s);
|
||||
}
|
||||
PriorityQueue<TransportRouteSegment> queue = new PriorityQueue<TransportRouteSegment>(new SegmentsComparator(ctx));
|
||||
PriorityQueue<TransportRouteSegment> queue = new PriorityQueue<TransportRouteSegment>(startStops.size(), new SegmentsComparator(ctx));
|
||||
for(TransportRouteSegment r : startStops){
|
||||
r.walkDist = (float) MapUtils.getDistance(r.getLocation(), start);
|
||||
r.distFromStart = r.walkDist / ctx.cfg.walkSpeed;
|
||||
|
|
10
OsmAnd/res/drawable/btn_border_pressed_trans_dark.xml
Normal file
10
OsmAnd/res/drawable/btn_border_pressed_trans_dark.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<solid android:color="@color/active_buttons_and_links_trans_dark" />
|
||||
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_dark" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
10
OsmAnd/res/drawable/btn_border_pressed_trans_light.xml
Normal file
10
OsmAnd/res/drawable/btn_border_pressed_trans_light.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<solid android:color="@color/active_buttons_and_links_trans_light" />
|
||||
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_light" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
9
OsmAnd/res/drawable/btn_pressed_trans_dark.xml
Normal file
9
OsmAnd/res/drawable/btn_pressed_trans_dark.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<solid android:color="@color/active_buttons_and_links_trans_dark" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
10
OsmAnd/res/drawable/btn_pressed_trans_light.xml
Normal file
10
OsmAnd/res/drawable/btn_pressed_trans_light.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true">
|
||||
<shape android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<solid android:color="@color/active_buttons_and_links_trans_light" />
|
||||
<stroke android:width="1dp" android:color="@color/active_buttons_and_links_light" />
|
||||
</shape>
|
||||
</item>
|
||||
</selector>
|
|
@ -1,19 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/route_option_button"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="32dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="visible"
|
||||
tools:background="@drawable/btn_border_dark">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/removable_option"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/route_removable_option_container"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -31,8 +26,8 @@
|
|||
android:gravity="center"
|
||||
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||
android:maxLines="1"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingTop="3dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:text="@string/routing_attr_avoid_motorway_name"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
|
@ -57,10 +52,11 @@
|
|||
android:layout_gravity="end|center_vertical"
|
||||
android:layout_marginLeft="1dp"
|
||||
android:layout_marginRight="1dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingLeft="@dimen/route_info_icon_vertical_padding"
|
||||
android:paddingRight="@dimen/route_info_icon_vertical_padding"
|
||||
android:paddingTop="3dp"
|
||||
android:paddingRight="@dimen/route_info_icon_vertical_padding"
|
||||
android:paddingBottom="3dp"
|
||||
android:contentDescription="@string/shared_string_remove"
|
||||
tools:src="@drawable/ic_action_remove_dark" />
|
||||
|
||||
<View
|
||||
|
@ -69,6 +65,4 @@
|
|||
android:layout_height="16dp"
|
||||
android:layout_gravity="end|center_vertical" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
|
@ -157,9 +157,10 @@ public class AppModeDialog {
|
|||
}
|
||||
iv.setImageDrawable(drawable);
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||
AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.btn_border_pressed_light, R.drawable.btn_border_pressed_dark);
|
||||
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.btn_border_pressed_light, R.drawable.btn_border_pressed_dark);
|
||||
AndroidUtils.setBackground(ctx, selection, nightMode, R.drawable.btn_border_pressed_trans_light, R.drawable.btn_border_pressed_trans_dark);
|
||||
}
|
||||
} else {
|
||||
iv.setImageDrawable(ctx.getUIUtilities().getThemedIcon(mode.getSmallIconDark()));
|
||||
|
|
|
@ -874,7 +874,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||
AndroidUtils.setForeground(app, container, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||
} else {
|
||||
AndroidUtils.setForeground(app, container, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||
AndroidUtils.setForeground(app, container, nightMode, R.drawable.btn_pressed_trans_light, R.drawable.btn_pressed_trans_dark);
|
||||
}
|
||||
AndroidUtils.setBackground(app, container.findViewById(R.id.options_divider_end), nightMode, R.color.divider_light, R.color.divider_dark);
|
||||
AndroidUtils.setBackground(app, routeOptionImageView, nightMode, R.drawable.route_info_trans_gradient_light, R.drawable.route_info_trans_gradient_dark);
|
||||
|
@ -1450,7 +1450,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
@Override
|
||||
public long getItemId(int position) {
|
||||
RouteSpinnerRow row = getItem(position);
|
||||
return row.id;
|
||||
return row != null ? row.id : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1462,7 +1462,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
View getRowItemView(int position, View convertView, ViewGroup parent) {
|
||||
TextView label = (TextView) super.getView(position, convertView, parent);
|
||||
RouteSpinnerRow row = getItem(position);
|
||||
label.setText(row.text);
|
||||
label.setText(row != null ? row.text : "");
|
||||
label.setTextColor(!isLight() ?
|
||||
ContextCompat.getColorStateList(mapActivity, android.R.color.primary_text_dark) : ContextCompat.getColorStateList(mapActivity, android.R.color.primary_text_light));
|
||||
return label;
|
||||
|
@ -1473,8 +1473,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
TextView label = (TextView) super.getDropDownView(position, convertView, parent);
|
||||
|
||||
RouteSpinnerRow row = getItem(position);
|
||||
label.setText(row.text);
|
||||
if (id != SPINNER_HINT_ID) {
|
||||
label.setText(row != null ? row.text : "");
|
||||
if (row != null && id != SPINNER_HINT_ID) {
|
||||
Drawable icon = null;
|
||||
if (row.icon != null) {
|
||||
icon = row.icon;
|
||||
|
|
|
@ -227,7 +227,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
@Override
|
||||
public String getTitle() {
|
||||
List<Object> activeObjects;
|
||||
if ((getMyApplication().getRoutingHelper().isRoutePlanningMode() || getMyApplication().getRoutingHelper().isFollowingMode())
|
||||
if ((mapActivity.getRoutingHelper().isRoutePlanningMode() || mapActivity.getRoutingHelper().isFollowingMode())
|
||||
&& item != null
|
||||
&& ((activeObjects = stableAdapter.getActiveObjects()).isEmpty() || isContainsOnlyStart(activeObjects))) {
|
||||
return mapActivity.getResources().getString(R.string.cancel_navigation);
|
||||
|
@ -247,7 +247,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
List<Object> activeObjects = stableAdapter.getActiveObjects();
|
||||
if (activeObjects.isEmpty() || isContainsOnlyStart(activeObjects)) {
|
||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||
getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, true);
|
||||
mapActivity.getMyApplication().getTargetPointsHelper().removeAllWayPoints(false, true);
|
||||
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().hide();
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
}
|
||||
|
||||
addButtonDescr.setText(R.string.shared_string_add);
|
||||
addButtonDescr.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_plus, R.color.active_buttons_and_links_light), null, null, null);
|
||||
addButtonDescr.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_plus, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light), null, null, null);
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||
AndroidUtils.setBackground(app, addButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
|
||||
AndroidUtils.setBackground(app, addButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||
|
@ -425,13 +425,13 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
FrameLayout clearButton = view.findViewById(R.id.clear_all_button);
|
||||
TextView clearButtonDescr = (TextView) view.findViewById(R.id.clear_all_button_descr);
|
||||
clearButtonDescr.setText(R.string.shared_string_clear_all);
|
||||
clearButtonDescr.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_clear_all, R.color.active_buttons_and_links_light), null, null, null);
|
||||
AndroidUtils.setBackground(app, clearButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
|
||||
clearButtonDescr.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_clear_all, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light), null, null, null);
|
||||
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP) {
|
||||
AndroidUtils.setBackground(app, clearButton, nightMode, R.drawable.btn_border_light, R.drawable.btn_border_dark);
|
||||
AndroidUtils.setBackground(app, clearButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(app, clearButtonDescr, nightMode, R.drawable.ripple_light, R.drawable.ripple_dark);
|
||||
AndroidUtils.setBackground(app, clearButtonDescr, nightMode, R.drawable.btn_border_trans_light, R.drawable.btn_border_trans_dark);
|
||||
}
|
||||
|
||||
AndroidUtils.setBackground(app, view.findViewById(R.id.dividerControlButtons), nightMode,
|
||||
|
@ -468,7 +468,9 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
||||
if (listAdapter.getItem(item) instanceof WaypointHelper.LocationPointWrapper) {
|
||||
WaypointHelper.LocationPointWrapper ps = (WaypointHelper.LocationPointWrapper) listAdapter.getItem(item);
|
||||
if (ps != null) {
|
||||
showOnMap(app, ctx, ps.getPoint(), false);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
@ -552,7 +554,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
|
||||
public void setupRouteCalculationButtonProgressBar(@NonNull ProgressBar pb) {
|
||||
int bgColor = ContextCompat.getColor(app, nightMode ? R.color.route_info_cancel_button_color_dark : R.color.activity_background_light);
|
||||
int progressColor = ContextCompat.getColor(getMyApplication(), nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||
int progressColor = ContextCompat.getColor(app, nightMode ? R.color.active_buttons_and_links_dark : R.color.active_buttons_and_links_light);
|
||||
|
||||
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
|
||||
}
|
||||
|
@ -565,7 +567,7 @@ public class WaypointsFragment extends BaseOsmAndFragment implements ObservableS
|
|||
private void updateListAdapter() {
|
||||
List<WaypointHelper.LocationPointWrapper> deletedPoints = new ArrayList<>();
|
||||
listView.setEmptyView(null);
|
||||
StableArrayAdapter listAdapter = getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running, false, false);
|
||||
StableArrayAdapter listAdapter = getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running, false, nightMode);
|
||||
AdapterView.OnItemClickListener listener = getDrawerItemClickListener(mapActivity, running, listAdapter);
|
||||
setDynamicListItems(listView, listAdapter);
|
||||
updateListAdapter(listAdapter, listener);
|
||||
|
|
|
@ -27,6 +27,7 @@ public abstract class BaseRouteCard {
|
|||
public BaseRouteCard(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
this.app = mapActivity.getMyApplication();
|
||||
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
}
|
||||
|
||||
public abstract int getCardLayoutId();
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.routepreparationmenu.routeCards;
|
|||
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.RippleDrawable;
|
||||
import android.os.Build;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.SpannableString;
|
||||
|
|
Loading…
Reference in a new issue