use of io.jawg.osmcontributor.utils.upload.PoiUpdateWrapper in project osm-contributor by jawg.
the class PoiManager method onPleaseLoadPoisToUpdateEvent.
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseLoadPoisToUpdateEvent(PleaseLoadPoisToUpdateEvent event) {
List<Poi> updatedPois = poiDao.queryForAllUpdated();
List<Poi> newPois = poiDao.queryForAllNew();
List<Poi> toDeletePois = poiDao.queryToDelete();
List<PoiNodeRef> wayPoiNodeRef = poiNodeRefDao.queryAllToUpdate();
List<PoiUpdateWrapper> allPois = new ArrayList<>();
for (Poi p : updatedPois) {
Long oldPoiId = p.getOldPoiId();
if (oldPoiId != null) {
allPois.add(new PoiUpdateWrapper(true, p, poiDao.queryForId(oldPoiId), null, PoiUpdateWrapper.PoiAction.UPDATE));
}
}
for (Poi p : newPois) {
allPois.add(new PoiUpdateWrapper(true, p, null, null, PoiUpdateWrapper.PoiAction.CREATE));
}
for (Poi p : toDeletePois) {
allPois.add(new PoiUpdateWrapper(true, p, poiDao.queryForId(p.getOldPoiId()), null, PoiUpdateWrapper.PoiAction.DELETED));
}
for (PoiNodeRef p : wayPoiNodeRef) {
allPois.add(new PoiUpdateWrapper(false, null, null, p, PoiUpdateWrapper.PoiAction.UPDATE));
}
bus.post(new PoisToUpdateLoadedEvent(allPois));
}
use of io.jawg.osmcontributor.utils.upload.PoiUpdateWrapper in project osm-contributor by jawg.
the class PoisAdapter method remove.
public void remove(int position) {
PoiUpdateWrapper wrapper = poisWrapper.remove(position);
if (OnRemoveListener != null) {
OnRemoveListener.onItemRemoved(wrapper, position);
}
notifyItemRemoved(position);
}
use of io.jawg.osmcontributor.utils.upload.PoiUpdateWrapper in project osm-contributor by jawg.
the class PoisAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final PoiViewHolder holder, final int position) {
final PoiUpdateWrapper poiWrapper = poisWrapper.get(position);
switch(poiWrapper.getAction()) {
case CREATE:
holder.getPoiAction().setText(context.getString(R.string.created));
break;
case DELETED:
holder.getPoiAction().setText(context.getString(R.string.deleted));
break;
case UPDATE:
holder.getPoiAction().setText(context.getString(R.string.updated));
break;
}
final LinearLayout wrapper = holder.getDetailsWrapper();
if (poiWrapper.getIsPoi()) {
holder.getPoiType().setText(poiWrapper.getPoiType());
holder.getPoiName().setText(poiWrapper.getName());
holder.getExpandBtn().setVisibility(View.VISIBLE);
populateDiffs(holder, holder.getDetailsWrapper(), poiWrapper);
View.OnClickListener expendCardnew = new View.OnClickListener() {
@Override
public void onClick(View v) {
poiWrapper.setOpen(!poiWrapper.isOpen());
ViewAnimation.animate(wrapper, poiWrapper.isOpen());
if (poiWrapper.isOpen()) {
holder.getExpandBtn().setImageResource(R.drawable.chevron_up);
} else {
holder.getExpandBtn().setImageResource(R.drawable.chevron_down);
}
}
};
holder.getExpandBtn().setOnClickListener(expendCardnew);
holder.getHeader().setOnClickListener(expendCardnew);
if (poiWrapper.isOpen()) {
wrapper.setVisibility(View.VISIBLE);
holder.getExpandBtn().setImageResource(R.drawable.chevron_up);
} else {
wrapper.setVisibility(View.GONE);
holder.getExpandBtn().setImageResource(R.drawable.chevron_down);
}
} else {
holder.getExpandBtn().setVisibility(View.GONE);
wrapper.setVisibility(View.GONE);
holder.getPoiType().setText(context.getString(R.string.node_ref_title));
holder.getPoiName().setText("");
}
holder.getRevertBtn().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
remove(poisWrapper.indexOf(poiWrapper));
}
});
holder.getCheckbox().setChecked(poiWrapper.isSelected());
holder.getCheckbox().setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
poiWrapper.setSelected(isChecked);
}
});
}
Aggregations