forked from upstream-mirrors/OpenTracks
@@ -38,7 +38,7 @@ public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
private final SparseBooleanArray selection = new SparseBooleanArray();
|
private final SparseBooleanArray selection = new SparseBooleanArray();
|
||||||
private RecordingStatus recordingStatus;
|
private RecordingStatus recordingStatus;
|
||||||
private UnitSystem unitSystem;
|
private UnitSystem unitSystem;
|
||||||
private TrackListIterator cursor;
|
private TrackListIterator trackIterator;
|
||||||
private boolean selectionMode = false;
|
private boolean selectionMode = false;
|
||||||
private ActivityUtils.ContextualActionModeCallback actionModeCallback;
|
private ActivityUtils.ContextualActionModeCallback actionModeCallback;
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
@@ -66,26 +66,26 @@ public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
ViewHolder viewHolder = (ViewHolder) holder;
|
ViewHolder viewHolder = (ViewHolder) holder;
|
||||||
|
|
||||||
cursor.moveToPosition(position);
|
trackIterator.moveToPosition(position);
|
||||||
viewHolder.bind(cursor);
|
viewHolder.bind(trackIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int position) {
|
public long getItemId(int position) {
|
||||||
cursor.moveToPosition(position);
|
trackIterator.moveToPosition(position);
|
||||||
return cursor.get().id().id();
|
return trackIterator.get().id().id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemCount() {
|
public int getItemCount() {
|
||||||
if (cursor == null) {
|
if (trackIterator == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return cursor.getCount();
|
return trackIterator.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void swapData(TrackListIterator cursor) {
|
public void swapData(TrackListIterator cursor) {
|
||||||
this.cursor = cursor;
|
this.trackIterator = cursor;
|
||||||
this.notifyDataSetChanged();
|
this.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,10 +132,10 @@ public class TrackListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
|
|||||||
|
|
||||||
public void setAllSelected(boolean isSelected) {
|
public void setAllSelected(boolean isSelected) {
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
cursor.moveToPosition(-1);
|
trackIterator.moveToFirst();
|
||||||
while (cursor.hasNext()) {
|
while (trackIterator.hasNext()) {
|
||||||
selection.put((int) cursor.get().id().id(), true);
|
selection.put((int) trackIterator.get().id().id(), true);
|
||||||
cursor.next();
|
trackIterator.next();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
selection.clear();
|
selection.clear();
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class MarkerListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||||||
|
|
||||||
public void setAllSelected(boolean isSelected) {
|
public void setAllSelected(boolean isSelected) {
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
markerIterator.moveToPosition(-1);
|
markerIterator.moveToFirst();
|
||||||
while (markerIterator.hasNext()) {
|
while (markerIterator.hasNext()) {
|
||||||
selection.put((int) markerIterator.get().id().id(), true);
|
selection.put((int) markerIterator.get().id().id(), true);
|
||||||
markerIterator.next();
|
markerIterator.next();
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ public abstract class AutoCloseableIterator<T> implements Iterator<T>, AutoClose
|
|||||||
return cursor.getPosition();
|
return cursor.getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final boolean moveToFirst() {
|
||||||
|
return cursor.moveToFirst();
|
||||||
|
}
|
||||||
|
|
||||||
public final boolean moveToPosition(int position) {
|
public final boolean moveToPosition(int position) {
|
||||||
return cursor.moveToPosition(position);
|
return cursor.moveToPosition(position);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user