Merge pull request #8569 from osmandapp/minor_fixes

Minor fixes
This commit is contained in:
vshcherb 2020-02-26 17:59:06 +02:00 committed by GitHub
commit eeeda95f2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 31 deletions

View file

@ -550,7 +550,11 @@ public class TileSourceManager {
private static String findOneTile(File dir) {
if (dir.isDirectory()) {
for (File file : dir.listFiles()) {
File[] files = dir.listFiles();
if (files == null) {
return null;
}
for (File file : files) {
if (file.isDirectory()) {
String ext = findOneTile(file);
if (ext != null) {

View file

@ -641,7 +641,7 @@ public class FavouritesDbHelper {
@Nullable
public FavoriteGroup getGroup(FavouritePoint p) {
if (flatGroups.containsKey(p.getCategory())) {
if (p != null && flatGroups.containsKey(p.getCategory())) {
return flatGroups.get(p.getCategory());
} else {
return null;

View file

@ -649,7 +649,7 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
public void onGetItems() {
OsmandApplication app = getMyApplication();
if (app != null && InAppPurchaseHelper.isSubscribedToLiveUpdates(app)) {
dismiss();
dismissAllowingStateLoss();
}
}
@ -661,7 +661,7 @@ public abstract class ChoosePlanDialogFragment extends BaseOsmAndDialogFragment
showDonationSettings();
}
}
dismiss();
dismissAllowingStateLoss();
}
@Override

View file

@ -16,6 +16,7 @@ import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoritesListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.FavoriteImageDrawable;
@ -94,8 +95,11 @@ public class DashFavoritesFragment extends DashLocationFragment {
public void setupFavorites() {
View mainView = getView();
final FavouritesDbHelper helper = getMyApplication().getFavorites();
points = new ArrayList<FavouritePoint>(helper.getFavouritePoints());
OsmandApplication app = getMyApplication();
if (mainView == null || app == null) {
return;
}
points = new ArrayList<FavouritePoint>(app.getFavorites().getFavouritePoints());
if (points.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return;

View file

@ -71,11 +71,9 @@ import org.apache.commons.logging.Log;
import java.io.File;
import java.lang.ref.WeakReference;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -833,15 +831,18 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
app.getSettings().setMapLocationToShow(
regionCenter.getLatitude(),
regionCenter.getLongitude(),
5,
new PointDescription(PointDescription.POINT_TYPE_WORLD_REGION_SHOW_ON_MAP, ""));
FragmentActivity activity = getActivity();
if (activity != null && regionCenter != null) {
OsmandApplication app = (OsmandApplication) activity.getApplication();
app.getSettings().setMapLocationToShow(
regionCenter.getLatitude(),
regionCenter.getLongitude(),
5,
new PointDescription(PointDescription.POINT_TYPE_WORLD_REGION_SHOW_ON_MAP, ""));
dismiss();
MapActivity.launchMapActivityMoveToTop(getActivity());
dismiss();
MapActivity.launchMapActivityMoveToTop(activity);
}
}
});

View file

@ -303,7 +303,7 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
@Override
public void onItemPurchased(String sku, boolean active) {
dismiss();
dismissAllowingStateLoss();
}
@Override

View file

@ -1,12 +1,13 @@
package net.osmand.plus.measurementtool;
import android.support.annotation.Nullable;
import android.util.Pair;
import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode;
import net.osmand.GPXUtilities.TrkSegment;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.measurementtool.command.MeasurementCommandManager;
import net.osmand.plus.routing.RouteCalculationParams;
@ -212,14 +213,17 @@ public class MeasurementEditingContext {
snapToRoadPairsToCalculate.clear();
findPointsToCalculate(Arrays.asList(before.points, after.points));
RoutingHelper routingHelper = application.getRoutingHelper();
if (!snapToRoadPairsToCalculate.isEmpty() && progressListener != null && !routingHelper.isRouteBeingCalculated()) {
routingHelper.startRouteCalculationThread(getParams(), true, true);
application.runInUIThread(new Runnable() {
@Override
public void run() {
progressListener.showProgressBar();
}
});
if (progressListener != null && !routingHelper.isRouteBeingCalculated()) {
RouteCalculationParams params = getParams();
if (params != null) {
routingHelper.startRouteCalculationThread(params, true, true);
application.runInUIThread(new Runnable() {
@Override
public void run() {
progressListener.showProgressBar();
}
});
}
}
}
@ -270,9 +274,12 @@ public class MeasurementEditingContext {
}
}
@Nullable
private RouteCalculationParams getParams() {
final Pair<WptPt, WptPt> currentPair = snapToRoadPairsToCalculate.poll();
if (currentPair == null) {
return null;
}
Location start = new Location("");
start.setLatitude(currentPair.first.getLatitude());
start.setLongitude(currentPair.first.getLongitude());
@ -341,8 +348,9 @@ public class MeasurementEditingContext {
progressListener.refresh();
}
});
if (!snapToRoadPairsToCalculate.isEmpty()) {
application.getRoutingHelper().startRouteCalculationThread(getParams(), true, true);
RouteCalculationParams params = getParams();
if (params != null) {
application.getRoutingHelper().startRouteCalculationThread(params, true, true);
} else {
application.runInUIThread(new Runnable() {
@Override

View file

@ -454,7 +454,7 @@ public class DataStorageFragment extends BaseSettingsFragment implements DataSto
}
protected void reloadData() {
new ReloadData(activity, getMyApplication()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
new ReloadData(activity, app).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
}
@Override