use of org.qii.weiciyuan.support.error.WeiboException in project weiciyuan by qii.
the class LocationInfoDao method getInfo.
public String getInfo() {
Map<String, String> map = new HashMap<String, String>();
map.put("language", "zh-CN");
map.put("sensor", "false");
map.put("latlng", getLatlng());
String url = URLHelper.GOOGLELOCATION;
String jsonData = null;
try {
jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
} catch (WeiboException e) {
AppLogger.e(e.getMessage());
}
try {
JSONObject jsonObject = new JSONObject(jsonData);
JSONArray results = jsonObject.optJSONArray("results");
JSONObject jsonObject1 = results.getJSONObject(0);
String formatAddress = jsonObject1.optString("formatted_address");
int index = formatAddress.indexOf(" ");
if (index > 0) {
String location = formatAddress.substring(0, index);
return location;
} else {
return formatAddress;
}
} catch (JSONException e) {
AppLogger.e(e.getMessage());
}
return "";
}
use of org.qii.weiciyuan.support.error.WeiboException in project weiciyuan by qii.
the class MainFriendsTimeLineDao method getMsgListJson.
private String getMsgListJson() throws WeiboException {
String url = getUrl();
Map<String, String> map = new HashMap<String, String>();
map.put("access_token", access_token);
map.put("since_id", since_id);
map.put("max_id", max_id);
map.put("count", count);
map.put("page", page);
map.put("base_app", base_app);
map.put("feature", feature);
map.put("trim_user", trim_user);
String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
try {
new ClearUnreadDao(access_token, ClearUnreadDao.STATUS).clearUnread();
} catch (WeiboException ignored) {
}
return jsonData;
}
use of org.qii.weiciyuan.support.error.WeiboException in project weiciyuan by qii.
the class JBInboxNotification method get.
public Notification get() {
Notification.Builder builder = new Notification.Builder(context).setTicker(NotificationUtility.getTicker(unreadBean, null, null, null)).setContentText(accountBean.getUsernick()).setSmallIcon(R.drawable.ic_notification).setAutoCancel(true).setContentIntent(getPendingIntent()).setOnlyAlertOnce(true);
builder.setContentTitle(NotificationUtility.getTicker(unreadBean, null, null, null));
if (NotificationUtility.getCount(unreadBean) > 1) {
builder.setNumber(NotificationUtility.getCount(unreadBean));
}
if (clearNotificationEventReceiver != null) {
GlobalContext.getInstance().unregisterReceiver(clearNotificationEventReceiver);
JBInboxNotification.clearNotificationEventReceiver = null;
}
clearNotificationEventReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
new Thread(new Runnable() {
@Override
public void run() {
try {
new ClearUnreadDao(accountBean.getAccess_token()).clearMentionStatusUnread(unreadBean, accountBean.getUid());
new ClearUnreadDao(accountBean.getAccess_token()).clearMentionCommentUnread(unreadBean, accountBean.getUid());
new ClearUnreadDao(accountBean.getAccess_token()).clearCommentUnread(unreadBean, accountBean.getUid());
} catch (WeiboException ignored) {
} finally {
GlobalContext.getInstance().unregisterReceiver(clearNotificationEventReceiver);
JBInboxNotification.clearNotificationEventReceiver = null;
}
}
}).start();
}
};
IntentFilter intentFilter = new IntentFilter("org.qii.weiciyuan.Notification.unread");
GlobalContext.getInstance().registerReceiver(clearNotificationEventReceiver, intentFilter);
Intent broadcastIntent = new Intent("org.qii.weiciyuan.Notification.unread");
PendingIntent deletedPendingIntent = PendingIntent.getBroadcast(GlobalContext.getInstance(), 0, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setDeleteIntent(deletedPendingIntent);
Notification.InboxStyle inboxStyle = new Notification.InboxStyle(builder);
inboxStyle.setBigContentTitle(NotificationUtility.getTicker(unreadBean, null, null, null));
if (comment != null) {
for (CommentBean c : comment.getItemList()) {
inboxStyle.addLine(c.getUser().getScreen_name() + ":" + c.getText());
}
}
if (repost != null) {
for (MessageBean m : repost.getItemList()) {
inboxStyle.addLine(m.getUser().getScreen_name() + ":" + m.getText());
}
}
if (mentionCommentsResult != null) {
for (CommentBean m : mentionCommentsResult.getItemList()) {
inboxStyle.addLine(m.getUser().getScreen_name() + ":" + m.getText());
}
}
inboxStyle.setSummaryText(accountBean.getUsernick());
builder.setStyle(inboxStyle);
Utility.configVibrateLedRingTone(builder);
return builder.build();
}
use of org.qii.weiciyuan.support.error.WeiboException in project weiciyuan by qii.
the class SimpleTextNotificationService method buildNotification.
private void buildNotification(String uid) {
ValueWrapper valueWrapper = valueBagHashMap.get(uid);
if (valueWrapper == null) {
return;
}
final AccountBean accountBean = valueWrapper.accountBean;
final UnreadBean unreadBean = valueWrapper.unreadBean;
Intent clickToOpenAppPendingIntentInner = valueWrapper.clickToOpenAppPendingIntentInner;
String ticker = valueWrapper.ticker;
final RecordOperationAppBroadcastReceiver clearNotificationEventReceiver = valueWrapper.clearNotificationEventReceiver;
Notification.Builder builder = new Notification.Builder(getBaseContext()).setTicker(ticker).setContentText(accountBean.getUsernick()).setSmallIcon(R.drawable.ic_notification).setAutoCancel(true).setContentIntent(getPendingIntent(clickToOpenAppPendingIntentInner)).setOnlyAlertOnce(true);
builder.setContentTitle(ticker);
Utility.unregisterReceiverIgnoredReceiverNotRegisteredException(GlobalContext.getInstance(), clearNotificationEventReceiver);
valueWrapper.clearNotificationEventReceiver = new RecordOperationAppBroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
new Thread(new Runnable() {
@Override
public void run() {
try {
new ClearUnreadDao(accountBean.getAccess_token()).clearMentionStatusUnread(unreadBean, accountBean.getUid());
new ClearUnreadDao(accountBean.getAccess_token()).clearMentionCommentUnread(unreadBean, accountBean.getUid());
new ClearUnreadDao(accountBean.getAccess_token()).clearCommentUnread(unreadBean, accountBean.getUid());
} catch (WeiboException ignored) {
} finally {
Utility.unregisterReceiverIgnoredReceiverNotRegisteredException(GlobalContext.getInstance(), clearNotificationEventReceiver);
if (Utility.isDebugMode()) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
Toast.makeText(getApplicationContext(), "weiciyuan:remove notification items", Toast.LENGTH_SHORT).show();
}
});
}
}
}
}).start();
}
};
IntentFilter intentFilter = new IntentFilter(RESET_UNREAD_MENTIONS_WEIBO_ACTION);
GlobalContext.getInstance().registerReceiver(valueWrapper.clearNotificationEventReceiver, intentFilter);
Intent broadcastIntent = new Intent(RESET_UNREAD_MENTIONS_WEIBO_ACTION);
PendingIntent deletedPendingIntent = PendingIntent.getBroadcast(GlobalContext.getInstance(), accountBean.getUid().hashCode(), broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setDeleteIntent(deletedPendingIntent);
Utility.configVibrateLedRingTone(builder);
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(getMentionsWeiboNotificationId(accountBean), builder.build());
}
use of org.qii.weiciyuan.support.error.WeiboException in project weiciyuan by qii.
the class JavaHttpUtility method handleResponse.
private String handleResponse(HttpURLConnection httpURLConnection) throws WeiboException {
GlobalContext globalContext = GlobalContext.getInstance();
String errorStr = globalContext.getString(R.string.timeout);
globalContext = null;
int status = 0;
try {
status = httpURLConnection.getResponseCode();
} catch (IOException e) {
e.printStackTrace();
httpURLConnection.disconnect();
throw new WeiboException(errorStr, e);
}
if (status != HttpURLConnection.HTTP_OK) {
return handleError(httpURLConnection);
}
return readResult(httpURLConnection);
}
Aggregations