use of net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard in project Osmand by osmandapp.
the class ExploreTabFragment method populateData.
public void populateData() {
final List<BaseTravelCard> items = new ArrayList<>();
final FragmentActivity activity = getActivity();
final OsmandApplication app = activity != null ? (OsmandApplication) activity.getApplication() : null;
if (app != null) {
if (!Version.isPaidVersion(app) && !OpenBetaTravelCard.isClosed()) {
items.add(new OpenBetaTravelCard(activity, nightMode));
}
final List<TravelArticle> popularArticles = app.getTravelHelper().getPopularArticles();
if (!popularArticles.isEmpty()) {
items.add(new HeaderTravelCard(app, nightMode, getString(R.string.popular_destinations)));
for (TravelArticle article : popularArticles) {
if (article instanceof TravelGpx) {
items.add(new TravelGpxCard(app, nightMode, (TravelGpx) article, activity));
} else {
items.add(new ArticleTravelCard(app, nightMode, article, activity.getSupportFragmentManager()));
}
}
}
if (!isOnlyDefaultTravelBookPresent()) {
TravelButtonCard travelButtonCard = new TravelButtonCard(app, nightMode);
travelButtonCard.setListener(new TravelNeededMapsCard.CardListener() {
@Override
public void onPrimaryButtonClick() {
WikivoyageExploreActivity exploreActivity = getExploreActivity();
if (exploreActivity != null) {
exploreActivity.populateData(false);
}
}
@Override
public void onSecondaryButtonClick() {
}
@Override
public void onIndexItemClick(IndexItem item) {
}
});
items.add(travelButtonCard);
}
items.add(new StartEditingTravelCard(activity, nightMode));
adapter.setItems(items);
final DownloadIndexesThread downloadThread = app.getDownloadThread();
if (!downloadThread.getIndexes().isDownloadedFromInternet) {
waitForIndexes = true;
downloadThread.runReloadIndexFilesSilent();
} else {
checkDownloadIndexes();
}
}
}
Aggregations