This commit is contained in:
Victor Shcherb 2015-10-19 22:18:03 +02:00
parent 6f1b683629
commit 6fd9bafa51
7 changed files with 157 additions and 132 deletions

View file

@ -32,6 +32,7 @@ public class WorldRegion {
private String regionId; private String regionId;
private String downloadsId; private String downloadsId;
private String name; private String name;
private String searchText;
// Hierarchy // Hierarchy
private WorldRegion superregion; private WorldRegion superregion;
@ -95,10 +96,11 @@ public class WorldRegion {
private WorldRegion init(String regionId, OsmandRegions osmandRegions, String name) { private WorldRegion init(String regionId, OsmandRegions osmandRegions, String name) {
this.regionId = regionId; this.regionId = regionId;
String downloadName = osmandRegions.getDownloadName(regionId); String downloadName = osmandRegions.getDownloadName(regionId);
this.searchText = osmandRegions.getDownloadNameIndexLowercase(downloadName);
if (downloadName != null) { if (downloadName != null) {
downloadsId = downloadName.toLowerCase(); downloadsId = downloadName.toLowerCase();
} else { } else {
this.downloadsId = regionId.toLowerCase(); downloadsId = regionId.toLowerCase();
} }
if (name != null) { if (name != null) {
this.name = name; this.name = name;
@ -111,6 +113,10 @@ public class WorldRegion {
return this; return this;
} }
public String getSearchText() {
return searchText;
}
private void addSubregion(WorldRegion subregion, WorldRegion world) { private void addSubregion(WorldRegion subregion, WorldRegion world) {
subregion.superregion = this; subregion.superregion = this;
subregions.add(subregion); subregions.add(subregion);

View file

@ -1,6 +1,7 @@
package net.osmand.plus.download.ui; package net.osmand.plus.download.ui;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
@ -8,7 +9,6 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
@ -26,7 +26,7 @@ public class ActiveDownloadsDialogFragment extends DialogFragment implements Dow
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.downloads).setNegativeButton(R.string.shared_string_dismiss, null); builder.setTitle(R.string.downloads).setNegativeButton(R.string.shared_string_dismiss, null);
adapter = new IndexItemAdapter(getDownloadActivity()); adapter = new IndexItemAdapter(this, getDownloadActivity());
builder.setAdapter(adapter, null); builder.setAdapter(adapter, null);
return builder.create(); return builder.create();
} }
@ -50,20 +50,22 @@ public class ActiveDownloadsDialogFragment extends DialogFragment implements Dow
} }
public static class IndexItemAdapter extends ArrayAdapter<IndexItem> { public static class IndexItemAdapter extends ArrayAdapter<IndexItem> {
private final Drawable deleteDrawable;
private final DownloadActivity context; private final DownloadActivity context;
private DialogFragment dlgFragment;
public IndexItemAdapter(DownloadActivity context) { public IndexItemAdapter(DialogFragment dlgFragment, DownloadActivity context) {
super(context, R.layout.two_line_with_images_list_item, new ArrayList<IndexItem>()); super(context, R.layout.two_line_with_images_list_item, new ArrayList<IndexItem>());
this.dlgFragment = dlgFragment;
this.context = context; this.context = context;
deleteDrawable = context.getMyApplication().getIconsCache()
.getPaintedContentIcon(R.drawable.ic_action_remove_dark,
context.getResources().getColor(R.color.dash_search_icon_dark));
refreshAllData(); refreshAllData();
} }
public void refreshAllData() { public void refreshAllData() {
clear(); clear();
List<IndexItem> items = context.getDownloadThread().getCurrentDownloadingItems();
if(items.isEmpty()) {
dlgFragment.dismissAllowingStateLoss();
}
addAll(context.getDownloadThread().getCurrentDownloadingItems()); addAll(context.getDownloadThread().getCurrentDownloadingItems());
} }
@ -72,70 +74,20 @@ public class ActiveDownloadsDialogFragment extends DialogFragment implements Dow
if (convertView == null) { if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()) convertView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.two_line_with_images_list_item, parent, false); .inflate(R.layout.two_line_with_images_list_item, parent, false);
DownloadEntryViewHolder viewHolder = ItemViewHolder viewHolder =
new DownloadEntryViewHolder(convertView, context, deleteDrawable, this); new ItemViewHolder(convertView, context);
viewHolder.setSilentCancelDownload(true);
viewHolder.setShowProgressInDescr(true);
convertView.setTag(viewHolder); convertView.setTag(viewHolder);
} }
DownloadEntryViewHolder viewHolder = (DownloadEntryViewHolder) convertView.getTag(); ItemViewHolder viewHolder = (ItemViewHolder) convertView.getTag();
IndexItem item = getItem(position); IndexItem item = getItem(position);
IndexItem cdi = context.getDownloadThread().getCurrentDownloadingItem(); viewHolder.bindIndexItem(item);
viewHolder.bindDownloadEntry(getItem(position),
cdi == item ? context.getDownloadThread().getCurrentDownloadingItemProgress() : -1,
context.getDownloadThread().isDownloading(item));
return convertView; return convertView;
} }
} }
// FIXME review view holder
private static class DownloadEntryViewHolder extends ItemViewHolder {
private final Drawable deleteDrawable;
private final IndexItemAdapter adapter;
private DownloadEntryViewHolder(View convertView, final DownloadActivity context,
Drawable deleteDrawable, IndexItemAdapter adapter) {
super(convertView, context);
this.deleteDrawable = deleteDrawable;
this.adapter = adapter;
progressBar.setVisibility(View.VISIBLE);
rightImageButton.setImageDrawable(deleteDrawable);
}
public void bindDownloadEntry(final IndexItem item, final int progress,
boolean isDownloaded) {
nameTextView.setText(item.getVisibleName(context,
context.getMyApplication().getRegions()));
rightImageButton.setVisibility(View.VISIBLE);
int localProgress = progress;
boolean isIndeterminate = true;
if (progress != -1) {
isIndeterminate = false;
double downloaded = item.getContentSizeMB() * progress / 100;
descrTextView.setText(context.getString(R.string.value_downloaded_from_max, downloaded,
item.getContentSizeMB()));
} else if (isDownloaded) {
isIndeterminate = false;
localProgress = progressBar.getMax();
descrTextView.setText(context.getString(R.string.file_size_in_mb,
item.getContentSizeMB()));
rightImageButton.setVisibility(View.GONE);
} else {
descrTextView.setText(context.getString(R.string.file_size_in_mb,
item.getContentSizeMB()));
}
rightImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
context.getDownloadThread().cancelDownload(item);
adapter.refreshAllData();
}
});
progressBar.setIndeterminate(isIndeterminate);
progressBar.setProgress(localProgress);
}
}
} }

View file

@ -36,6 +36,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ExpandableListView; import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener; import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.TextView; import android.widget.TextView;
@ -170,16 +171,27 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
return true; return true;
} else if (child instanceof IndexItem) { } else if (child instanceof IndexItem) {
IndexItem indexItem = (IndexItem) child; IndexItem indexItem = (IndexItem) child;
if (indexItem.getType() == DownloadActivityType.ROADS_FILE) { DownloadResourceGroup groupObj = listAdapter.getGroupObj(groupPosition);
// FIXME boolean handled = false;
// if (regularMap.getType() == DownloadActivityType.NORMAL_FILE if (indexItem.getType() == DownloadActivityType.ROADS_FILE && groupObj != null
// && regularMap.isAlreadyDownloaded(getMyActivity().getIndexFileNames())) { && !activity.getDownloadThread().isDownloading(indexItem)) {
// ConfirmDownloadUnneededMapDialogFragment.createInstance(indexItem) for (IndexItem ii : groupObj.getIndividualResources()) {
// .show(getChildFragmentManager(), "dialog"); if (ii.getType() == DownloadActivityType.NORMAL_FILE) {
// return true; if (ii.isDownloaded()) {
// } handled = true;
ConfirmDownloadUnneededMapDialogFragment.createInstance(indexItem).show(
getChildFragmentManager(), "dialog");
}
break;
}
}
} }
((DownloadActivity) getActivity()).startDownload(indexItem); ((DownloadActivity) getActivity()).startDownload(indexItem);
if (!handled) {
ItemViewHolder vh = (ItemViewHolder) v.getTag();
OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem));
ls.onClick(v);
}
return true; return true;
} }
return false; return false;
@ -220,8 +232,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
getDownloadActivity().getDownloadThread().runReloadIndexFiles(); getDownloadActivity().getDownloadThread().runReloadIndexFiles();
return true; return true;
case SEARCH_ID: case SEARCH_ID:
// FIXME getDownloadActivity().showDialog(getActivity(), SearchDialogFragment.createInstance(""));
//getDownloadActivity().showDialog(getActivity(), SearchDialogFragment.createInstance(""));
return true; return true;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
@ -237,7 +248,6 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
} }
public static class ConfirmDownloadUnneededMapDialogFragment extends DialogFragment { public static class ConfirmDownloadUnneededMapDialogFragment extends DialogFragment {
private static final String INDEX_ITEM = "index_item";
private static IndexItem item = null; private static IndexItem item = null;
@NonNull @NonNull
@ -422,6 +432,10 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
return data.get(groupPosition).size(); return data.get(groupPosition).size();
} }
public DownloadResourceGroup getGroupObj(int groupPosition) {
return data.get(groupPosition);
}
@Override @Override
public String getGroup(int groupPosition) { public String getGroup(int groupPosition) {
DownloadResourceGroup drg = data.get(groupPosition); DownloadResourceGroup drg = data.get(groupPosition);

View file

@ -16,6 +16,7 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button; import android.widget.Button;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
@ -24,7 +25,6 @@ import android.widget.Toast;
public class ItemViewHolder { public class ItemViewHolder {
private final java.text.DateFormat dateFormat;
protected final TextView nameTextView; protected final TextView nameTextView;
protected final TextView descrTextView; protected final TextView descrTextView;
@ -42,10 +42,11 @@ public class ItemViewHolder {
private int textColorPrimary; private int textColorPrimary;
private int textColorSecondary; private int textColorSecondary;
private RightButtonAction clickAction;
boolean showTypeInDesc; boolean showTypeInDesc;
boolean showRemoteDate; boolean showRemoteDate;
boolean silentCancelDownload;
boolean showProgressInDesc;
@ -67,7 +68,6 @@ public class ItemViewHolder {
rightImageButton = (ImageView) view.findViewById(R.id.rightImageButton); rightImageButton = (ImageView) view.findViewById(R.id.rightImageButton);
nameTextView = (TextView) view.findViewById(R.id.name); nameTextView = (TextView) view.findViewById(R.id.name);
this.dateFormat = context.getMyApplication().getResourceManager().getDateFormat();
TypedValue typedValue = new TypedValue(); TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme(); Resources.Theme theme = context.getTheme();
@ -81,6 +81,14 @@ public class ItemViewHolder {
this.showRemoteDate = showRemoteDate; this.showRemoteDate = showRemoteDate;
} }
public void setShowProgressInDescr(boolean b) {
showProgressInDesc = b;
}
public void setSilentCancelDownload(boolean silentCancelDownload) {
this.silentCancelDownload = silentCancelDownload;
}
public void setShowTypeInDesc(boolean showTypeInDesc) { public void setShowTypeInDesc(boolean showTypeInDesc) {
this.showTypeInDesc = showTypeInDesc; this.showTypeInDesc = showTypeInDesc;
} }
@ -111,7 +119,7 @@ public class ItemViewHolder {
nameTextView.setTextColor(textColorSecondary); nameTextView.setTextColor(textColorSecondary);
} }
int color = textColorSecondary; int color = textColorSecondary;
if(indexItem.isDownloaded()) { if(indexItem.isDownloaded() && !isDownloading) {
int colorId = indexItem.isOutdated() ? R.color.color_distance : R.color.color_ok; int colorId = indexItem.isOutdated() ? R.color.color_distance : R.color.color_ok;
color = context.getResources().getColor(colorId); color = context.getResources().getColor(colorId);
} }
@ -125,11 +133,9 @@ public class ItemViewHolder {
leftImageView.setImageDrawable(getContentIcon(context, leftImageView.setImageDrawable(getContentIcon(context,
indexItem.getType().getIconResource())); indexItem.getType().getIconResource()));
} }
descrTextView.setTextColor(color);
if (!isDownloading) { if (!isDownloading) {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
descrTextView.setTextColor(color);
descrTextView.setVisibility(View.VISIBLE); descrTextView.setVisibility(View.VISIBLE);
if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE || if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE ||
indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) { indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) {
@ -151,15 +157,31 @@ public class ItemViewHolder {
}); });
} else { } else {
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(progress == -1);
progressBar.setProgress(progress); progressBar.setProgress(progress);
descrTextView.setVisibility(View.GONE); if (showProgressInDesc) {
double mb = indexItem.getContentSizeMB();
if (progress != -1) {
descrTextView.setText(context.getString(R.string.value_downloaded_from_max, mb * progress / 100,
mb));
} else {
descrTextView.setText(context.getString(R.string.file_size_in_mb, mb));
}
descrTextView.setVisibility(View.VISIBLE);
} else {
descrTextView.setVisibility(View.GONE);
}
rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_remove_dark)); rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_remove_dark));
rightImageButton.setOnClickListener(new View.OnClickListener() { rightImageButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
context.makeSureUserCancelDownload(indexItem); if(silentCancelDownload) {
context.getDownloadThread().cancelDownload(indexItem);
} else {
context.makeSureUserCancelDownload(indexItem);
}
} }
}); });
} }
@ -167,12 +189,26 @@ public class ItemViewHolder {
private boolean checkDisabledAndClickAction(final IndexItem indexItem) { private boolean checkDisabledAndClickAction(final IndexItem indexItem) {
boolean disabled = false; RightButtonAction clickAction = getClickAction(indexItem);
clickAction = RightButtonAction.DOWNLOAD; boolean disabled = clickAction != RightButtonAction.DOWNLOAD;
if (clickAction != RightButtonAction.DOWNLOAD) {
rightButton.setText(R.string.get_plugin);
rightButton.setVisibility(View.VISIBLE);
rightImageButton.setVisibility(View.GONE);
rightButton.setOnClickListener(getRightButtonAction(indexItem, clickAction));
} else {
rightButton.setVisibility(View.GONE);
rightImageButton.setVisibility(View.VISIBLE);
}
return disabled;
}
public RightButtonAction getClickAction(final IndexItem indexItem) {
RightButtonAction clickAction = RightButtonAction.DOWNLOAD;
if (indexItem.getBasename().toLowerCase().equals(DownloadResources.WORLD_SEAMARKS_KEY) if (indexItem.getBasename().toLowerCase().equals(DownloadResources.WORLD_SEAMARKS_KEY)
&& nauticalPluginDisabled) { && nauticalPluginDisabled) {
clickAction = RightButtonAction.ASK_FOR_SEAMARKS_PLUGIN; clickAction = RightButtonAction.ASK_FOR_SEAMARKS_PLUGIN;
disabled = true;
} else if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE || } else if ((indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE ||
indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) { indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) {
if (srtmNeedsInstallation) { if (srtmNeedsInstallation) {
@ -181,55 +217,61 @@ public class ItemViewHolder {
clickAction = RightButtonAction.ASK_FOR_SRTM_PLUGIN_ENABLE; clickAction = RightButtonAction.ASK_FOR_SRTM_PLUGIN_ENABLE;
} }
disabled = true;
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE && freeVersion) { } else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE && freeVersion) {
clickAction = RightButtonAction.ASK_FOR_FULL_VERSION_PURCHASE; clickAction = RightButtonAction.ASK_FOR_FULL_VERSION_PURCHASE;
disabled = true;
} }
return clickAction;
}
public OnClickListener getRightButtonAction(final IndexItem item, final RightButtonAction clickAction) {
if (clickAction != RightButtonAction.DOWNLOAD) { if (clickAction != RightButtonAction.DOWNLOAD) {
rightButton.setText(R.string.get_plugin); return new View.OnClickListener() {
rightButton.setVisibility(View.VISIBLE);
rightImageButton.setVisibility(View.GONE);
final RightButtonAction action = clickAction;
rightButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (action) { switch (clickAction) {
case ASK_FOR_FULL_VERSION_PURCHASE: case ASK_FOR_FULL_VERSION_PURCHASE:
Intent intent = new Intent(Intent.ACTION_VIEW, Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(context
Uri.parse(Version.marketPrefix(context.getMyApplication()) .getMyApplication()) + "net.osmand.plus"));
+ "net.osmand.plus")); context.startActivity(intent);
context.startActivity(intent); break;
break; case ASK_FOR_SEAMARKS_PLUGIN:
case ASK_FOR_SEAMARKS_PLUGIN: context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization()
context.startActivity(new Intent(context, .getPluginsActivity()));
context.getMyApplication().getAppCustomization().getPluginsActivity())); AccessibleToast.makeText(context.getApplicationContext(),
AccessibleToast.makeText(context.getApplicationContext(), context.getString(R.string.activate_seamarks_plugin), Toast.LENGTH_SHORT).show();
context.getString(R.string.activate_seamarks_plugin), Toast.LENGTH_SHORT).show(); break;
break; case ASK_FOR_SRTM_PLUGIN_PURCHASE:
case ASK_FOR_SRTM_PLUGIN_PURCHASE: OsmandPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class);
OsmandPlugin plugin = OsmandPlugin.getPlugin(SRTMPlugin.class); context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL()))); break;
break; case ASK_FOR_SRTM_PLUGIN_ENABLE:
case ASK_FOR_SRTM_PLUGIN_ENABLE: context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization()
context.startActivity(new Intent(context, .getPluginsActivity()));
context.getMyApplication().getAppCustomization().getPluginsActivity())); AccessibleToast.makeText(context, context.getString(R.string.activate_srtm_plugin),
AccessibleToast.makeText(context, Toast.LENGTH_SHORT).show();
context.getString(R.string.activate_srtm_plugin), Toast.LENGTH_SHORT).show(); break;
break; case DOWNLOAD:
case DOWNLOAD: break;
break;
} }
} }
}); };
} else { } else {
rightButton.setVisibility(View.GONE); final boolean isDownloading = context.getDownloadThread().isDownloading(item);
rightImageButton.setVisibility(View.VISIBLE); return new View.OnClickListener() {
@Override
public void onClick(View v) {
if(isDownloading) {
if(silentCancelDownload) {
context.getDownloadThread().cancelDownload(item);
} else {
context.makeSureUserCancelDownload(item);
}
} else {
context.startDownload(item);
}
}
};
} }
return disabled;
} }
private Drawable getContentIcon(DownloadActivity context, int resourceId) { private Drawable getContentIcon(DownloadActivity context, int resourceId) {
@ -240,7 +282,5 @@ public class ItemViewHolder {
return context.getMyApplication().getIconsCache().getPaintedContentIcon(resourceId, color); return context.getMyApplication().getIconsCache().getPaintedContentIcon(resourceId, color);
} }
public boolean isItemAvailable() {
return clickAction == RightButtonAction.DOWNLOAD;
}
} }

View file

@ -16,7 +16,16 @@ import net.osmand.plus.R;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
public class SearchDialogFragment { /*extends DialogFragment implements DownloadEvents { // FIXME
public class SearchDialogFragment extends DialogFragment {
public static DialogFragment createInstance(String tg) {
return new SearchDialogFragment();
}
/*extends DialogFragment implements DownloadEvents {
public static final String TAG = "SearchDialogFragment"; public static final String TAG = "SearchDialogFragment";
private static final String SEARCH_TEXT_DLG_KEY = "search_text_dlg_key"; private static final String SEARCH_TEXT_DLG_KEY = "search_text_dlg_key";

View file

@ -29,6 +29,7 @@ import android.widget.Filter;
import android.widget.Filterable; import android.widget.Filterable;
import android.widget.ListView; import android.widget.ListView;
//FIXME merge into search dialog fragment
public class SearchItemsFragment { /*extends Fragment implements DownloadEvents { public class SearchItemsFragment { /*extends Fragment implements DownloadEvents {
public static final String TAG = "SearchItemsFragment"; public static final String TAG = "SearchItemsFragment";

View file

@ -20,6 +20,7 @@ import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
@ -118,7 +119,9 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
@Override @Override
public void onListItemClick(ListView l, View v, int position, long id) { public void onListItemClick(ListView l, View v, int position, long id) {
final IndexItem e = (IndexItem) getListAdapter().getItem(position); final IndexItem e = (IndexItem) getListAdapter().getItem(position);
getMyActivity().startDownload(e); ItemViewHolder vh = (ItemViewHolder) v.getTag();
OnClickListener ls = vh.getRightButtonAction(e, vh.getClickAction(e));
ls.onClick(v);
} }
public DownloadActivity getMyActivity() { public DownloadActivity getMyActivity() {