use of net.osmand.plus.wikivoyage.explore.travelcards.ArticleTravelCard 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();
}
}
}
use of net.osmand.plus.wikivoyage.explore.travelcards.ArticleTravelCard in project Osmand by osmandapp.
the class ExploreRvAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
BaseTravelCard item = getItem(position);
if (viewHolder instanceof HeaderTravelVH && item instanceof HeaderTravelCard) {
HeaderTravelCard headerTravelCard = (HeaderTravelCard) item;
headerTravelCard.setArticleItemCount(getArticleItemCount());
headerTravelCard.bindViewHolder(viewHolder);
} else if (viewHolder instanceof ArticleTravelVH && item instanceof TravelGpxCard) {
TravelGpxCard travelGpxCard = (TravelGpxCard) item;
travelGpxCard.setLastItem(position == getLastArticleItemIndex());
travelGpxCard.bindViewHolder(viewHolder);
} else if (viewHolder instanceof ArticleTravelVH && item instanceof ArticleTravelCard) {
ArticleTravelCard articleTravelCard = (ArticleTravelCard) item;
articleTravelCard.setLastItem(position == getLastArticleItemIndex());
articleTravelCard.bindViewHolder(viewHolder);
} else {
item.bindViewHolder(viewHolder);
}
}
Aggregations