use of net.osmand.plus.activities.LocalIndexHelper.LocalIndexType in project Osmand by osmandapp.
the class ItemViewHolder method contextMenu.
protected void contextMenu(View v, final IndexItem indexItem, final DownloadResourceGroup parentOptional) {
final PopupMenu optionsMenu = new PopupMenu(context, v);
MenuItem item;
final File fl = indexItem.getTargetFile(context.getMyApplication());
if (fl.exists()) {
item = optionsMenu.getMenu().add(R.string.shared_string_remove).setIcon(context.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_remove_dark));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
LocalIndexType tp = LocalIndexType.MAP_DATA;
if (indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) {
tp = LocalIndexType.TILES_DATA;
} else if (indexItem.getType() == DownloadActivityType.ROADS_FILE) {
tp = LocalIndexType.MAP_DATA;
} else if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
tp = LocalIndexType.SRTM_DATA;
} else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE) {
tp = LocalIndexType.MAP_DATA;
} else if (indexItem.getType() == DownloadActivityType.FONT_FILE) {
tp = LocalIndexType.FONT_DATA;
} else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
tp = indexItem.getBasename().contains("tts") ? LocalIndexType.TTS_VOICE_DATA : LocalIndexType.VOICE_DATA;
}
final LocalIndexInfo info = new LocalIndexInfo(tp, fl, false, context.getMyApplication());
AlertDialog.Builder confirm = new AlertDialog.Builder(context);
confirm.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
new LocalIndexOperationTask(context, null, LocalIndexOperationTask.DELETE_OPERATION).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, info);
}
});
confirm.setNegativeButton(R.string.shared_string_no, null);
String fn = FileNameTranslationHelper.getFileName(context, context.getMyApplication().getRegions(), indexItem.getVisibleName(context, context.getMyApplication().getRegions()));
confirm.setMessage(context.getString(R.string.delete_confirmation_msg, fn));
confirm.show();
return true;
}
});
}
item = optionsMenu.getMenu().add(R.string.shared_string_download).setIcon(context.getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_import));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
download(indexItem, parentOptional);
return true;
}
});
optionsMenu.show();
}
Aggregations