Merge branch 'master' of github.com:osmandapp/Osmand

This commit is contained in:
Victor Shcherb 2018-04-28 16:19:44 +03:00
commit 5eee6e4348
2 changed files with 16 additions and 13 deletions

View file

@ -116,8 +116,10 @@ public class ExploreRvAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
return items; return items;
} }
public void setItems(List<BaseTravelCard> items) { public void setItems(List<BaseTravelCard> items, boolean clearCurrent) {
this.items.clear(); if (clearCurrent) {
this.items.clear();
}
this.items.addAll(items); this.items.addAll(items);
} }

View file

@ -35,6 +35,8 @@ import java.util.List;
public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIndexesThread.DownloadEvents { public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIndexesThread.DownloadEvents {
private static final String WORLD_WIKIVOYAGE_FILE_NAME = "World_wikivoyage.sqlite";
private ExploreRvAdapter adapter = new ExploreRvAdapter(); private ExploreRvAdapter adapter = new ExploreRvAdapter();
private StartEditingTravelCard startEditingTravelCard; private StartEditingTravelCard startEditingTravelCard;
@ -56,7 +58,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn
final View mainView = inflater.inflate(R.layout.fragment_explore_tab, container, false); final View mainView = inflater.inflate(R.layout.fragment_explore_tab, container, false);
final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view); final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view);
adapter.setItems(generateItems()); adapter.setItems(generateItems(), false);
rv.setLayoutManager(new LinearLayoutManager(getContext())); rv.setLayoutManager(new LinearLayoutManager(getContext()));
rv.setAdapter(adapter); rv.setAdapter(adapter);
@ -68,10 +70,8 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn
public void newDownloadIndexes() { public void newDownloadIndexes() {
if (downloadIndexesRequested) { if (downloadIndexesRequested) {
downloadIndexesRequested = false; downloadIndexesRequested = false;
if (selectedTravelBook != null) { indexItem = getMyApplication().getDownloadThread().getIndexes()
indexItem = getMyApplication().getDownloadThread().getIndexes() .getWikivoyageItem(getWikivoyageFileName());
.getWikivoyageItem(selectedTravelBook.getName());
}
addDownloadUpdateCard(false); addDownloadUpdateCard(false);
} }
} }
@ -80,9 +80,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn
public void downloadInProgress() { public void downloadInProgress() {
DownloadIndexesThread downloadThread = getMyApplication().getDownloadThread(); DownloadIndexesThread downloadThread = getMyApplication().getDownloadThread();
IndexItem current = downloadThread.getCurrentDownloadingItem(); IndexItem current = downloadThread.getCurrentDownloadingItem();
if (selectedTravelBook != null) { indexItem = downloadThread.getIndexes().getWikivoyageItem(getWikivoyageFileName());
indexItem = downloadThread.getIndexes().getWikivoyageItem(selectedTravelBook.getName());
}
if (current != null if (current != null
&& indexItem != null && indexItem != null
&& current == indexItem && current == indexItem
@ -143,6 +141,11 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn
} }
} }
@NonNull
private String getWikivoyageFileName() {
return selectedTravelBook == null ? WORLD_WIKIVOYAGE_FILE_NAME : selectedTravelBook.getName();
}
private void removeDownloadUpdateCard() { private void removeDownloadUpdateCard() {
adapter.removeDownloadUpdateCard(); adapter.removeDownloadUpdateCard();
downloadUpdateCardAdded = false; downloadUpdateCardAdded = false;
@ -174,9 +177,7 @@ public class ExploreTabFragment extends BaseOsmAndFragment implements DownloadIn
downloadIndexesRequested = true; downloadIndexesRequested = true;
downloadThread.runReloadIndexFilesSilent(); downloadThread.runReloadIndexFilesSilent();
} else { } else {
if (selectedTravelBook != null) { indexItem = downloadThread.getIndexes().getWikivoyageItem(getWikivoyageFileName());
indexItem = downloadThread.getIndexes().getWikivoyageItem(selectedTravelBook.getName());
}
IndexItem current = downloadThread.getCurrentDownloadingItem(); IndexItem current = downloadThread.getCurrentDownloadingItem();
boolean loadingInProgress = current != null && indexItem != null && current == indexItem; boolean loadingInProgress = current != null && indexItem != null && current == indexItem;
addDownloadUpdateCard(loadingInProgress); addDownloadUpdateCard(loadingInProgress);