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