Search in sources :

Example 76 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Osmand by osmandapp.

the class DashboardOnMap method updateListAdapter.

private void updateListAdapter() {
    listEmptyTextView.setVisibility(View.GONE);
    listView.setEmptyView(null);
    ContextMenuAdapter cm = null;
    if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
        StableArrayAdapter listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running, DashboardType.WAYPOINTS_FLAT == visibleType, nightMode);
        OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running, listAdapter);
        setDynamicListItems(listView, listAdapter);
        updateListAdapter(listAdapter, listener);
        if (listAdapter.getObjects().size() == 0) {
            listEmptyTextView.setText(mapActivity.getString(R.string.no_waypoints_found));
            if (landscape) {
                listView.setEmptyView(listEmptyTextView);
            } else {
                listEmptyTextView.setVisibility(View.VISIBLE);
            }
        }
    } else {
        if (visibleType == DashboardType.CONFIGURE_SCREEN) {
            cm = mapActivity.getMapLayers().getMapWidgetRegistry().getViewConfigureMenuAdapter(mapActivity);
        } else if (visibleType == DashboardType.CONFIGURE_MAP) {
            cm = new ConfigureMapMenu().createListAdapter(mapActivity);
        } else if (visibleType == DashboardType.LIST_MENU) {
            cm = mapActivity.getMapActions().createMainOptionsMenu();
        } else if (visibleType == DashboardType.ROUTE_PREFERENCES) {
            RoutePreferencesMenu routePreferencesMenu = new RoutePreferencesMenu(mapActivity);
            ArrayAdapter<LocalRoutingParameter> listAdapter = routePreferencesMenu.getRoutePreferencesDrawerAdapter(nightMode);
            OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter);
            updateListAdapter(listAdapter, listener);
        } else if (visibleType == DashboardType.UNDERLAY_MAP) {
            cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.UNDERLAY);
        } else if (visibleType == DashboardType.OVERLAY_MAP) {
            cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.OVERLAY);
        } else if (visibleType == DashboardType.CONTOUR_LINES) {
            cm = ContourLinesMenu.createListAdapter(mapActivity);
        } else if (visibleType == DashboardType.HILLSHADE) {
            cm = HillshadeMenu.createListAdapter(mapActivity);
        } else if (visibleType == DashboardType.OSM_NOTES) {
            cm = OsmNotesMenu.createListAdapter(mapActivity);
        }
        if (cm != null) {
            updateListAdapter(cm);
        }
    }
}
Also used : ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) StableArrayAdapter(net.osmand.plus.views.controls.StableArrayAdapter) ConfigureMapMenu(net.osmand.plus.dialogs.ConfigureMapMenu) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) RoutePreferencesMenu(net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu) ArrayAdapter(android.widget.ArrayAdapter) StableArrayAdapter(net.osmand.plus.views.controls.StableArrayAdapter)

Example 77 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Osmand by osmandapp.

the class SearchHistoryFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    View view = inflater.inflate(R.layout.search_history, container, false);
    clearButton = (Button) view.findViewById(R.id.clearAll);
    clearButton.setText(R.string.shared_string_clear_all);
    clearButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            clearWithConfirmation();
        }
    });
    ((ListView) view.findViewById(android.R.id.list)).setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            onListItemClick((ListView) parent, view, position, id);
        }
    });
    return view;
}
Also used : ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 78 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Zom-Android by zom.

the class ContactsPickerActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ((ImApp) getApplication()).setAppTheme(this);
    setContentView(R.layout.contacts_picker_activity);
    if (getIntent().getData() != null)
        mUri = getIntent().getData();
    mLayoutContactSelect = findViewById(R.id.layoutContactSelect);
    mLayoutGroupSelect = findViewById(R.id.layoutGroupSelect);
    mSelectedContacts = (FlowLayout) findViewById(R.id.flSelectedContacts);
    mSelectedContacts.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            // When the tag view grows we don't want the list to jump around, so
            // compensate for this by trying to scroll the list.
            final int diff = bottom - oldBottom;
            ListViewCompat.scrollListBy(mListView, diff);
        }
    });
    boolean isGroupOnlyMode = isGroupOnlyMode();
    excludedContacts = getIntent().getStringArrayListExtra(EXTRA_EXCLUDED_CONTACTS);
    mShowGroups = getIntent().getBooleanExtra(EXTRA_SHOW_GROUPS, false);
    View btnCreateGroup = findViewById(R.id.btnCreateGroup);
    btnCreateGroup.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            setGroupMode(true);
        }
    });
    btnCreateGroup.setVisibility(isGroupOnlyMode ? View.GONE : View.VISIBLE);
    View btnAddContact = findViewById(R.id.btnAddFriend);
    btnAddContact.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(ContactsPickerActivity.this, AddContactActivity.class);
            startActivityForResult(i, REQUEST_CODE_ADD_CONTACT);
        }
    });
    btnAddContact.setVisibility(isGroupOnlyMode ? View.GONE : View.VISIBLE);
    // Make sure the tag view can not be more than a third of the screen
    View root = findViewById(R.id.llRoot);
    if (root != null) {
        root.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

            @Override
            public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                if ((bottom - top) != (oldBottom - oldTop)) {
                    ViewGroup.LayoutParams lp = mSelectedContacts.getLayoutParams();
                    lp.height = (bottom - top) / 3;
                    mSelectedContacts.setLayoutParams(lp);
                }
            }
        });
    }
    mListView = (ListView) findViewById(R.id.contactsList);
    setGroupMode(isGroupOnlyMode);
    mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
            multiStart(i);
            return true;
        }
    });
    // Uncomment this to set as list view header instead.
    // ((ViewGroup)mSelectedContacts.getParent()).removeView(mSelectedContacts);
    // mSelectedContacts.setLayoutParams(new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
    // mListView.addHeaderView(mSelectedContacts);
    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
            if (mListView.getChoiceMode() == ListView.CHOICE_MODE_MULTIPLE) {
                if (isSelected(id)) {
                    unselect(id);
                } else {
                    select(position);
                }
            } else {
                Cursor cursor = (Cursor) mAdapter.getItem(position);
                Intent data = new Intent();
                data.putExtra(EXTRA_RESULT_USERNAME, cursor.getString(ContactListItem.COLUMN_CONTACT_USERNAME));
                data.putExtra(EXTRA_RESULT_PROVIDER, cursor.getLong(ContactListItem.COLUMN_CONTACT_PROVIDER));
                data.putExtra(EXTRA_RESULT_ACCOUNT, cursor.getLong(ContactListItem.COLUMN_CONTACT_ACCOUNT));
                setResult(RESULT_OK, data);
                finish();
            }
        }
    });
    doFilterAsync("");
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ImApp(org.awesomeapp.messenger.ImApp) Intent(android.content.Intent) Cursor(android.database.Cursor) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView)

Example 79 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Zom-Android by zom.

the class ContactListFilterView method onFinishInflate.

@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    // mFilterList = (AbsListView) findViewById(R.id.filteredList);
    mFilterList.setTextFilterEnabled(true);
    // mEmptyView = (TextView) findViewById(R.id.empty);
    mFilterList.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor c = (Cursor) mFilterList.getItemAtPosition(position);
            if (mListener != null)
                mListener.openChat(c);
        }
    });
    mFilterList.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, final int position, long arg3) {
            String[] contactOptions = { // mContext.getString(R.string.menu_verify),
            mContext.getString(R.string.menu_contact_nickname), mContext.getString(R.string.menu_remove_contact) };
            // mContext.getString(R.string.menu_block_contact)};
            AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
            builder.setItems(contactOptions, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    if (which == 0)
                        setContactNickname(position);
                    else if (which == 1)
                        removeContactAtPosition(position);
                    else if (which == 2)
                        blockContactAtPosition(position);
                }
            });
            builder.create().show();
            return true;
        }
    });
/**
 *        mEtSearch = (EditText)findViewById(R.id.contactSearch);
 *
 *        mEtSearch.addTextChangedListener(new TextWatcher()
 *        {
 *
 *            @Override
 *            public void afterTextChanged(Editable s) {
 *
 *            }
 *
 *            @Override
 *            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
 *
 *            }
 *
 *            @Override
 *            public void onTextChanged(CharSequence s, int start, int before, int count) {
 *
 *                ContactListFilterView.this.doFilter(mEtSearch.getText().toString());
 *
 *            }
 *
 *        });
 *
 *        mEtSearch.setOnKeyListener(new OnKeyListener ()
 *        {
 *
 *            @Override
 *            public boolean onKey(View v, int keyCode, KeyEvent event) {
 *
 *                ContactListFilterView.this.doFilter(mEtSearch.getText().toString());
 *                return false;
 *            }
 *
 *        });
 */
/*
        mFilterList.setItemActionListener(new ListView.OnActionClickListener() {

            @Override
            public void onClick(View listView, View buttonview, int position) {

                Cursor c = (Cursor) mFilterList.getItemAtPosition(position);
                if (mListener != null)
                    if (buttonview.getId() == R.id.btnExListChat)
                        mListener.startChat(c);
                    else if (buttonview.getId() == R.id.btnExListProfile)
                        mListener.showProfile(c);

            }
    }, R.id.btnExListChat, R.id.btnExListProfile);
    */
// 
// if (!isInEditMode())
// mPresenceView = (UserPresenceView) findViewById(R.id.userPresence);
}
Also used : AlertDialog(android.app.AlertDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) DialogInterface(android.content.DialogInterface) Cursor(android.database.Cursor) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener)

Example 80 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener 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> list, final ContextMenuAdapter adapter) {
    final OsmandApplication app = (OsmandApplication) activity.getApplication();
    final DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(activity);
    final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    final int layout = R.layout.gpx_track_item;
    final Map<String, String> gpxAppearanceParams = new HashMap<>();
    final ArrayAdapter<String> listAdapter = new ArrayAdapter<String>(activity, layout, R.id.title, adapter.getItemNames()) {

        List<GpxDataItem> dataItems = null;

        @Override
        public int getItemViewType(int position) {
            return showCurrentGpx && position == 0 ? 1 : 0;
        }

        @Override
        public int getViewTypeCount() {
            return 2;
        }

        private GpxDataItem getDataItem(GPXInfo info) {
            if (dataItems != null) {
                for (GpxDataItem item : dataItems) {
                    if (item.getFile().getAbsolutePath().endsWith(info.fileName)) {
                        return item;
                    }
                }
            }
            return null;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            // User super class to create the View
            View v = convertView;
            boolean checkLayout = getItemViewType(position) == 0;
            if (v == null) {
                v = activity.getLayoutInflater().inflate(layout, null);
            }
            if (dataItems == null) {
                dataItems = app.getGpxDatabase().getItems();
            }
            final ContextMenuItem item = adapter.getItem(position);
            GPXInfo info = list.get(position);
            updateGpxInfoView(v, item, info, getDataItem(info), showCurrentGpx && position == 0, 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 = ((CheckBox) 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);
                        }
                    });
                } else {
                    final SwitchCompat ch = ((SwitchCompat) 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);
                        }
                    });
                }
                v.findViewById(R.id.check_item).setVisibility(View.VISIBLE);
            }
            return v;
        }
    };
    OnClickListener onClickListener = new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int position) {
        }
    };
    builder.setAdapter(listAdapter, 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 = activity.getLayoutInflater().inflate(R.layout.select_gpx_appearance_title, null);
                final OsmandSettings.CommonPreference<String> prefWidth = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR);
                final OsmandSettings.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(activity);
                        popup.setAnchorView(apprTitleView);
                        popup.setContentWidth(AndroidUtils.dpToPx(activity, 200f));
                        popup.setModal(true);
                        popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
                        popup.setVerticalOffset(AndroidUtils.dpToPx(activity, -48f));
                        popup.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f));
                        final GpxAppearanceAdapter gpxApprAdapter = new GpxAppearanceAdapter(activity, gpxAppearanceParams.containsKey(CURRENT_TRACK_COLOR_ATTR) ? gpxAppearanceParams.get(CURRENT_TRACK_COLOR_ATTR) : prefColor.get(), GpxAppearanceAdapter.GpxAppearanceAdapterType.TRACK_WIDTH_COLOR);
                        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 (item.getAttrName() == CURRENT_TRACK_WIDTH_ATTR) {
                                        gpxAppearanceParams.put(CURRENT_TRACK_WIDTH_ATTR, item.getValue());
                                    } else if (item.getAttrName() == CURRENT_TRACK_COLOR_ATTR) {
                                        gpxAppearanceParams.put(CURRENT_TRACK_COLOR_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()) {
                        final OsmandSettings.CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(entry.getKey());
                        pref.set(entry.getValue());
                    }
                    if (activity instanceof MapActivity) {
                        ConfigureMapMenu.refreshMapComplete((MapActivity) activity);
                    }
                }
                GPXFile currentGPX = null;
                // clear all previously selected files before adding new one
                OsmandApplication app = (OsmandApplication) activity.getApplication();
                if (app != null && app.getSelectedGpxHelper() != null) {
                    app.getSelectedGpxHelper().clearAllGpxFileToShow();
                }
                if (app != null && showCurrentGpx && adapter.getItem(0).getSelected()) {
                    currentGPX = app.getSavingTrackHelper().getCurrentGpx();
                }
                List<String> s = new ArrayList<>();
                for (int i = (showCurrentGpx ? 1 : 0); i < adapter.length(); i++) {
                    if (adapter.getItem(i).getSelected()) {
                        s.add(list.get(i).getFileName());
                    }
                }
                dialog.dismiss();
                loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX, s.toArray(new String[s.size()]));
            }
        });
        builder.setNegativeButton(R.string.shared_string_cancel, null);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && list.size() > 1 || !showCurrentGpx && list.size() > 0) {
            builder.setNeutralButton(R.string.gpx_add_track, null);
        }
    }
    final AlertDialog dlg = builder.create();
    dlg.setCanceledOnTouchOutside(true);
    if (list.size() == 0 || showCurrentGpx && list.size() == 1) {
        final View footerView = activity.getLayoutInflater().inflate(R.layout.no_gpx_files_list_footer, null);
        TextView descTextView = (TextView) 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, dlg);
                }
            });
        }
        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 = adapter.getItem(position);
                item.setSelected(!item.getSelected());
                listAdapter.notifyDataSetInvalidated();
                if (position == 0 && showCurrentGpx && item.getSelected()) {
                    OsmandMonitoringPlugin monitoringPlugin = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class);
                    if (monitoringPlugin == null) {
                        AlertDialog.Builder confirm = new AlertDialog.Builder(activity);
                        confirm.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Intent intent = new Intent(activity, PluginActivity.class);
                                intent.putExtra(PluginActivity.EXTRA_PLUGIN_ID, OsmandMonitoringPlugin.ID);
                                activity.startActivity(intent);
                            }
                        });
                        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, false);
                    }
                }
            } else {
                dlg.dismiss();
                if (showCurrentGpx && position == 0) {
                    callbackWithObject.processResult(null);
                } else {
                    String fileName = list.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, dlg);
                    }
                });
            }
        }
    });
    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;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) HashMap(java.util.HashMap) SpannableString(android.text.SpannableString) OsmandMonitoringPlugin(net.osmand.plus.monitoring.OsmandMonitoringPlugin) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) GpxDataItem(net.osmand.plus.GPXDatabase.GpxDataItem) ArrayList(java.util.ArrayList) List(java.util.List) TextView(android.widget.TextView) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) ContextMenuItem(net.osmand.plus.ContextMenuItem) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) OsmandSettings(net.osmand.plus.OsmandSettings) SpannableString(android.text.SpannableString) CheckBox(android.widget.CheckBox) AppCompatCheckBox(android.support.v7.widget.AppCompatCheckBox) OnClickListener(android.content.DialogInterface.OnClickListener) AdapterView(android.widget.AdapterView) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) File(java.io.File) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) SwitchCompat(android.support.v7.widget.SwitchCompat) DialogInterface(android.content.DialogInterface) AppearanceListItem(net.osmand.plus.dialogs.ConfigureMapMenu.AppearanceListItem) Entry(com.github.mikephil.charting.data.Entry) ListPopupWindow(android.support.v7.widget.ListPopupWindow) GpxAppearanceAdapter(net.osmand.plus.dialogs.ConfigureMapMenu.GpxAppearanceAdapter) MapActivity(net.osmand.plus.activities.MapActivity) ViewGroup(android.view.ViewGroup) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) MarkerView(com.github.mikephil.charting.components.MarkerView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) DateFormat(java.text.DateFormat) StyleSpan(android.text.style.StyleSpan) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) ArrayAdapter(android.widget.ArrayAdapter) CompoundButton(android.widget.CompoundButton)

Aggregations

OnItemClickListener (android.widget.AdapterView.OnItemClickListener)241 AdapterView (android.widget.AdapterView)238 View (android.view.View)237 ListView (android.widget.ListView)188 TextView (android.widget.TextView)135 ImageView (android.widget.ImageView)86 Intent (android.content.Intent)68 OnClickListener (android.view.View.OnClickListener)44 SuppressLint (android.annotation.SuppressLint)32 LayoutInflater (android.view.LayoutInflater)32 AlertDialog (android.app.AlertDialog)27 DialogInterface (android.content.DialogInterface)27 GridView (android.widget.GridView)26 ArrayAdapter (android.widget.ArrayAdapter)24 Bundle (android.os.Bundle)23 Dialog (android.app.Dialog)22 ArrayList (java.util.ArrayList)21 Paint (android.graphics.Paint)17 File (java.io.File)17 AbsListView (android.widget.AbsListView)16