use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class SendCommentService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
int lastNotificationId = intent.getIntExtra("lastNotificationId", -1);
if (lastNotificationId != -1) {
NotificationUtility.cancel(lastNotificationId);
}
String token = intent.getStringExtra("token");
AccountBean account = (AccountBean) intent.getParcelableExtra("account");
String content = intent.getStringExtra("content");
MessageBean oriMsg = (MessageBean) intent.getParcelableExtra("oriMsg");
boolean comment_ori = intent.getBooleanExtra("comment_ori", false);
CommentDraftBean commentDraftBean = (CommentDraftBean) intent.getParcelableExtra("draft");
WeiboSendTask task = new WeiboSendTask(account, token, content, oriMsg, comment_ori, commentDraftBean);
task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
tasksResult.put(task, false);
return START_REDELIVER_INTENT;
}
use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class SendReplyToCommentService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
int lastNotificationId = intent.getIntExtra("lastNotificationId", -1);
if (lastNotificationId != -1) {
NotificationUtility.cancel(lastNotificationId);
}
String token = intent.getStringExtra("token");
AccountBean account = (AccountBean) intent.getParcelableExtra("account");
String content = intent.getStringExtra("content");
String repostContent = intent.getStringExtra("repostContent");
CommentBean oriMsg = (CommentBean) intent.getParcelableExtra("oriMsg");
ReplyDraftBean replyDraftBean = (ReplyDraftBean) intent.getParcelableExtra("draft");
WeiboSendTask task = new WeiboSendTask(account, token, content, repostContent, oriMsg, replyDraftBean);
task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
tasksResult.put(task, false);
return START_REDELIVER_INTENT;
}
use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class SendRepostService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
int lastNotificationId = intent.getIntExtra("lastNotificationId", -1);
if (lastNotificationId != -1) {
NotificationUtility.cancel(lastNotificationId);
}
String token = intent.getStringExtra("token");
AccountBean account = (AccountBean) intent.getParcelableExtra("account");
String content = intent.getStringExtra("content");
MessageBean oriMsg = (MessageBean) intent.getParcelableExtra("oriMsg");
String is_comment = intent.getStringExtra("is_comment");
RepostDraftBean repostDraftBean = (RepostDraftBean) intent.getParcelableExtra("draft");
WeiboSendTask task = new WeiboSendTask(token, account, content, oriMsg, is_comment, repostDraftBean);
task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
tasksResult.put(task, false);
return START_REDELIVER_INTENT;
}
use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class FetchNewMsgService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
if (intent == null) {
return;
}
String action = intent.getAction();
if (ACTION_ALARM_MANAGER.equals(action)) {
AppLogger.i("FetchNewMsgService is started by " + ACTION_ALARM_MANAGER);
if (SettingUtility.disableFetchAtNight() && isNowNight()) {
AppLogger.i("FetchNewMsgService is disabled at night, so give up");
return;
}
} else if (ACTION_OPEN_APP.equals(action)) {
//empty
AppLogger.i("FetchNewMsgService is started by " + ACTION_OPEN_APP);
} else {
AppLogger.i("FetchNewMsgService receive Intent whose Action is empty");
//why System send Intent object whose Action is empty? fuck google, it is impossible according to api documents when this service flag is START_NOT_STICKY
return;
}
List<AccountBean> accountBeanList = AccountDBTask.getAccountList();
if (accountBeanList.size() == 0) {
return;
}
for (AccountBean account : accountBeanList) {
try {
AppLogger.i("FetchNewMsgService start fetch " + account.getUsernick() + "'s unread data");
fetchMsg(account);
} catch (WeiboException e) {
e.printStackTrace();
}
}
AppLogger.i("FetchNewMsgService finished");
}
use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class AccountDBTask method getAccountList.
public static List<AccountBean> getAccountList() {
List<AccountBean> accountList = new ArrayList<AccountBean>();
String sql = "select * from " + AccountTable.TABLE_NAME;
Cursor c = getWsd().rawQuery(sql, null);
while (c.moveToNext()) {
AccountBean account = new AccountBean();
int colid = c.getColumnIndex(AccountTable.OAUTH_TOKEN);
account.setAccess_token(c.getString(colid));
colid = c.getColumnIndex(AccountTable.OAUTH_TOKEN_EXPIRES_TIME);
account.setExpires_time(Long.valueOf(c.getString(colid)));
colid = c.getColumnIndex(AccountTable.BLACK_MAGIC);
account.setBlack_magic(c.getInt(colid) == 1);
colid = c.getColumnIndex(AccountTable.NAVIGATION_POSITION);
account.setNavigationPosition(c.getInt(colid));
Gson gson = new Gson();
String json = c.getString(c.getColumnIndex(AccountTable.INFOJSON));
try {
UserBean value = gson.fromJson(json, UserBean.class);
account.setInfo(value);
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
}
accountList.add(account);
}
c.close();
return accountList;
}
Aggregations