keep list position on delete item
This commit is contained in:
parent
43a66ac0d3
commit
10e01ea2e3
1 changed files with 11 additions and 2 deletions
|
@ -667,10 +667,19 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
recreateAdapterData();
|
||||
}
|
||||
|
||||
private int getFirstVisible() {
|
||||
return getListView().getFirstVisiblePosition();
|
||||
}
|
||||
|
||||
private void notifyDataSetChanged() {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private void notifyDataSetChangedWithSelection(int firstVisible) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
getListView().setSelection(firstVisible);
|
||||
}
|
||||
|
||||
public static class DeleteOsmEditsConfirmDialogFragment extends DialogFragment {
|
||||
public static final String TAG = "DeleteOsmEditsConfirmDialogFragment";
|
||||
private static final String POINTS_LIST = "points_list";
|
||||
|
@ -698,6 +707,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
builder.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
int firstVisible = parentFragment.getFirstVisible();
|
||||
Iterator<OsmPoint> it = points.iterator();
|
||||
while (it.hasNext()) {
|
||||
OsmPoint osmPoint = it.next();
|
||||
|
@ -710,8 +720,7 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
|||
it.remove();
|
||||
parentFragment.deletePoint(osmPoint);
|
||||
}
|
||||
parentFragment.notifyDataSetChanged();
|
||||
|
||||
parentFragment.notifyDataSetChangedWithSelection(firstVisible);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
|
|
Loading…
Reference in a new issue