Search in sources :

Example 1 with FavouritesAdapter

use of net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter in project Osmand by osmandapp.

the class FavoriteDialogs method createReplaceFavouriteDialog.

public static Dialog createReplaceFavouriteDialog(final Activity activity, final Bundle args) {
    final FavouritesDbHelper helper = ((OsmandApplication) activity.getApplication()).getFavorites();
    final List<FavouritePoint> points = new ArrayList<FavouritePoint>(helper.getFavouritePoints());
    final FavouritesAdapter favouritesAdapter = new FavouritesAdapter(activity, ((OsmandApplication) activity.getApplication()).getFavorites().getFavouritePoints(), false);
    final Dialog[] dlgHolder = new Dialog[1];
    OnItemClickListener click = new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            confirmReplace(activity, args, helper, favouritesAdapter, dlgHolder, position);
        }
    };
    if (activity instanceof MapActivity) {
        favouritesAdapter.updateLocation(((MapActivity) activity).getMapLocation());
    }
    if (points.size() == 0) {
        Toast.makeText(activity, activity.getString(R.string.fav_points_not_exist), Toast.LENGTH_SHORT).show();
        return null;
    }
    return showFavoritesDialog(activity, favouritesAdapter, click, null, dlgHolder, true);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) FavouritePoint(net.osmand.data.FavouritePoint) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) FavouritesAdapter(net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter) Dialog(android.app.Dialog) AlertDialog(android.support.v7.app.AlertDialog) ArrayList(java.util.ArrayList) AdapterView(android.widget.AdapterView) FavouritesDbHelper(net.osmand.plus.FavouritesDbHelper) View(android.view.View) AdapterView(android.widget.AdapterView) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) ListView(android.widget.ListView) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

Dialog (android.app.Dialog)1 AlertDialog (android.support.v7.app.AlertDialog)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 FavouritePoint (net.osmand.data.FavouritePoint)1 FavouritesDbHelper (net.osmand.plus.FavouritesDbHelper)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 FavouritesAdapter (net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter)1 MapActivity (net.osmand.plus.activities.MapActivity)1