use of org.greenrobot.eventbus.Subscribe in project krypton-android by kryptco.
the class MemberQR method onCreateClient.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onCreateClient(TeamService.GenerateClientResult r) {
if (r.c.error != null) {
Error.shortToast(getContext(), r.c.error);
Transitions.beginFade(this).remove(this).commitAllowingStateLoss();
return;
}
Sigchain.Identity identity = r.c.success;
Sigchain.MemberQRPayload memberQRPayload = new Sigchain.MemberQRPayload(identity.email, identity.publicKey);
Sigchain.QRPayload qrPayload = new Sigchain.QRPayload(memberQRPayload);
try {
BitMatrix qrData = new QRCodeWriter().encode(JSON.toJson(qrPayload), BarcodeFormat.DATA_MATRIX.QR_CODE, 500, 500);
qr.setImageBitmap(new BarcodeEncoder().createBitmap(qrData));
qrPayloads.set(new QRPayloads(memberQRPayload, MemberScan.lastScannedPayload.get()));
loadQRProgress.setAlpha(0);
joinProgress.animate().setDuration(1000).alpha(1).start();
new JoinTeamProgress(getContext()).updateTeamData((s, d) -> {
d.identity = identity;
d.teamName = qrPayloads.get().admin.teamName;
return s;
});
} catch (WriterException e) {
e.printStackTrace();
Error.shortToast(getContext(), "Error creating QRCode");
Transitions.beginFade(this).remove(this).commitAllowingStateLoss();
return;
}
EventBus.getDefault().post(new PollRead());
}
use of org.greenrobot.eventbus.Subscribe in project osm-contributor by jawg.
the class MapActivity method onPleaseInitializeDrawer.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPleaseInitializeDrawer(PleaseInitializeDrawer event) {
Timber.d("initializing drawer with poiType");
if (filtersItemList == null) {
filtersItemList = new ArrayList<>();
}
List<PoiType> poiTypes = event.getPoiTypes();
poiTypesHidden = event.getPoiTypeHidden();
filters.clear();
for (PoiType poiType : poiTypes) {
Long id = poiType.getId();
filters.add(new PoiTypeFilter(poiType.getName(), id, poiType.getIcon(), !poiTypesHidden.contains(id)));
}
Collections.sort(filters);
Menu menu = filterView.getMenu();
int order = 1;
for (PoiTypeFilter poiTypeFilter : filters) {
PoiTypeFilter nextPoiTypeFilter = null;
if (order < filters.size()) {
nextPoiTypeFilter = filters.get(order);
}
// Add only menu if not present
if (menu.findItem(poiTypeFilter.getPoiTypeId().intValue()) == null) {
filtersItemList.add(menu.add(Menu.NONE, poiTypeFilter.getPoiTypeId().intValue(), (nextPoiTypeFilter != null ? (poiTypeFilter.compareTo(nextPoiTypeFilter) > 0 ? order - 1 : order) : order), poiTypeFilter.getPoiTypeName()).setChecked(poiTypeFilter.isActive()).setIcon(bitmapHandler.getDrawable(poiTypeFilter.getPoiTypeIconName())));
}
order++;
}
// Remove only filter removed by user
if (filters.size() < filtersItemList.size()) {
List<MenuItem> temp = new ArrayList<>(filters.size());
for (MenuItem menuItem : filtersItemList) {
PoiTypeFilter poiTypeFilter = new PoiTypeFilter("", (long) menuItem.getItemId(), "", true);
if (!filters.contains(poiTypeFilter)) {
menu.removeItem(poiTypeFilter.getPoiTypeId().intValue());
} else {
temp.add(menuItem);
}
}
filtersItemList.clear();
filtersItemList.addAll(temp);
temp.clear();
}
selectAllMenuItem.setChecked(poiTypesHidden.isEmpty());
}
use of org.greenrobot.eventbus.Subscribe in project osm-contributor by jawg.
the class EditPoiFragment method onPoiForEditionLoadedEvent.
/*=========================================*/
/*------------------EVENTS-----------------*/
/*=========================================*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPoiForEditionLoadedEvent(PoiForEditionLoadedEvent event) {
poi = event.getPoi();
// Set the poitype name in the action bar
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (actionBar != null) {
actionBar.setSubtitle(poi.getType().getName());
}
Log.i(TAG, "onPoiForEditionLoadedEvent: " + poi);
tagsAdapter = new TagsAdapter(poi, tagItemList, getActivity(), event.getValuesMap(), sharedPreferences.getBoolean(getString(R.string.shared_prefs_expert_mode), false));
recyclerView.setAdapter(tagsAdapter);
}
use of org.greenrobot.eventbus.Subscribe in project osm-contributor by jawg.
the class MyPreferenceFragment method onGoogleAuthenticatedEvent.
@Subscribe
public void onGoogleAuthenticatedEvent(GoogleAuthenticatedEvent event) {
if (event.isSuccessful()) {
Snackbar.make(getView(), R.string.valid_login, Snackbar.LENGTH_SHORT).show();
bus.post(new UpdateGoogleCredentialsEvent(event.getToken(), event.getTokenSecret(), event.getConsumer(), event.getConsumerSecret()));
} else {
Snackbar.make(getView(), R.string.error_login, Snackbar.LENGTH_SHORT).show();
}
}
use of org.greenrobot.eventbus.Subscribe in project osm-contributor by jawg.
the class EditPoiManager method onPleaseCreatePoiEvent.
@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseCreatePoiEvent(PleaseCreatePoiEvent event) {
Timber.d("Please create poi");
Poi poi = event.getPoi();
poi.setUpdated(true);
poi.applyChanges(event.getPoiChanges().getTagsMap());
poi.applyChanges(applyConstraints(poi));
poiManager.savePoi(poi);
poiManager.updatePoiTypeLastUse(poi.getType().getId());
eventBus.post(new PoiChangesApplyEvent());
}
Aggregations