Search in sources :

Example 11 with AccountBean

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;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) CommentDraftBean(org.qii.weiciyuan.support.database.draftbean.CommentDraftBean) AccountBean(org.qii.weiciyuan.bean.AccountBean)

Example 12 with AccountBean

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;
}
Also used : ReplyDraftBean(org.qii.weiciyuan.support.database.draftbean.ReplyDraftBean) AccountBean(org.qii.weiciyuan.bean.AccountBean) CommentBean(org.qii.weiciyuan.bean.CommentBean)

Example 13 with AccountBean

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;
}
Also used : MessageBean(org.qii.weiciyuan.bean.MessageBean) RepostDraftBean(org.qii.weiciyuan.support.database.draftbean.RepostDraftBean) AccountBean(org.qii.weiciyuan.bean.AccountBean)

Example 14 with AccountBean

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");
}
Also used : WeiboException(org.qii.weiciyuan.support.error.WeiboException) AccountBean(org.qii.weiciyuan.bean.AccountBean)

Example 15 with AccountBean

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;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) UserBean(org.qii.weiciyuan.bean.UserBean) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) AccountBean(org.qii.weiciyuan.bean.AccountBean) Cursor(android.database.Cursor)

Aggregations

AccountBean (org.qii.weiciyuan.bean.AccountBean)19 Intent (android.content.Intent)4 Notification (android.app.Notification)3 NotificationManager (android.app.NotificationManager)3 PendingIntent (android.app.PendingIntent)3 ArrayList (java.util.ArrayList)3 MessageBean (org.qii.weiciyuan.bean.MessageBean)3 UnreadBean (org.qii.weiciyuan.bean.UnreadBean)3 Context (android.content.Context)2 IntentFilter (android.content.IntentFilter)2 Cursor (android.database.Cursor)2 Handler (android.os.Handler)2 Parcelable (android.os.Parcelable)2 Gson (com.google.gson.Gson)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 CommentBean (org.qii.weiciyuan.bean.CommentBean)2 CommentListBean (org.qii.weiciyuan.bean.CommentListBean)2 MessageListBean (org.qii.weiciyuan.bean.MessageListBean)2 UserBean (org.qii.weiciyuan.bean.UserBean)2 WeiboException (org.qii.weiciyuan.support.error.WeiboException)2