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);
}
}
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);
}
}
}
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;
}
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);
}
}
}
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);
}
}
Aggregations