commit
4e62896c0a
5 changed files with 72 additions and 56 deletions
|
@ -11,6 +11,7 @@ import net.osmand.binary.RouteDataBundle;
|
|||
import net.osmand.binary.StringBundle;
|
||||
import net.osmand.binary.StringBundleWriter;
|
||||
import net.osmand.binary.StringBundleXmlWriter;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.xmlpull.v1.XmlSerializer;
|
||||
|
||||
|
@ -38,6 +39,7 @@ public class RouteExporter {
|
|||
RouteDataResources resources = new RouteDataResources(locations);
|
||||
final RouteDataBundle bundle = new RouteDataBundle(resources);
|
||||
|
||||
if (!Algorithms.isEmpty(route)) {
|
||||
for (RouteSegmentResult sr : route) {
|
||||
sr.collectTypes(resources);
|
||||
}
|
||||
|
@ -52,6 +54,7 @@ public class RouteExporter {
|
|||
routeItems.add(itemBundle);
|
||||
}
|
||||
bundle.putBundleList("route", "segment", routeItems);
|
||||
}
|
||||
|
||||
List<StringBundle> typeList = new ArrayList<>();
|
||||
Map<RouteTypeRule, Integer> rules = resources.getRules();
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
android:id="@+id/ZoomToDownload"
|
||||
style="@style/Widget.Styled.Slider"
|
||||
android:layout_width="fill_parent"
|
||||
android:stepSize="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/content_padding"
|
||||
android:layout_marginRight="@dimen/content_padding"
|
||||
|
|
|
@ -53,6 +53,7 @@ public class DownloadTilesDialog {
|
|||
BaseMapLayer mainLayer = mapView.getMainLayer();
|
||||
if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
|
||||
Toast.makeText(ctx, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
|
||||
if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
|
||||
|
@ -69,26 +70,25 @@ public class DownloadTilesDialog {
|
|||
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View view = inflater.inflate(R.layout.download_tiles, null);
|
||||
|
||||
((TextView) view.findViewById(R.id.MinZoom)).setText(String.valueOf(zoom));
|
||||
((TextView) view.findViewById(R.id.MaxZoom)).setText(String.valueOf(max));
|
||||
|
||||
|
||||
((TextView)view.findViewById(R.id.MinZoom)).setText(zoom+""); //$NON-NLS-1$
|
||||
((TextView)view.findViewById(R.id.MaxZoom)).setText(max+""); //$NON-NLS-1$
|
||||
final Slider slider = (Slider) view.findViewById(R.id.ZoomToDownload);
|
||||
slider.setValueTo(max - zoom);
|
||||
int progress = (max - zoom) / 2;
|
||||
slider.setValue(progress);
|
||||
|
||||
final TextView downloadText = ((TextView) view.findViewById(R.id.DownloadDescription));
|
||||
final String template = ctx.getString(R.string.tiles_to_download_estimated_size);
|
||||
|
||||
|
||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) slider.getValue());
|
||||
if (max > zoom) {
|
||||
slider.setValueTo(max - zoom);
|
||||
int progress = (max - zoom) / 2;
|
||||
slider.setValue(progress);
|
||||
slider.addOnChangeListener(new Slider.OnChangeListener() {
|
||||
@Override
|
||||
public void onValueChange(@NonNull Slider slider, float value, boolean fromUser) {
|
||||
updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, (int) value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
builder.setPositiveButton(R.string.shared_string_download, new DialogInterface.OnClickListener(){
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.squareup.picasso.Picasso;
|
|||
|
||||
import net.osmand.PicassoUtils;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -56,6 +57,7 @@ public class ImagesPagerAdapter extends PagerAdapter {
|
|||
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
|
||||
|
||||
final String imageUrl = imageUrls.get(position);
|
||||
if (!Algorithms.isEmpty(imageUrl)) {
|
||||
Picasso.get().load(imageUrl).into(imageView, new Callback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
@ -69,6 +71,10 @@ public class ImagesPagerAdapter extends PagerAdapter {
|
|||
picassoUtils.setResultLoaded(imageUrl, false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
imageView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
return imageView;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -167,8 +166,9 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
@Override
|
||||
public void setCategory(String name, int color) {
|
||||
FavouritesDbHelper helper = getHelper();
|
||||
if (helper != null) {
|
||||
FavoriteGroup group = helper.getGroup(FavoriteGroup.convertDisplayNameToGroupIdName(requireContext(), name));
|
||||
Context ctx = getContext();
|
||||
if (helper != null && ctx != null) {
|
||||
FavoriteGroup group = helper.getGroup(FavoriteGroup.convertDisplayNameToGroupIdName(ctx, name));
|
||||
this.group = group;
|
||||
super.setCategory(name, group != null ? group.getColor() : 0);
|
||||
}
|
||||
|
@ -176,11 +176,14 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
|
||||
@Override
|
||||
protected String getLastUsedGroup() {
|
||||
OsmandApplication app = requireMyApplication();
|
||||
String lastCategory = app.getSettings().LAST_FAV_CATEGORY_ENTERED.get();
|
||||
String lastCategory = "";
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
lastCategory = app.getSettings().LAST_FAV_CATEGORY_ENTERED.get();
|
||||
if (!Algorithms.isEmpty(lastCategory) && !app.getFavorites().groupExists(lastCategory)) {
|
||||
lastCategory = "";
|
||||
}
|
||||
}
|
||||
return lastCategory;
|
||||
}
|
||||
|
||||
|
@ -325,12 +328,15 @@ public class FavoritePointEditorFragmentNew extends PointEditorFragmentNew {
|
|||
private void doEditFavorite(FavouritePoint favorite, String name, String category, String description,
|
||||
@ColorInt int color, BackgroundType backgroundType, @DrawableRes int iconId,
|
||||
FavouritesDbHelper helper) {
|
||||
requireMyApplication().getSettings().LAST_FAV_CATEGORY_ENTERED.set(category);
|
||||
OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
app.getSettings().LAST_FAV_CATEGORY_ENTERED.set(category);
|
||||
favorite.setColor(color);
|
||||
favorite.setBackgroundType(backgroundType);
|
||||
favorite.setIconId(iconId);
|
||||
helper.editFavouriteName(favorite, name, category, description);
|
||||
}
|
||||
}
|
||||
|
||||
private void doAddFavorite(String name, String category, String description, @ColorInt int color,
|
||||
BackgroundType backgroundType, @DrawableRes int iconId) {
|
||||
|
|
Loading…
Reference in a new issue