This commit is contained in:
GaidamakUA 2016-01-12 09:58:37 +02:00
commit 22d335cc48
13 changed files with 346 additions and 55 deletions

View file

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?><resources><string name="auto_zoom_none">Без аўтаматычнага маштабаваньня</string>
<?xml version='1.0' encoding='utf-8'?>
<resources><string name="auto_zoom_none">Без аўтаматычнага маштабаваньня</string>
<string name="auto_zoom_close">Буйней</string>
<string name="auto_zoom_far">Для сярэдняга маштаба</string>
<string name="auto_zoom_farthest">Драбней</string>
@ -599,7 +600,7 @@
<string name="poi_filter_nominatim">Сеткавы Nominatim</string>
<string name="search_position_current_location_search">Вызначэньне становішча…</string>
<string name="search_position_current_location_found">Становішча (знойдзена)</string>
<string name="search_position_current_location_found">Маё становішча (знойдзена)</string>
<string name="search_position_address">Адрас…</string>
<string name="search_position_favorites">Упадабаныя…</string>
<string name="search_position_undefined">Нявызначана</string>
@ -2088,4 +2089,9 @@
<string name="weekly">Штотыднёва</string>
<string name="morning">Раніца</string>
<string name="Night">Ноч</string>
</resources>
<string name="shared_string_type">Тып</string>
<string name="starting_point">Пачатковы пункт</string>
<string name="shared_string_undo_all">ВЯРНУЦЬ УСЁ</string>
<string name="rec_split_storage_size">Памер сховішча</string>
<string name="select_month_and_country">Выберыце месяц і краіну</string>
</resources>

View file

@ -2023,7 +2023,7 @@
<string name="update_time">Tiempo de actualización</string>
<string name="rec_split_storage_size">Tamaño del almacenamiento</string>
<string name="updates_size">Actualizaciones: %s</string>
<string name="updates_size">Tamaño de la actualización</string>
<string name="last_map_change">Último cambio de mapa: %s</string>
<string name="rec_split">División de grabación</string>
<string name="rec_split_title">Usar la división de grabación</string>
@ -2032,8 +2032,8 @@
<string name="rec_split_clip_length_desc">La duración de cada clip grabado no excederá el tiempo de intervalo establecido</string>
<string name="rec_split_storage_size_desc">Cantidad de espacio que pueden ocupar todos los clips grabados</string>
<string name="hourly">Cada hora</string>
<string name="daily">Diario</string>
<string name="weekly">Semanal</string>
<string name="daily">A diario</string>
<string name="weekly">Cada semana</string>
<string name="morning">Por la mañana</string>
<string name="Night">Por la noche</string>
<string name="shared_string_not_selected">No seleccionado</string>

View file

@ -2108,7 +2108,7 @@
<string name="rec_split_desc">Écraser les enregistrements quand l\'espace utilisé dépasse la capacité de stockage</string>
<string name="rec_split_clip_length">Durée de l\'enregistrement</string>
<string name="rec_split_clip_length_desc">La longueur de chaque enregistrement ne sera plus par intervalle de temps</string>
<string name="rec_split_storage_size">Espace de stockage</string>
<string name="rec_split_storage_size">Taille de l\'espace de stockage</string>
<string name="rec_split_storage_size_desc">Espace maximum alloué pour tous les enregistrements</string>
<string name="shared_string_type">Type</string>
</resources>

View file

@ -701,7 +701,7 @@
<string name="poi_wiki_lang_vo">Wiki en volapük</string>
<string name="poi_wiki_lang_zh">Wiki en chinés</string>
<string name="poi_barrier_entrance">Entrada</string>
<string name="poi_barrier_entrance">Pasaxe nun muro ou valado</string>
<string name="poi_entrance_main">Entrada principal</string>
<string name="poi_entrance">Entrada</string>
<string name="poi_entrance_exit">Saída</string>
@ -727,8 +727,8 @@
<string name="poi_disused">En desuso</string>
<string name="poi_brand">Marca</string>
<string name="poi_drinking_water_yes">Auga potábel</string>
<string name="poi_drinking_water_no">Auga non potábel</string>
<string name="poi_drinking_water_yes">Auga potábel: si</string>
<string name="poi_drinking_water_no">Auga potábel: non</string>
<string name="poi_supervised_yes">Vixiado</string>
<string name="poi_supervised_no">Non vixiado</string>
<string name="poi_seasonal_yes">Temporal</string>
@ -739,7 +739,7 @@
<string name="poi_seasonal_summer">Verán</string>
<string name="poi_seasonal_autumn">Outono</string>
<string name="poi_seasonal_winter">Inverno</string>
<string name="poi_crossing_traffic_signals">Con sinais de tráfico</string>
<string name="poi_crossing_traffic_signals">Con semáforo</string>
<string name="poi_crossing_uncontrolled">Sen control</string>
<string name="poi_crossing_unmarked">Sen marcas</string>
<string name="poi_start_date">Data de inicio</string>
@ -752,14 +752,14 @@
<string name="poi_access_delivery">Acceso para entregas</string>
<string name="poi_access_agricultural">Acceso agrícola</string>
<string name="poi_content_water">Auga (contido)</string>
<string name="poi_content_fuel">Combustíbel (contido)</string>
<string name="poi_content_wine">Viño (contido)</string>
<string name="poi_content_biomass">Biomasa (contido)</string>
<string name="poi_content_crop">Colleita (contido)</string>
<string name="poi_content_fodder">Forraxe (contido)</string>
<string name="poi_content_beer">Cervexa (contido)</string>
<string name="poi_content_salt">Sal (contido)</string>
<string name="poi_content_water">Contido: auga</string>
<string name="poi_content_fuel">Contido: combustíbel</string>
<string name="poi_content_wine">Contido: viño</string>
<string name="poi_content_biomass">Contido: biomasa</string>
<string name="poi_content_crop">Contido: colleita</string>
<string name="poi_content_fodder">Contido: foraxe</string>
<string name="poi_content_beer">Contido: cervexa</string>
<string name="poi_content_salt">Contido: sal</string>
<string name="poi_scuba_diving_shop">Tenda de materiais de mergullo con botella</string>
<string name="poi_car_repair">Taller de automoción</string>
<string name="poi_recycling_low_energy_bulbs">Lámpadas de baixo consumo</string>
@ -770,7 +770,7 @@
<string name="poi_collection_times">Horario de recollida</string>
<string name="poi_building">Edificio</string>
<string name="poi_content_grain">Gran (contido)</string>
<string name="poi_content_grain">Contido: gran</string>
<string name="poi_animal_shelter_dog">Canceira</string>
<string name="poi_animal_shelter_cat">Refuxio para gatos</string>
@ -816,4 +816,62 @@
<string name="poi_glaziery">Tenda de vidro</string>
<string name="poi_tableware">Tenda de vaixela</string>
<string name="poi_ticket">Billeteira</string>
<string name="poi_window_blind">Tenda de persianas</string>
<string name="poi_car">Concesionario de automóbiles</string>
<string name="poi_swimming_pool_shop">Tenda de material de piscina</string>
<string name="poi_gate">Cancela</string>
<string name="poi_traffic_signals">Semáforo</string>
<string name="poi_fuel_e10">E10</string>
<string name="poi_fuel_e20">E20</string>
<string name="poi_fuel_e85">E85</string>
<string name="poi_runway">Pista de aterraxe</string>
<string name="poi_junction">Encrucillada</string>
<string name="poi_power_tower">Torre eléctrica</string>
<string name="poi_power_pole">Poste eléctrico</string>
<string name="poi_telephone_exchange">Central telefónica</string>
<string name="poi_recycling_small_appliances">Electrodomésticos pequenos</string>
<string name="poi_recycling_garden_waste">Residuos de xardín</string>
<string name="poi_recycling_hazardous_waste">Residuos perigosos</string>
<string name="poi_recycling_light_bulbs">Lámpadas eléctricas</string>
<string name="poi_recycling_polyester">Poliéster</string>
<string name="poi_school">Centro educativo</string>
<string name="poi_college">Universidade</string>
<string name="poi_paediatrics">Pediatría</string>
<string name="poi_archery">Tiro con arco</string>
<string name="poi_shooting">Salón de tiro</string>
<string name="poi_tourism_yes">Obxecto turístico</string>
<string name="poi_attraction_animal">Animal (atracción)</string>
<string name="poi_attraction_water_slide">Tobogán de auga</string>
<string name="poi_wilderness_hut">Refuxio</string>
<string name="poi_hunting_lodge">Refuxio de caza</string>
<string name="poi_religion_unitarian_universalist">Universalismo unitario</string>
<string name="poi_wine_cellar">Adega</string>
<string name="poi_piste_snow_park">Parque de neve</string>
<string name="poi_craft_bookbinder">Encadernación</string>
<string name="poi_craft_window_construction">Carpintaría de aluminio</string>
<string name="poi_military_bunker">Búnker militar</string>
<string name="poi_bollard">Bolardo</string>
<string name="poi_cycle_barrier">Barreira para bicicletas</string>
<string name="poi_motorcycle_barrier">Barreira para motos</string>
<string name="poi_service_times">Horario de funcionamento</string>
<string name="poi_height">Altura</string>
<string name="poi_ele">Elevación sobre o nivel do mar</string>
<string name="poi_wheelchair_no">Cadeira de rodas: inaccesíbel</string>
<string name="poi_wheelchair_limited">Cadeira de rodas: limitado</string>
<string name="poi_content_oil">Contido: aceite</string>
<string name="poi_content_gas">Contido: gas</string>
<string name="poi_content_wastewater">Contido: augas residuais</string>
<string name="poi_nudism_yes">Nudismo: permitido</string>
<string name="poi_nudism_no">Nudismo: prohibido</string>
<string name="poi_nudism_obligatory">Nudismo: obrigatorio</string>
<string name="poi_nudism_customary">Nudismo: tradicional</string>
<string name="poi_nudism_permissive">Nudismo: permisivo</string>
</resources>

View file

@ -2026,4 +2026,9 @@
<string name="updates_size">Güncelleme boyutu</string>
<string name="select_month_and_country">Ayı ve ülke seçin</string>
</resources>
<string name="item_deleted">Öğe silindi</string>
<string name="n_items_deleted">öğe silindi</string>
<string name="shared_string_undo_all">UNDO TÜM</string>
<string name="shared_string_type">Tip</string>
<string name="starting_point">Başlangıç noktası</string>
</resources>

View file

@ -224,6 +224,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
stableAdapter.getObjects().remove(item);
activeObjPos = stableAdapter.getActiveObjects().indexOf(item);
stableAdapter.getActiveObjects().remove(item);
stableAdapter.refreshData();
stableAdapter.notifyDataSetChanged();
} else {
@ -240,7 +241,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
stableAdapter.insert(item, position);
stableAdapter.getObjects().add(position, item);
stableAdapter.getActiveObjects().add(activeObjPos, item);
stableAdapter.updateIdMap();
stableAdapter.refreshData();
onItemsSwapped(stableAdapter.getActiveObjects());
}
@ -252,7 +253,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
public void onHidePopup() {
if (listAdapter instanceof StableArrayAdapter) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
stableAdapter.updateIdMap();
stableAdapter.refreshData();
onItemsSwapped(stableAdapter.getActiveObjects());
}
}
@ -1186,7 +1187,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
}
getMyApplication().getTargetPointsHelper().reorderAllTargetPoints(allTargets, false);
newRouteIsCalculated(false, null);
newRouteIsCalculated(false, new ValueHolder<Boolean>());
getMyApplication().getTargetPointsHelper().updateRouteAndReferesh(true);
if (swipeDismissListener != null) {
@ -1209,6 +1210,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
dynamicListView.setActiveItemsList(stableAdapter.getActiveObjects());
}
}
showToast.value = false;
}
@Override

View file

@ -1,9 +1,14 @@
package net.osmand.plus.helpers;
import android.app.Activity;
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;
@ -30,6 +35,7 @@ import net.osmand.plus.activities.IntermediatePointsDialog;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.views.controls.ListDividerShape;
import net.osmand.plus.views.controls.StableArrayAdapter;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@ -161,6 +167,85 @@ public class WaypointDialogHelper {
return activePoints;
}
private List<Drawable> getCustomDividers(Context ctx, List<Object> points, boolean nightMode) {
int color;
int pointColor;
if (nightMode) {
color = ctx.getResources().getColor(R.color.dashboard_divider_dark);
pointColor = ctx.getResources().getColor(R.color.dashboard_divider_dark);
} else {
color = ctx.getResources().getColor(R.color.dashboard_divider_light);
pointColor = ctx.getResources().getColor(R.color.ctx_menu_info_divider_light);
}
Shape fullDividerShape = new ListDividerShape(color, 0);
Shape halfDividerShape = new ListDividerShape(color, AndroidUtils.dpToPx(ctx, 56f));
Shape halfPointDividerShape = new ListDividerShape(color, AndroidUtils.dpToPx(ctx, 56f),
pointColor, AndroidUtils.dpToPx(ctx, 1.5f), true);
Shape headerDividerShape = new ListDividerShape(color, AndroidUtils.dpToPx(ctx, 16f));
final ShapeDrawable fullDivider = new ShapeDrawable(fullDividerShape);
final ShapeDrawable halfDivider = new ShapeDrawable(halfDividerShape);
final ShapeDrawable halfPointDivider = new ShapeDrawable(halfPointDividerShape);
final ShapeDrawable headerDivider = new ShapeDrawable(headerDividerShape);
final Drawable startingPointDivider = app.getIconsCache().getIcon(R.drawable.bg_shadow_list_bottom);
int divHeight = AndroidUtils.dpToPx(ctx, 1f);
fullDivider.setIntrinsicHeight(divHeight);
halfDivider.setIntrinsicHeight(divHeight);
halfPointDivider.setIntrinsicHeight(divHeight);
headerDivider.setIntrinsicHeight(divHeight);
List<Drawable> res = new ArrayList<>();
for (int i = 0; i < points.size(); i++) {
Object obj = points.get(i);
Object objNext = i + 1 < points.size() ? points.get(i + 1) : null;
if (objNext == null) {
break;
}
boolean labelView = (obj instanceof Integer);
boolean bottomDividerViewNext = (objNext instanceof Boolean) && !((Boolean) objNext);
boolean locationPoint = (obj instanceof LocationPointWrapper);
boolean locationPointNext = (objNext instanceof LocationPointWrapper);
Drawable d = null;
if (locationPointNext) {
if (locationPoint) {
LocationPointWrapper w = (LocationPointWrapper) obj;
if (w.type == WaypointHelper.TARGETS && ((TargetPoint) w.point).start) {
d = startingPointDivider; // starting point divider
} else {
if (w.type == WaypointHelper.TARGETS) {
d = halfPointDivider;
} else {
d = halfDivider;
}
}
} else {
LocationPointWrapper w = (LocationPointWrapper) objNext;
if (w.type == WaypointHelper.TARGETS) {
if (!((TargetPoint) w.point).start) {
d = fullDivider;
}
} else {
d = fullDivider;
}
}
} else if (objNext instanceof RadiusItem && labelView) {
d = headerDivider;
} else if (locationPoint && !bottomDividerViewNext) {
d = fullDivider;
}
res.add(d);
}
return res;
}
public StableArrayAdapter getWaypointsDrawerAdapter(
final boolean edit, final List<LocationPointWrapper> deletedPoints,
final MapActivity ctx, final int[] running, final boolean flat, final boolean nightMode) {
@ -176,6 +261,11 @@ public class WaypointDialogHelper {
return new StableArrayAdapter(ctx,
R.layout.waypoint_reached, R.id.title, points, activePoints) {
@Override
public void buildDividers() {
dividers = getCustomDividers(ctx, getObjects(), nightMode);
}
@Override
public boolean isEnabled(int position) {
Object obj = getItem(position);

View file

@ -287,40 +287,43 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
break;
case MotionEvent.ACTION_MOVE:
hasMoved = true;
float y = event.getY();
float newY = getViewY() + (y - dy);
setViewY((int) newY, false, false);
if (moving) {
hasMoved = true;
float y = event.getY();
float newY = getViewY() + (y - dy);
setViewY((int) newY, false, false);
menuFullHeight = view.getHeight() - (int) newY + 10;
if (!oldAndroid()) {
ViewGroup.LayoutParams lp = mainView.getLayoutParams();
lp.height = Math.max(menuFullHeight, menuTitleHeight);
mainView.setLayoutParams(lp);
mainView.requestLayout();
menuFullHeight = view.getHeight() - (int) newY + 10;
if (!oldAndroid()) {
ViewGroup.LayoutParams lp = mainView.getLayoutParams();
lp.height = Math.max(menuFullHeight, menuTitleHeight);
mainView.setLayoutParams(lp);
mainView.requestLayout();
}
velocity.addMovement(event);
velocity.computeCurrentVelocity(1000);
velocityY = Math.abs(velocity.getYVelocity());
if (velocityY > maxVelocityY)
maxVelocityY = velocityY;
}
velocity.addMovement(event);
velocity.computeCurrentVelocity(1000);
velocityY = Math.abs(velocity.getYVelocity());
if (velocityY > maxVelocityY)
maxVelocityY = velocityY;
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
moving = false;
int currentY = getViewY();
if (moving) {
moving = false;
int currentY = getViewY();
slidingUp = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) < -50;
slidingDown = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) > 50;
slidingUp = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) < -50;
slidingDown = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) > 50;
velocity.recycle();
boolean skipHalfScreenState = Math.abs(currentY - dyMain) > skipHalfScreenStateLimit;
changeMenuState(currentY, skipHalfScreenState, slidingUp, slidingDown);
velocity.recycle();
boolean skipHalfScreenState = Math.abs(currentY - dyMain) > skipHalfScreenStateLimit;
changeMenuState(currentY, skipHalfScreenState, slidingUp, slidingDown);
}
break;
}

View file

@ -454,7 +454,9 @@ public class RoutingHelper {
}
// 2. check if intermediate found
if(route.getIntermediatePointsToPass() > 0 && route.getDistanceToNextIntermediate(lastFixedLocation) < POSITION_TOLERANCE * 2) {
if(route.getIntermediatePointsToPass() > 0
&& route.getDistanceToNextIntermediate(lastFixedLocation) < POSITION_TOLERANCE * 2
&& !isRoutePlanningMode) {
showMessage(app.getString(R.string.arrived_at_intermediate_point));
route.passIntermediatePoint();
TargetPointsHelper targets = app.getTargetPointsHelper();
@ -485,7 +487,9 @@ public class RoutingHelper {
// 3. check if destination found
Location lastPoint = routeNodes.get(routeNodes.size() - 1);
if (currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < (((float)settings.getApplicationMode().getArrivalDistance()) * settings.ARRIVAL_DISTANCE_FACTOR.get())) {
if (currentRoute > routeNodes.size() - 3
&& currentLocation.distanceTo(lastPoint) < (((float)settings.getApplicationMode().getArrivalDistance()) * settings.ARRIVAL_DISTANCE_FACTOR.get())
&& !isRoutePlanningMode) {
showMessage(app.getString(R.string.arrived_at_destination));
TargetPointsHelper targets = app.getTargetPointsHelper();
TargetPoint tp = targets.getPointToNavigate();

View file

@ -27,6 +27,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
@ -245,6 +246,51 @@ public class DynamicListView extends ObservableListView {
if (mHoverCell != null) {
mHoverCell.draw(canvas);
}
// Draw dividers
StableArrayAdapter stableAdapter = getStableAdapter();
if (stableAdapter != null && stableAdapter.hasDividers()) {
List<Drawable> dividers = stableAdapter.getDividers();
final int count = getChildCount();
final int first = getFirstVisiblePosition();
final int headerCount = getHeaderViewsCount();
final int itemCount = getCount();
final int footerLimit = (itemCount - getFooterViewsCount());
final Rect bounds = new Rect();
bounds.left = getPaddingLeft();
bounds.right = getRight() - getLeft() - getPaddingRight();
final int listBottom = getBottom() - getTop() + getScrollY();
for (int i = 0; i < count; i++) {
final int itemIndex = (first + i);
final boolean isHeader = (itemIndex < headerCount);
final boolean isFooter = (itemIndex >= footerLimit);
if (!isHeader && !isFooter && itemIndex < dividers.size()) {
Drawable divider = dividers.get(itemIndex - headerCount);
if (divider != null) {
final View child = getChildAt(i);
int bottom = child.getBottom();
final boolean isLastItem = (i == (count - 1));
if (bottom < listBottom && !isLastItem) {
final int nextIndex = (itemIndex + 1);
if (nextIndex >= headerCount && nextIndex < footerLimit) {
bounds.top = bottom;
bounds.bottom = bottom + divider.getIntrinsicHeight();
drawDivider(canvas, divider, bounds);
}
}
}
}
}
}
}
void drawDivider(Canvas canvas, Drawable divider, Rect bounds) {
divider.setBounds(bounds);
divider.draw(canvas);
}
@Override

View file

@ -0,0 +1,59 @@
package net.osmand.plus.views.controls;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.shapes.Shape;
public class ListDividerShape extends Shape {
private RectF mRect = new RectF();
private int lineColor;
private int paddingLeft;
private int pointColor;
private float pointRadius;
private boolean drawPoint;
public ListDividerShape(int lineColor, int paddingLeft) {
this.lineColor = lineColor;
this.paddingLeft = paddingLeft;
this.pointColor = 0;
this.pointRadius = 0f;
this.drawPoint = false;
}
public ListDividerShape(int lineColor, int paddingLeft, int pointColor, float pointRadius, boolean drawPoint) {
this.lineColor = lineColor;
this.paddingLeft = paddingLeft;
this.pointColor = pointColor;
this.pointRadius = pointRadius;
this.drawPoint = drawPoint;
}
@Override
public void draw(Canvas canvas, Paint paint) {
paint.setColor(lineColor);
mRect.left = paddingLeft;
canvas.drawRect(mRect, paint);
if (paddingLeft > 0 && drawPoint) {
paint.setColor(pointColor);
canvas.drawCircle(paddingLeft / 2f, (mRect.bottom - mRect.top) / 2f, pointRadius, paint);
}
}
@Override
protected void onResize(float width, float height) {
mRect.set(0, 0, width, height);
}
@Override
public ListDividerShape clone() throws CloneNotSupportedException {
final ListDividerShape shape = (ListDividerShape) super.clone();
shape.mRect = new RectF(mRect);
shape.lineColor = lineColor;
shape.paddingLeft = paddingLeft;
shape.pointColor = pointColor;
shape.pointRadius = pointRadius;
shape.drawPoint = drawPoint;
return shape;
}
}

View file

@ -1,6 +1,7 @@
package net.osmand.plus.views.controls;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.widget.ArrayAdapter;
@ -17,6 +18,7 @@ public class StableArrayAdapter extends ArrayAdapter<Object> {
List<Object> objects;
List<Object> activeObjects;
HashMap<Object, Integer> mIdMap = new HashMap<>();
protected List<Drawable> dividers;
public StableArrayAdapter(Context context, int textViewResourceId, int titleId,
List<Object> objects, List<Object> activeObjects) {
@ -32,13 +34,21 @@ public class StableArrayAdapter extends ArrayAdapter<Object> {
return activeObjects;
}
public List<Drawable> getDividers() {
return dividers;
}
public boolean hasDividers() {
return dividers != null && dividers.size() > 0;
}
public void updateObjects(List<Object> objects, List<Object> activeObjects) {
this.objects = objects;
this.activeObjects = activeObjects;
updateIdMap();
refreshData();
}
public void updateIdMap() {
private void updateIdMap() {
HashMap<Object, Integer> idMap = new HashMap<>();
for (int i = 0; i < objects.size(); ++i) {
idMap.put(objects.get(i), i);
@ -46,6 +56,14 @@ public class StableArrayAdapter extends ArrayAdapter<Object> {
mIdMap = idMap;
}
public void refreshData() {
updateIdMap();
buildDividers();
}
public void buildDividers() {
}
@Override
public Object getItem(int position) {
return objects.get(position);

View file

@ -460,10 +460,10 @@ public class SwipeDismissListViewTouchListener implements View.OnTouchListener {
undoable.discard();
}
mUndoActions.clear();
if (mCallbacks != null) {
mCallbacks.onHidePopup();
}
if (mUndoPopup.isShowing()) {
if (mCallbacks != null) {
mCallbacks.onHidePopup();
}
mUndoPopup.dismiss();
}
}