add categories and open wikivoyage article to markers
This commit is contained in:
parent
fcfc1a2bac
commit
c41238fdb1
6 changed files with 303 additions and 6 deletions
78
OsmAnd/res/layout/map_marker_item_categories.xml
Normal file
78
OsmAnd/res/layout/map_marker_item_categories.xml
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:descendantFocusability="blocksDescendants"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/top_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/bg_shadow_list_top"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/main_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/map_button_shadow_width"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/icon_left"
|
||||||
|
android:layout_width="@dimen/map_button_shadow_width"
|
||||||
|
android:layout_height="@dimen/map_button_shadow_width"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
|
android:visibility="invisible"
|
||||||
|
tools:background="@drawable/marker_circle_background_dark_with_inset"
|
||||||
|
tools:src="@drawable/ic_action_marker_passed" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<android.support.v7.widget.AppCompatTextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textColor="@color/dashboard_blue"
|
||||||
|
android:textSize="@dimen/default_list_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:text="Van Gogh Museum" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/icon_right"
|
||||||
|
android:layout_width="@dimen/map_button_shadow_width"
|
||||||
|
android:layout_height="@dimen/map_button_shadow_width"
|
||||||
|
tools:background="@drawable/marker_circle_background_dark_with_inset"
|
||||||
|
tools:src="@drawable/ic_action_marker_passed" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/divider"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
tools:background="?attr/dashboard_divider" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -462,13 +462,20 @@ public class MapMarkersHelper {
|
||||||
|
|
||||||
private void createHeaderInGroup(@NonNull MapMarkersGroup group) {
|
private void createHeaderInGroup(@NonNull MapMarkersGroup group) {
|
||||||
GroupHeader header = new GroupHeader();
|
GroupHeader header = new GroupHeader();
|
||||||
|
CategoriesHeader categoriesHeader = new CategoriesHeader();
|
||||||
|
WikivoyageArticleHeader wikivoyageArticleHeader = new WikivoyageArticleHeader();
|
||||||
int type = group.getType();
|
int type = group.getType();
|
||||||
if (type != -1) {
|
if (type != -1) {
|
||||||
header.iconRes = type == MapMarkersGroup.FAVORITES_TYPE
|
header.iconRes = type == MapMarkersGroup.FAVORITES_TYPE
|
||||||
? R.drawable.ic_action_fav_dark : R.drawable.ic_action_polygom_dark;
|
? R.drawable.ic_action_fav_dark : R.drawable.ic_action_polygom_dark;
|
||||||
|
categoriesHeader.iconRes = R.drawable.ic_action_filter;
|
||||||
}
|
}
|
||||||
header.group = group;
|
header.group = group;
|
||||||
|
categoriesHeader.group = group;
|
||||||
|
wikivoyageArticleHeader.group = group;
|
||||||
group.header = header;
|
group.header = header;
|
||||||
|
group.categoriesHeader = categoriesHeader;
|
||||||
|
group.wikivoyageArticleHeader = wikivoyageArticleHeader;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeMarkerFromGroup(MapMarker marker) {
|
private void removeMarkerFromGroup(MapMarker marker) {
|
||||||
|
@ -1216,6 +1223,8 @@ public class MapMarkersHelper {
|
||||||
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:
|
||||||
private GroupHeader header;
|
private GroupHeader header;
|
||||||
|
private CategoriesHeader categoriesHeader;
|
||||||
|
private WikivoyageArticleHeader wikivoyageArticleHeader;
|
||||||
private ShowHideHistoryButton showHideHistoryButton;
|
private ShowHideHistoryButton showHideHistoryButton;
|
||||||
|
|
||||||
public MapMarkersGroup() {
|
public MapMarkersGroup() {
|
||||||
|
@ -1272,6 +1281,14 @@ public class MapMarkersHelper {
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CategoriesHeader getCategoriesHeader() {
|
||||||
|
return categoriesHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WikivoyageArticleHeader getWikivoyageArticleHeader() {
|
||||||
|
return wikivoyageArticleHeader;
|
||||||
|
}
|
||||||
|
|
||||||
public ShowHideHistoryButton getShowHideHistoryButton() {
|
public ShowHideHistoryButton getShowHideHistoryButton() {
|
||||||
return showHideHistoryButton;
|
return showHideHistoryButton;
|
||||||
}
|
}
|
||||||
|
@ -1323,6 +1340,32 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class CategoriesHeader {
|
||||||
|
private int iconRes;
|
||||||
|
private MapMarkersGroup group;
|
||||||
|
|
||||||
|
public int getIconRes() {
|
||||||
|
return iconRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapMarkersGroup getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class WikivoyageArticleHeader {
|
||||||
|
private int iconRes;
|
||||||
|
private MapMarkersGroup group;
|
||||||
|
|
||||||
|
public int getIconRes() {
|
||||||
|
return iconRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapMarkersGroup getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class MapMarker implements LocationPoint {
|
public static class MapMarker implements LocationPoint {
|
||||||
private static int[] colors;
|
private static int[] colors;
|
||||||
|
|
||||||
|
|
|
@ -32,19 +32,22 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
|
||||||
|
|
||||||
public static final String TAG = "SelectWptCategoriesBottomSheetDialogFragment";
|
public static final String TAG = "SelectWptCategoriesBottomSheetDialogFragment";
|
||||||
public static final String GPX_FILE_PATH_KEY = "gpx_file_path";
|
public static final String GPX_FILE_PATH_KEY = "gpx_file_path";
|
||||||
|
public static final String UPDATE_CATEGORIES_KEY = "update_categories";
|
||||||
|
|
||||||
private GPXFile gpxFile;
|
private GPXFile gpxFile;
|
||||||
|
|
||||||
private Set<String> selectedCategories = new HashSet<>();
|
private Set<String> selectedCategories = new HashSet<>();
|
||||||
private List<BottomSheetItemWithCompoundButton> categoryItems = new ArrayList<>();
|
private List<BottomSheetItemWithCompoundButton> categoryItems = new ArrayList<>();
|
||||||
|
|
||||||
|
private boolean isUpdateMode =false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createMenuItems(Bundle savedInstanceState) {
|
public void createMenuItems(Bundle savedInstanceState) {
|
||||||
gpxFile = getGpxFile();
|
gpxFile = getGpxFile();
|
||||||
if (gpxFile == null) {
|
if (gpxFile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
isUpdateMode = getArguments().getBoolean(UPDATE_CATEGORIES_KEY);
|
||||||
items.add(new TitleItem(getGpxName(gpxFile)));
|
items.add(new TitleItem(getGpxName(gpxFile)));
|
||||||
|
|
||||||
items.add(new DescriptionItem(getString(R.string.select_waypoints_category_description)));
|
items.add(new DescriptionItem(getString(R.string.select_waypoints_category_description)));
|
||||||
|
@ -108,11 +111,35 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getRightBottomButtonTextId() {
|
protected int getRightBottomButtonTextId() {
|
||||||
return R.string.shared_string_import;
|
if (isUpdateMode) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
return super.getRightBottomButtonTextId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getDismissButtonTextId() {
|
||||||
|
if (isUpdateMode) {
|
||||||
|
return R.string.update;
|
||||||
|
} else {
|
||||||
|
return super.getDismissButtonTextId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onDismissButtonClickAction() {
|
||||||
|
if (isUpdateMode) {
|
||||||
|
updateGroupWptCategories();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onRightBottomButtonClick() {
|
protected void onRightBottomButtonClick() {
|
||||||
|
updateGroupWptCategories();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateGroupWptCategories() {
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
GpxSelectionHelper gpxSelectionHelper = app.getSelectedGpxHelper();
|
GpxSelectionHelper gpxSelectionHelper = app.getSelectedGpxHelper();
|
||||||
MapMarkersHelper mapMarkersHelper = app.getMapMarkersHelper();
|
MapMarkersHelper mapMarkersHelper = app.getMapMarkersHelper();
|
||||||
|
@ -126,8 +153,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
|
||||||
group = mapMarkersHelper.addOrEnableGroup(gpxFile);
|
group = mapMarkersHelper.addOrEnableGroup(gpxFile);
|
||||||
}
|
}
|
||||||
mapMarkersHelper.updateGroupWptCategories(group, selectedCategories);
|
mapMarkersHelper.updateGroupWptCategories(group, selectedCategories);
|
||||||
|
mapMarkersHelper.runSynchronization(group);
|
||||||
dismiss();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAllChecked() {
|
private boolean isAllChecked() {
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
package net.osmand.plus.mapmarkers.adapters;
|
||||||
|
|
||||||
|
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.support.v7.widget.SwitchCompat;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
|
public class MapMarkerCategoriesViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
final ImageView icon;
|
||||||
|
final TextView title;
|
||||||
|
|
||||||
|
public MapMarkerCategoriesViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
icon = (ImageView) itemView.findViewById(R.id.icon_right);
|
||||||
|
title = (TextView) itemView.findViewById(R.id.title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package net.osmand.plus.mapmarkers.adapters;
|
||||||
|
|
||||||
|
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
|
public class MapMarkerWikivoyageArticleViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
|
final ImageView icon;
|
||||||
|
final TextView title;
|
||||||
|
|
||||||
|
public MapMarkerWikivoyageArticleViewHolder(View itemView) {
|
||||||
|
super(itemView);
|
||||||
|
icon = (ImageView) itemView.findViewById(R.id.icon_right);
|
||||||
|
title = (TextView) itemView.findViewById(R.id.title);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,24 @@
|
||||||
package net.osmand.plus.mapmarkers.adapters;
|
package net.osmand.plus.mapmarkers.adapters;
|
||||||
|
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.Snackbar;
|
import android.support.design.widget.Snackbar;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.OsmAndCollator;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.plus.GPXDatabase;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
|
@ -25,6 +33,12 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||||
|
import net.osmand.plus.mapmarkers.AddTracksGroupBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.mapmarkers.SelectWptCategoriesBottomSheetDialogFragment;
|
||||||
|
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
||||||
|
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||||
|
import net.osmand.plus.wikivoyage.data.TravelDbHelper;
|
||||||
|
import net.osmand.plus.wikivoyage.data.TravelLocalDataHelper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -39,6 +53,8 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
private static final int HEADER_TYPE = 1;
|
private static final int HEADER_TYPE = 1;
|
||||||
private static final int MARKER_TYPE = 2;
|
private static final int MARKER_TYPE = 2;
|
||||||
private static final int SHOW_HIDE_HISTORY_TYPE = 3;
|
private static final int SHOW_HIDE_HISTORY_TYPE = 3;
|
||||||
|
private static final int CATEGORIES_TYPE = 4;
|
||||||
|
private static final int WIKIVOYAGE_ARTICLE_TYPE = 5;
|
||||||
|
|
||||||
private static final int TODAY_HEADER = 56;
|
private static final int TODAY_HEADER = 56;
|
||||||
private static final int YESTERDAY_HEADER = 57;
|
private static final int YESTERDAY_HEADER = 57;
|
||||||
|
@ -145,6 +161,24 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
} else {
|
} else {
|
||||||
GroupHeader header = group.getGroupHeader();
|
GroupHeader header = group.getGroupHeader();
|
||||||
items.add(header);
|
items.add(header);
|
||||||
|
if (!group.isDisabled()) {
|
||||||
|
if (group.getWptCategoriesString() != null) {
|
||||||
|
MapMarkersHelper.CategoriesHeader categoriesHeader = group.getCategoriesHeader();
|
||||||
|
items.add(categoriesHeader);
|
||||||
|
}
|
||||||
|
TravelDbHelper travelDbHelper = mapActivity.getMyApplication().getTravelDbHelper();
|
||||||
|
if (travelDbHelper.getSelectedTravelBook() != null) {
|
||||||
|
List<TravelArticle> savedArticles = travelDbHelper.getLocalDataHelper().getSavedArticles();
|
||||||
|
for (TravelArticle art : savedArticles) {
|
||||||
|
String gpxName = travelDbHelper.getGPXName(art);
|
||||||
|
File path = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName);
|
||||||
|
if (path.getAbsolutePath().equals(group.getGpxPath())) {
|
||||||
|
MapMarkersHelper.WikivoyageArticleHeader wikivoyageArticleHeader = group.getWikivoyageArticleHeader();
|
||||||
|
items.add(wikivoyageArticleHeader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
populateAdapterWithGroupMarkers(group, getItemCount());
|
populateAdapterWithGroupMarkers(group, getItemCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,6 +255,12 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
} else if (viewType == SHOW_HIDE_HISTORY_TYPE) {
|
} else if (viewType == SHOW_HIDE_HISTORY_TYPE) {
|
||||||
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_show_hide_history, viewGroup, false);
|
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_show_hide_history, viewGroup, false);
|
||||||
return new MapMarkersShowHideHistoryViewHolder(view);
|
return new MapMarkersShowHideHistoryViewHolder(view);
|
||||||
|
} else if (viewType == CATEGORIES_TYPE) {
|
||||||
|
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_categories, viewGroup, false);
|
||||||
|
return new MapMarkerCategoriesViewHolder(view);
|
||||||
|
}else if (viewType == WIKIVOYAGE_ARTICLE_TYPE) {
|
||||||
|
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_categories, viewGroup, false);
|
||||||
|
return new MapMarkerWikivoyageArticleViewHolder(view);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unsupported view type");
|
throw new IllegalArgumentException("Unsupported view type");
|
||||||
}
|
}
|
||||||
|
@ -391,7 +431,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
headerViewHolder.icon.setVisibility(View.VISIBLE);
|
headerViewHolder.icon.setVisibility(View.VISIBLE);
|
||||||
headerViewHolder.iconSpace.setVisibility(View.GONE);
|
headerViewHolder.iconSpace.setVisibility(View.GONE);
|
||||||
headerViewHolder.icon.setImageDrawable(iconsCache.getIcon(groupHeader.getIconRes(), R.color.divider_color));
|
headerViewHolder.icon.setImageDrawable(iconsCache.getIcon(groupHeader.getIconRes(), R.color.divider_color));
|
||||||
boolean groupIsDisabled = group.isDisabled();
|
final boolean groupIsDisabled = group.isDisabled();
|
||||||
headerViewHolder.disableGroupSwitch.setVisibility(View.VISIBLE);
|
headerViewHolder.disableGroupSwitch.setVisibility(View.VISIBLE);
|
||||||
CompoundButton.OnCheckedChangeListener checkedChangeListener = new CompoundButton.OnCheckedChangeListener() {
|
CompoundButton.OnCheckedChangeListener checkedChangeListener = new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -399,7 +439,17 @@ 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) {
|
||||||
|
String m = group.getGpxPath();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString(SelectWptCategoriesBottomSheetDialogFragment.GPX_FILE_PATH_KEY, m);
|
||||||
|
args.putBoolean(SelectWptCategoriesBottomSheetDialogFragment.UPDATE_CATEGORIES_KEY, true);
|
||||||
|
|
||||||
|
SelectWptCategoriesBottomSheetDialogFragment fragment = new SelectWptCategoriesBottomSheetDialogFragment();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
|
fragment.show(mapActivity.getSupportFragmentManager(), SelectWptCategoriesBottomSheetDialogFragment.TAG);
|
||||||
|
}
|
||||||
mapMarkersHelper.updateGroupDisabled(group, disabled);
|
mapMarkersHelper.updateGroupDisabled(group, disabled);
|
||||||
if (group.getType() == MapMarkersGroup.GPX_TYPE) {
|
if (group.getType() == MapMarkersGroup.GPX_TYPE) {
|
||||||
group.setVisibleUntilRestart(disabled);
|
group.setVisibleUntilRestart(disabled);
|
||||||
|
@ -467,6 +517,57 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (holder instanceof MapMarkerCategoriesViewHolder) {
|
||||||
|
final MapMarkerCategoriesViewHolder categoriesViewHolder = (MapMarkerCategoriesViewHolder) holder;
|
||||||
|
final Object header = getItem(position);
|
||||||
|
if (header instanceof MapMarkersHelper.CategoriesHeader) {
|
||||||
|
final MapMarkersHelper.CategoriesHeader groupHeader = (MapMarkersHelper.CategoriesHeader) header;
|
||||||
|
final MapMarkersGroup group = groupHeader.getGroup();
|
||||||
|
|
||||||
|
categoriesViewHolder.icon.setImageDrawable(iconsCache.getIcon(groupHeader.getIconRes()));
|
||||||
|
categoriesViewHolder.title.setText(group.getWptCategoriesString());
|
||||||
|
categoriesViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString(SelectWptCategoriesBottomSheetDialogFragment.GPX_FILE_PATH_KEY, group.getGpxPath());
|
||||||
|
args.putBoolean(SelectWptCategoriesBottomSheetDialogFragment.UPDATE_CATEGORIES_KEY, true);
|
||||||
|
|
||||||
|
SelectWptCategoriesBottomSheetDialogFragment fragment = new SelectWptCategoriesBottomSheetDialogFragment();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
fragment.setUsedOnMap(false);
|
||||||
|
fragment.show(mapActivity.getSupportFragmentManager(), SelectWptCategoriesBottomSheetDialogFragment.TAG);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (holder instanceof MapMarkerWikivoyageArticleViewHolder) {
|
||||||
|
final MapMarkerWikivoyageArticleViewHolder wikivoyageArticleViewHolder = (MapMarkerWikivoyageArticleViewHolder) holder;
|
||||||
|
final Object header = getItem(position);
|
||||||
|
final MapMarkersHelper.WikivoyageArticleHeader groupHeader = (MapMarkersHelper.WikivoyageArticleHeader) header;
|
||||||
|
final MapMarkersGroup group = groupHeader.getGroup();
|
||||||
|
wikivoyageArticleViewHolder.title.setText(R.string.context_menu_read_article);
|
||||||
|
wikivoyageArticleViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
TravelArticle test = null;
|
||||||
|
TravelDbHelper travelDbHelper = mapActivity.getMyApplication().getTravelDbHelper();
|
||||||
|
if (travelDbHelper.getSelectedTravelBook() != null) {
|
||||||
|
List<TravelArticle> savedArticles = travelDbHelper.getLocalDataHelper().getSavedArticles();
|
||||||
|
for (TravelArticle art : savedArticles) {
|
||||||
|
String gpxName = travelDbHelper.getGPXName(art);
|
||||||
|
File path = mapActivity.getMyApplication().getAppPath(IndexConstants.GPX_TRAVEL_DIR + gpxName);
|
||||||
|
if (path.getAbsolutePath().equals(group.getGpxPath())) {
|
||||||
|
MapMarkersHelper.WikivoyageArticleHeader wikivoyageArticleHeader = group.getWikivoyageArticleHeader();
|
||||||
|
items.add(wikivoyageArticleHeader);
|
||||||
|
test = art;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mapActivity.getSupportFragmentManager() != null && test != null) {
|
||||||
|
WikivoyageArticleDialogFragment.showInstance(app, mapActivity.getSupportFragmentManager(), test.getCityId(), test.getLang());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,6 +591,10 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
||||||
return HEADER_TYPE;
|
return HEADER_TYPE;
|
||||||
} else if (item instanceof ShowHideHistoryButton) {
|
} else if (item instanceof ShowHideHistoryButton) {
|
||||||
return SHOW_HIDE_HISTORY_TYPE;
|
return SHOW_HIDE_HISTORY_TYPE;
|
||||||
|
}else if (item instanceof MapMarkersHelper.CategoriesHeader) {
|
||||||
|
return CATEGORIES_TYPE;
|
||||||
|
}else if (item instanceof MapMarkersHelper.WikivoyageArticleHeader) {
|
||||||
|
return WIKIVOYAGE_ARTICLE_TYPE;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unsupported view type");
|
throw new IllegalArgumentException("Unsupported view type");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue