use of com.squareup.otto.Subscribe in project open-event-android by fossasia.
the class MainActivity method startDownloadFromNetwork.
private void startDownloadFromNetwork() {
fromServer = true;
boolean preference = SharedPreferencesUtil.getBoolean(getResources().getString(R.string.download_mode_key), true);
if (preference) {
disposable.add(NetworkUtils.haveNetworkConnectionObservable(MainActivity.this).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(isConnected -> {
if (isConnected) {
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(new DataDownloadEvent());
} else {
final Snackbar snackbar = Snackbar.make(mainFrame, R.string.internet_preference_warning, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.yes, view -> downloadFromAssets());
snackbar.show();
}
}));
} else {
StrategyRegistry.getInstance().getEventBusStrategy().postEventOnUIThread(new DataDownloadEvent());
}
}
use of com.squareup.otto.Subscribe in project sms-backup-plus by jberkel.
the class SmsJobService method backupStateChanged.
@Subscribe
public void backupStateChanged(BackupState state) {
if (!state.isFinished()) {
return;
}
final JobParameters jobParameters = jobs.remove(state.backupType.name());
if (jobParameters != null) {
final boolean needsReschedule = state.isError() && !state.isPermissionException();
if (LOCAL_LOGV) {
Log.v(TAG, "jobFinished(" + jobParameters + ", isError=" + state.isError() + ", needsReschedule=" + needsReschedule + ")");
}
jobFinished(jobParameters, needsReschedule);
} else {
Log.w(TAG, "unknown job for state " + state);
}
}
use of com.squareup.otto.Subscribe in project meatspace-android by RomainPiel.
the class ChatService method onEvent.
/**
* a new chat request to post was posted
*
* @param chatRequest chat request to post
*/
@Subscribe
public void onEvent(ChatRequest chatRequest) {
if (socketIOClient != null && socketIOClient.isConnected()) {
Gson jsonParser = apiManager.getJsonParser();
// 4 : json type (? not sure why)
socketIOClient.emitRaw(4, jsonParser.toJson(chatRequest), null);
} else {
postError();
}
}
use of com.squareup.otto.Subscribe in project philm by chrisbanes.
the class UserController method onAccountChanged.
@Subscribe
public void onAccountChanged(UserState.AccountChangedEvent event) {
PhilmAccount currentAccount = mUserState.getCurrentAccount();
if (currentAccount != null) {
final String username = currentAccount.getAccountName();
mUserState.setUsername(username);
mTraktClient.setAuthentication(username, currentAccount.getPassword());
mDbHelper.getUserProfile(username, new UserProfileDbLoadCallback());
} else {
mUserState.setUsername(null);
mTraktClient.setAuthentication(null, null);
final PhilmUserProfile currentUserProfile = mUserState.getUserProfile();
if (currentUserProfile != null) {
mUserState.setUserProfile(null);
mDbHelper.delete(currentUserProfile);
}
// TODO: Also nuke rest of state
}
mLogger.d(LOG_TAG, "onAccountChanged: " + mUserState.getUsername());
}
use of com.squareup.otto.Subscribe in project zype-android by zype.
the class FavoritesFragment method handleConsumerFavoriteVideo.
// ///////////
// Subscriptions
//
@Subscribe
public void handleConsumerFavoriteVideo(ConsumerFavoriteVideoEvent event) {
Logger.d("handleConsumerFavoriteVideo");
ConsumerFavoriteVideo favorite = event.getEventData().getModelData();
if (Pagination.hasNextPage(favorite.getPagination()) && !favorite.getResponse().isEmpty()) {
requestConsumerFavoriteVideo(Pagination.getNextPage(favorite.getPagination()));
}
DataHelper.insertFavorites(getActivity().getContentResolver(), favorite.getResponse());
// Retrieve videos
for (ConsumerFavoriteVideoData item : favorite.getResponse()) {
VideoParamsBuilder builder = new VideoParamsBuilder().addVideoId(item.getVideoId());
getApi().executeRequest(WebApiManager.Request.VIDEO_LIST, builder.build());
}
}
Aggregations