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);
}
}
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);
}
}
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 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);
}
Aggregations