use of androidx.appcompat.widget.ListPopupWindow in project boon by Wing-Li.
the class Html5Activity method initListPopuItem.
private void initListPopuItem(View view) {
ArrayList<String> moreItems = new ArrayList<>();
if (isFavorite) {
moreItems.add("取消收藏");
} else {
moreItems.add("收藏");
}
moreItems.add("复制链接");
moreItems.add("分享");
final ListPopupWindow mListPop = new ListPopupWindow(this);
mListPop.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, moreItems));
mListPop.setWidth(500);
mListPop.setHeight(LinearLayoutCompat.LayoutParams.WRAP_CONTENT);
mListPop.setAnchorView(view);
mListPop.setModal(true);
mListPop.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mListPop.dismiss();
switch(position) {
case 0:
{
if (isFavorite) {
LeanCloudNet.INSTANCE.deleteFavorite(mDesc, mAuthor, mUrl);
showToast("取消收藏");
isFavorite = false;
} else {
LeanCloudNet.INSTANCE.saveFavorite(mDesc, mAuthor, mUrl);
showToast("收藏成功");
isFavorite = true;
}
break;
}
case 1:
{
MyUtils.setClipText(mContext, mUrl);
showToast("复制成功");
break;
}
case 2:
{
String share = mDesc + " 链接地址:" + mUrl;
shareContent(mDesc, share);
break;
}
}
}
});
mListPop.show();
}
use of androidx.appcompat.widget.ListPopupWindow in project Osmand by osmandapp.
the class GpxUiHelper method createDialog.
private static AlertDialog createDialog(final Activity activity, final boolean showCurrentGpx, final boolean multipleChoice, final boolean showAppearanceSetting, final CallbackWithObject<GPXFile[]> callbackWithObject, final List<GPXInfo> gpxInfoList, final ContextMenuAdapter contextMenuAdapter, final int themeRes, final boolean nightMode) {
final OsmandApplication app = (OsmandApplication) activity.getApplication();
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
final int layout = R.layout.gpx_track_item;
final Map<String, String> gpxAppearanceParams = new HashMap<>();
final DialogGpxDataItemCallback gpxDataItemCallback = new DialogGpxDataItemCallback(app);
ArrayList<String> modifiableGpxFileNames = new ArrayList<>(Arrays.asList(contextMenuAdapter.getItemNames()));
final ArrayAdapter<String> alertDialogAdapter = new ArrayAdapter<String>(activity, layout, R.id.title, modifiableGpxFileNames) {
@Override
public int getItemViewType(int position) {
return showCurrentGpx && position == 0 ? 1 : 0;
}
@Override
public int getViewTypeCount() {
return 2;
}
private GpxDataItem getDataItem(GPXInfo info) {
return app.getGpxDbHelper().getItem(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), info.getFileName()), gpxDataItemCallback);
}
@Override
@NonNull
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
// User super class to create the View
View v = convertView;
boolean checkLayout = getItemViewType(position) == 0;
if (v == null) {
v = View.inflate(new ContextThemeWrapper(activity, themeRes), layout, null);
}
final ContextMenuItem item = contextMenuAdapter.getItem(position);
GPXInfo info = gpxInfoList.get(position);
boolean currentlyRecordingTrack = showCurrentGpx && position == 0;
GPXTrackAnalysis analysis = null;
if (currentlyRecordingTrack) {
analysis = app.getSavingTrackHelper().getCurrentTrack().getTrackAnalysis(app);
} else {
GpxDataItem dataItem = getDataItem(info);
if (dataItem != null) {
analysis = dataItem.getAnalysis();
}
}
updateGpxInfoView(v, item.getTitle(), info, analysis, app);
if (item.getSelected() == null) {
v.findViewById(R.id.check_item).setVisibility(View.GONE);
v.findViewById(R.id.check_local_index).setVisibility(View.GONE);
} else {
if (checkLayout) {
final CheckBox ch = v.findViewById(R.id.check_local_index);
ch.setVisibility(View.VISIBLE);
v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
ch.setOnCheckedChangeListener(null);
ch.setChecked(item.getSelected());
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
item.setSelected(isChecked);
}
});
UiUtilities.setupCompoundButton(ch, nightMode, PROFILE_DEPENDENT);
} else {
final SwitchCompat ch = v.findViewById(R.id.toggle_item);
ch.setVisibility(View.VISIBLE);
v.findViewById(R.id.toggle_checkbox_item).setVisibility(View.GONE);
ch.setOnCheckedChangeListener(null);
ch.setChecked(item.getSelected());
ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
item.setSelected(isChecked);
}
});
UiUtilities.setupCompoundButton(ch, nightMode, PROFILE_DEPENDENT);
}
v.findViewById(R.id.check_item).setVisibility(View.VISIBLE);
}
return v;
}
};
OnClickListener onClickListener = new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
}
};
gpxDataItemCallback.setListAdapter(alertDialogAdapter);
builder.setAdapter(alertDialogAdapter, onClickListener);
if (multipleChoice) {
if (showAppearanceSetting) {
final RenderingRuleProperty trackWidthProp;
final RenderingRuleProperty trackColorProp;
final RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
if (renderer != null) {
trackWidthProp = renderer.PROPS.getCustomRule(CURRENT_TRACK_WIDTH_ATTR);
trackColorProp = renderer.PROPS.getCustomRule(CURRENT_TRACK_COLOR_ATTR);
} else {
trackWidthProp = null;
trackColorProp = null;
}
if (trackWidthProp == null || trackColorProp == null) {
builder.setTitle(R.string.show_gpx);
} else {
final View apprTitleView = View.inflate(new ContextThemeWrapper(activity, themeRes), R.layout.select_gpx_appearance_title, null);
final CommonPreference<String> prefWidth = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR);
final CommonPreference<String> prefColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
updateAppearanceTitle(activity, app, trackWidthProp, renderer, apprTitleView, prefWidth.get(), prefColor.get());
apprTitleView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popup = new ListPopupWindow(new ContextThemeWrapper(activity, themeRes));
popup.setAnchorView(apprTitleView);
popup.setContentWidth(AndroidUtils.dpToPx(activity, 200f));
popup.setModal(true);
popup.setDropDownGravity(Gravity.END | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(activity, -48f));
popup.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f));
final GpxAppearanceAdapter gpxApprAdapter = new GpxAppearanceAdapter(new ContextThemeWrapper(activity, themeRes), gpxAppearanceParams.containsKey(CURRENT_TRACK_COLOR_ATTR) ? gpxAppearanceParams.get(CURRENT_TRACK_COLOR_ATTR) : prefColor.get(), GpxAppearanceAdapter.GpxAppearanceAdapterType.TRACK_WIDTH_COLOR, gpxAppearanceParams.containsKey(SHOW_START_FINISH_ATTR) ? "true".equals(gpxAppearanceParams.get(SHOW_START_FINISH_ATTR)) : app.getSettings().SHOW_START_FINISH_ICONS.get(), nightMode);
popup.setAdapter(gpxApprAdapter);
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
AppearanceListItem item = gpxApprAdapter.getItem(position);
if (item != null) {
if (CURRENT_TRACK_WIDTH_ATTR.equals(item.getAttrName())) {
gpxAppearanceParams.put(CURRENT_TRACK_WIDTH_ATTR, item.getValue());
} else if (CURRENT_TRACK_COLOR_ATTR.equals(item.getAttrName())) {
gpxAppearanceParams.put(CURRENT_TRACK_COLOR_ATTR, item.getValue());
} else if (SHOW_START_FINISH_ATTR.equals(item.getAttrName())) {
gpxAppearanceParams.put(SHOW_START_FINISH_ATTR, item.getValue());
}
}
popup.dismiss();
updateAppearanceTitle(activity, app, trackWidthProp, renderer, apprTitleView, gpxAppearanceParams.containsKey(CURRENT_TRACK_WIDTH_ATTR) ? gpxAppearanceParams.get(CURRENT_TRACK_WIDTH_ATTR) : prefWidth.get(), gpxAppearanceParams.containsKey(CURRENT_TRACK_COLOR_ATTR) ? gpxAppearanceParams.get(CURRENT_TRACK_COLOR_ATTR) : prefColor.get());
}
});
popup.show();
}
});
builder.setCustomTitle(apprTitleView);
}
} else {
builder.setTitle(R.string.show_gpx);
}
builder.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (gpxAppearanceParams.size() > 0) {
for (Map.Entry<String, String> entry : gpxAppearanceParams.entrySet()) {
if (SHOW_START_FINISH_ATTR.equals(entry.getKey())) {
app.getSettings().SHOW_START_FINISH_ICONS.set("true".equals(entry.getValue()));
} else {
final CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(entry.getKey());
pref.set(entry.getValue());
}
}
if (activity instanceof MapActivity) {
((MapActivity) activity).refreshMapComplete();
}
}
GPXFile currentGPX = null;
// clear all previously selected files before adding new one
OsmandApplication app = (OsmandApplication) activity.getApplication();
if (app.getSelectedGpxHelper() != null) {
app.getSelectedGpxHelper().clearAllGpxFilesToShow(false);
}
if (showCurrentGpx && contextMenuAdapter.getItem(0).getSelected()) {
currentGPX = app.getSavingTrackHelper().getCurrentGpx();
}
List<String> selectedGpxNames = new ArrayList<>();
for (int i = (showCurrentGpx ? 1 : 0); i < contextMenuAdapter.length(); i++) {
if (contextMenuAdapter.getItem(i).getSelected()) {
selectedGpxNames.add(gpxInfoList.get(i).getFileName());
}
}
dialog.dismiss();
updateSelectedTracksAppearance(app, selectedGpxNames, gpxAppearanceParams);
loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX, selectedGpxNames.toArray(new String[0]));
}
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && gpxInfoList.size() > 1 || !showCurrentGpx && gpxInfoList.size() > 0) {
builder.setNeutralButton(R.string.gpx_add_track, null);
}
}
final AlertDialog dlg = builder.create();
dlg.setCanceledOnTouchOutside(true);
if (gpxInfoList.size() == 0 || showCurrentGpx && gpxInfoList.size() == 1) {
final View footerView = activity.getLayoutInflater().inflate(R.layout.no_gpx_files_list_footer, null);
TextView descTextView = footerView.findViewById(R.id.descFolder);
String descPrefix = app.getString(R.string.gpx_no_tracks_title_folder);
SpannableString spannableDesc = new SpannableString(descPrefix + ": " + dir.getAbsolutePath());
spannableDesc.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), descPrefix.length() + 1, spannableDesc.length(), 0);
descTextView.setText(spannableDesc);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
footerView.findViewById(R.id.button).setVisibility(View.GONE);
} else {
footerView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addTrack(activity, alertDialogAdapter, contextMenuAdapter, gpxInfoList);
}
});
}
dlg.getListView().addFooterView(footerView, null, false);
}
dlg.getListView().setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (multipleChoice) {
ContextMenuItem item = contextMenuAdapter.getItem(position);
item.setSelected(!item.getSelected());
alertDialogAdapter.notifyDataSetInvalidated();
if (position == 0 && showCurrentGpx && item.getSelected()) {
OsmandMonitoringPlugin monitoringPlugin = OsmandPlugin.getActivePlugin(OsmandMonitoringPlugin.class);
if (monitoringPlugin == null) {
AlertDialog.Builder confirm = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
confirm.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Bundle params = new Bundle();
params.putBoolean(PluginsFragment.OPEN_PLUGINS, true);
MapActivity.launchMapActivityMoveToTop(activity, null, null, params);
}
});
confirm.setNegativeButton(R.string.shared_string_cancel, null);
confirm.setMessage(activity.getString(R.string.enable_plugin_monitoring_services));
confirm.show();
} else if (!app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
monitoringPlugin.controlDialog(activity);
}
}
} else {
dlg.dismiss();
if (showCurrentGpx && position == 0) {
callbackWithObject.processResult(null);
} else {
String fileName = gpxInfoList.get(position).getFileName();
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByName(fileName);
if (selectedGpxFile != null) {
callbackWithObject.processResult(new GPXFile[] { selectedGpxFile.getGpxFile() });
} else {
loadGPXFileInDifferentThread(activity, callbackWithObject, dir, null, fileName);
}
}
}
}
});
dlg.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
Button addTrackButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEUTRAL);
if (addTrackButton != null) {
addTrackButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addTrack(activity, alertDialogAdapter, contextMenuAdapter, gpxInfoList);
}
});
}
}
});
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
gpxDataItemCallback.setUpdateEnable(false);
}
});
dlg.show();
try {
dlg.getListView().setFastScrollEnabled(true);
} catch (Exception e) {
// java.lang.ClassCastException: com.android.internal.widget.RoundCornerListAdapter
// Unknown reason but on some devices fail
}
return dlg;
}
use of androidx.appcompat.widget.ListPopupWindow in project Osmand by osmandapp.
the class EditTrackGroupDialogFragment method createChangeColorItem.
private BaseBottomSheetItem createChangeColorItem() {
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View changeColorView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.change_fav_color, null);
ImageView icon = ((ImageView) changeColorView.findViewById(R.id.change_color_icon));
icon.setImageDrawable(getContentIcon(R.drawable.ic_action_appearance));
int margin = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_icon_margin_large);
UiUtilities.setMargins(icon, 0, 0, margin, 0);
updateColorView((ImageView) changeColorView.findViewById(R.id.colorImage));
return new BaseBottomSheetItem.Builder().setCustomView(changeColorView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final FragmentActivity activity = getActivity();
if (activity != null) {
final ListPopupWindow popup = new ListPopupWindow(activity);
popup.setAnchorView(v);
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
popup.setModal(true);
popup.setDropDownGravity(Gravity.END | Gravity.TOP);
if (AndroidUiHelper.isOrientationPortrait(activity)) {
popup.setVerticalOffset(AndroidUtils.dpToPx(app, 48f));
} else {
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
}
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
final FavoriteColorAdapter colorAdapter = new FavoriteColorAdapter(activity);
popup.setAdapter(colorAdapter);
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Integer color = colorAdapter.getItem(position);
if (color != null) {
if (color != group.getColor()) {
new UpdateGpxCategoryTask(activity, group, color).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
popup.dismiss();
dismiss();
}
});
popup.show();
}
}
}).create();
}
use of androidx.appcompat.widget.ListPopupWindow in project Osmand by osmandapp.
the class SplitSegmentDialogFragment method updateHeader.
private void updateHeader() {
final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
if (getGpx() != null && !getGpx().showCurrentTrack && adapter.getCount() > 0) {
setupSplitIntervalView(splitIntervalView);
if (options.size() == 0) {
prepareSplitIntervalAdapterData();
}
updateSplitIntervalView(splitIntervalView);
splitIntervalView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popup = new ListPopupWindow(v.getContext());
popup.setAnchorView(splitIntervalView);
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
popup.setModal(true);
popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
popup.setAdapter(new ArrayAdapter<>(v.getContext(), R.layout.popup_list_text_item, options));
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedSplitInterval = position;
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), true, false);
final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, sf);
}
popup.dismiss();
updateSplitIntervalView(splitIntervalView);
}
});
popup.show();
}
});
splitIntervalView.setVisibility(View.VISIBLE);
} else {
splitIntervalView.setVisibility(View.GONE);
}
}
use of androidx.appcompat.widget.ListPopupWindow in project Osmand by osmandapp.
the class EditFavoriteGroupDialogFragment method createMenuItems.
@Override
public void createMenuItems(Bundle savedInstanceState) {
final OsmandApplication app = getMyApplication();
FavouritesHelper helper = app.getFavoritesHelper();
Bundle args = getArguments();
if (args != null) {
String groupName = args.getString(GROUP_NAME_KEY);
if (groupName != null) {
group = helper.getGroup(groupName);
}
}
if (group == null) {
return;
}
items.add(new TitleItem(Algorithms.isEmpty(group.getName()) ? app.getString(R.string.shared_string_favorites) : group.getName()));
BaseBottomSheetItem editNameItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(R.drawable.ic_action_edit_dark)).setTitle(getString(R.string.edit_name)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Activity activity = getActivity();
if (activity != null) {
Context themedContext = UiUtilities.getThemedContext(activity, nightMode);
AlertDialog.Builder b = new AlertDialog.Builder(themedContext);
b.setTitle(R.string.favorite_category_name);
final EditText nameEditText = new EditText(themedContext);
nameEditText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
nameEditText.setText(group.getName());
LinearLayout container = new LinearLayout(themedContext);
int sidePadding = AndroidUtils.dpToPx(activity, 24f);
int topPadding = AndroidUtils.dpToPx(activity, 4f);
container.setPadding(sidePadding, topPadding, sidePadding, topPadding);
container.addView(nameEditText);
b.setView(container);
b.setNegativeButton(R.string.shared_string_cancel, null);
b.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = nameEditText.getText().toString();
boolean nameChanged = !Algorithms.objectEquals(group.getName(), name);
if (nameChanged) {
app.getFavoritesHelper().editFavouriteGroup(group, name, group.getColor(), group.isVisible());
updateParentFragment();
}
dismiss();
}
});
b.show();
}
}
}).create();
items.add(editNameItem);
final View changeColorView = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.change_fav_color, null, false);
((ImageView) changeColorView.findViewById(R.id.change_color_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_appearance));
updateColorView((ImageView) changeColorView.findViewById(R.id.colorImage));
BaseBottomSheetItem changeColorItem = new BaseBottomSheetItem.Builder().setCustomView(changeColorView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Activity activity = getActivity();
if (activity != null) {
final ListPopupWindow popup = new ListPopupWindow(v.getContext());
popup.setAnchorView(v);
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
popup.setModal(true);
popup.setDropDownGravity(Gravity.END | Gravity.TOP);
if (AndroidUiHelper.isOrientationPortrait(activity)) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
popup.setVerticalOffset(AndroidUtils.dpToPx(app, 48f));
}
} else {
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
}
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
final FavoriteColorAdapter colorAdapter = new FavoriteColorAdapter(activity);
popup.setAdapter(colorAdapter);
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Integer color = colorAdapter.getItem(position);
if (color != null) {
if (color != group.getColor()) {
app.getFavoritesHelper().editFavouriteGroup(group, group.getName(), color, group.isVisible());
updateParentFragment();
}
}
popup.dismiss();
dismiss();
}
});
popup.show();
}
}
}).create();
items.add(changeColorItem);
BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithCompoundButton.Builder().setChecked(group.isVisible()).setIcon(getContentIcon(R.drawable.ic_map)).setTitle(getString(R.string.shared_string_show_on_map)).setLayoutId(R.layout.bottom_sheet_item_with_switch).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean visible = !group.isVisible();
app.getFavoritesHelper().editFavouriteGroup(group, group.getName(), group.getColor(), visible);
updateParentFragment();
dismiss();
}
}).create();
items.add(showOnMapItem);
if (group.getPoints().size() > 0) {
items.add(new DividerHalfItem(getContext()));
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
final FavoriteGroup favGroup = this.group;
final MapMarkersGroup markersGr = markersHelper.getMarkersGroup(this.group);
final boolean synced = markersGr != null;
BaseBottomSheetItem markersGroupItem = new SimpleBottomSheetItem.Builder().setIcon(getContentIcon(synced ? R.drawable.ic_action_delete_dark : R.drawable.ic_action_flag)).setTitle(getString(synced ? R.string.remove_from_map_markers : R.string.shared_string_add_to_map_markers)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (synced) {
markersHelper.removeMarkersGroup(markersGr);
} else {
markersHelper.addOrEnableGroup(favGroup);
}
dismiss();
MapActivity.launchMapActivityMoveToTop(getActivity());
}
}).create();
items.add(markersGroupItem);
Drawable shareIcon = getContentIcon(R.drawable.ic_action_gshare_dark);
if (shareIcon != null) {
shareIcon = AndroidUtils.getDrawableForDirection(app, shareIcon);
}
BaseBottomSheetItem shareItem = new SimpleBottomSheetItem.Builder().setIcon(shareIcon).setTitle(getString(R.string.shared_string_share)).setLayoutId(R.layout.bottom_sheet_item_simple).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FavoritesTreeFragment fragment = getFavoritesTreeFragment();
if (fragment != null) {
fragment.shareFavorites(EditFavoriteGroupDialogFragment.this.group);
}
dismiss();
}
}).create();
items.add(shareItem);
}
}
Aggregations