use of net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard in project Osmand by osmandapp.
the class ExploreTabFragment method addNeededMapsCard.
private void addNeededMapsCard() {
final OsmandApplication app = getMyApplication();
if (app != null && !neededIndexItems.isEmpty() && SHOW_TRAVEL_NEEDED_MAPS_CARD) {
neededMapsCard = new TravelNeededMapsCard(app, nightMode, neededIndexItems);
neededMapsCard.setListener(new TravelNeededMapsCard.CardListener() {
@Override
public void onPrimaryButtonClick() {
if (downloadManager != null) {
downloadManager.startDownload(getMyActivity(), getAllItemsForDownload(neededIndexItems));
adapter.updateNeededMapsCard(false);
}
}
@Override
public void onSecondaryButtonClick() {
if (neededMapsCard.isDownloading()) {
app.getDownloadThread().cancelDownload(neededIndexItems);
adapter.updateNeededMapsCard(false);
} else {
SHOW_TRAVEL_NEEDED_MAPS_CARD = false;
removeNeededMapsCard();
}
}
@Override
public void onIndexItemClick(IndexItem item) {
if ((item.getType() == DownloadActivityType.WIKIPEDIA_FILE || item.getType() == DownloadActivityType.TRAVEL_FILE) && !Version.isPaidVersion(app)) {
FragmentActivity activity = getActivity();
if (activity != null) {
ChoosePlanFragment.showInstance(activity, OsmAndFeature.WIKIPEDIA);
}
} else {
DownloadIndexesThread downloadThread = app.getDownloadThread();
if (downloadThread.isDownloading(item)) {
downloadThread.cancelDownload(item);
} else if (!item.isDownloaded() && downloadManager != null) {
downloadManager.startDownload(getMyActivity(), item);
}
adapter.updateNeededMapsCard(false);
}
}
});
adapter.addNeededMapsCard(neededMapsCard);
}
}
Aggregations