add check for shown groups

This commit is contained in:
Chumva 2018-04-17 12:46:05 +03:00
parent c41238fdb1
commit 429aeeb403
3 changed files with 16 additions and 8 deletions

View file

@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical"> android:orientation="vertical">
<ImageView <ImageView
@ -24,9 +23,9 @@
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:background="?attr/selectableItemBackground"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/map_button_shadow_width" android:layout_height="@dimen/map_button_shadow_width">
android:background="?attr/selectableItemBackground">
<ImageButton <ImageButton
android:id="@+id/icon_left" android:id="@+id/icon_left"

View file

@ -1219,6 +1219,7 @@ public class MapMarkersHelper {
private long creationDate; private long creationDate;
private boolean disabled; private boolean disabled;
private boolean visible = true; private boolean visible = true;
private boolean wasShown = false;
private boolean visibleUntilRestart; private boolean visibleUntilRestart;
private List<MapMarker> markers = new ArrayList<>(); private List<MapMarker> markers = new ArrayList<>();
// TODO should be removed from this class: // TODO should be removed from this class:
@ -1269,6 +1270,14 @@ public class MapMarkersHelper {
return visible; return visible;
} }
public boolean wasShown() {
return wasShown;
}
public void setWasShown(boolean wasShown) {
this.wasShown = wasShown;
}
public void setVisibleUntilRestart(boolean visibleUntilRestart) { public void setVisibleUntilRestart(boolean visibleUntilRestart) {
this.visibleUntilRestart = visibleUntilRestart; this.visibleUntilRestart = visibleUntilRestart;
} }

View file

@ -439,10 +439,11 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
final MapMarkersHelper mapMarkersHelper = app.getMapMarkersHelper(); final MapMarkersHelper mapMarkersHelper = app.getMapMarkersHelper();
final GPXFile[] gpxFile = new GPXFile[1]; final GPXFile[] gpxFile = new GPXFile[1];
boolean disabled = !enabled; boolean disabled = !enabled;
if (groupIsDisabled) { if (groupIsDisabled&&!group.wasShown()) {
String m = group.getGpxPath(); group.setWasShown(true);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString(SelectWptCategoriesBottomSheetDialogFragment.GPX_FILE_PATH_KEY, m); args.putString(SelectWptCategoriesBottomSheetDialogFragment.GPX_FILE_PATH_KEY, group.getGpxPath());
args.putBoolean(SelectWptCategoriesBottomSheetDialogFragment.UPDATE_CATEGORIES_KEY, true); args.putBoolean(SelectWptCategoriesBottomSheetDialogFragment.UPDATE_CATEGORIES_KEY, true);
SelectWptCategoriesBottomSheetDialogFragment fragment = new SelectWptCategoriesBottomSheetDialogFragment(); SelectWptCategoriesBottomSheetDialogFragment fragment = new SelectWptCategoriesBottomSheetDialogFragment();
@ -523,8 +524,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
if (header instanceof MapMarkersHelper.CategoriesHeader) { if (header instanceof MapMarkersHelper.CategoriesHeader) {
final MapMarkersHelper.CategoriesHeader groupHeader = (MapMarkersHelper.CategoriesHeader) header; final MapMarkersHelper.CategoriesHeader groupHeader = (MapMarkersHelper.CategoriesHeader) header;
final MapMarkersGroup group = groupHeader.getGroup(); final MapMarkersGroup group = groupHeader.getGroup();
categoriesViewHolder.icon.setImageDrawable(iconsCache.getIcon(groupHeader.getIconRes(), R.color.divider_color));
categoriesViewHolder.icon.setImageDrawable(iconsCache.getIcon(groupHeader.getIconRes()));
categoriesViewHolder.title.setText(group.getWptCategoriesString()); categoriesViewHolder.title.setText(group.getWptCategoriesString());
categoriesViewHolder.itemView.setOnClickListener(new View.OnClickListener() { categoriesViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override @Override