commit
45543c9108
12 changed files with 170 additions and 57 deletions
11
OsmAnd/.gitignore
vendored
11
OsmAnd/.gitignore
vendored
|
@ -39,11 +39,7 @@ mx_*
|
||||||
valgrind/
|
valgrind/
|
||||||
bin/
|
bin/
|
||||||
dist/
|
dist/
|
||||||
assets/specialphrases/*
|
|
||||||
assets/voice/*
|
|
||||||
assets/fonts/*
|
|
||||||
assets/feature_articles/*
|
|
||||||
assets/World_basemap_mini*
|
|
||||||
gen/
|
gen/
|
||||||
local.properties
|
local.properties
|
||||||
raw/
|
raw/
|
||||||
|
@ -56,6 +52,11 @@ out/
|
||||||
use/
|
use/
|
||||||
osmand.properties
|
osmand.properties
|
||||||
osmand.xml
|
osmand.xml
|
||||||
|
assets/specialphrases/*
|
||||||
|
assets/voice/*
|
||||||
|
assets/fonts/*
|
||||||
|
assets/feature_articles/*
|
||||||
|
assets/*.obf
|
||||||
assets/style.css
|
assets/style.css
|
||||||
assets/poi_categories.json
|
assets/poi_categories.json
|
||||||
assets/help/*.html
|
assets/help/*.html
|
||||||
|
|
20
OsmAnd/res/layout/track_groups_card.xml
Normal file
20
OsmAnd/res/layout/track_groups_card.xml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding"
|
||||||
|
android:paddingStart="@dimen/content_padding"
|
||||||
|
android:paddingEnd="@dimen/content_padding"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:scrollbars="none" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -673,7 +673,10 @@ public class ImportHelper {
|
||||||
public static List<FavouritePoint> asFavourites(OsmandApplication app, List<WptPt> wptPts, String fileName, boolean forceImportFavourites) {
|
public static List<FavouritePoint> asFavourites(OsmandApplication app, List<WptPt> wptPts, String fileName, boolean forceImportFavourites) {
|
||||||
List<FavouritePoint> favourites = new ArrayList<>();
|
List<FavouritePoint> favourites = new ArrayList<>();
|
||||||
for (WptPt p : wptPts) {
|
for (WptPt p : wptPts) {
|
||||||
if (p.name != null) {
|
if (Algorithms.isEmpty(p.name)) {
|
||||||
|
p.name = app.getResources().getString(R.string.shared_string_waypoint);
|
||||||
|
}
|
||||||
|
if (!Algorithms.isEmpty(p.name)) {
|
||||||
final String fpCat;
|
final String fpCat;
|
||||||
if (p.category == null) {
|
if (p.category == null) {
|
||||||
if (forceImportFavourites) {
|
if (forceImportFavourites) {
|
||||||
|
|
79
OsmAnd/src/net/osmand/plus/track/PointsGroupsCard.java
Normal file
79
OsmAnd/src/net/osmand/plus/track/PointsGroupsCard.java
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
package net.osmand.plus.track;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter;
|
||||||
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionAdapterListener;
|
||||||
|
import net.osmand.plus.mapcontextmenu.other.HorizontalSelectionAdapter.HorizontalSelectionItem;
|
||||||
|
import net.osmand.plus.routepreparationmenu.cards.BaseCard;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PointsGroupsCard extends BaseCard {
|
||||||
|
|
||||||
|
public static final int SELECT_GROUP_INDEX = 0;
|
||||||
|
|
||||||
|
private GpxDisplayGroup selectedGroup;
|
||||||
|
private final List<GpxDisplayGroup> displayGroups = new ArrayList<>();
|
||||||
|
|
||||||
|
public PointsGroupsCard(@NonNull MapActivity mapActivity, @NonNull List<GpxDisplayGroup> groups) {
|
||||||
|
super(mapActivity);
|
||||||
|
displayGroups.addAll(groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCardLayoutId() {
|
||||||
|
return R.layout.track_groups_card;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GpxDisplayGroup getSelectedGroup() {
|
||||||
|
return selectedGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateContent() {
|
||||||
|
ArrayList<HorizontalSelectionItem> items = new ArrayList<>();
|
||||||
|
items.add(new HorizontalSelectionItem(app.getString(R.string.shared_string_all), null));
|
||||||
|
for (GpxDisplayGroup group : displayGroups) {
|
||||||
|
String categoryName = group.getName();
|
||||||
|
if (Algorithms.isEmpty(categoryName)) {
|
||||||
|
categoryName = app.getString(R.string.shared_string_gpx_points);
|
||||||
|
}
|
||||||
|
items.add(new HorizontalSelectionItem(categoryName, group));
|
||||||
|
}
|
||||||
|
final HorizontalSelectionAdapter selectionAdapter = new HorizontalSelectionAdapter(app, nightMode);
|
||||||
|
selectionAdapter.setItems(items);
|
||||||
|
selectionAdapter.setListener(new HorizontalSelectionAdapterListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemSelected(HorizontalSelectionItem item) {
|
||||||
|
selectedGroup = (GpxDisplayGroup) item.getObject();
|
||||||
|
CardListener listener = getListener();
|
||||||
|
if (listener != null) {
|
||||||
|
listener.onCardButtonPressed(PointsGroupsCard.this, SELECT_GROUP_INDEX);
|
||||||
|
}
|
||||||
|
selectionAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (selectedGroup != null) {
|
||||||
|
String categoryName = selectedGroup.getName();
|
||||||
|
if (Algorithms.isEmpty(categoryName)) {
|
||||||
|
categoryName = app.getString(R.string.shared_string_gpx_points);
|
||||||
|
}
|
||||||
|
selectionAdapter.setSelectedItemByTitle(categoryName);
|
||||||
|
} else {
|
||||||
|
selectionAdapter.setSelectedItemByTitle(app.getString(R.string.shared_string_all));
|
||||||
|
}
|
||||||
|
|
||||||
|
RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
|
||||||
|
recyclerView.setAdapter(selectionAdapter);
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(app, RecyclerView.HORIZONTAL, false));
|
||||||
|
selectionAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
}
|
|
@ -136,6 +136,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
private DescriptionCard descriptionCard;
|
private DescriptionCard descriptionCard;
|
||||||
private OverviewCard overviewCard;
|
private OverviewCard overviewCard;
|
||||||
private TrackPointsCard pointsCard;
|
private TrackPointsCard pointsCard;
|
||||||
|
private PointsGroupsCard groupsCard;
|
||||||
|
|
||||||
private TextView headerTitle;
|
private TextView headerTitle;
|
||||||
private ImageView headerIcon;
|
private ImageView headerIcon;
|
||||||
|
@ -373,6 +374,21 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
blocksBuilder.runUpdatingStatBlocksIfNeeded();
|
blocksBuilder.runUpdatingStatBlocksIfNeeded();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (menuType == TrackMenuType.POINTS && !Algorithms.isEmpty(pointsCard.getGroups())) {
|
||||||
|
if (groupsCard != null && groupsCard.getView() != null) {
|
||||||
|
ViewGroup parent = ((ViewGroup) groupsCard.getView().getParent());
|
||||||
|
if (parent != null) {
|
||||||
|
parent.removeView(groupsCard.getView());
|
||||||
|
}
|
||||||
|
headerContainer.addView(groupsCard.getView());
|
||||||
|
} else {
|
||||||
|
groupsCard = new PointsGroupsCard(getMapActivity(), pointsCard.getGroups());
|
||||||
|
groupsCard.setListener(this);
|
||||||
|
headerContainer.addView(groupsCard.build(getMapActivity()));
|
||||||
|
}
|
||||||
|
} else if (groupsCard != null && groupsCard.getView() != null) {
|
||||||
|
headerContainer.removeView(groupsCard.getView());
|
||||||
|
}
|
||||||
if (overviewCard != null && overviewCard.getView() != null) {
|
if (overviewCard != null && overviewCard.getView() != null) {
|
||||||
overviewCard.getBlockStatisticsBuilder().stopUpdatingStatBlocks();
|
overviewCard.getBlockStatisticsBuilder().stopUpdatingStatBlocks();
|
||||||
headerContainer.removeView(overviewCard.getView());
|
headerContainer.removeView(overviewCard.getView());
|
||||||
|
@ -869,6 +885,13 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
|
||||||
} else if (buttonIndex == OPEN_WAYPOINT_INDEX) {
|
} else if (buttonIndex == OPEN_WAYPOINT_INDEX) {
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
} else if (card instanceof PointsGroupsCard) {
|
||||||
|
PointsGroupsCard groupsCard = (PointsGroupsCard) card;
|
||||||
|
GpxDisplayGroup group = groupsCard.getSelectedGroup();
|
||||||
|
if (pointsCard != null) {
|
||||||
|
pointsCard.setSelectedGroup(group);
|
||||||
|
pointsCard.updateContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
|
||||||
private final TrackDisplayHelper displayHelper;
|
private final TrackDisplayHelper displayHelper;
|
||||||
private final GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_POINTS, GpxDisplayItemType.TRACK_ROUTE_POINTS};
|
private final GpxDisplayItemType[] filterTypes = new GpxDisplayItemType[] {GpxDisplayItemType.TRACK_POINTS, GpxDisplayItemType.TRACK_ROUTE_POINTS};
|
||||||
|
|
||||||
|
private GpxDisplayGroup selectedGroup;
|
||||||
private final Set<Integer> selectedGroups = new LinkedHashSet<>();
|
private final Set<Integer> selectedGroups = new LinkedHashSet<>();
|
||||||
private final LinkedHashMap<GpxDisplayItemType, Set<GpxDisplayItem>> selectedItems = new LinkedHashMap<>();
|
private final LinkedHashMap<GpxDisplayItemType, Set<GpxDisplayItem>> selectedItems = new LinkedHashMap<>();
|
||||||
private boolean selectionMode;
|
private boolean selectionMode;
|
||||||
|
@ -97,7 +98,7 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
|
||||||
listView.setOnChildClickListener(this);
|
listView.setOnChildClickListener(this);
|
||||||
|
|
||||||
adapter.setFilterResults(null);
|
adapter.setFilterResults(null);
|
||||||
adapter.synchronizeGroups(getOriginalGroups());
|
adapter.synchronizeGroups(getDisplayGroups());
|
||||||
if (listView.getAdapter() == null) {
|
if (listView.getAdapter() == null) {
|
||||||
listView.setAdapter(adapter);
|
listView.setAdapter(adapter);
|
||||||
}
|
}
|
||||||
|
@ -109,6 +110,14 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSelectedGroup(GpxDisplayGroup selectedGroup) {
|
||||||
|
this.selectedGroup = selectedGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GpxDisplayGroup> getGroups() {
|
||||||
|
return adapter.groups;
|
||||||
|
}
|
||||||
|
|
||||||
private void addActions(LayoutInflater inflater) {
|
private void addActions(LayoutInflater inflater) {
|
||||||
View view = inflater.inflate(R.layout.preference_category_with_descr, listView, false);
|
View view = inflater.inflate(R.layout.preference_category_with_descr, listView, false);
|
||||||
TextView title = view.findViewById(android.R.id.title);
|
TextView title = view.findViewById(android.R.id.title);
|
||||||
|
@ -174,6 +183,10 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
|
||||||
return displayHelper.getOriginalGroups(filterTypes);
|
return displayHelper.getOriginalGroups(filterTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<GpxDisplayGroup> getDisplayGroups() {
|
||||||
|
return selectedGroup != null ? Collections.singletonList(selectedGroup) : getOriginalGroups();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||||
GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
|
GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
|
||||||
|
@ -246,7 +259,7 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
|
||||||
public void onPointsDeleted() {
|
public void onPointsDeleted() {
|
||||||
selectedItems.clear();
|
selectedItems.clear();
|
||||||
selectedGroups.clear();
|
selectedGroups.clear();
|
||||||
adapter.synchronizeGroups(getOriginalGroups());
|
adapter.synchronizeGroups(getDisplayGroups());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void filter(String text) {
|
public void filter(String text) {
|
||||||
|
@ -618,9 +631,7 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
|
||||||
} else {
|
} else {
|
||||||
Set<Object> filter = new HashSet<>();
|
Set<Object> filter = new HashSet<>();
|
||||||
String cs = constraint.toString().toLowerCase();
|
String cs = constraint.toString().toLowerCase();
|
||||||
List<GpxDisplayGroup> groups = getOriginalGroups();
|
for (GpxDisplayGroup g : getDisplayGroups()) {
|
||||||
if (groups != null) {
|
|
||||||
for (GpxDisplayGroup g : groups) {
|
|
||||||
for (GpxDisplayItem i : g.getModifiableList()) {
|
for (GpxDisplayItem i : g.getModifiableList()) {
|
||||||
if (i.name.toLowerCase().contains(cs)) {
|
if (i.name.toLowerCase().contains(cs)) {
|
||||||
filter.add(i);
|
filter.add(i);
|
||||||
|
@ -630,7 +641,6 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
results.values = filter;
|
results.values = filter;
|
||||||
results.count = filter.size();
|
results.count = filter.size();
|
||||||
}
|
}
|
||||||
|
@ -641,10 +651,7 @@ public class TrackPointsCard extends BaseCard implements OnChildClickListener, O
|
||||||
protected void publishResults(CharSequence constraint, FilterResults results) {
|
protected void publishResults(CharSequence constraint, FilterResults results) {
|
||||||
synchronized (adapter) {
|
synchronized (adapter) {
|
||||||
adapter.setFilterResults((Set<?>) results.values);
|
adapter.setFilterResults((Set<?>) results.values);
|
||||||
List<GpxDisplayGroup> groups = getOriginalGroups();
|
adapter.synchronizeGroups(getDisplayGroups());
|
||||||
if (groups != null) {
|
|
||||||
adapter.synchronizeGroups(groups);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
|
|
|
@ -300,8 +300,9 @@ public class WikiArticleHelper {
|
||||||
if (firstParagraphStart != -1 && firstParagraphEnd != -1
|
if (firstParagraphStart != -1 && firstParagraphEnd != -1
|
||||||
&& firstParagraphEnd >= firstParagraphStart) {
|
&& firstParagraphEnd >= firstParagraphStart) {
|
||||||
firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + P_CLOSED.length());
|
firstParagraphHtml = content.substring(firstParagraphStart, firstParagraphEnd + P_CLOSED.length());
|
||||||
while (firstParagraphHtml.substring(P_OPENED.length(), firstParagraphHtml.length() - P_CLOSED.length()).trim().isEmpty()
|
while ((firstParagraphHtml.substring(P_OPENED.length(), firstParagraphHtml.length() - P_CLOSED.length()).trim().isEmpty()
|
||||||
&& (firstParagraphEnd + P_CLOSED.length()) < content.length()) {
|
&& (firstParagraphEnd + P_CLOSED.length()) < content.length())
|
||||||
|
|| Html.fromHtml(firstParagraphHtml.replaceAll("(<a.+?/a>)|(<div.+?/div>)", "")).toString().trim().length() == 0) {
|
||||||
firstParagraphStart = content.indexOf(P_OPENED, firstParagraphEnd);
|
firstParagraphStart = content.indexOf(P_OPENED, firstParagraphEnd);
|
||||||
firstParagraphEnd = firstParagraphStart == -1 ? -1 : content.indexOf(P_CLOSED, firstParagraphStart);
|
firstParagraphEnd = firstParagraphStart == -1 ? -1 : content.indexOf(P_CLOSED, firstParagraphStart);
|
||||||
if (firstParagraphStart != -1 && firstParagraphEnd != -1) {
|
if (firstParagraphStart != -1 && firstParagraphEnd != -1) {
|
||||||
|
|
|
@ -159,7 +159,8 @@ public class TravelArticle {
|
||||||
System.err.println(e.getMessage());
|
System.err.println(e.getMessage());
|
||||||
}
|
}
|
||||||
String prefix = thumbnail ? THUMB_PREFIX : REGULAR_PREFIX;
|
String prefix = thumbnail ? THUMB_PREFIX : REGULAR_PREFIX;
|
||||||
return IMAGE_ROOT_URL + "thumb/" + hash[0] + "/" + hash[1] + "/" + imageTitle + "/" + prefix + imageTitle;
|
String suffix = imageTitle.endsWith(".svg") ? ".png" : "";
|
||||||
|
return IMAGE_ROOT_URL + "thumb/" + hash[0] + "/" + hash[1] + "/" + imageTitle + "/" + prefix + imageTitle + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Size(2)
|
@Size(2)
|
||||||
|
|
|
@ -948,6 +948,7 @@ public class TravelObfHelper implements TravelHelper {
|
||||||
}
|
}
|
||||||
if (!Algorithms.isEmpty(amenities)) {
|
if (!Algorithms.isEmpty(amenities)) {
|
||||||
article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, readGpx, callback);
|
article = cacheTravelArticles(reader.getFile(), amenities.get(0), lang, readGpx, callback);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return article;
|
return article;
|
||||||
|
|
|
@ -49,7 +49,6 @@ import java.util.List;
|
||||||
|
|
||||||
import static net.osmand.plus.download.DownloadResources.WIKIVOYAGE_FILE_FILTER;
|
import static net.osmand.plus.download.DownloadResources.WIKIVOYAGE_FILE_FILTER;
|
||||||
import static net.osmand.plus.resources.ResourceManager.DEFAULT_WIKIVOYAGE_TRAVEL_OBF;
|
import static net.osmand.plus.resources.ResourceManager.DEFAULT_WIKIVOYAGE_TRAVEL_OBF;
|
||||||
import static net.osmand.plus.wikivoyage.explore.WikivoyageExploreActivity.*;
|
|
||||||
|
|
||||||
public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEvents, TravelLocalDataHelper.Listener {
|
public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEvents, TravelLocalDataHelper.Listener {
|
||||||
|
|
||||||
|
@ -95,10 +94,6 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
||||||
if (app != null) {
|
if (app != null) {
|
||||||
app.getTravelHelper().getBookmarksHelper().addListener(this);
|
app.getTravelHelper().getBookmarksHelper().addListener(this);
|
||||||
}
|
}
|
||||||
WikivoyageExploreActivity exploreActivity = getExploreActivity();
|
|
||||||
if (exploreActivity != null) {
|
|
||||||
exploreActivity.onTabFragmentResume(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -141,7 +136,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
||||||
app.getTravelHelper().initializeDataOnAppStartup();
|
app.getTravelHelper().initializeDataOnAppStartup();
|
||||||
WikivoyageExploreActivity exploreActivity = getExploreActivity();
|
WikivoyageExploreActivity exploreActivity = getExploreActivity();
|
||||||
if (exploreActivity != null) {
|
if (exploreActivity != null) {
|
||||||
exploreActivity.populateData();
|
exploreActivity.populateData(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
removeRedundantCards();
|
removeRedundantCards();
|
||||||
|
@ -194,8 +189,9 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
|
||||||
travelButtonCard.setListener(new TravelNeededMapsCard.CardListener() {
|
travelButtonCard.setListener(new TravelNeededMapsCard.CardListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPrimaryButtonClick() {
|
public void onPrimaryButtonClick() {
|
||||||
if (activity instanceof WikivoyageExploreActivity) {
|
WikivoyageExploreActivity exploreActivity = getExploreActivity();
|
||||||
new LoadWikivoyageData((WikivoyageExploreActivity) activity, false).execute();
|
if (exploreActivity != null) {
|
||||||
|
exploreActivity.populateData(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package net.osmand.plus.wikivoyage.explore;
|
package net.osmand.plus.wikivoyage.explore;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -80,10 +79,6 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Trav
|
||||||
if (dataHelper != null) {
|
if (dataHelper != null) {
|
||||||
dataHelper.addListener(this);
|
dataHelper.addListener(this);
|
||||||
}
|
}
|
||||||
WikivoyageExploreActivity exploreActivity = getExploreActivity();
|
|
||||||
if (exploreActivity != null) {
|
|
||||||
exploreActivity.onTabFragmentResume(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -105,16 +100,6 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Trav
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private WikivoyageExploreActivity getExploreActivity() {
|
|
||||||
Activity activity = getActivity();
|
|
||||||
if (activity != null && activity instanceof WikivoyageExploreActivity) {
|
|
||||||
return (WikivoyageExploreActivity) activity;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void invalidateAdapter() {
|
public void invalidateAdapter() {
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
|
||||||
});
|
});
|
||||||
|
|
||||||
updateSearchBarVisibility();
|
updateSearchBarVisibility();
|
||||||
populateData();
|
populateData(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -249,7 +249,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
|
||||||
invalidateTabAdapters();
|
invalidateTabAdapters();
|
||||||
break;
|
break;
|
||||||
case WikivoyageOptionsBottomSheetDialogFragment.TRAVEL_BOOK_CHANGED:
|
case WikivoyageOptionsBottomSheetDialogFragment.TRAVEL_BOOK_CHANGED:
|
||||||
populateData();
|
populateData(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -313,7 +313,7 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
|
||||||
return ContextCompat.getColor(app, colorId);
|
return ContextCompat.getColor(app, colorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateData() {
|
public void populateData(final boolean resetData) {
|
||||||
switchProgressBarVisibility(true);
|
switchProgressBarVisibility(true);
|
||||||
if (app.isApplicationInitializing()) {
|
if (app.isApplicationInitializing()) {
|
||||||
final WeakReference<WikivoyageExploreActivity> activityRef = new WeakReference<>(this);
|
final WeakReference<WikivoyageExploreActivity> activityRef = new WeakReference<>(this);
|
||||||
|
@ -326,12 +326,12 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
|
||||||
public void onFinish(AppInitializer init) {
|
public void onFinish(AppInitializer init) {
|
||||||
WikivoyageExploreActivity activity = activityRef.get();
|
WikivoyageExploreActivity activity = activityRef.get();
|
||||||
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
if (AndroidUtils.isActivityNotDestroyed(activity)) {
|
||||||
new LoadWikivoyageData(activity,true).execute();
|
new LoadWikivoyageData(activity, resetData).execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
new LoadWikivoyageData(this,true).execute();
|
new LoadWikivoyageData(this, resetData).execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,10 +371,6 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTabFragmentResume(Fragment fragment) {
|
|
||||||
updateFragments();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void savedArticlesUpdated() {
|
public void savedArticlesUpdated() {
|
||||||
updateFragments();
|
updateFragments();
|
||||||
|
|
Loading…
Reference in a new issue