use of org.greenrobot.eventbus.Subscribe in project BookReader by JustWayward.
the class DownloadBookService method addToDownloadQueue.
@Subscribe(threadMode = ThreadMode.MAIN)
public synchronized void addToDownloadQueue(DownloadQueue queue) {
if (!TextUtils.isEmpty(queue.bookId)) {
boolean exists = false;
// 判断当前书籍缓存任务是否存在
for (int i = 0; i < downloadQueues.size(); i++) {
if (downloadQueues.get(i).bookId.equals(queue.bookId)) {
LogUtils.e("addToDownloadQueue:exists");
exists = true;
break;
}
}
if (exists) {
post(new DownloadMessage(queue.bookId, "当前缓存任务已存在", false));
return;
}
// 添加到下载队列
downloadQueues.add(queue);
LogUtils.e("addToDownloadQueue:" + queue.bookId);
post(new DownloadMessage(queue.bookId, "成功加入缓存队列", false));
}
// 从队列顺序取出第一条下载
if (downloadQueues.size() > 0 && !isBusy) {
isBusy = true;
downloadBook(downloadQueues.get(0));
}
}
use of org.greenrobot.eventbus.Subscribe in project chefly_android by chef-ly.
the class GetCookingActivity method onEvent.
// This method will be called when the VoiceRec class sends a nextInstruction event
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(VoiceInstructionEvent event) {
String instruction = event.getInstruction();
switch(instruction) {
case "next":
updateStepText();
pager.setCurrentItem(step + 1, true);
break;
case "back":
if (ingredientsShowing) {
ingredientsPopup.dismiss();
//directionsPopup.dismiss();
ingredientsShowing = false;
} else if (directionsShowing) {
directionsPopup.dismiss();
directionsShowing = false;
} else {
updateStepText();
pager.setCurrentItem(step - 1, true);
}
break;
case "repeat":
read(directions.get(step));
break;
case "ingredients":
FragmentManager fm = getSupportFragmentManager();
ingredientsPopup.show(fm, "Ingredients");
ingredientsShowing = true;
break;
case "directions":
fm = getSupportFragmentManager();
directionsPopup.show(fm, "Directions");
directionsShowing = true;
break;
case "question":
//TODO - make chefly icon at bottom of screen blow to show hes listening
break;
case "listen":
//btnSpeak.setImageDrawable(getResources().getDrawable(R.drawable.heartselected, getApplicationContext().getTheme()));
//ImageView imgFp = (ImageView) findViewById(R.id.btnSpeak);
//imgFp.setImageResource(0);
//imgFp.setImageResource(R.drawable.heartselected);
ImageView image = (ImageView) findViewById(R.id.btnSpeak);
Glide.with(getApplicationContext()).load(R.drawable.heartselected).asGif().crossFade().into(image);
//((ImageView) v.findViewById(R.id.ImageView1)).setImageResource(0);
break;
default:
Toast.makeText(this, "Can you please say that again?", Toast.LENGTH_LONG).show();
}
Log.e("DEBUG", "Received VoiceInstructionEvent " + event.getInstruction());
}
use of org.greenrobot.eventbus.Subscribe in project cw-omnibus by commonsguy.
the class ModelFragment method onSearchRequested.
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onSearchRequested(SearchRequestedEvent event) {
try {
Cursor results = DatabaseHelper.getInstance(app).loadQuestions(app, event.match);
EventBus.getDefault().postSticky(new ModelLoadedEvent(results));
} catch (Exception e) {
Log.e(getClass().getSimpleName(), "Exception searching database", e);
}
}
use of org.greenrobot.eventbus.Subscribe in project Pokemap by omkarmoghe.
the class MainActivity method onEvent.
/**
* Called whenever a use whats to search pokemons on a different position
*
* @param event PoJo with LatLng obj
*/
@Subscribe
public void onEvent(SearchInPosition event) {
List<LatLng> list = MapHelper.getSearchArea(event.getSteps(), new LatLng(event.getPosition().latitude, event.getPosition().longitude));
snackMe(getString(R.string.toast_searching));
nianticManager.getGyms(event.getPosition().latitude, event.getPosition().longitude, 0D);
nianticManager.getPokeStops(event.getPosition().latitude, event.getPosition().longitude, 0D);
nianticManager.getLuredPokemon(event.getPosition().latitude, event.getPosition().longitude, 0D);
for (LatLng p : list) {
nianticManager.getCatchablePokemon(p.latitude, p.longitude, 0D);
}
}
use of org.greenrobot.eventbus.Subscribe in project SeriesGuide by UweTrottmann.
the class AmazonBillingActivity method onEventMainThread.
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(AmazonIapManager.AmazonIapProductEvent event) {
Product product = event.product;
// display the actual price like "1.23 C"
String price = product.getPrice();
if (price == null) {
price = "--";
}
if (AmazonSku.SERIESGUIDE_SUB_YEARLY.getSku().equals(product.getSku())) {
if (textViewPriceSub != null) {
textViewPriceSub.setText(getString(R.string.billing_price_subscribe, price));
}
return;
}
if (AmazonSku.SERIESGUIDE_PASS.getSku().equals(product.getSku())) {
if (textViewPricePass != null) {
textViewPricePass.setText(String.format("%s\n%s", price, getString(R.string.billing_price_pass)));
}
}
}
Aggregations