use of net.osmand.plus.download.DownloadResources in project Osmand by osmandapp.
the class DownloadResourceGroupFragment method reloadData.
private void reloadData() {
if (!openAsDialog()) {
updateSearchView();
}
updateSubscribeEmailView();
DownloadResources indexes = activity.getDownloadThread().getIndexes();
group = indexes.getGroupById(groupId);
if (group != null) {
listAdapter.update(group);
toolbar.setTitle(group.getName(activity));
}
expandAllGroups();
}
use of net.osmand.plus.download.DownloadResources in project Osmand by osmandapp.
the class UpdatesIndexFragment method invalidateListView.
public void invalidateListView(Activity a) {
DownloadResources indexes = getMyApplication().getDownloadThread().getIndexes();
List<IndexItem> indexItems = indexes.getItemsToUpdate();
final OsmandRegions osmandRegions = getMyApplication().getResourceManager().getOsmandRegions();
OsmandSettings settings = getMyApplication().getSettings();
listAdapter = new UpdateIndexAdapter(a, R.layout.download_index_list_item, indexItems, !settings.LIVE_UPDATES_PURCHASED.get() || settings.SHOULD_SHOW_FREE_VERSION_BANNER.get());
listAdapter.sort(new Comparator<IndexItem>() {
@Override
public int compare(IndexItem indexItem, IndexItem indexItem2) {
return indexItem.getVisibleName(getMyApplication(), osmandRegions).compareTo(indexItem2.getVisibleName(getMyApplication(), osmandRegions));
}
});
setListAdapter(listAdapter);
updateErrorMessage();
}
use of net.osmand.plus.download.DownloadResources in project Osmand by osmandapp.
the class UpdatesIndexFragment method updateUpdateAllButton.
private void updateUpdateAllButton() {
View view = getView();
if (view == null) {
return;
}
DownloadResources indexes = getMyActivity().getDownloadThread().getIndexes();
final List<IndexItem> indexItems = indexes.getItemsToUpdate();
final TextView updateAllButton = (TextView) view.findViewById(R.id.updateAllButton);
if (indexItems.size() == 0 || indexItems.get(0).getType() == null) {
if (!Algorithms.isEmpty(errorMessage)) {
updateAllButton.setText(errorMessage);
updateAllButton.setEnabled(false);
updateAllButton.setVisibility(View.VISIBLE);
} else {
updateAllButton.setVisibility(View.GONE);
}
} else {
updateAllButton.setVisibility(View.VISIBLE);
updateAllButton.setEnabled(true);
long downloadsSize = 0;
for (IndexItem indexItem : indexItems) {
downloadsSize += indexItem.getSize();
}
String updateAllText = getActivity().getString(R.string.update_all, downloadsSize >> 20);
updateAllButton.setText(updateAllText);
updateAllButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getMyActivity().startDownload(indexItems.toArray(new IndexItem[indexItems.size()]));
}
});
}
}
use of net.osmand.plus.download.DownloadResources in project Osmand by osmandapp.
the class UpdatesIndexFragment method updateErrorMessage.
private void updateErrorMessage() {
final View view = getView();
if (view == null)
return;
DownloadResources indexes = getMyApplication().getDownloadThread().getIndexes();
List<IndexItem> indexItems = indexes.getItemsToUpdate();
if (getListAdapter() != null && indexItems.size() == 0) {
int messageId = indexes.isDownloadedFromInternet ? R.string.everything_up_to_date : R.string.no_index_file_to_download;
errorMessage = getString(messageId);
} else {
errorMessage = null;
}
updateUpdateAllButton();
}
Aggregations