예제 #1
0
파일: VClient.java 프로젝트: Vendar/cactus
 public boolean addAccount(VAccount account) {
   if (account == null) {
     return false;
   }
   try {
     this.sinaWeibo.setOAuthAccessToken(account.getAccessToken(), account.getTokenSecret());
     weibo4android.User me = this.sinaWeibo.verifyCredentials();
     if (me != null) {
       account.setUserName(me.getScreenName());
       CactusDb.getInstance().saveAccount(account);
     } else {
       return false;
     }
   } catch (WeiboException e) {
     e.printStackTrace();
     return false;
   }
   this.accountAdapter.add(account);
   if (this.activatedAccount != null) {
     this.sinaWeibo.setOAuthAccessToken(
         this.activatedAccount.getAccessToken(), this.activatedAccount.getTokenSecret());
   } else {
     this.activatedAccount = account;
   }
   return true;
 }
예제 #2
0
파일: VClient.java 프로젝트: Vendar/cactus
 public boolean activateAccount(VAccount account) {
   if (account == null) {
     return false;
   }
   if (this.activatedAccount != null && account.getId() == this.activatedAccount.getId()) {
     return true;
   }
   this.activatedAccount = account;
   switch (account.getServiceProvider()) {
     case SP_SINA_WEIBO:
       {
         this.sinaWeibo.setOAuthAccessToken(account.getAccessToken(), account.getTokenSecret());
         this.retrieveStatuses();
         return true;
       }
     default:
       return false;
   }
 }
예제 #3
0
파일: VClient.java 프로젝트: Vendar/cactus
 private void tweet(VAccount account, String status) throws weibo4android.WeiboException {
   switch (account.getServiceProvider()) {
     case SP_SINA_WEIBO:
       {
         if (hasClientActivated(SP_SINA_WEIBO)) {
           if (activateAccount(account)) {
             weibo4android.Status wbs = this.sinaWeibo.updateStatus(status);
             if (wbs != null) {
               // append to home & my weibo timeline
               this.statusAdapter.insertStatus(0, new VStatus(VStatus.HOME, wbs));
             }
           }
         }
         break;
       }
     default:
       break;
   }
 }