use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class MapFragment method loadPoiTypeFloatingBtn.
public void loadPoiTypeFloatingBtn() {
if (addPoiFloatingMenu != null) {
addPoiFloatingMenu.removeAllMenuButtons();
}
FloatingActionButton floatingActionButton;
// add note
if (!FlavorUtils.isBus()) {
floatingActionButton = new FloatingActionButton(getActivity());
floatingActionButton.setLabelText(getString(R.string.note));
floatingActionButton.setColorPressed(ContextCompat.getColor(getActivity(), R.color.material_green_700));
floatingActionButton.setColorNormal(ContextCompat.getColor(getActivity(), R.color.material_green_500));
floatingActionButton.setButtonSize(FloatingActionButton.SIZE_MINI);
floatingActionButton.setImageDrawable(bitmapHandler.getIconWhite(null));
floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
switchMode(MapMode.NOTE_CREATION);
addPoiFloatingMenu.close(true);
}
});
addPoiFloatingMenu.addMenuButton(floatingActionButton);
}
if (presenter.getNumberOfPoiTypes() <= maxPoiType) {
// add a btn per poiType
for (final PoiType poiType : presenter.getPoiTypes()) {
floatingActionButton = new FloatingActionButton(getActivity());
floatingActionButton.setLabelText(poiType.getName());
floatingActionButton.setColorPressed(ContextCompat.getColor(getActivity(), R.color.material_blue_grey_800));
floatingActionButton.setColorNormal(ContextCompat.getColor(getActivity(), R.color.material_blue_500));
floatingActionButton.setButtonSize(FloatingActionButton.SIZE_MINI);
floatingActionButton.setImageDrawable(bitmapHandler.getIconWhite(poiType));
floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (configManager.hasPoiAddition()) {
switchMode(MapMode.POI_CREATION);
poiTypeSelected(poiType);
addPoiFloatingMenu.close(true);
} else {
Toast.makeText(getActivity(), getResources().getString(R.string.point_modification_forbidden), Toast.LENGTH_SHORT).show();
}
}
});
addPoiFloatingMenu.addMenuButton(floatingActionButton);
}
} else {
// add a btn for all poiTypes
floatingActionButton = new FloatingActionButton(getActivity());
floatingActionButton.setLabelText(getResources().getString(R.string.add_poi));
floatingActionButton.setColorPressed(ContextCompat.getColor(getActivity(), R.color.material_blue_grey_800));
floatingActionButton.setColorNormal(ContextCompat.getColor(getActivity(), R.color.material_blue_500));
floatingActionButton.setButtonSize(FloatingActionButton.SIZE_MINI);
floatingActionButton.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.fab_poi));
floatingActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (configManager.hasPoiAddition()) {
switchMode(MapMode.TYPE_PICKER);
} else {
Toast.makeText(getActivity(), getResources().getString(R.string.point_modification_forbidden), Toast.LENGTH_SHORT).show();
}
}
});
addPoiFloatingMenu.addMenuButton(floatingActionButton);
}
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class TypeManager method onInternalRemovePoiTagEvent.
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onInternalRemovePoiTagEvent(InternalRemovePoiTagEvent event) {
PoiTypeTag poiTypeTag = event.getPoiTypeTag();
// FIXME clone POI type to avoid border effects?;
PoiType poiType = poiTypeTag.getPoiType();
poiType.getTags().remove(poiTypeTag);
poiManager.savePoiType(poiType);
Timber.i("Removed poi tag %d", poiTypeTag.getId());
bus.post(new PoiTagDeletedEvent(poiTypeTag));
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class PoiMapperTest method poiType.
private PoiType poiType(String name, String... tags) {
PoiType t1 = new PoiType();
t1.setName(name);
List<PoiTypeTag> poiTypeTags = new ArrayList<>();
if (tags.length % 2 != 0) {
throw new AssertionError("Malformed tags ! Array must be an even number");
}
for (int i = 0; i < tags.length; i += 2) {
poiTypeTags.add(poiTypeTag(tags[i], tags[i + 1]));
}
t1.setTags(poiTypeTags);
return t1;
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class PoiManager method savePoiTypes.
public void savePoiTypes(List<PoiType> poiTypes) {
if (poiTypes != null) {
Timber.d("Loaded %s poiTypes, trying to insert them", poiTypes.size());
for (PoiType poiType : poiTypes) {
Timber.d("saving poiType %s", poiType);
savePoiType(poiType);
Timber.d("poiType saved");
}
}
}
use of io.jawg.osmcontributor.model.entities.PoiType in project osm-contributor by jawg.
the class PoiManager method loadPoiTypes.
/**
* Get all the PoiTypes in the database.
*
* @return A ID,PoiType map with all the PoiTypes.
*/
public Map<Long, PoiType> loadPoiTypes() {
List<PoiType> poiTypes = poiTypeDao.queryForAll();
Map<Long, PoiType> result = new HashMap<>();
for (PoiType poiType : poiTypes) {
result.put(poiType.getId(), poiType);
}
return result;
}
Aggregations