Search in sources :

Example 21 with Subscribe

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));
    }
}
Also used : DownloadMessage(com.justwayward.reader.bean.support.DownloadMessage) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 22 with Subscribe

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());
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) ImageView(android.widget.ImageView) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 23 with Subscribe

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);
    }
}
Also used : Cursor(android.database.Cursor) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 24 with Subscribe

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);
    }
}
Also used : LatLng(com.google.android.gms.maps.model.LatLng) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 25 with Subscribe

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)));
        }
    }
}
Also used : Product(com.amazon.device.iap.model.Product) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

Subscribe (org.greenrobot.eventbus.Subscribe)43 Intent (android.content.Intent)7 SiteModel (org.wordpress.android.fluxc.model.SiteModel)5 NotificationManager (android.app.NotificationManager)3 NotificationCompat (android.support.v4.app.NotificationCompat)3 Activity (android.app.Activity)2 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 Cursor (android.database.Cursor)2 AspectPermission (com.yydcdut.note.aspect.permission.AspectPermission)2 CategoryCreateEvent (com.yydcdut.note.bus.CategoryCreateEvent)2 CategoryDeleteEvent (com.yydcdut.note.bus.CategoryDeleteEvent)2 CategoryEditEvent (com.yydcdut.note.bus.CategoryEditEvent)2 CategoryMoveEvent (com.yydcdut.note.bus.CategoryMoveEvent)2 CategoryUpdateEvent (com.yydcdut.note.bus.CategoryUpdateEvent)2 PhotoNoteCreateEvent (com.yydcdut.note.bus.PhotoNoteCreateEvent)2 PhotoNoteDeleteEvent (com.yydcdut.note.bus.PhotoNoteDeleteEvent)2 UserImageEvent (com.yydcdut.note.bus.UserImageEvent)2 Category (com.yydcdut.note.entity.Category)2 ContextLife (com.yydcdut.note.injector.ContextLife)2