use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class Utility method showExpiredTokenDialogOrNotification.
public static void showExpiredTokenDialogOrNotification() {
final Activity activity = GlobalContext.getInstance().getCurrentRunningActivity();
boolean currentAccountTokenIsExpired = true;
AccountBean currentAccount = GlobalContext.getInstance().getAccountBean();
if (currentAccount != null) {
currentAccountTokenIsExpired = !Utility.isTokenValid(currentAccount);
}
if (currentAccountTokenIsExpired && activity != null && !GlobalContext.getInstance().tokenExpiredDialogIsShowing) {
if (activity.getClass() == AccountActivity.class) {
return;
}
if (activity.getClass() == OAuthActivity.class) {
return;
}
if (activity.getClass() == BlackMagicActivity.class) {
return;
}
if (activity.getClass() == SSOActivity.class) {
return;
}
final AccountBean needRefreshTokenAccount = currentAccount;
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
new AlertDialog.Builder(activity).setTitle(R.string.dialog_title_error).setMessage(R.string.your_token_is_expired).setPositiveButton(R.string.logout_to_login_again, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
activity.startActivity(AccountActivity.newIntent(needRefreshTokenAccount));
activity.finish();
GlobalContext.getInstance().tokenExpiredDialogIsShowing = false;
}
}).setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
//do nothing
}
}).show();
GlobalContext.getInstance().tokenExpiredDialogIsShowing = true;
}
});
} else if (!currentAccountTokenIsExpired || activity == null) {
Intent i = AccountActivity.newIntent();
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(GlobalContext.getInstance(), 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
Notification.Builder builder = new Notification.Builder(GlobalContext.getInstance()).setContentTitle(GlobalContext.getInstance().getString(R.string.login_again)).setContentText(GlobalContext.getInstance().getString(R.string.have_account_whose_token_is_expired)).setSmallIcon(R.drawable.ic_notification).setAutoCancel(true).setContentIntent(pendingIntent).setOnlyAlertOnce(true);
NotificationManager notificationManager = (NotificationManager) GlobalContext.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(NotificationServiceHelper.getTokenExpiredNotificationId(), builder.build());
} else if (GlobalContext.getInstance().tokenExpiredDialogIsShowing) {
NotificationManager notificationManager = (NotificationManager) GlobalContext.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NotificationServiceHelper.getTokenExpiredNotificationId());
}
}
use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class FriendsTimeLineListNavAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null || convertView.getTag() == null) {
LayoutInflater inflater = activity.getLayoutInflater();
convertView = inflater.inflate(R.layout.spinner_selector_text_view, parent, false);
holder = new ViewHolder();
holder.textView = (TextView) convertView;
} else {
holder = (ViewHolder) convertView.getTag();
}
if (position != 0) {
holder.textView.setText(valueArray[position]);
} else {
AccountBean accountBean = GlobalContext.getInstance().getAccountBean();
holder.textView.setText(accountBean.getUsernick());
}
return convertView;
}
use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class AccountActivity method jumpToMainTimeLineActivity.
private void jumpToMainTimeLineActivity() {
String id = SettingUtility.getDefaultAccountId();
if (!TextUtils.isEmpty(id)) {
AccountBean bean = AccountDBTask.getAccount(id);
if (bean != null) {
Intent start = MainTimeLineActivity.newIntent(bean);
startActivity(start);
finish();
}
}
}
use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class WriteCommentActivity method handleNotificationCommentOperation.
private void handleNotificationCommentOperation(Intent intent) {
AccountBean accountBean = intent.getParcelableExtra("account");
token = accountBean.getAccess_token();
msg = intent.getParcelableExtra("msg");
getEditTextView().setHint("@" + msg.getUser().getScreen_name() + ":" + msg.getText());
}
use of org.qii.weiciyuan.bean.AccountBean in project weiciyuan by qii.
the class WriteRepostActivity method handleDraftOperation.
private void handleDraftOperation(Intent intent) {
AccountBean account = (AccountBean) intent.getParcelableExtra("account");
token = account.getAccess_token();
repostDraftBean = (RepostDraftBean) intent.getParcelableExtra("draft");
getEditTextView().setText(repostDraftBean.getContent());
msg = repostDraftBean.getMessageBean();
if (msg.getRetweeted_status() != null) {
getEditTextView().setHint("//@" + msg.getRetweeted_status().getUser().getScreen_name() + ":" + msg.getRetweeted_status().getText());
} else {
getEditTextView().setHint("@" + msg.getUser().getScreen_name() + ":" + msg.getText());
}
}
Aggregations