Search in sources :

Example 1 with OpenBetaTravelCard

use of net.osmand.plus.wikivoyage.explore.travelcards.OpenBetaTravelCard 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();
        }
    }
}
Also used : ArticleTravelCard(net.osmand.plus.wikivoyage.explore.travelcards.ArticleTravelCard) TravelGpx(net.osmand.plus.wikivoyage.data.TravelGpx) OsmandApplication(net.osmand.plus.OsmandApplication) TravelButtonCard(net.osmand.plus.wikivoyage.explore.travelcards.TravelButtonCard) ArrayList(java.util.ArrayList) TravelGpxCard(net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard) TravelNeededMapsCard(net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard) IndexItem(net.osmand.plus.download.IndexItem) BaseTravelCard(net.osmand.plus.wikivoyage.explore.travelcards.BaseTravelCard) FragmentActivity(androidx.fragment.app.FragmentActivity) TravelArticle(net.osmand.plus.wikivoyage.data.TravelArticle) OpenBetaTravelCard(net.osmand.plus.wikivoyage.explore.travelcards.OpenBetaTravelCard) HeaderTravelCard(net.osmand.plus.wikivoyage.explore.travelcards.HeaderTravelCard) StartEditingTravelCard(net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard) DownloadIndexesThread(net.osmand.plus.download.DownloadIndexesThread)

Aggregations

FragmentActivity (androidx.fragment.app.FragmentActivity)1 ArrayList (java.util.ArrayList)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 DownloadIndexesThread (net.osmand.plus.download.DownloadIndexesThread)1 IndexItem (net.osmand.plus.download.IndexItem)1 TravelArticle (net.osmand.plus.wikivoyage.data.TravelArticle)1 TravelGpx (net.osmand.plus.wikivoyage.data.TravelGpx)1 ArticleTravelCard (net.osmand.plus.wikivoyage.explore.travelcards.ArticleTravelCard)1 BaseTravelCard (net.osmand.plus.wikivoyage.explore.travelcards.BaseTravelCard)1 HeaderTravelCard (net.osmand.plus.wikivoyage.explore.travelcards.HeaderTravelCard)1 OpenBetaTravelCard (net.osmand.plus.wikivoyage.explore.travelcards.OpenBetaTravelCard)1 StartEditingTravelCard (net.osmand.plus.wikivoyage.explore.travelcards.StartEditingTravelCard)1 TravelButtonCard (net.osmand.plus.wikivoyage.explore.travelcards.TravelButtonCard)1 TravelGpxCard (net.osmand.plus.wikivoyage.explore.travelcards.TravelGpxCard)1 TravelNeededMapsCard (net.osmand.plus.wikivoyage.explore.travelcards.TravelNeededMapsCard)1