Search in sources :

Example 11 with PoiType

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()));
}
Also used : PoiTypeDeletedEvent(io.jawg.osmcontributor.ui.events.type.PoiTypeDeletedEvent) PoiType(io.jawg.osmcontributor.model.entities.PoiType) PoiTypesLoaded(io.jawg.osmcontributor.model.events.PoiTypesLoaded) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 12 with PoiType

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);
}
Also used : PoiType(io.jawg.osmcontributor.model.entities.PoiType) PoiTypeTag(io.jawg.osmcontributor.model.entities.PoiTypeTag)

Example 13 with 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;
}
Also used : PoiType(io.jawg.osmcontributor.model.entities.PoiType) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 14 with PoiType

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));
}
Also used : PoiType(io.jawg.osmcontributor.model.entities.PoiType) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 15 with PoiType

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());
                }
            });
        }
    };
}
Also used : PoiType(io.jawg.osmcontributor.model.entities.PoiType) View(android.view.View) Snackbar(android.support.design.widget.Snackbar)

Aggregations

PoiType (io.jawg.osmcontributor.model.entities.PoiType)28 PoiTypeTag (io.jawg.osmcontributor.model.entities.PoiTypeTag)9 Subscribe (org.greenrobot.eventbus.Subscribe)9 ArrayList (java.util.ArrayList)7 PleaseLoadLastUsedPoiType (io.jawg.osmcontributor.ui.events.map.PleaseLoadLastUsedPoiType)5 View (android.view.View)3 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 BindView (butterknife.BindView)2 Poi (io.jawg.osmcontributor.model.entities.Poi)2 PoiTag (io.jawg.osmcontributor.model.entities.PoiTag)2 PoiTypesLoaded (io.jawg.osmcontributor.model.events.PoiTypesLoaded)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 DateTime (org.joda.time.DateTime)2 NonNull (android.support.annotation.NonNull)1 Snackbar (android.support.design.widget.Snackbar)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 ListView (android.widget.ListView)1