Search in sources :

Example 21 with IndexItem

use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.

the class SearchDialogFragment method onItemClick.

@Override
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
    Object obj = listAdapter.getItem(position);
    if (obj instanceof DownloadResourceGroup) {
        String uniqueId = ((DownloadResourceGroup) obj).getUniqueId();
        final DownloadResourceGroupFragment regionDialogFragment = DownloadResourceGroupFragment.createInstance(uniqueId);
        ((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment);
    } else if (obj instanceof IndexItem) {
        IndexItem indexItem = (IndexItem) obj;
        ItemViewHolder vh = (ItemViewHolder) v.getTag();
        View.OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem));
        ls.onClick(v);
    }
}
Also used : DownloadResourceGroup(net.osmand.plus.download.DownloadResourceGroup) BinaryMapDataObject(net.osmand.binary.BinaryMapDataObject) IndexItem(net.osmand.plus.download.IndexItem) DownloadActivity(net.osmand.plus.download.DownloadActivity)

Example 22 with IndexItem

use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.

the class DownloadResourceGroupFragment method updateSearchView.

private void updateSearchView() {
    IndexItem worldBaseMapItem = null;
    if (searchView != null && searchView.findViewById(R.id.title).getVisibility() == View.GONE) {
        worldBaseMapItem = activity.getDownloadThread().getIndexes().getWorldBaseMapItem();
        if (worldBaseMapItem != null && worldBaseMapItem.isDownloaded()) {
            searchView.findViewById(R.id.title).setVisibility(View.VISIBLE);
            listView.setHeaderDividersEnabled(true);
        }
    }
    if (restorePurchasesView != null && restorePurchasesView.findViewById(R.id.container).getVisibility() == View.GONE && !InAppHelper.isInAppIntentoryRead()) {
        if (worldBaseMapItem != null && worldBaseMapItem.isDownloaded()) {
            restorePurchasesView.findViewById(R.id.container).setVisibility(View.VISIBLE);
        }
    }
}
Also used : IndexItem(net.osmand.plus.download.IndexItem)

Example 23 with IndexItem

use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.

the class DownloadResourceGroupFragment method onChildClick.

@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
    Object child = listAdapter.getChild(groupPosition, childPosition);
    if (child instanceof DownloadResourceGroup) {
        String uniqueId = ((DownloadResourceGroup) child).getUniqueId();
        final DownloadResourceGroupFragment regionDialogFragment = DownloadResourceGroupFragment.createInstance(uniqueId);
        ((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment);
        return true;
    } else if (child instanceof IndexItem) {
        IndexItem indexItem = (IndexItem) child;
        ItemViewHolder vh = (ItemViewHolder) v.getTag();
        OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem));
        ls.onClick(v);
        return true;
    }
    return false;
}
Also used : DownloadResourceGroup(net.osmand.plus.download.DownloadResourceGroup) OnClickListener(android.view.View.OnClickListener) JSONObject(org.json.JSONObject) IndexItem(net.osmand.plus.download.IndexItem) DownloadActivity(net.osmand.plus.download.DownloadActivity)

Example 24 with IndexItem

use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.

the class DownloadResourceGroupFragment method addSearchRow.

private void addSearchRow() {
    if (!openAsDialog()) {
        searchView = activity.getLayoutInflater().inflate(R.layout.simple_list_menu_item, null);
        searchView.setBackgroundResource(android.R.drawable.list_selector_background);
        TextView title = (TextView) searchView.findViewById(R.id.title);
        title.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null);
        title.setHint(R.string.search_map_hint);
        searchView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                getDownloadActivity().showDialog(getActivity(), SearchDialogFragment.createInstance(""));
            }
        });
        listView.addHeaderView(searchView);
        listView.setHeaderDividersEnabled(true);
        IndexItem worldBaseMapItem = activity.getDownloadThread().getIndexes().getWorldBaseMapItem();
        if (worldBaseMapItem == null || !worldBaseMapItem.isDownloaded()) {
            searchView.findViewById(R.id.title).setVisibility(View.GONE);
            listView.setHeaderDividersEnabled(false);
        }
    }
}
Also used : OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ExpandableListView(android.widget.ExpandableListView) IndexItem(net.osmand.plus.download.IndexItem)

Example 25 with IndexItem

use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.

the class ItemViewHolder method download.

protected void download(IndexItem indexItem, DownloadResourceGroup parentOptional) {
    boolean handled = false;
    if (parentOptional != null) {
        WorldRegion region = DownloadResourceGroup.getRegion(parentOptional);
        context.setDownloadItem(region, indexItem.getTargetFile(context.getMyApplication()).getAbsolutePath());
    }
    if (indexItem.getType() == DownloadActivityType.ROADS_FILE && parentOptional != null) {
        for (IndexItem ii : parentOptional.getIndividualResources()) {
            if (ii.getType() == DownloadActivityType.NORMAL_FILE) {
                if (ii.isDownloaded()) {
                    handled = true;
                    confirmDownload(indexItem);
                }
                break;
            }
        }
    }
    if (!handled) {
        context.startDownload(indexItem);
    }
}
Also used : WorldRegion(net.osmand.map.WorldRegion) IndexItem(net.osmand.plus.download.IndexItem)

Aggregations

IndexItem (net.osmand.plus.download.IndexItem)27 View (android.view.View)9 TextView (android.widget.TextView)8 OnClickListener (android.view.View.OnClickListener)6 ContextMenuItem (net.osmand.plus.ContextMenuItem)5 IOException (java.io.IOException)4 LinkedList (java.util.LinkedList)4 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)4 LatLon (net.osmand.data.LatLon)4 OsmandRegions (net.osmand.map.OsmandRegions)4 WorldRegion (net.osmand.map.WorldRegion)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 OsmandSettings (net.osmand.plus.OsmandSettings)4 DownloadIndexesThread (net.osmand.plus.download.DownloadIndexesThread)4 Intent (android.content.Intent)3 ArrayAdapter (android.widget.ArrayAdapter)3 ExpandableListView (android.widget.ExpandableListView)3 ImageView (android.widget.ImageView)3 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)3 DownloadResources (net.osmand.plus.download.DownloadResources)3