Search in sources :

Example 1 with UpdateGpxCategoryTask

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();
}
Also used : BaseBottomSheetItem(net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem) ImageView(android.widget.ImageView) View(android.view.View) BooleanPreferenceBottomSheet.updateCustomButtonView(net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView) AdapterView(android.widget.AdapterView) BooleanPreferenceBottomSheet.getCustomButtonView(net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView) FragmentActivity(androidx.fragment.app.FragmentActivity) ContextThemeWrapper(android.view.ContextThemeWrapper) ListPopupWindow(androidx.appcompat.widget.ListPopupWindow) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) UpdateGpxCategoryTask(net.osmand.plus.myplaces.UpdateGpxCategoryTask) FavoriteColorAdapter(net.osmand.plus.myplaces.ui.EditFavoriteGroupDialogFragment.FavoriteColorAdapter)

Example 2 with UpdateGpxCategoryTask

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();
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) UpdateGpxCategoryTask(net.osmand.plus.myplaces.UpdateGpxCategoryTask) Fragment(androidx.fragment.app.Fragment)

Aggregations

FragmentActivity (androidx.fragment.app.FragmentActivity)2 UpdateGpxCategoryTask (net.osmand.plus.myplaces.UpdateGpxCategoryTask)2 ContextThemeWrapper (android.view.ContextThemeWrapper)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListPopupWindow (androidx.appcompat.widget.ListPopupWindow)1 Fragment (androidx.fragment.app.Fragment)1 BaseBottomSheetItem (net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem)1 FavoriteColorAdapter (net.osmand.plus.myplaces.ui.EditFavoriteGroupDialogFragment.FavoriteColorAdapter)1 BooleanPreferenceBottomSheet.getCustomButtonView (net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.getCustomButtonView)1 BooleanPreferenceBottomSheet.updateCustomButtonView (net.osmand.plus.settings.bottomsheets.BooleanPreferenceBottomSheet.updateCustomButtonView)1