Merge pull request #11179 from osmandapp/Travel-cards

Travel: Maps you need card, popular articles jumping
This commit is contained in:
Vitaliy 2021-03-21 20:53:35 +02:00 committed by GitHub
commit 4117295fe8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 5 deletions

View file

@ -159,7 +159,7 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
if (isCardExists(getNeededMapsCardPosition(), TravelNeededMapsCard.TYPE)) { if (isCardExists(getNeededMapsCardPosition(), TravelNeededMapsCard.TYPE)) {
updateNeededMapsCard(false); updateNeededMapsCard(false);
} else if (addItem(getNeededMapsCardPosition(), card)) { } else if (addItem(getNeededMapsCardPosition(), card)) {
notifyDataSetChanged(); notifyItemInserted(getNeededMapsCardPosition());
} }
} }

View file

@ -147,8 +147,15 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
@Override @Override
public void savedArticlesUpdated() { public void savedArticlesUpdated() {
if (isAdded()) { OsmandApplication app = getMyApplication();
adapter.notifyDataSetChanged(); if (app != null) {
DownloadIndexesThread downloadThread = app.getDownloadThread();
if (!downloadThread.getIndexes().isDownloadedFromInternet) {
waitForIndexes = true;
downloadThread.runReloadIndexFilesSilent();
} else {
checkDownloadIndexes();
}
} }
} }
@ -443,8 +450,12 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadEv
@Override @Override
protected void onPostExecute(Pair<List<IndexItem>, List<IndexItem>> res) { protected void onPostExecute(Pair<List<IndexItem>, List<IndexItem>> res) {
ExploreTabFragment fragment = weakFragment.get(); ExploreTabFragment fragment = weakFragment.get();
if (res != null && fragment != null && fragment.isResumed()) { if (res != null && fragment != null && fragment.isAdded()) {
fragment.addIndexItemCards(res.first, res.second); fragment.addIndexItemCards(res.first, res.second);
fragment.removeRedundantCards();
if (!fragment.isResumed()) {
fragment.invalidateAdapter();
}
} }
} }
} }

View file

@ -373,7 +373,13 @@ public class WikivoyageExploreActivity extends TabActivity implements DownloadEv
@Override @Override
public void savedArticlesUpdated() { public void savedArticlesUpdated() {
updateFragments(); ExploreTabFragment exploreTabFragment = getExploreTabFragment();
SavedArticlesTabFragment savedArticlesTabFragment = getSavedArticlesTabFragment();
if (exploreTabFragment != null && savedArticlesTabFragment != null
&& exploreTabFragment.isAdded() && savedArticlesTabFragment.isAdded()) {
exploreTabFragment.savedArticlesUpdated();
savedArticlesTabFragment.savedArticlesUpdated();
}
} }
public static class LoadWikivoyageData extends AsyncTask<Void, Void, Void> { public static class LoadWikivoyageData extends AsyncTask<Void, Void, Void> {