Fix favorites
This commit is contained in:
parent
072087ae2c
commit
8e5aa00648
4 changed files with 117 additions and 135 deletions
|
@ -63,8 +63,8 @@
|
||||||
android:id="@+id/direction"
|
android:id="@+id/direction"
|
||||||
android:layout_width="@dimen/dashFavDirectionSize"
|
android:layout_width="@dimen/dashFavDirectionSize"
|
||||||
android:layout_height="@dimen/dashFavDirectionSize"
|
android:layout_height="@dimen/dashFavDirectionSize"
|
||||||
android:layout_gravity="center_vertical"
|
android:src="@drawable/ic_destination_arrow_white"
|
||||||
android:visibility="gone" />
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/distance"
|
android:id="@+id/distance"
|
||||||
|
|
|
@ -128,20 +128,26 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
||||||
Location.distanceBetween(toLat, toLon, fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
|
Location.distanceBetween(toLat, toLon, fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
|
||||||
}
|
}
|
||||||
if (arrow != null) {
|
if (arrow != null) {
|
||||||
if (!(arrow.getDrawable() instanceof DirectionDrawable)) {
|
boolean newImage = false;
|
||||||
DirectionDrawable dd = new DirectionDrawable(ctx, 10, 10);
|
|
||||||
arrow.setImageDrawable(dd);
|
|
||||||
}
|
|
||||||
if (arrowResId == 0) {
|
if (arrowResId == 0) {
|
||||||
arrowResId = R.drawable.ic_destination_arrow_white;
|
arrowResId = R.drawable.ic_destination_arrow_white;
|
||||||
}
|
}
|
||||||
DirectionDrawable dd = (DirectionDrawable) arrow.getDrawable();
|
DirectionDrawable dd;
|
||||||
|
if(!(arrow.getDrawable() instanceof DirectionDrawable)) {
|
||||||
|
newImage = true;
|
||||||
|
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight());
|
||||||
|
} else {
|
||||||
|
dd = (DirectionDrawable) arrow.getDrawable();
|
||||||
|
}
|
||||||
dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance);
|
dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance);
|
||||||
if (fromLoc == null || h == null) {
|
if (fromLoc == null || h == null) {
|
||||||
dd.setAngle(0);
|
dd.setAngle(0);
|
||||||
} else {
|
} else {
|
||||||
dd.setAngle(mes[1] - h + 180 + screenOrientation);
|
dd.setAngle(mes[1] - h + 180 + screenOrientation);
|
||||||
}
|
}
|
||||||
|
if (newImage) {
|
||||||
|
arrow.setImageDrawable(dd);
|
||||||
|
}
|
||||||
arrow.invalidate();
|
arrow.invalidate();
|
||||||
}
|
}
|
||||||
if (txt != null) {
|
if (txt != null) {
|
||||||
|
|
|
@ -3,9 +3,7 @@ package net.osmand.plus.dialogs;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
@ -14,30 +12,28 @@ import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.AutoCompleteTextView;
|
import android.widget.AutoCompleteTextView;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ListView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class FavoriteDialogs {
|
public class FavoriteDialogs {
|
||||||
|
@ -46,87 +42,19 @@ public class FavoriteDialogs {
|
||||||
public static Dialog createReplaceFavouriteDialog(final Activity activity, final Bundle args) {
|
public static Dialog createReplaceFavouriteDialog(final Activity activity, final Bundle args) {
|
||||||
final FavouritesDbHelper helper = ((OsmandApplication) activity.getApplication()).getFavorites();
|
final FavouritesDbHelper helper = ((OsmandApplication) activity.getApplication()).getFavorites();
|
||||||
final List<FavouritePoint> points = new ArrayList<FavouritePoint>(helper.getFavouritePoints());
|
final List<FavouritePoint> points = new ArrayList<FavouritePoint>(helper.getFavouritePoints());
|
||||||
final Collator ci = java.text.Collator.getInstance();
|
final FavouritesAdapter favouritesAdapter = new FavouritesAdapter(activity,
|
||||||
final boolean distance = args.containsKey("DISTANCE");
|
((OsmandApplication) activity.getApplication()).getFavorites().getFavouritePoints());
|
||||||
Collections.sort(points, new Comparator<FavouritePoint>() {
|
final Dialog[] dlgHolder = new Dialog[1];
|
||||||
|
OnItemClickListener click = new AdapterView.OnItemClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(FavouritePoint o1, FavouritePoint o2) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
if (distance && activity instanceof MapActivity) {
|
FavouritePoint fp = favouritesAdapter.getItem(position);
|
||||||
float f1 = (float) MapUtils.getDistance(((MapActivity) activity).getMapLocation(), o1.getLatitude(),
|
if(dlgHolder != null && dlgHolder.length > 0 && dlgHolder[0] != null) {
|
||||||
o1.getLongitude());
|
dlgHolder[0].dismiss();
|
||||||
float f2 = (float) MapUtils.getDistance(((MapActivity) activity).getMapLocation(), o2.getLatitude(),
|
|
||||||
o2.getLongitude());
|
|
||||||
return Float.compare(f1, f2);
|
|
||||||
}
|
}
|
||||||
return ci.compare(o1.getCategory() + " " + o1.getName(), o2.getCategory() + " " + o2.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
final String[] names = new String[points.size()];
|
|
||||||
if(points.size() == 0){
|
|
||||||
AccessibleToast.makeText(activity, activity.getString(R.string.fav_points_not_exist), Toast.LENGTH_SHORT).show();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Builder b = new AlertDialog.Builder(activity);
|
|
||||||
final FavouritePoint[] favs = new FavouritePoint[points.size()];
|
|
||||||
Iterator<FavouritePoint> it = points.iterator();
|
|
||||||
int i=0;
|
|
||||||
while (it.hasNext()) {
|
|
||||||
FavouritePoint fp = it.next();
|
|
||||||
// filter gpx points
|
|
||||||
favs[i] = fp;
|
|
||||||
if(fp.getCategory().trim().length() ==0){
|
|
||||||
names[i] = fp.getName();
|
|
||||||
} else {
|
|
||||||
names[i] = fp.getCategory() + ": " + fp.getName();
|
|
||||||
}
|
|
||||||
if(activity instanceof MapActivity) {
|
|
||||||
names[i] += " " + OsmAndFormatter.getFormattedDistance(
|
|
||||||
(float) MapUtils.getDistance(((MapActivity) activity).getMapLocation(), fp.getLatitude(),
|
|
||||||
fp.getLongitude()), ((MapActivity) activity).getMyApplication());
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
final int layout;
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
|
|
||||||
layout = R.layout.list_menu_item;
|
|
||||||
} else {
|
|
||||||
layout = R.layout.list_menu_item_native;
|
|
||||||
}
|
|
||||||
final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(activity, layout, R.id.title,
|
|
||||||
names) {
|
|
||||||
@Override
|
|
||||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
|
||||||
// User super class to create the View
|
|
||||||
View v = convertView;
|
|
||||||
if (v == null) {
|
|
||||||
v = activity.getLayoutInflater().inflate(layout, null);
|
|
||||||
int vl = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, activity.getResources()
|
|
||||||
.getDisplayMetrics());
|
|
||||||
final LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(vl, vl);
|
|
||||||
ll.setMargins(vl / 4, vl / 4, vl / 4, vl / 4);
|
|
||||||
v.findViewById(R.id.icon).setLayoutParams(ll);
|
|
||||||
}
|
|
||||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
|
||||||
FavouritePoint fp = points.get(position);
|
|
||||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, fp.getColor()));
|
|
||||||
|
|
||||||
icon.setVisibility(View.VISIBLE);
|
|
||||||
TextView tv = (TextView) v.findViewById(R.id.title);
|
|
||||||
tv.setText(names[position]);
|
|
||||||
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
|
|
||||||
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
|
|
||||||
ch.setVisibility(View.INVISIBLE);
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
b.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
FavouritePoint fv = favs[which];
|
|
||||||
FavouritePoint point = (FavouritePoint) args.getSerializable(KEY_FAVORITE);
|
FavouritePoint point = (FavouritePoint) args.getSerializable(KEY_FAVORITE);
|
||||||
if (helper.editFavourite(fv, point.getLatitude(), point.getLongitude())) {
|
if (helper.editFavourite(fp, point.getLatitude(), point.getLongitude())) {
|
||||||
AccessibleToast.makeText(activity, activity.getString(R.string.fav_points_edited),
|
AccessibleToast.makeText(activity, activity.getString(R.string.fav_points_edited),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
@ -134,24 +62,16 @@ public class FavoriteDialogs {
|
||||||
((MapActivity) activity).getMapView().refreshMap();
|
((MapActivity) activity).getMapView().refreshMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
if (activity instanceof MapActivity) {
|
if (activity instanceof MapActivity) {
|
||||||
b.setPositiveButton(distance ? R.string.sort_by_name : R.string.sort_by_distance,
|
favouritesAdapter.updateLocation(((MapActivity) activity).getMapLocation());
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (distance) {
|
|
||||||
args.remove("DISTANCE");
|
|
||||||
} else {
|
|
||||||
args.putBoolean("DISTANCE", true);
|
|
||||||
}
|
}
|
||||||
createReplaceFavouriteDialog(activity, args).show();
|
final String[] names = new String[points.size()];
|
||||||
|
if(points.size() == 0){
|
||||||
|
AccessibleToast.makeText(activity, activity.getString(R.string.fav_points_not_exist), Toast.LENGTH_SHORT).show();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
});
|
return showFavoritesDialog(activity, favouritesAdapter, click, null, dlgHolder, true);
|
||||||
}
|
|
||||||
AlertDialog al = b.create();
|
|
||||||
return al;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void prepareAddFavouriteDialog(Activity activity, Dialog dialog, Bundle args, double lat, double lon, PointDescription desc) {
|
public static void prepareAddFavouriteDialog(Activity activity, Dialog dialog, Bundle args, double lat, double lon, PointDescription desc) {
|
||||||
|
@ -242,4 +162,49 @@ public class FavoriteDialogs {
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final AlertDialog showFavoritesDialog(
|
||||||
|
final Context uiContext,
|
||||||
|
final FavouritesAdapter favouritesAdapter, final OnItemClickListener click,
|
||||||
|
final OnDismissListener dismissListener, final Dialog[] dialogHolder, final boolean sortByDist) {
|
||||||
|
ListView listView = new ListView(uiContext);
|
||||||
|
Builder bld = new AlertDialog.Builder(uiContext);
|
||||||
|
final Collator inst = Collator.getInstance();
|
||||||
|
favouritesAdapter.sort(new Comparator<FavouritePoint>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(FavouritePoint lhs, FavouritePoint rhs) {
|
||||||
|
if (sortByDist) {
|
||||||
|
if (favouritesAdapter.getLocation() == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
double ld = MapUtils.getDistance(favouritesAdapter.getLocation(), lhs.getLatitude(),
|
||||||
|
lhs.getLongitude());
|
||||||
|
double rd = MapUtils.getDistance(favouritesAdapter.getLocation(), rhs.getLatitude(),
|
||||||
|
rhs.getLongitude());
|
||||||
|
return Double.compare(ld, rd);
|
||||||
|
}
|
||||||
|
return inst.compare(lhs.getName(), rhs.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
listView.setAdapter(favouritesAdapter);
|
||||||
|
listView.setOnItemClickListener(click);
|
||||||
|
bld.setPositiveButton(sortByDist ? R.string.sort_by_name :
|
||||||
|
R.string.sort_by_distance, new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
showFavoritesDialog(uiContext, favouritesAdapter, click, dismissListener, dialogHolder, !sortByDist);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bld.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
bld.setView(listView);
|
||||||
|
AlertDialog dlg = bld.show();
|
||||||
|
if(dialogHolder != null) {
|
||||||
|
dialogHolder[0] = dlg;
|
||||||
|
}
|
||||||
|
dlg.setOnDismissListener(dismissListener);
|
||||||
|
return dlg;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package net.osmand.plus.views.controls;
|
package net.osmand.plus.views.controls;
|
||||||
|
|
||||||
|
import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
|
@ -14,22 +16,25 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
import net.osmand.plus.TargetPointsHelper;
|
||||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||||
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
||||||
import net.osmand.plus.activities.search.SearchActivity;
|
|
||||||
import net.osmand.plus.activities.search.SearchAddressActivity;
|
|
||||||
import net.osmand.plus.activities.search.SearchAddressFragment;
|
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.ShowRouteInfoActivity;
|
import net.osmand.plus.activities.ShowRouteInfoActivity;
|
||||||
|
import net.osmand.plus.activities.search.SearchAddressActivity;
|
||||||
|
import net.osmand.plus.activities.search.SearchAddressFragment;
|
||||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||||
|
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||||
import net.osmand.plus.routing.RouteDirectionInfo;
|
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||||
import net.osmand.plus.views.ContextMenuLayer;
|
import net.osmand.plus.views.ContextMenuLayer;
|
||||||
import net.osmand.plus.views.MapControlsLayer;
|
import net.osmand.plus.views.MapControlsLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
|
import net.osmand.util.MapUtils;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
import android.content.DialogInterface.OnDismissListener;
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
|
@ -38,6 +43,7 @@ import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.AdapterView.OnItemClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageButton;
|
import android.widget.ImageButton;
|
||||||
|
@ -52,7 +58,6 @@ public class MapRouteInfoControl implements IRouteInformationListener {
|
||||||
private final RoutingHelper routingHelper;
|
private final RoutingHelper routingHelper;
|
||||||
private OsmandMapTileView mapView;
|
private OsmandMapTileView mapView;
|
||||||
private Dialog dialog;
|
private Dialog dialog;
|
||||||
private AlertDialog favoritesDialog;
|
|
||||||
private boolean selectFromMapTouch;
|
private boolean selectFromMapTouch;
|
||||||
private boolean selectFromMapForTarget;
|
private boolean selectFromMapForTarget;
|
||||||
|
|
||||||
|
@ -229,12 +234,29 @@ public class MapRouteInfoControl implements IRouteInformationListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void selectFavorite(final View parentView, final boolean target) {
|
protected void selectFavorite(final View parentView, final boolean target) {
|
||||||
Builder bld = new AlertDialog.Builder(mapActivity);
|
final FavouritesAdapter favouritesAdapter = new FavouritesAdapter(mapActivity, mapActivity.getMyApplication()
|
||||||
ListView listView = new ListView(mapActivity);
|
.getFavorites().getFavouritePoints());
|
||||||
final FavouritesAdapter favouritesAdapter = new FavouritesAdapter(mapActivity, mapActivity.getMyApplication().getFavorites().getFavouritePoints());
|
Dialog[] dlgHolder = new Dialog[1];
|
||||||
|
OnItemClickListener click = getOnClickListener(target, favouritesAdapter, dlgHolder);
|
||||||
|
OnDismissListener dismissListener = new DialogInterface.OnDismissListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialog) {
|
||||||
|
if (target) {
|
||||||
|
setupToSpinner(parentView);
|
||||||
|
} else {
|
||||||
|
setupFromSpinner(parentView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
favouritesAdapter.updateLocation(mapActivity.getMapLocation());
|
favouritesAdapter.updateLocation(mapActivity.getMapLocation());
|
||||||
listView.setAdapter(favouritesAdapter);
|
FavoriteDialogs.showFavoritesDialog(mapActivity, favouritesAdapter, click, dismissListener, dlgHolder, true);
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private OnItemClickListener getOnClickListener(final boolean target, final FavouritesAdapter favouritesAdapter,
|
||||||
|
final Dialog[] dlg) {
|
||||||
|
return new AdapterView.OnItemClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
@ -245,25 +267,14 @@ public class MapRouteInfoControl implements IRouteInformationListener {
|
||||||
} else {
|
} else {
|
||||||
getTargets().setStartPoint(point, true, fp.getPointDescription());
|
getTargets().setStartPoint(point, true, fp.getPointDescription());
|
||||||
}
|
}
|
||||||
favoritesDialog.dismiss();
|
if(dlg != null && dlg.length > 0 && dlg[0] != null) {
|
||||||
|
dlg[0].dismiss();
|
||||||
|
}
|
||||||
//Next 2 lines ensure Dialog is shown in the right correct position after a selection been made
|
//Next 2 lines ensure Dialog is shown in the right correct position after a selection been made
|
||||||
hideDialog();
|
hideDialog();
|
||||||
showDialog();
|
showDialog();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
bld.setView(listView);
|
|
||||||
favoritesDialog = bld.show();
|
|
||||||
favoritesDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDismiss(DialogInterface dialog) {
|
|
||||||
if(target){
|
|
||||||
setupToSpinner(parentView);
|
|
||||||
} else {
|
|
||||||
setupFromSpinner(parentView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDirectionInfo() {
|
public static int getDirectionInfo() {
|
||||||
|
|
Loading…
Reference in a new issue