use of net.osmand.plus.myplaces.UpdateGpxCategoryTask 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 net.osmand.plus.myplaces.UpdateGpxCategoryTask in project Osmand by osmandapp.
the class RenameTrackGroupBottomSheet method renameGroupName.
private void renameGroupName() {
FragmentActivity activity = getActivity();
if (activity != null) {
new UpdateGpxCategoryTask(activity, group, groupName).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Fragment fragment = getTargetFragment();
if (fragment instanceof OnGroupNameChangeListener) {
OnGroupNameChangeListener listener = (OnGroupNameChangeListener) fragment;
listener.onTrackGroupChanged();
}
dismiss();
}
Aggregations