Search in sources :

Example 96 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project android by nextcloud.

the class OCFileListFragment method onMessageEvent.

@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(FavoriteEvent event) {
    try {
        User user = accountManager.getUser();
        OwnCloudClient client = clientFactory.create(user);
        ToggleFavoriteRemoteOperation toggleFavoriteOperation = new ToggleFavoriteRemoteOperation(event.shouldFavorite, event.remotePath);
        RemoteOperationResult remoteOperationResult = toggleFavoriteOperation.execute(client);
        if (remoteOperationResult.isSuccess()) {
            boolean removeFromList = currentSearchType == SearchType.FAVORITE_SEARCH && !event.shouldFavorite;
            mAdapter.setFavoriteAttributeForItemID(event.remoteId, event.shouldFavorite, removeFromList);
        }
    } catch (ClientFactory.CreationException e) {
        Log_OC.e(TAG, "Error processing event", e);
    }
}
Also used : User(com.nextcloud.client.account.User) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) ClientFactory(com.nextcloud.client.network.ClientFactory) ToggleFavoriteRemoteOperation(com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation) OwnCloudClient(com.owncloud.android.lib.common.OwnCloudClient) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 97 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project android by nextcloud.

the class FileDetailFragment method onMessageEvent.

@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(FavoriteEvent event) {
    try {
        User user = accountManager.getUser();
        OwnCloudClient client = clientFactory.create(user);
        ToggleFavoriteRemoteOperation toggleFavoriteOperation = new ToggleFavoriteRemoteOperation(event.shouldFavorite, event.remotePath);
        RemoteOperationResult remoteOperationResult = toggleFavoriteOperation.execute(client);
        if (remoteOperationResult.isSuccess()) {
            getFile().setFavorite(event.shouldFavorite);
            OCFile file = storageManager.getFileByEncryptedRemotePath(event.remotePath);
            file.setFavorite(event.shouldFavorite);
            storageManager.saveFile(file);
        }
    } catch (ClientFactory.CreationException e) {
        Log_OC.e(TAG, "Error processing event", e);
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) User(com.nextcloud.client.account.User) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) ClientFactory(com.nextcloud.client.network.ClientFactory) ToggleFavoriteRemoteOperation(com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation) OwnCloudClient(com.owncloud.android.lib.common.OwnCloudClient) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 98 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 99 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 100 with Subscribe

use of org.greenrobot.eventbus.Subscribe in project SeriesGuide by UweTrottmann.

the class MovieDetailsFragment method handleLanguageEvent.

@Subscribe(threadMode = ThreadMode.MAIN)
public void handleLanguageEvent(LanguageChoiceDialogFragment.LanguageChangedEvent event) {
    if (!AndroidUtils.isNetworkConnected(getContext())) {
        Toast.makeText(getContext(), R.string.offline, Toast.LENGTH_LONG).show();
        return;
    }
    String languageCode = getResources().getStringArray(R.array.languageCodesMovies)[event.selectedLanguageIndex];
    PreferenceManager.getDefaultSharedPreferences(getContext()).edit().putString(DisplaySettings.KEY_MOVIES_LANGUAGE, languageCode).apply();
    progressBar.setVisibility(View.VISIBLE);
    // reload movie details and trailers (but not cast/crew info which is not language dependent)
    restartMovieLoader();
    Bundle args = new Bundle();
    args.putInt(InitBundle.TMDB_ID, tmdbId);
    getLoaderManager().restartLoader(MovieDetailsActivity.LOADER_ID_MOVIE_TRAILERS, args, mMovieTrailerLoaderCallbacks);
}
Also used : Bundle(android.os.Bundle) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

Subscribe (org.greenrobot.eventbus.Subscribe)164 Intent (android.content.Intent)20 Bundle (android.os.Bundle)11 EventBus (org.greenrobot.eventbus.EventBus)10 ThreadMode (org.greenrobot.eventbus.ThreadMode)10 View (android.view.View)9 Poi (io.jawg.osmcontributor.model.entities.Poi)9 PoiType (io.jawg.osmcontributor.model.entities.PoiType)9 ArrayList (java.util.ArrayList)9 Context (android.content.Context)8 Handler (android.os.Handler)8 ViewGroup (android.view.ViewGroup)8 FeedItem (de.danoeh.antennapod.model.feed.FeedItem)8 SuppressLint (android.annotation.SuppressLint)6 LayoutInflater (android.view.LayoutInflater)6 MenuItem (android.view.MenuItem)6 DownloaderUpdate (de.danoeh.antennapod.core.event.DownloaderUpdate)6 AndroidSchedulers (io.reactivex.android.schedulers.AndroidSchedulers)6 Disposable (io.reactivex.disposables.Disposable)6 Schedulers (io.reactivex.schedulers.Schedulers)6