diff --git a/OsmAnd/res/drawable-hdpi/ic_action_reorder.png b/OsmAnd/res/drawable-hdpi/ic_action_reorder.png new file mode 100644 index 0000000000..1180451a26 Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_reorder.png differ diff --git a/OsmAnd/res/drawable-mdpi/ic_action_reorder.png b/OsmAnd/res/drawable-mdpi/ic_action_reorder.png new file mode 100644 index 0000000000..6a730249db Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_reorder.png differ diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_reorder.png b/OsmAnd/res/drawable-xhdpi/ic_action_reorder.png new file mode 100644 index 0000000000..09931760cf Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_reorder.png differ diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_reorder.png b/OsmAnd/res/drawable-xxhdpi/ic_action_reorder.png new file mode 100644 index 0000000000..cce6c9be88 Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_reorder.png differ diff --git a/OsmAnd/res/layout/waypoint_reached.xml b/OsmAnd/res/layout/waypoint_reached.xml index 50a4772d9e..cb7b9df929 100644 --- a/OsmAnd/res/layout/waypoint_reached.xml +++ b/OsmAnd/res/layout/waypoint_reached.xml @@ -99,7 +99,6 @@ android:clickable="false" android:scaleType="center" android:src="@drawable/ic_flat_list_dark" - android:tag="DragIcon" android:visibility="gone"/> \ No newline at end of file diff --git a/OsmAnd/res/values-da/phrases.xml b/OsmAnd/res/values-da/phrases.xml index 3c50d8b42d..350337a40c 100644 --- a/OsmAnd/res/values-da/phrases.xml +++ b/OsmAnd/res/values-da/phrases.xml @@ -2623,4 +2623,23 @@ Officielle navn +Sømærke dige + Delfin + + Vejskilt: skovbrugshytte + Vejskilt: skovbrug tildeling + Inskription: N + Inskription: NV + Inskription: V + Inskription: SV + Inskription: S + Inskription: SØ + Inskription: Ø + Inskription: NØ + + Under opførelse + +Hæveautomat: ja + Hæveautomat: nej + diff --git a/OsmAnd/res/values-da/strings.xml b/OsmAnd/res/values-da/strings.xml index 628d702b3a..d57be4b5b5 100644 --- a/OsmAnd/res/values-da/strings.xml +++ b/OsmAnd/res/values-da/strings.xml @@ -1,4 +1,5 @@ - + + Overvej at købe Højdekurve udvidelsen (\'Contour lines\') på Google Play for at støtte den videre udvikling. Optag video Optag audio @@ -2224,4 +2225,6 @@ Emne slettet Emner slettet FORTRYD ALLE - \ No newline at end of file + Skjul IP ikoner + Byt rundt på startpunkt & destination + diff --git a/OsmAnd/res/values-de/strings.xml b/OsmAnd/res/values-de/strings.xml index c598cbaaaf..73221b69f6 100644 --- a/OsmAnd/res/values-de/strings.xml +++ b/OsmAnd/res/values-de/strings.xml @@ -1,4 +1,5 @@ - + + Keine Adresse bekannt Nähe Regionen @@ -1995,4 +1996,6 @@ Typ Startpunkt Alles rückgängig machen - \ No newline at end of file + Symbole ausblenden + Startpunkt und Ziel vertauschen + diff --git a/OsmAnd/res/values-es-rAR/phrases.xml b/OsmAnd/res/values-es-rAR/phrases.xml index 6642f9a26e..04639fe348 100644 --- a/OsmAnd/res/values-es-rAR/phrases.xml +++ b/OsmAnd/res/values-es-rAR/phrases.xml @@ -2596,4 +2596,22 @@ Nombre oficial +Dique náutico + Duque de alba (náutico) + + Cartel: Compartimento forestal + Cartel: Parcela forestal + Inscripción: N + Inscripción: NO + Inscripción: O + Inscripción: SO + Inscripción: S + Inscripción: SE + Inscripción: E + Inscripción: NE + + En construcción + Con cajero automático + Sin cajero automático + diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 791c65bcc0..d182ef950c 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -1,4 +1,5 @@ - + + Ocultar números de casa Falló al copiar archivos @@ -2044,4 +2045,6 @@ Elemento borrado elementos borrados DESHACER TODO - \ No newline at end of file + Ocultar iconos + Cambiar inicio y final + diff --git a/OsmAnd/res/values-es/phrases.xml b/OsmAnd/res/values-es/phrases.xml index 5e904a43b5..a8b87ad8ba 100644 --- a/OsmAnd/res/values-es/phrases.xml +++ b/OsmAnd/res/values-es/phrases.xml @@ -2600,4 +2600,20 @@ Nombre oficial - +Señal ďe Dique + Delfín + + Inscripción: N + Inscripción: NO + Inscripción: O + Inscripción: SO + Inscripción: S + Inscripción: SE + Inscripción: E + Inscripción: NE + + En construcción + Cajero automático: no + +Cajero automático: sí + diff --git a/OsmAnd/res/values-fr/strings.xml b/OsmAnd/res/values-fr/strings.xml index f4ae42242c..4c5d8edbe6 100644 --- a/OsmAnd/res/values-fr/strings.xml +++ b/OsmAnd/res/values-fr/strings.xml @@ -1,4 +1,5 @@ - + + Modifications hors-ligne Toujours utiliser l\'édition hors-ligne @@ -2110,4 +2111,6 @@ Taille de l\'espace de stockage Espace maximum alloué pour tous les enregistrements Type - \ No newline at end of file + Inverser Départ et Destination + Masquer les icônes de PI + diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index 410fdf0c91..2c838f39de 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -1,4 +1,5 @@ - + + Configureer scherm Toon rijstroken @@ -2162,4 +2163,6 @@ Item verwijderd items verwijderd Alles terugzetten - \ No newline at end of file + Verberg iconen + Verwissel start en einde + diff --git a/OsmAnd/res/values-pt-rBR/phrases.xml b/OsmAnd/res/values-pt-rBR/phrases.xml index f9723d8988..0511ba31d9 100644 --- a/OsmAnd/res/values-pt-rBR/phrases.xml +++ b/OsmAnd/res/values-pt-rBR/phrases.xml @@ -2591,4 +2591,22 @@ Nome oficial - +Dique náutico + Inscrição: N + Inscrição: NO + Inscrição: O + Inscrição: SO + Inscrição: S + Inscrição: SE + Inscrição: E + Inscrição: NE + + Em construção + ATM: sim + ATM: não + +Pôster: compartimento florestal + Pôster: loteamento florestal + Dolphin (náutico) + + diff --git a/OsmAnd/res/values-pt-rBR/strings.xml b/OsmAnd/res/values-pt-rBR/strings.xml index d2b7770e2f..8160f0e423 100644 --- a/OsmAnd/res/values-pt-rBR/strings.xml +++ b/OsmAnd/res/values-pt-rBR/strings.xml @@ -1,4 +1,5 @@ -Meus locais + +Meus locais dias atrás Ver Pista de preparação @@ -1990,4 +1991,6 @@ Item apagado itens apagados DESFAZER TUDO - \ No newline at end of file + Ocultar ícones + Alternar iniciar e finalizar + diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index 7f09dd3753..6b440c770e 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -875,7 +875,6 @@ Художественная галерея Горнолыжный курорт Площадка для игр - Насыпь Платежный терминал Часы работы @@ -2571,4 +2570,21 @@ Официальное имя + Насыпь для сдерживания потока воды + + Указатель: квартальный столб + Указатель: деляночный столб + Надпись:С + Надпись:СВ + Надпись:В + Надпись:ЮВ + Надпись:Ю + Надпись:ЮЗ + Надпись:З + Надпись:СЗ + + В процессе строительства + С банкоматом + Без банкомата + diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index aff765b46e..bf479cb885 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -1,5 +1,6 @@ + Скрыть значки Конные маршруты Низкое качество Высокое качество diff --git a/OsmAnd/res/values-sr/strings.xml b/OsmAnd/res/values-sr/strings.xml index 7160a32014..61c8e985df 100644 --- a/OsmAnd/res/values-sr/strings.xml +++ b/OsmAnd/res/values-sr/strings.xml @@ -1,4 +1,5 @@ - + + Верзија: Oko Верзија инфо, лиценце, чланови пројекта @@ -977,4 +978,95 @@ " • Ново сучеље осетљиво на положај тапкања по карти или другим површима\n\n • Приказ карте се сада покреће непосредно осим ако је означено „Приказуј полетника при покретању“\n\n • Подешава се која карта и како се приказује у полетнику\n\n • Премошћава се полетник ако Вам се више свиђа управљање програмом изборником\n\n • За преузимање карата, области се могу непосредно изабрати тапкањем по светској карти\n\n • Претрага тачака занимања сада подржава одређеније упите\n\n • Побољшане су могућности тачака занимања и уређивања ОСМ-а\n\n • Прерађен је склоп преузимања карата и његово сучеље\n\n и још којешта... " Слој сенчења падина је онемогућен - \ No newline at end of file + Албански + Арапски + Баскијски + Белоруски + Бугарски + Хрватски + Чешки + Дански + Фински + Француски + Германски + Грчки + Мађарски + Индонезијски + Италијански + Јапански + Корејски + Норвешки + Персијски + Пољски + Португалски + Румунски + Руски + Словачки + Шпански + Шведски + Турски + Украјински + Вијетнамски + Северна Америка - Канада + Европа - Италија + Европа - Велика Британија + Рачунај одсечак стазе Османда без приступа мрежи + Рачунај од првог до последњег осдечка стазе Османда + Да ли желите приказ стазе за навођење? + Изаберите ГПИкс… + Избегавај путеве са наплатним станицама + Избегавај путеве са наплатним станицама + Избегавај неасвалтиране путеве + Избегавај неасвалтиране путеве + Одреди/уреди… + Замени полазну и циљну тачку + Сакриј иконице + Означи месец и државу +Седмично + Откажи путању + Могућности приступачности + Подаци ГПС-а + Отворене карте ЕУ-а + Подаци звука/видеа + Да ли сигурно желите да очистите тачку одредишта (и пролазна одредишта)? + Омогући рачунање тачних путања без грешака. Радња је ограничена даљином и спора. + Тачно рачунање путања (споро) + Молим, размислите о куповини Линија обриса из продавнице ради давања подршке даљем развоју програма. + Означи на захтев + Изаберите облик излазног снимка + Облик излазног снимка + Користи склопног снимача за видео + Користи склопног снимача видеа + Користи склопни програм за слике + Користи програм камере + Звук/видео је снимљен. Зауставите снимање притиском на справицу ЗВ-а + Изводи се одређени звучни запис\n%1$s + Отвори програм спољног извођача + Снимак се не може извести + Снимам %1$s %3$s %2$s + Положај за придруживање белешци и даље није одређен. „Користи положај …“ за придруживање белешке одређеном положају + делови + Приказуј путеве према лествици САЦ-а + Приказуј путеве према путањама ОСМЦ-а + + Одредите када ће се приказивати само путне карте: + Само путне карте + Покрени програм у безбедном начину рада (користећи спорији Андроидов код уместо бржег програмског). + Безбедни начин рада + Програм је у безбедном начину рада (онемогућава се у поставкама). + Изаберите образац боја путева: + Образац боја путева + Омогућите прикључак снимања путовања ради коришћења услуга бележења (бележење ГПИксом, праћење положаја на мрежи) + Рачунај могућу приближну путању за велике раздаљине + Молим, омогућите ГПС у поставкама + Услуге бележења путање + Нема пута + Стигли сте на пролазно одредиште + Додај као пролазно одредиште + Пролазно одредиште + Завршна тачка је предалеко од најближег пута. + Напредни начин рада… + Користи компас + Користи компас када правац није препознат на други начин + Избегавај путеве за моторна возила + diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml index 9d7e9ddc51..42fcd9759c 100644 --- a/OsmAnd/res/values-sv/strings.xml +++ b/OsmAnd/res/values-sv/strings.xml @@ -1,4 +1,5 @@ - + + För att låsa upp skärmen tryck på låsikonen Välj land Välj stad @@ -2063,4 +2064,5 @@ post raderad poster raderade ÅNGRA ALLA - \ No newline at end of file + Dölj ikonerna + diff --git a/OsmAnd/res/values-tr/strings.xml b/OsmAnd/res/values-tr/strings.xml index 1ff10e4d63..7848556f48 100644 --- a/OsmAnd/res/values-tr/strings.xml +++ b/OsmAnd/res/values-tr/strings.xml @@ -1,4 +1,5 @@ -Değişiklik listesini kapat + +Değişiklik listesini kapat ZXing Barcode Scanner uygulaması kurulu değil. Uygulama marketinde aramak ister misiniz? Yol renk şemasını seç: Yol renk şeması @@ -1327,7 +1328,7 @@ Mekik treninden kaçın Vikipedi - OSM Düzeltmesini Sil + OSM düzeltmesini sil Rota kapsamına göre Boyama Çıkış yap OsmAnd\'ın verileri ayrıca yeni hedefe de kopyalamasını ister misiniz? @@ -2030,4 +2031,4 @@ UNDO TÜM Tip Başlangıç noktası - \ No newline at end of file + diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index e84a9a9e12..41d66a255e 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -1,4 +1,5 @@ - + + 選擇道路的色彩調配: 道路的色彩調配 顯示目的地方向 @@ -2070,4 +2071,6 @@ 項目已刪除 項目已刪除 全部取消 - \ No newline at end of file + 隱藏圖示 + 切換開始以及結束 + diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index 749710c6fe..c4f0f04f46 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -953,7 +953,7 @@ Daymark Distance mark Dry dock - Dyke + Seamark dyke Floating dock Fog signal Harbour basin @@ -2566,4 +2566,22 @@ Official name + Dyke + Dolphin + + Signpost: forestry compartment + Signpost: forestry allotment + Inscription:N + Inscription:NW + Inscription:W + Inscription:SW + Inscription:S + Inscription:SE + Inscription:E + Inscription:NE + + Under construction + Atm: yes + Atm: no + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 91f80b908c..e2abab01ca 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,8 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + Reverse starting point & destination + Hide POI icons Item deleted items deleted UNDO ALL diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index fb7dd9f67f..9c19de02c2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -86,7 +86,7 @@ public class MapActivityActions implements DialogProvider { routingHelper = mapActivity.getMyApplication().getRoutingHelper(); } - + /* public void addAsWaypoint(double latitude, double longitude, PointDescription pd) { TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); boolean destination = (targets.getPointToNavigate() == null); @@ -97,7 +97,8 @@ public class MapActivityActions implements DialogProvider { openIntermediateEditPointsDialog(); } - + */ + public void addAsTarget(double latitude, double longitude, PointDescription pd) { TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1, @@ -736,9 +737,11 @@ public class MapActivityActions implements DialogProvider { mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS); } + /* public void openIntermediateEditPointsDialog() { mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS_EDIT); } + */ public void openRoutePreferencesDialog() { mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.ROUTE_PREFERENCES); @@ -758,6 +761,7 @@ public class MapActivityActions implements DialogProvider { settings.LAST_ROUTING_APPLICATION_MODE = settings.APPLICATION_MODE.get(); settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get()); mapActivity.updateApplicationModeSettings(); + mapActivity.getDashboard().clearDeletedPoints(); } public AlertDialog stopNavigationActionConfirm() { diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java index 0d5a723f89..edace008cf 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashWaypointsFragment.java @@ -96,7 +96,7 @@ public class DashWaypointsFragment extends DashLocationFragment { View dv = getActivity().getLayoutInflater().inflate(R.layout.divider, null); favorites.addView(dv); View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(), - getActivity(), null, ps, null, !getMyApplication().getSettings().isLightContent(), true); + getActivity(), null, null, ps, null, !getMyApplication().getSettings().isLightContent(), true); favorites.addView(v); } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 364efa4192..8c5bdff6c9 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -54,6 +54,7 @@ import net.osmand.plus.dialogs.ConfigureMapMenu; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.WaypointDialogHelper; +import net.osmand.plus.helpers.WaypointDialogHelper.PointDeleteCallback; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu; import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter; @@ -79,7 +80,8 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP; /** */ -public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicListViewCallbacks, IRouteInformationListener { +public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicListViewCallbacks, + IRouteInformationListener, PointDeleteCallback { private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(DashboardOnMap.class); private static final String TAG = "DashboardOnMap"; @@ -149,7 +151,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis public enum DashboardType { WAYPOINTS, WAYPOINTS_FLAT, - WAYPOINTS_EDIT, CONFIGURE_SCREEN, CONFIGURE_MAP, LIST_MENU, @@ -178,6 +179,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis public void createDashboardView() { baseColor = mapActivity.getResources().getColor(R.color.osmand_orange) & 0x00ffffff; waypointDialogHelper = new WaypointDialogHelper(mapActivity); + waypointDialogHelper.setPointDeleteCallback(this); landscape = !AndroidUiHelper.isOrientationPortrait(mapActivity); dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard); final View.OnClickListener listener = new View.OnClickListener() { @@ -202,7 +204,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis @Override public boolean canDismiss(int position) { boolean res = false; - if (listAdapter instanceof StableArrayAdapter) { + if (visibleType == DashboardType.WAYPOINTS && listAdapter instanceof StableArrayAdapter) { List activeObjects = ((StableArrayAdapter) listAdapter).getActiveObjects(); Object obj = listAdapter.getItem(position); res = activeObjects.contains(obj); @@ -232,7 +234,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis stableAdapter = null; activeObjPos = 0; } - return new Undoable() { @Override public void undo() { @@ -242,7 +243,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis stableAdapter.getObjects().add(position, item); stableAdapter.getActiveObjects().add(activeObjPos, item); stableAdapter.refreshData(); - onItemsSwapped(stableAdapter.getActiveObjects()); } } @@ -380,7 +380,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis // // @Override // public void onClick(View v) { - mapActivity.getMyApplication().getWaypointHelper().removeVisibleLocationPoint(deletedPoints); +// mapActivity.getMyApplication().getWaypointHelper().removeVisibleLocationPoint(deletedPoints); // hideDashboard(); // } // }); @@ -473,7 +473,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis button = actionButtons.get(DashboardActionButtonType.MY_LOCATION); } else if (type == DashboardType.ROUTE_PREFERENCES) { button = actionButtons.get(DashboardActionButtonType.NAVIGATE); - } else if (type == DashboardType.WAYPOINTS || type == DashboardType.WAYPOINTS_EDIT || type == DashboardType.WAYPOINTS_FLAT) { + } else if (type == DashboardType.WAYPOINTS || type == DashboardType.WAYPOINTS_FLAT) { boolean routePlanningMode = false; RoutingHelper rh = mapActivity.getRoutingHelper(); if (rh.isRoutePlanningMode()) { @@ -679,13 +679,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis dynamicListView.setActiveItemsList(listAdapter.getActiveObjects()); updateListAdapter(listAdapter, listener); - } else if (DashboardType.WAYPOINTS_EDIT == visibleType) { - deletedPoints.clear(); - ArrayAdapter listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running, - DashboardType.WAYPOINTS_FLAT == visibleType, nightMode); - OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running, - listAdapter); - updateListAdapter(listAdapter, listener); } else { if (DashboardType.CONFIGURE_SCREEN == visibleType) { @@ -718,8 +711,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis } public void refreshContent(boolean force) { - if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_EDIT - || force) { + if (visibleType == DashboardType.WAYPOINTS || force) { updateListAdapter(); } else if (visibleType == DashboardType.CONFIGURE_MAP || visibleType == DashboardType.ROUTE_PREFERENCES) { int index = listView.getFirstVisiblePosition(); @@ -981,7 +973,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis private boolean isActionButtonVisible() { return visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.WAYPOINTS - || visibleType == DashboardType.WAYPOINTS_EDIT || visibleType == DashboardType.WAYPOINTS_FLAT || visibleType == DashboardType.LIST_MENU || visibleType == DashboardType.ROUTE_PREFERENCES @@ -1132,6 +1123,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis transaction.show(frag).commit(); } + public void clearDeletedPoints() { + deletedPoints.clear(); + } + View getParentView() { return dashboardView; } @@ -1167,7 +1162,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis getMyApplication().runInUIThread(new Runnable() { @Override public void run() { - if (visibleType == DashboardType.WAYPOINTS) { + if (visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT) { List allTargets = new ArrayList<>(); if (items != null) { for (Object obj : items) { @@ -1223,4 +1218,11 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis swipeDismissListener.discardUndo(); } } + + @Override + public void deleteWaypoint(int position) { + if (swipeDismissListener != null) { + swipeDismissListener.delete(position); + } + } } diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index b604345791..30aec6ce18 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -1,17 +1,19 @@ package net.osmand.plus.helpers; import android.app.Activity; +import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnDismissListener; -import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.Shape; import android.os.AsyncTask; import android.support.v4.app.FragmentActivity; import android.support.v7.app.AlertDialog; +import android.support.v7.widget.PopupMenu; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; @@ -23,6 +25,7 @@ import android.widget.TextView; import net.osmand.AndroidUtils; import net.osmand.Location; +import net.osmand.TspAnt; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; import net.osmand.data.LocationPoint; @@ -30,11 +33,13 @@ import net.osmand.data.PointDescription; import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; -import net.osmand.plus.activities.IntermediatePointsDialog; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.poi.PoiUIFilter; +import net.osmand.plus.views.controls.DynamicListView.DragIcon; import net.osmand.plus.views.controls.ListDividerShape; import net.osmand.plus.views.controls.StableArrayAdapter; import net.osmand.util.Algorithms; @@ -49,7 +54,14 @@ public class WaypointDialogHelper { private MapActivity mapActivity; private OsmandApplication app; private WaypointHelper waypointHelper; + private PointDeleteCallback dCallback; + private boolean flat; + private List deletedPoints; + + public interface PointDeleteCallback { + void deleteWaypoint(int position); + } private static class RadiusItem { int type; @@ -59,6 +71,10 @@ public class WaypointDialogHelper { } } + public void setPointDeleteCallback(PointDeleteCallback callback) { + this.dCallback = callback; + } + public WaypointDialogHelper(MapActivity mapActivity) { this.app = mapActivity.getMyApplication(); waypointHelper = this.app.getWaypointHelper(); @@ -114,7 +130,7 @@ public class WaypointDialogHelper { case WaypointHelper.FAVORITES: FavouritePoint favPoint = (FavouritePoint) ps.point; - pointDescription = favPoint.getCategory(); + pointDescription = Algorithms.isEmpty(favPoint.getCategory()) ? activity.getResources().getString(R.string.shared_string_favorites) : favPoint.getCategory(); break; } } @@ -154,6 +170,16 @@ public class WaypointDialogHelper { // 0); } + private List getPoints() { + final List points; + if (flat) { + points = new ArrayList(waypointHelper.getAllPoints()); + } else { + points = getStandardPoints(); + } + return points; + } + private List getActivePoints(List points) { List activePoints = new ArrayList<>(); for (Object p : points) { @@ -250,14 +276,14 @@ public class WaypointDialogHelper { final boolean edit, final List deletedPoints, final MapActivity ctx, final int[] running, final boolean flat, final boolean nightMode) { - final List points; - if (flat) { - points = new ArrayList(waypointHelper.getAllPoints()); - } else { - points = getPoints(); - } + this.flat = flat; + this.deletedPoints = deletedPoints; + + final List points = getPoints(); List activePoints = getActivePoints(points); + final WaypointDialogHelper helper = this; + return new StableArrayAdapter(ctx, R.layout.waypoint_reached, R.id.title, points, activePoints) { @@ -306,7 +332,7 @@ public class WaypointDialogHelper { v = ctx.getLayoutInflater().inflate(R.layout.card_bottom_divider, null); } else if (obj instanceof LocationPointWrapper) { LocationPointWrapper point = (LocationPointWrapper) obj; - v = updateWaypointItemView(edit, deletedPoints, app, ctx, v, point, this, + v = updateWaypointItemView(edit, deletedPoints, app, ctx, helper, v, point, this, nightMode, flat); AndroidUtils.setListItemBackground(mapActivity, v, nightMode); } @@ -317,7 +343,8 @@ public class WaypointDialogHelper { public static View updateWaypointItemView(final boolean edit, final List deletedPoints, - final OsmandApplication app, final Activity ctx, View v, + final OsmandApplication app, final Activity ctx, + final WaypointDialogHelper helper, View v, final LocationPointWrapper point, final ArrayAdapter adapter, final boolean nightMode, final boolean flat) { @@ -325,9 +352,9 @@ public class WaypointDialogHelper { v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null); } updatePointInfoView(app, ctx, v, point, true, nightMode, edit); - View more = v.findViewById(R.id.all_points); - View move = v.findViewById(R.id.info_move); - View remove = v.findViewById(R.id.info_close); + final View more = v.findViewById(R.id.all_points); + final View move = v.findViewById(R.id.info_move); + final View remove = v.findViewById(R.id.info_close); if (!edit) { remove.setVisibility(View.GONE); move.setVisibility(View.GONE); @@ -342,8 +369,31 @@ public class WaypointDialogHelper { more.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - //hideDashboard(); - IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true); + final PopupMenu optionsMenu = new PopupMenu(ctx, more); + DirectionsDialogs.setupPopUpMenuIcon(optionsMenu); + MenuItem item; + item = optionsMenu.getMenu().add( + R.string.intermediate_items_sort_by_distance).setIcon(app.getIconsCache(). + getContentIcon(R.drawable.ic_sort_waypoint_dark)); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + // sort door-to-door + sortAllTargets(app, ctx); + return true; + } + }); + item = optionsMenu.getMenu().add( + R.string.switch_start_finish).setIcon(app.getIconsCache(). + getContentIcon(R.drawable.ic_action_undo_dark)); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + // switch start & finish + return true; + } + }); + optionsMenu.show(); } }); } else { @@ -351,7 +401,26 @@ public class WaypointDialogHelper { move.setVisibility(View.VISIBLE); more.setVisibility(View.GONE); ((ImageView) move).setImageDrawable(app.getIconsCache().getContentIcon( - R.drawable.ic_flat_list_dark, !nightMode)); + R.drawable.ic_action_reorder, !nightMode)); + move.setTag(new DragIcon() { + @Override + public void onClick() { + final PopupMenu optionsMenu = new PopupMenu(ctx, move); + DirectionsDialogs.setupPopUpMenuIcon(optionsMenu); + MenuItem item; + item = optionsMenu.getMenu().add( + R.string.shared_string_delete).setIcon(app.getIconsCache(). + getContentIcon(R.drawable.ic_action_remove_dark)); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + deletePoint(app, adapter, helper, point, deletedPoints, true); + return true; + } + }); + optionsMenu.show(); + } + }); } } else { remove.setVisibility(View.VISIBLE); @@ -362,22 +431,45 @@ public class WaypointDialogHelper { remove.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - ArrayList arr = new ArrayList<>(); - arr.add(point); - app.getWaypointHelper().removeVisibleLocationPoint(arr); - - deletedPoints.add(point); - if (adapter != null) { - adapter.setNotifyOnChange(false); - adapter.remove(point); - adapter.notifyDataSetChanged(); - } + deletePoint(app, adapter, helper, point, deletedPoints, true); } }); } return v; } + public static void deletePoint(final OsmandApplication app, final ArrayAdapter adapter, + final WaypointDialogHelper helper, + final Object item, + final List deletedPoints, + final boolean needCallback) { + + if (item instanceof LocationPointWrapper && adapter != null) { + LocationPointWrapper point = (LocationPointWrapper) item; + if (point.type == WaypointHelper.TARGETS && adapter instanceof StableArrayAdapter) { + StableArrayAdapter stableAdapter = (StableArrayAdapter) adapter; + if (helper != null && helper.dCallback != null && needCallback) { + helper.dCallback.deleteWaypoint(stableAdapter.getPosition(item)); + } + } else { + ArrayList arr = new ArrayList<>(); + arr.add(point); + app.getWaypointHelper().removeVisibleLocationPoint(arr); + + deletedPoints.add(point); + + adapter.setNotifyOnChange(false); + adapter.remove(point); + if (adapter instanceof StableArrayAdapter) { + StableArrayAdapter stableAdapter = (StableArrayAdapter) adapter; + stableAdapter.getObjects().remove(item); + stableAdapter.refreshData(); + } + adapter.notifyDataSetChanged(); + } + } + } + protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running, final int position, final ArrayAdapter thisAdapter, boolean nightMode) { @@ -569,6 +661,8 @@ public class WaypointDialogHelper { } public void reloadListAdapter(ArrayAdapter listAdapter) { + mapActivity.getMyApplication().getWaypointHelper().removeVisibleLocationPoint(deletedPoints); + listAdapter.setNotifyOnChange(false); listAdapter.clear(); List points = getPoints(); @@ -603,8 +697,8 @@ public class WaypointDialogHelper { return str; } - protected List getPoints() { - final List points = new ArrayList(); + protected List getStandardPoints() { + final List points = new ArrayList<>(); boolean rc = waypointHelper.isRouteCalculated(); for (int i = 0; i < WaypointHelper.MAX; i++) { List tp = waypointHelper.getWaypoints(i); @@ -702,4 +796,88 @@ public class WaypointDialogHelper { */ } + public static void sortAllTargets(final OsmandApplication app, final Activity activity) { + + new AsyncTask() { + + ProgressDialog dlg = null; + long startDialogTime = 0; + List intermediates; + + protected void onPreExecute() { + startDialogTime = System.currentTimeMillis(); + dlg = new ProgressDialog(activity); + dlg.setTitle(""); + dlg.setMessage(activity.getResources().getString(R.string.intermediate_items_sort_by_distance)); + dlg.show(); + } + + protected int[] doInBackground(Void[] params) { + + TargetPointsHelper targets = app.getTargetPointsHelper(); + intermediates = targets.getIntermediatePointsWithTarget(); + + Location cll = app.getLocationProvider().getLastKnownLocation(); + ArrayList lt = new ArrayList<>(intermediates); + TargetPoint start; + + if (cll != null) { + LatLon ll = new LatLon(cll.getLatitude(), cll.getLongitude()); + start = TargetPoint.create(ll, null); + } else if (app.getTargetPointsHelper().getPointToStart() != null) { + TargetPoint ps = app.getTargetPointsHelper().getPointToStart(); + LatLon ll = new LatLon(ps.getLatitude(), ps.getLongitude()); + start = TargetPoint.create(ll, null); + } else { + start = lt.get(0); + } + TargetPoint end = lt.remove(lt.size() - 1); + ArrayList al = new ArrayList<>(); + for (TargetPoint p : lt) { + al.add(p.point); + } + return new TspAnt().readGraph(al, start.point, end.point).solve(); + } + + protected void onPostExecute(int[] result) { + if (dlg != null) { + long t = System.currentTimeMillis(); + if (t - startDialogTime < 500) { + app.runInUIThread(new Runnable() { + @Override + public void run() { + dlg.dismiss(); + } + }, 500 - (t - startDialogTime)); + } else { + dlg.dismiss(); + } + } + + List alocs = new ArrayList<>(); + for (int i : result) { + if (i > 0) { + TargetPoint loc = intermediates.get(i - 1); + alocs.add(loc); + } + } + intermediates.clear(); + intermediates.addAll(alocs); + + TargetPointsHelper targets = app.getTargetPointsHelper(); + List cur = targets.getIntermediatePointsWithTarget(); + boolean eq = true; + for (int j = 0; j < cur.size() && j < intermediates.size(); j++) { + if (cur.get(j) != intermediates.get(j)) { + eq = false; + break; + } + } + if (!eq) { + targets.reorderAllTargetPoints(intermediates, true); + } + } + + }.execute(); + } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index a6163d1003..dbe811f5e5 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -12,7 +12,6 @@ import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import android.util.TypedValue; import android.view.GestureDetector; -import android.view.GestureDetector.OnGestureListener; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -45,6 +44,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.OsmandMapTileView; +import net.osmand.plus.views.controls.SingleTapConfirm; import net.osmand.util.Algorithms; import static android.util.TypedValue.COMPLEX_UNIT_DIP; @@ -98,41 +98,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents { private int screenOrientation; - private class SingleTapConfirm implements OnGestureListener { - - @Override - public boolean onDown(MotionEvent e) { - return false; - } - - @Override - public void onShowPress(MotionEvent e) { - - } - - @Override - public boolean onSingleTapUp(MotionEvent e) { - return true; - } - - @Override - public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { - return false; - } - - @Override - public void onLongPress(MotionEvent e) { - - } - - @Override - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - return false; - } - - - } - @TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, diff --git a/OsmAnd/src/net/osmand/plus/views/controls/DynamicListView.java b/OsmAnd/src/net/osmand/plus/views/controls/DynamicListView.java index 2c7f6efe07..741bdce1d2 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/DynamicListView.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/DynamicListView.java @@ -32,6 +32,8 @@ import android.support.annotation.NonNull; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.util.DisplayMetrics; +import android.util.Log; +import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; @@ -46,7 +48,6 @@ import java.util.List; public class DynamicListView extends ObservableListView { - public final String TAG_DRAG_ICON = "DragIcon"; protected final int SMOOTH_SCROLL_AMOUNT_AT_EDGE = 15; protected final int MOVE_DURATION = 150; @@ -82,6 +83,13 @@ public class DynamicListView extends ObservableListView { private boolean mIsWaitingForScrollFinish = false; private int mScrollState = OnScrollListener.SCROLL_STATE_IDLE; + private GestureDetector singleTapDetector; + private DragIcon tag; + + public interface DragIcon { + void onClick(); + } + public DynamicListView(Context context) { super(context); init(context); @@ -101,6 +109,7 @@ public class DynamicListView extends ObservableListView { setOnScrollListener(mScrollListener); DisplayMetrics metrics = context.getResources().getDisplayMetrics(); mSmoothScrollAmountAtEdge = (int) (SMOOTH_SCROLL_AMOUNT_AT_EDGE / metrics.density); + singleTapDetector = new GestureDetector(context, new SingleTapConfirm()); } public void setDynamicListViewCallbacks(DynamicListViewCallbacks callbacks) { @@ -249,7 +258,7 @@ public class DynamicListView extends ObservableListView { // Draw dividers StableArrayAdapter stableAdapter = getStableAdapter(); - if (stableAdapter != null && stableAdapter.hasDividers()) { + if (getDivider() == null && stableAdapter != null && stableAdapter.hasDividers()) { List dividers = stableAdapter.getDividers(); final int count = getChildCount(); @@ -296,20 +305,28 @@ public class DynamicListView extends ObservableListView { @Override public boolean onTouchEvent(@NonNull MotionEvent event) { + if (singleTapDetector.onTouchEvent(event)) { + if (tag != null) { + tag.onClick(); + } + touchEventsCancelled(); + return true; + } + switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: if (!mCellIsMobile && mHoverCell == null) { - mDownX = (int) event.getX(); - mDownY = (int) event.getY(); - mActivePointerId = event.getPointerId(0); - // Find the view that the user pressed their finger down on. - View v = findViewAtPositionWithTag(getRootView(), (int) event.getRawX(), (int) event.getRawY(), TAG_DRAG_ICON); + View v = findViewAtPositionWithDragIconTag(getRootView(), (int) event.getRawX(), (int) event.getRawY()); - // If the view contains a tag set to "DragIcon", it means that the user wants to + // If the view contains a tag set to "DragIcon" class, it means that the user wants to // reorder the list item. - if ((v != null) && (v.getTag() != null) && (v.getTag().equals(TAG_DRAG_ICON))) { + if ((v != null) && (v.getTag() != null) && (v.getTag() instanceof DragIcon)) { + mDownX = (int) event.getX(); + mDownY = (int) event.getY(); + mActivePointerId = event.getPointerId(0); mTotalOffset = 0; + tag = (DragIcon) v.getTag(); int position = pointToPosition(mDownX, mDownY); if (position != INVALID_POSITION) { @@ -564,6 +581,7 @@ public class DynamicListView extends ObservableListView { mBelowItemId = INVALID_ID; setAllVisible(); mHoverCell = null; + tag = null; setEnabled(true); invalidate(); processSwapped(); @@ -718,7 +736,7 @@ public class DynamicListView extends ObservableListView { * @param y The Y location to be tested. * @return Returns the most inner view that contains the XY coordinate or null if no view could be found. */ - private View findViewAtPositionWithTag(View v, int x, int y, String tag) { + private View findViewAtPositionWithDragIconTag(View v, int x, int y) { View vXY = null; if (v instanceof ViewGroup) { @@ -732,9 +750,9 @@ public class DynamicListView extends ObservableListView { if ((x >= loc[0] && (x <= (loc[0] + c.getWidth()))) && (y >= loc[1] && (y <= (loc[1] + c.getHeight())))) { vXY = c; - View viewAtPosition = findViewAtPositionWithTag(c, x, y, tag); + View viewAtPosition = findViewAtPositionWithDragIconTag(c, x, y); - if ((viewAtPosition != null) && (viewAtPosition.getTag() != null) && viewAtPosition.getTag().equals(tag)) { + if ((viewAtPosition != null) && (viewAtPosition.getTag() != null) && viewAtPosition.getTag() instanceof DragIcon) { vXY = viewAtPosition; break; } diff --git a/OsmAnd/src/net/osmand/plus/views/controls/SingleTapConfirm.java b/OsmAnd/src/net/osmand/plus/views/controls/SingleTapConfirm.java new file mode 100644 index 0000000000..bbda5f2a72 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/views/controls/SingleTapConfirm.java @@ -0,0 +1,37 @@ +package net.osmand.plus.views.controls; + +import android.view.GestureDetector; +import android.view.MotionEvent; + +public class SingleTapConfirm implements GestureDetector.OnGestureListener { + + @Override + public boolean onDown(MotionEvent e) { + return false; + } + + @Override + public void onShowPress(MotionEvent e) { + + } + + @Override + public boolean onSingleTapUp(MotionEvent e) { + return true; + } + + @Override + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { + return false; + } + + @Override + public void onLongPress(MotionEvent e) { + + } + + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { + return false; + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/views/controls/SwipeDismissListViewTouchListener.java b/OsmAnd/src/net/osmand/plus/views/controls/SwipeDismissListViewTouchListener.java index 8aa5c84d42..c4b65ab3be 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/SwipeDismissListViewTouchListener.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/SwipeDismissListViewTouchListener.java @@ -472,20 +472,18 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener { * Delete the list item at the specified position. This will animate the item sliding out of the * list and then collapsing until it vanished (same as if the user slides out an item). *

- * NOTE: If you are using list headers, be aware, that the position argument must take care of - * them. Meaning 0 references the first list header. So if you want to delete the first list - * item, you have to pass the number of list headers as {@code position}. Most of the times - * that shouldn't be a problem, since you most probably will evaluate the position which should - * be deleted in a way, that respects the list headers. */ public void delete(int position) { if (mCallbacks == null) { throw new IllegalStateException("You must set an OnDismissCallback, before deleting items."); } - if (position < 0 || position >= mListView.getCount()) { - throw new IndexOutOfBoundsException(String.format("Tried to delete item %d. #items in list: %d", position, mListView.getCount())); + + int pos = position + mListView.getHeaderViewsCount(); + + if (pos < 0 || pos >= mListView.getCount()) { + throw new IndexOutOfBoundsException(String.format("Tried to delete item %d. #items in list: %d", pos, mListView.getCount())); } - View childView = mListView.getChildAt(position - mListView.getFirstVisiblePosition()); + View childView = mListView.getChildAt(pos - mListView.getFirstVisiblePosition()); View view = null; if (mSwipingLayout > 0) { view = childView.findViewById(mSwipingLayout);