Exemple #1
0
  public List<String> getInfo() throws WeiboException {

    String url = URLHelper.GROUP_MEMBER_LIST;

    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("uids", uids);

    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);

    Gson gson = new Gson();

    List<GroupUser> value = null;
    try {
      value = gson.fromJson(jsonData, new TypeToken<List<GroupUser>>() {}.getType());
    } catch (JsonSyntaxException e) {
      AppLogger.e(e.getMessage());
    }

    if (value != null && value.size() > 0) {
      GroupUser user = value.get(0);
      List<String> ids = new ArrayList<String>();
      for (GroupBean b : user.lists) {
        ids.add(b.getIdstr());
      }
      return ids;
    }

    return null;
  }
  public List<TagBean> getGSONMsgList() throws WeiboException {

    String json = getMsgListJson();
    List<TagBean> tagBeanList = new ArrayList<TagBean>();

    try {
      JSONArray array = new JSONArray(json);
      int size = array.length();
      for (int i = 0; i < size; i++) {
        TagBean bean = new TagBean();
        JSONObject jsonObject = array.getJSONObject(i);
        Iterator<String> iterator = jsonObject.keys();
        while (iterator.hasNext()) {
          String key = iterator.next();
          if (key.equalsIgnoreCase("weight")) {
            String value = jsonObject.optString(key);
            bean.setWeight(value);
          } else {
            String value = jsonObject.optString(key);
            bean.setId(Integer.valueOf(key));
            bean.setName(value);
          }
        }
        tagBeanList.add(bean);
      }

    } catch (JSONException e) {
      AppLogger.e(e.getMessage());
    }

    return tagBeanList;
  }
 private void stopDownloadingOtherPicturesOnWifiNetworkEnvironment() {
   if (backgroundWifiDownloadPicThread != null) {
     backgroundWifiDownloadPicThread.interrupt();
     backgroundWifiDownloadPicThread = null;
     AppLogger.i(
         "WifiAutoDownloadPictureRunnable stopDownloadingOtherPicturesOnWifiNetworkEnvironment");
   }
 }
Exemple #4
0
 private void handleFile(File file) {
   long time = file.lastModified();
   long calcMills = now - time;
   long day = TimeUnit.MILLISECONDS.toDays(calcMills);
   if (day > AppConfig.SAVED_DAYS) {
     AppLogger.d(file.getAbsolutePath());
     if (file.delete()) clearEmptyDir(file.getParentFile());
   }
 }
Exemple #5
0
  @Override
  public void run() {

    Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

    AppLogger.d("clear cache task start");

    if (Utility.isWifi(GlobalContext.getInstance())) {

      List<String> pathList = FileManager.getCachePath();

      for (String path : pathList) {
        if (!TextUtils.isEmpty(path)) handleDir(new File(path));
      }

      AppLogger.d("clear cache task stop");
    } else {
      AppLogger.d("this device dont have wifi network, clear cache task stop");
    }
  }
Exemple #6
0
    @Override
    protected DBResult doInBackground(String... params) {

      String token = params[0];
      long expiresInSeconds = Long.valueOf(params[1]);

      try {
        UserBean user = new OAuthDao(token).getOAuthUserInfo();
        AccountBean account = new AccountBean();
        account.setAccess_token(token);
        account.setExpires_time(System.currentTimeMillis() + expiresInSeconds * 1000);
        account.setInfo(user);
        AppLogger.e("token expires in " + Utility.calcTokenExpiresInDays(account) + " days");
        return AccountDBTask.addOrUpdateAccount(account, false);
      } catch (WeiboException e) {
        AppLogger.e(e.getError());
        this.e = e;
        cancel(true);
        return null;
      }
    }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {

    AccountBean accountBean = intent.getParcelableExtra(NotificationServiceHelper.ACCOUNT_ARG);

    if (accountBean == null) {
      throw new IllegalArgumentException(
          "you must use BigTextNotificationService newIntent method");
    }

    ValueWrapper valueWrapper = valueBagHashMap.get(accountBean.getUid());

    if (valueWrapper == null) {
      valueWrapper = new ValueWrapper();
    }

    valueWrapper.accountBean = intent.getParcelableExtra(NotificationServiceHelper.ACCOUNT_ARG);
    valueWrapper.mentionsWeibo =
        intent.getParcelableExtra(NotificationServiceHelper.MENTIONS_WEIBO_ARG);
    valueWrapper.commentsToMe =
        intent.getParcelableExtra(NotificationServiceHelper.COMMENTS_TO_ME_ARG);
    valueWrapper.mentionsComment =
        intent.getParcelableExtra(NotificationServiceHelper.MENTIONS_COMMENT_ARG);
    valueWrapper.unreadBean = intent.getParcelableExtra(NotificationServiceHelper.UNREAD_ARG);
    valueWrapper.currentIndex = intent.getIntExtra(NotificationServiceHelper.CURRENT_INDEX_ARG, 0);
    valueWrapper.clickToOpenAppPendingIntentInner =
        intent.getParcelableExtra(NotificationServiceHelper.PENDING_INTENT_INNER_ARG);
    valueWrapper.ticker = intent.getStringExtra(NotificationServiceHelper.TICKER);

    ArrayList<Parcelable> notificationItems = new ArrayList<Parcelable>();
    if (valueWrapper.commentsToMe != null) {
      notificationItems.addAll(valueWrapper.commentsToMe.getItemList());
    }
    if (valueWrapper.mentionsComment != null) {
      notificationItems.addAll(valueWrapper.mentionsComment.getItemList());
    }
    if (valueWrapper.mentionsWeibo != null) {
      notificationItems.addAll(valueWrapper.mentionsWeibo.getItemList());
    }
    valueWrapper.notificationItems = notificationItems;
    valueBagHashMap.put(valueWrapper.accountBean.getUid(), valueWrapper);

    AppLogger.i("service account name=" + valueWrapper.accountBean.getUsernick());

    buildNotification(valueWrapper.accountBean.getUid());

    stopSelf();

    return super.onStartCommand(intent, flags, startId);
  }
  public List<MessageReCmtCountBean> get() throws WeiboException {

    String json = getJson();

    List<MessageReCmtCountBean> value = null;
    try {
      value = new Gson().fromJson(json, new TypeToken<List<MessageReCmtCountBean>>() {}.getType());
    } catch (JsonSyntaxException e) {

      AppLogger.e(e.getMessage());
    }

    return value;
  }
 private void startDownloadingOtherPicturesOnWifiNetworkEnvironment() {
   if (backgroundWifiDownloadPicThread == null
       && Utility.isWifi(getActivity())
       && SettingUtility.getEnableBigPic()
       && SettingUtility.isWifiAutoDownloadPic()) {
     final int position = getListView().getFirstVisiblePosition();
     int listVewOrientation = ((VelocityListView) getListView()).getTowardsOrientation();
     WifiAutoDownloadPictureRunnable runnable =
         new WifiAutoDownloadPictureRunnable(getList(), position, listVewOrientation);
     backgroundWifiDownloadPicThread = new Thread(runnable);
     backgroundWifiDownloadPicThread.start();
     AppLogger.i(
         "WifiAutoDownloadPictureRunnable startDownloadingOtherPicturesOnWifiNetworkEnvironment");
   }
 }
  public boolean destroy() throws WeiboException {
    String url = URLHelper.STATUSES_DESTROY;
    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("id", id);

    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Post, url, map);
    Gson gson = new Gson();

    try {
      MessageBean value = gson.fromJson(jsonData, MessageBean.class);
    } catch (JsonSyntaxException e) {
      AppLogger.e(e.getMessage());
      return false;
    }

    return true;
  }
  public MessageListBean getGSONMsgList() throws WeiboException {

    String json = getMsgListJson();
    Gson gson = new Gson();

    MessageListBean value = null;
    try {
      value = gson.fromJson(json, MessageListBean.class);
    } catch (JsonSyntaxException e) {

      AppLogger.e(e.getMessage());
      return null;
    }
    if (value != null && value.getItemList().size() > 0) {
      TimeLineUtility.filterMessage(value);
    }

    return value;
  }
  public boolean destroy() throws WeiboException {

    String url = URLHelper.GROUP_DESTROY;

    Map<String, String> map = new HashMap<String, String>();
    map.put("access_token", access_token);
    map.put("list_id", list_id);

    String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Post, url, map);

    Gson gson = new Gson();

    Result value = null;
    try {
      value = gson.fromJson(jsonData, Result.class);
    } catch (JsonSyntaxException e) {
      AppLogger.e(e.getMessage());
    }

    return (value != null);
  }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {

    ValueWrapper valueWrapper = new ValueWrapper();

    valueWrapper.accountBean = intent.getParcelableExtra(NotificationServiceHelper.ACCOUNT_ARG);

    valueWrapper.unreadBean = intent.getParcelableExtra(NotificationServiceHelper.UNREAD_ARG);

    valueWrapper.clickToOpenAppPendingIntentInner =
        intent.getParcelableExtra(NotificationServiceHelper.PENDING_INTENT_INNER_ARG);
    valueWrapper.ticker = intent.getStringExtra(NotificationServiceHelper.TICKER);

    valueBagHashMap.put(valueWrapper.accountBean.getUid(), valueWrapper);

    AppLogger.i("service account name=" + valueWrapper.accountBean.getUsernick());

    buildNotification(valueWrapper.accountBean.getUid());

    stopSelf();

    return super.onStartCommand(intent, flags, startId);
  }