use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class TypeManager method onInternalRemovePoiTypeEvent.
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onInternalRemovePoiTypeEvent(InternalRemovePoiTypeEvent event) {
PoiType poiType = event.getPoiType();
poiManager.deletePoiType(poiType);
Timber.i("Removed poi type %d", poiType.getId());
bus.post(new PoiTypeDeletedEvent(poiType));
bus.post(new PoiTypesLoaded(poiManager.getPoiTypesSortedByName()));
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class EditPoiTypeDialogFragment method onOkClicked.
@Override
protected void onOkClicked() {
if (poiType == null) {
poiType = new PoiType();
poiType.setName(modelText.getText().toString());
poiType.setTechnicalName(poiType.getName());
poiType.setLastUse(DateTime.now());
poiType.setTags(new ArrayList<PoiTypeTag>());
}
typeManager.savePoiType(poiType);
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class TypeListActivityPresenter method onInternalTypesLoadedEvent.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onInternalTypesLoadedEvent(InternalTypesLoadedEvent event) {
List<PoiType> currentPoiTypes = event.getPoiTypes();
PoiType currentPoiType = event.getCurrentPoiType();
if (currentPoiType == null) {
typeListActivity.showTypes(currentPoiTypes);
} else {
typeListActivity.showTags(currentPoiType.getTags(), currentPoiType);
}
this.currentPoiType = currentPoiType;
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class TypeListActivityPresenter method onInternalPleaseLoadEvent.
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onInternalPleaseLoadEvent(InternalPleaseLoadEvent event) {
List<PoiType> poiTypesAlphabeticallySorted = poiManager.getPoiTypesSortedByName();
for (PoiType type : poiTypesAlphabeticallySorted) {
type.setTags(DatabaseHelper.loadLazyForeignCollection(type.getTags()));
}
PoiType currentPoiType = null;
Long currentPoiTypeId = event.getCurrentPoiTypeId();
if (currentPoiTypeId != null) {
for (PoiType type : poiTypesAlphabeticallySorted) {
if (currentPoiTypeId.equals(type.getId())) {
currentPoiType = type;
break;
}
}
if (currentPoiType == null) {
throw new IllegalStateException("Current POI type not found after reloading data");
}
}
bus.post(new InternalTypesLoadedEvent(poiTypesAlphabeticallySorted, currentPoiType));
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class TypeListActivityPresenter method getPoiTypeAdapterListener.
public PoiTypeAdapter.PoiTypeAdapterListener getPoiTypeAdapterListener() {
return new PoiTypeAdapter.PoiTypeAdapterListener() {
@Override
public void onItemClick(final PoiType item) {
currentPoiType = item;
typeManager.finishLastDeletionJob();
bus.post(new InternalPleaseLoadEvent(item.getId()));
}
@Override
public void onItemLongClick(final PoiType item) {
EditPoiTypeNameDialogFragment.display(typeListActivity.getSupportFragmentManager(), item);
}
@Override
public void onItemRemoved(final PoiType item) {
Snackbar snackbar = typeListActivity.createSnackbar(item.getName());
typeManager.deletePoiTypeDelayed(item, snackbar, new View.OnClickListener() {
@Override
public void onClick(View v) {
typeListActivity.undoPoiTypeRemoval();
Timber.i("Undone poi type %d removal", item.getId());
}
});
}
};
}
Aggregations