Example #1
0
 private void baseCommandEvent(BaseCommand event) {
   Timber.i("BaseCommand: %1$s", event);
   Intent intent = new Intent(_app, CommandIntentService.class);
   intent.putExtra(ARG_COMMAND_CLASS, event);
   intent.putExtra(CommandIntentService.ARG_RESULT_RECEIVER, getResultReceiver());
   _app.startService(intent);
 }
Example #2
0
 private void updateUser(User user) {
   _app.setCurrentUser(user);
   Gson gson =
       new GsonBuilder().registerTypeAdapterFactory(new AutoValueTypeAdapterFactory()).create();
   String userJson =
       gson.toJson(user, User.class.getAnnotation(AutoValueClass.class).autoValueClass());
   _prefs.edit().putString(Constants.KEY_LOGGED_IN_USER, userJson).apply();
 }
Example #3
0
 private void commandSuccessful(Bundle resultData) {
   EventCallback event = resultData.getParcelable(CommandIntentService.ARG_RESULT_BASE_EVENT);
   // update the logged in user from data saved to realm from the BaseCommand issued.
   User realmUser = queryUser(_app, _app.getCurrentUser().id());
   updateUser(realmUser);
   // issue event data to the main messaging system
   _bus.post(event);
   // issue secondary or causal events
   if (event instanceof UsersDownloadedEventCallback) {
     _bus.post(new SyncAllContactsSuccessEvent());
   }
   // log what happened successfully to fabric if we are not on debug
   if (!BuildConfig.DEBUG) {
     logAnalytics(Answers.getInstance(), realmUser, event);
   }
 }