Fix fav group npe
This commit is contained in:
parent
38983accea
commit
9244cf81ae
3 changed files with 12 additions and 9 deletions
|
@ -81,7 +81,7 @@ public class FavouritesDbHelper {
|
|||
return PERSONAL_CATEGORY.equals(name);
|
||||
}
|
||||
|
||||
public static boolean isPersonalCategoryDisplayName(Context ctx, String name){
|
||||
public static boolean isPersonalCategoryDisplayName(Context ctx, String name) {
|
||||
return name.equals(ctx.getString(R.string.personal_category_name));
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
|
||||
public static String convertDisplayNameToGroupIdName(Context context, String name) {
|
||||
if (isPersonalCategoryDisplayName(context,name)) {
|
||||
if (isPersonalCategoryDisplayName(context, name)) {
|
||||
return PERSONAL_CATEGORY;
|
||||
}
|
||||
if (name.equals(context.getString(R.string.shared_string_favorites))) {
|
||||
|
@ -589,7 +589,7 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
|
||||
public void addEmptyCategory(String name, int color) {
|
||||
addEmptyCategory(name, color, true);
|
||||
addEmptyCategory(name, color, true);
|
||||
}
|
||||
|
||||
public void addEmptyCategory(String name, int color, boolean visible) {
|
||||
|
@ -598,7 +598,7 @@ public class FavouritesDbHelper {
|
|||
group.color = color;
|
||||
group.visible = visible;
|
||||
favoriteGroups.add(group);
|
||||
flatGroups.put(name, group);
|
||||
flatGroups.put(group.name, group);
|
||||
}
|
||||
|
||||
public List<FavouritePoint> getFavouritePoints() {
|
||||
|
@ -639,6 +639,7 @@ public class FavouritesDbHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FavoriteGroup getGroup(FavouritePoint p) {
|
||||
if (flatGroups.containsKey(p.getCategory())) {
|
||||
return flatGroups.get(p.getCategory());
|
||||
|
@ -647,6 +648,7 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FavoriteGroup getGroup(String nameId) {
|
||||
if (flatGroups.containsKey(nameId)) {
|
||||
return flatGroups.get(nameId);
|
||||
|
@ -655,6 +657,7 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private FavouritePoint findFavoriteByAllProperties(String category, String name, double lat, double lon) {
|
||||
if (flatGroups.containsKey(category)) {
|
||||
FavoriteGroup fg = flatGroups.get(category);
|
||||
|
|
|
@ -448,9 +448,9 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
|||
List<LatLon> points = new ArrayList<>();
|
||||
List<PointDescription> names = new ArrayList<>();
|
||||
for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
|
||||
FavoriteGroup favGr = helper.getGroup(entry.getKey());
|
||||
if (entry.getValue().size() == favGr.getPoints().size()) {
|
||||
markersHelper.addOrEnableGroup(favGr);
|
||||
FavoriteGroup group = helper.getGroup(entry.getKey());
|
||||
if (group != null && entry.getValue().size() == group.getPoints().size()) {
|
||||
markersHelper.addOrEnableGroup(group);
|
||||
} else {
|
||||
for (FavouritePoint fp : entry.getValue()) {
|
||||
points.add(new LatLon(fp.getLatitude(), fp.getLongitude()));
|
||||
|
|
|
@ -147,9 +147,9 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
public void setCategory(String name, int color) {
|
||||
FavouritesDbHelper helper = getHelper();
|
||||
if (helper != null) {
|
||||
FavoriteGroup group = helper.getGroup(FavouritesDbHelper.FavoriteGroup.convertDisplayNameToGroupIdName(requireContext(), name));
|
||||
FavoriteGroup group = helper.getGroup(FavoriteGroup.convertDisplayNameToGroupIdName(requireContext(), name));
|
||||
this.group = group;
|
||||
super.setCategory(name, group.getColor());
|
||||
super.setCategory(name, group != null ? group.getColor() : 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue