コード例 #1
0
ファイル: UserInfoFragment.java プロジェクト: saispas/Berry
    @Override
    protected UserBean doInBackground(Object... params) {
      if (!isCancelled()) {
        ShowUserDao dao = new ShowUserDao(GlobalContext.getInstance().getSpecialToken());
        boolean haveId = !TextUtils.isEmpty(bean.getId());
        boolean haveName = !TextUtils.isEmpty(bean.getScreen_name());
        if (haveId) {
          dao.setUid(bean.getId());
        } else if (haveName) {
          dao.setScreen_name(bean.getScreen_name());
        } else {
          cancel(true);
          return null;
        }

        UserBean user = null;
        try {
          user = dao.getUserInfo();
        } catch (WeiboException e) {
          this.e = e;
          cancel(true);
        }
        if (user != null) {
          bean = user;
        } else {
          cancel(true);
        }
        return user;
      } else {
        return null;
      }
    }
コード例 #2
0
 @Override
 public int getItemViewType(int position) {
   DMBean dmBean = bean.get(position);
   if (dmBean.getUser().getId().equals(GlobalContext.getInstance().getCurrentAccountId())) {
     return TYPE_MYSELF;
   } else {
     return TYPE_NORMAL;
   }
 }
コード例 #3
0
 @Override
 public void removeItem(int position) {
   clearActionMode();
   if (removeTask == null || removeTask.getStatus() == MyAsyncTask.Status.FINISHED) {
     removeTask =
         new RemoveTask(
             GlobalContext.getInstance().getSpecialToken(),
             getList().getItemList().get(position).getId(),
             position);
     removeTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
   }
 }
コード例 #4
0
ファイル: UserInfoFragment.java プロジェクト: saispas/Berry
 @Override
 protected ArrayList<String> doInBackground(Void... params) {
   UserTopicListDao dao =
       new UserTopicListDao(GlobalContext.getInstance().getSpecialToken(), bean.getId());
   try {
     return dao.getGSONMsgList();
   } catch (WeiboException e) {
     this.e = e;
     cancel(true);
     return null;
   }
 }
コード例 #5
0
ファイル: BrowserWebActivity.java プロジェクト: saispas/Berry
    @Override
    protected Integer doInBackground(Void... params) {
      int result = 0;
      try {
        result =
            new ShareShortUrlCountDao(GlobalContext.getInstance().getSpecialToken(), url)
                .getCount();
      } catch (WeiboException e) {

      }
      return result;
    }
コード例 #6
0
  private void buildNotification() {

    int count =
        (data.getSize() >= Integer.valueOf(SettingUtility.getMsgCount())
            ? unreadBean.getMention_status()
            : data.getSize());

    Notification.Builder builder =
        new Notification.Builder(getBaseContext())
            .setTicker(ticker)
            .setContentText(accountBean.getUsernick())
            .setSmallIcon(R.drawable.ic_notification)
            .setAutoCancel(true)
            .setContentIntent(getPendingIntent())
            .setOnlyAlertOnce(true);

    builder.setContentTitle(
        String.format(
            GlobalContext.getInstance().getString(R.string.new_mentions_weibo),
            String.valueOf(count)));

    if (data.getSize() > 1) {
      builder.setNumber(count);
    }

    if (clearNotificationEventReceiver != null) {
      Utility.unregisterReceiverIgnoredReceiverNotRegisteredException(
          GlobalContext.getInstance(), clearNotificationEventReceiver);
      JBMentionsWeiboNotificationServiceHelper.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());

                        } catch (WeiboException ignored) {

                        } finally {
                          Utility.unregisterReceiverIgnoredReceiverNotRegisteredException(
                              GlobalContext.getInstance(), clearNotificationEventReceiver);
                          JBMentionsWeiboNotificationServiceHelper.clearNotificationEventReceiver =
                              null;
                        }
                      }
                    })
                .start();
          }
        };

    IntentFilter intentFilter = new IntentFilter(RESET_UNREAD_MENTIONS_WEIBO_ACTION);

    GlobalContext.getInstance().registerReceiver(clearNotificationEventReceiver, intentFilter);

    Intent broadcastIntent = new Intent(RESET_UNREAD_MENTIONS_WEIBO_ACTION);

    PendingIntent deletedPendingIntent =
        PendingIntent.getBroadcast(
            GlobalContext.getInstance(), 0, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.setDeleteIntent(deletedPendingIntent);

    Intent intent = new Intent(getApplicationContext(), WriteCommentActivity.class);
    intent.putExtra("token", accountBean.getAccess_token());
    intent.putExtra("msg", data.getItem(0));

    PendingIntent pendingIntent =
        PendingIntent.getActivity(
            getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    builder.addAction(
        R.drawable.comment_light,
        getApplicationContext().getString(R.string.comments),
        pendingIntent);

    if (data.getSize() > 1) {
      Intent nextIntent =
          new Intent(
              JBMentionsWeiboNotificationServiceHelper.this,
              JBMentionsWeiboNotificationServiceHelper.class);
      nextIntent.putExtra(NotificationServiceHelper.ACCOUNT_ARG, accountBean);
      nextIntent.putExtra(NotificationServiceHelper.MENTIONS_WEIBO_ARG, data);
      nextIntent.putExtra(NotificationServiceHelper.UNREAD_ARG, unreadBean);
      nextIntent.putExtra(
          NotificationServiceHelper.PENDING_INTENT_INNER_ARG, clickToOpenAppPendingIntentInner);
      nextIntent.putExtra(NotificationServiceHelper.TICKER, ticker);

      String actionName;
      int nextIndex;
      int actionDrawable;
      if (currentIndex < data.getSize() - 1) {
        nextIndex = currentIndex + 1;
        actionName = getString(R.string.next_message);
        actionDrawable = R.drawable.notification_action_next;
      } else {
        nextIndex = 0;
        actionName = getString(R.string.first_message);
        actionDrawable = R.drawable.notification_action_previous;
      }
      nextIntent.putExtra(NotificationServiceHelper.CURRENT_INDEX_ARG, nextIndex);
      PendingIntent retrySendIntent =
          PendingIntent.getService(
              JBMentionsWeiboNotificationServiceHelper.this,
              0,
              nextIntent,
              PendingIntent.FLAG_UPDATE_CURRENT);
      builder.addAction(actionDrawable, actionName, retrySendIntent);
    }

    Notification.BigTextStyle bigTextStyle = new Notification.BigTextStyle(builder);
    if (data.getItem(currentIndex).getText().contains(accountBean.getUsernick())) {
      // mentioned you
      bigTextStyle.setBigContentTitle(
          "@"
              + data.getItem(currentIndex).getUser().getScreen_name()
              + getString(R.string.weibo_at_to_you));
    } else {
      // retweeted your weibo
      bigTextStyle.setBigContentTitle(
          "@"
              + data.getItem(currentIndex).getUser().getScreen_name()
              + getString(R.string.retweeted_your_weibo));
    }
    bigTextStyle.bigText(data.getItem(currentIndex).getText());
    String summaryText;
    if (data.getSize() > 1) {
      summaryText =
          accountBean.getUsernick() + "(" + (currentIndex + 1) + "/" + data.getSize() + ")";
    } else {
      summaryText = accountBean.getUsernick();
    }
    bigTextStyle.setSummaryText(summaryText);

    builder.setStyle(bigTextStyle);
    Utility.configVibrateLedRingTone(builder);

    NotificationManager notificationManager =
        (NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(getMentionsWeiboNotificationId(accountBean), builder.build());
  }
コード例 #7
0
 @Override
 public Loader<CommentTimeLineData> onCreateLoader(int id, Bundle args) {
   getPullToRefreshListView().setVisibility(View.INVISIBLE);
   return new CommentsByMeDBLoader(
       getActivity(), GlobalContext.getInstance().getCurrentAccountId());
 }