Refactor clicking in row
This commit is contained in:
parent
31090be952
commit
e201a7db89
2 changed files with 11 additions and 17 deletions
|
@ -78,7 +78,9 @@ public class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
|
||||||
holder.selectCheckBox.setOnClickListener(new View.OnClickListener() {
|
holder.selectCheckBox.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
selectItem(holder.selectCheckBox, child);
|
if (listener != null) {
|
||||||
|
listener.onItemSelect(child, holder.selectCheckBox.isChecked());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,9 +102,7 @@ public class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
CheckBox checkBox = holder.selectCheckBox;
|
holder.selectCheckBox.performClick();
|
||||||
checkBox.setChecked(!checkBox.isChecked());
|
|
||||||
selectItem(checkBox, child);
|
|
||||||
} else {
|
} else {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
listener.onItemShowMap(child);
|
listener.onItemShowMap(child);
|
||||||
|
@ -114,17 +114,6 @@ public class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectItem(CheckBox checkBox, OsmPoint note) {
|
|
||||||
if (checkBox.isChecked()) {
|
|
||||||
selectedOsmEdits.add(note);
|
|
||||||
} else {
|
|
||||||
selectedOsmEdits.remove(note);
|
|
||||||
}
|
|
||||||
if (listener != null) {
|
|
||||||
listener.onItemSelect(note);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class OsmEditViewHolder {
|
private class OsmEditViewHolder {
|
||||||
View mainView;
|
View mainView;
|
||||||
ImageView icon;
|
ImageView icon;
|
||||||
|
@ -143,7 +132,7 @@ public class OsmEditsAdapter extends ArrayAdapter<OsmPoint> {
|
||||||
|
|
||||||
public interface OsmEditsAdapterListener {
|
public interface OsmEditsAdapterListener {
|
||||||
|
|
||||||
void onItemSelect(OsmPoint point);
|
void onItemSelect(OsmPoint point, boolean checked);
|
||||||
|
|
||||||
void onItemShowMap(OsmPoint point);
|
void onItemShowMap(OsmPoint point);
|
||||||
|
|
||||||
|
|
|
@ -361,7 +361,12 @@ public class OsmEditsFragment extends OsmAndListFragment implements SendPoiDialo
|
||||||
listAdapter.setSelectedOsmEdits(osmEditsSelected);
|
listAdapter.setSelectedOsmEdits(osmEditsSelected);
|
||||||
listAdapter.setAdapterListener(new OsmEditsAdapter.OsmEditsAdapterListener() {
|
listAdapter.setAdapterListener(new OsmEditsAdapter.OsmEditsAdapterListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelect(OsmPoint point) {
|
public void onItemSelect(OsmPoint point, boolean checked) {
|
||||||
|
if (checked) {
|
||||||
|
osmEditsSelected.add(point);
|
||||||
|
} else {
|
||||||
|
osmEditsSelected.remove(point);
|
||||||
|
}
|
||||||
updateSelectionMode(actionMode);
|
updateSelectionMode(actionMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue