Ejemplo n.º 1
0
 @Override
 public void updateOutboxEntry(final OutboxTweet ot) {
   final Long uid = ot.getUid();
   if (uid == null)
     throw new IllegalArgumentException("Can not update entry that is not already in DB.");
   this.mDb.beginTransaction();
   try {
     final ContentValues values = new ContentValues();
     values.put(TBL_OB_ACCOUNT_ID, ot.getAccountId());
     values.put(TBL_OB_SERVICES, ot.getSvcMetasStr());
     values.put(TBL_OB_BODY, ot.getBody());
     values.put(TBL_OB_IN_REPLY_TO_SID, ot.getInReplyToSid());
     values.put(TBL_OB_ATTACHMENT, ot.getAttachmentStr());
     values.put(TBL_OB_STATUS, ot.getStatusCode());
     values.put(TBL_OB_ATTEMPT_COUNT, ot.getAttemptCount());
     values.put(TBL_OB_LAST_ERROR, ot.getLastError());
     final int affected =
         this.mDb.update(TBL_OB, values, TBL_OB_ID + "=?", new String[] {String.valueOf(uid)});
     if (affected != 1)
       throw new IllegalStateException("Updated affected " + affected + " rows, expected 1.");
     this.mDb.setTransactionSuccessful();
   } finally {
     this.mDb.endTransaction();
   }
   this.log.d("Updated in outbox: %s", ot);
   notifyOutboxListeners();
 }
Ejemplo n.º 2
0
 @Override
 public void addPostToOutput(final OutboxTweet ot) {
   if (ot.getUid() != null)
     throw new IllegalArgumentException("Can not add entry that is already in DB.");
   this.mDb.beginTransaction();
   try {
     final ContentValues values = new ContentValues();
     values.put(TBL_OB_ACCOUNT_ID, ot.getAccountId());
     values.put(TBL_OB_SERVICES, ot.getSvcMetasStr());
     values.put(TBL_OB_BODY, ot.getBody());
     values.put(TBL_OB_IN_REPLY_TO_SID, ot.getInReplyToSid());
     values.put(TBL_OB_ATTACHMENT, ot.getAttachmentStr());
     values.put(TBL_OB_STATUS, ot.getStatusCode());
     values.put(TBL_OB_ATTEMPT_COUNT, ot.getAttemptCount());
     values.put(TBL_OB_LAST_ERROR, ot.getLastError());
     this.mDb.insert(TBL_OB, null, values);
     this.mDb.setTransactionSuccessful();
   } finally {
     this.mDb.endTransaction();
   }
   this.log.d("Stored in outbox: %s", ot);
   notifyOutboxListeners();
 }