Search in sources :

Example 1 with DownloadResources

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();
}
Also used : DownloadResources(net.osmand.plus.download.DownloadResources)

Example 2 with DownloadResources

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();
}
Also used : DownloadResources(net.osmand.plus.download.DownloadResources) OsmandRegions(net.osmand.map.OsmandRegions) IndexItem(net.osmand.plus.download.IndexItem) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 3 with DownloadResources

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()]));
            }
        });
    }
}
Also used : DownloadResources(net.osmand.plus.download.DownloadResources) TextView(android.widget.TextView) OnClickListener(android.view.View.OnClickListener) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) IndexItem(net.osmand.plus.download.IndexItem)

Example 4 with DownloadResources

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();
}
Also used : DownloadResources(net.osmand.plus.download.DownloadResources) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) IndexItem(net.osmand.plus.download.IndexItem)

Aggregations

DownloadResources (net.osmand.plus.download.DownloadResources)4 IndexItem (net.osmand.plus.download.IndexItem)3 View (android.view.View)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 OnClickListener (android.view.View.OnClickListener)1 OsmandRegions (net.osmand.map.OsmandRegions)1 OsmandSettings (net.osmand.plus.OsmandSettings)1