Search in sources :

Example 16 with AccountBean

use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.

the class AccountDBTask method getAccount.

public static AccountBean getAccount(String id) {
    String sql = "select * from " + AccountTable.TABLE_NAME + " where " + AccountTable.UID + " = " + id;
    Cursor c = getRsd().rawQuery(sql, null);
    if (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());
        }
        return account;
    }
    return null;
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) UserBean(org.qii.weiciyuan.bean.UserBean) Gson(com.google.gson.Gson) Cursor(android.database.Cursor) AccountBean(org.qii.weiciyuan.bean.AccountBean)

Example 17 with AccountBean

use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.

the class WriteWeiboActivity method getAccountInfo.

private void getAccountInfo() {
    AccountBean account = GlobalContext.getInstance().getAccountBean();
    if (account != null) {
        accountBean = account;
        token = account.getAccess_token();
        getActionBar().setSubtitle(account.getUsernick());
    }
}
Also used : AccountBean(org.qii.weiciyuan.bean.AccountBean)

Example 18 with AccountBean

use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.

the class MainTimeLineActivity method onNewIntent.

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    AccountBean intentAccountBean = intent.getParcelableExtra(BundleArgsConstants.ACCOUNT_EXTRA);
    if (intentAccountBean == null) {
        return;
    }
    if (accountBean.equals(intentAccountBean)) {
        accountBean = intentAccountBean;
        GlobalContext.getInstance().setAccountBean(accountBean);
        setIntent(intent);
    } else {
        finish();
        overridePendingTransition(0, 0);
        startActivity(intent);
        overridePendingTransition(0, 0);
    }
}
Also used : AccountBean(org.qii.weiciyuan.bean.AccountBean)

Example 19 with AccountBean

use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.

the class AccountActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    String action = getIntent() != null ? getIntent().getAction() : null;
    if (ACTION_OPEN_FROM_APP_INNER.equals(action)) {
    //empty
    } else if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) {
    //empty
    } else {
        //finish current Activity
        jumpToMainTimeLineActivity();
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.accountactivity_layout);
    getActionBar().setTitle(getString(R.string.app_name));
    listAdapter = new AccountAdapter();
    listView = (ListView) findViewById(R.id.listView);
    listView.setOnItemClickListener(new AccountListItemClickListener());
    listView.setAdapter(listAdapter);
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new AccountMultiChoiceModeListener());
    getLoaderManager().initLoader(LOADER_ID, null, this);
    if (SettingUtility.firstStart()) {
        showChangeLogDialog();
    }
    if (ACTION_OPEN_FROM_APP_INNER_REFRESH_TOKEN.equals(action)) {
        showAddAccountDialog();
        AccountBean accountBean = getIntent().getParcelableExtra(REFRESH_ACTION_EXTRA);
        Toast.makeText(this, String.format(getString(R.string.account_token_has_expired), accountBean.getUsernick()), Toast.LENGTH_SHORT).show();
    }
}
Also used : AccountBean(org.qii.weiciyuan.bean.AccountBean)

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