Search in sources :

Example 21 with Subscribe

use of com.squareup.otto.Subscribe in project FluxyAndroidTodo by armueller.

the class TodoListManager method reactToTodoAction.

@Subscribe
public void reactToTodoAction(TodoAction action) {
    DataBundle<TodoAction.DataKeys> data = action.getData();
    long id = (long) data.get(TodoAction.DataKeys.ID, -1L);
    String description = (String) data.get(TodoAction.DataKeys.DESCRIPTION, "");
    switch(action.getType()) {
        case ADD:
            addTodo(description);
            break;
        case TOGGLE:
            toggleTodoComplete(id);
            break;
        case TOGGLE_ALL:
            toggleAllTodosComplete();
            break;
        case EDIT:
            editTodo(id, description);
            break;
        case DELETE:
            deleteTodo(id);
            break;
        case DELETE_ALL:
            deleteAllCompleteTodos();
            break;
        case UNDO_DELETE_ALL:
            undoDeleteCompleteAllTodos();
            break;
    }
    dataBus.post(new RawTodoList(todoItems));
}
Also used : RawTodoList(com.armueller.fluxytodo.data.RawTodoList) Subscribe(com.squareup.otto.Subscribe)

Example 22 with Subscribe

use of com.squareup.otto.Subscribe in project caronae-android by caronae.

the class ChatAct method updateMsgsListWithServer.

@Subscribe
public void updateMsgsListWithServer(final String rideId) {
    translate = AnimationUtils.loadAnimation(this, R.anim.anim_loading_messages_down);
    cardLoadingMessages.startAnimation(translate);
    String since = null;
    if (chatMsgsList == null) {
        chatMsgsList = new ArrayList<>();
    }
    if (chatMsgsList.size() != 0) {
        boolean lastMessageIsMine = true;
        int counter = chatMsgsList.size() - 1;
        while (lastMessageIsMine && counter >= 0) {
            if (!chatMsgsList.get(counter).getSenderId().equals(String.valueOf(App.getUser().getDbId()))) {
                since = chatMsgsList.get(counter).getTime();
                lastMessageIsMine = false;
            }
            counter--;
        }
    }
    Intent fetchMessageService = new Intent(getApplicationContext(), FetchReceivedMessagesService.class);
    fetchMessageService.putExtra(RIDE_ID_BUNDLE_KEY, rideId);
    fetchMessageService.putExtra("since", since);
    getApplicationContext().startService(fetchMessageService);
}
Also used : Intent(android.content.Intent) Subscribe(com.squareup.otto.Subscribe)

Example 23 with Subscribe

use of com.squareup.otto.Subscribe in project caronae-android by caronae.

the class AllRidesListFrag method updateAdapter.

@Subscribe
public void updateAdapter(ArrayList<Object> listFiltered) {
    filteredGoingList.clear();
    filteredNotGoingList.clear();
    for (int rides = 1; rides < listFiltered.size(); rides++) {
        RideForJson ride = (RideForJson) listFiltered.get(rides);
        if (ride.isGoing()) {
            filteredGoingList.add((RideForJson) listFiltered.get(rides));
        } else {
            filteredNotGoingList.add((RideForJson) listFiltered.get(rides));
        }
    }
    if (pageIdentifier == AllRidesFragmentPagerAdapter.PAGE_GOING) {
        if (filteredGoingList.size() == 0) {
            filter = null;
            adapter.makeList(goingRides);
            Util.toast("Nenhuma carona encontrada para esta busca");
        } else {
            filter = (CharSequence) listFiltered.get(0);
            adapter.makeList(filteredGoingList);
        }
    } else {
        if (filteredNotGoingList.size() == 0) {
            filter = null;
            adapter.makeList(notGoingRides);
            Util.toast("Nenhuma carona encontrada para esta busca");
        } else {
            filter = (CharSequence) listFiltered.get(0);
            adapter.makeList(filteredNotGoingList);
        }
    }
}
Also used : RideForJson(br.ufrj.caronae.models.modelsforjson.RideForJson) Subscribe(com.squareup.otto.Subscribe)

Example 24 with Subscribe

use of com.squareup.otto.Subscribe in project android-store by soomla.

the class StorePacksActivity method onCurrencyBalanceChanged.

/**
 * Receives the given <code>currencyBalanceChangedEvent</code>, and upon notification, fetches
 * the currency balance and places it in the balance label.
 *
 * @param currencyBalanceChangedEvent event to receive
 */
@Subscribe
public void onCurrencyBalanceChanged(CurrencyBalanceChangedEvent currencyBalanceChangedEvent) {
    TextView muffinsBalance = (TextView) findViewById(R.id.balance);
    muffinsBalance.setText("" + currencyBalanceChangedEvent.getBalance());
}
Also used : TextView(android.widget.TextView) Subscribe(com.squareup.otto.Subscribe)

Example 25 with Subscribe

use of com.squareup.otto.Subscribe in project android-store by soomla.

the class StoreGoodsActivity method onCurrencyBalanceChanged.

/**
 * Receives the given <code>onCurrencyBalanceChanged</code>. Upon notification, fetches the
 * currency balance and places it in the balance label.
 *
 * @param currencyBalanceChangedEvent the event received
 */
@Subscribe
public void onCurrencyBalanceChanged(CurrencyBalanceChangedEvent currencyBalanceChangedEvent) {
    TextView muffinsBalance = (TextView) findViewById(R.id.balance);
    muffinsBalance.setText("" + currencyBalanceChangedEvent.getBalance());
}
Also used : TextView(android.widget.TextView) Subscribe(com.squareup.otto.Subscribe)

Aggregations

Subscribe (com.squareup.otto.Subscribe)85 Test (org.junit.Test)28 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)27 RawTodoList (com.armueller.fluxytodo.data.RawTodoList)13 ArrayList (java.util.ArrayList)12 TodoAction (com.armueller.fluxytodo.actions.TodoAction)9 VideoData (com.zype.android.webapi.model.video.VideoData)8 DataBundle (com.armueller.fluxytodo.actions.DataBundle)7 File (com.zype.android.webapi.model.player.File)7 Intent (android.content.Intent)6 FilteredTodoList (com.armueller.fluxytodo.data.FilteredTodoList)6 ConsumerFavoriteVideoData (com.zype.android.webapi.model.consumers.ConsumerFavoriteVideoData)6 Bundle (android.os.Bundle)5 Video (com.zype.android.Db.Entity.Video)5 Consumer (com.zype.android.webapi.model.consumers.Consumer)5 IOException (java.io.IOException)5 Context (android.content.Context)4 ConnectivityManager (android.net.ConnectivityManager)4 NetworkInfo (android.net.NetworkInfo)4 Dialog (android.app.Dialog)3