@Override
  public boolean onActionItemClicked(ActionMode mode, MenuItem item) {

    switch (item.getItemId()) {
      case R.id.menu_at:
        Intent intent = new Intent(getActivity(), WriteWeiboActivity.class);
        intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
        intent.putExtra("content", "@" + bean.getScreen_name());
        intent.putExtra("account", GlobalContext.getInstance().getAccountBean());
        getActivity().startActivity(intent);
        listView.clearChoices();
        mode.finish();
        break;
      case R.id.menu_follow:
        if (followOrUnfollowTask == null
            || followOrUnfollowTask.getStatus() == MyAsyncTask.Status.FINISHED) {
          followOrUnfollowTask = new FollowTask();
          followOrUnfollowTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
        }
        listView.clearChoices();
        mode.finish();
        break;
      case R.id.menu_unfollow:
        if (followOrUnfollowTask == null
            || followOrUnfollowTask.getStatus() == MyAsyncTask.Status.FINISHED) {
          followOrUnfollowTask = new UnFollowTask();
          followOrUnfollowTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
        }
        listView.clearChoices();
        mode.finish();
        break;
    }

    return true;
  }
 @Override
 protected void onPostExecute(Boolean aBoolean) {
   super.onPostExecute(aBoolean);
   if (aBoolean) {
     finish();
   }
 }
 @Override
 protected void onCancelled(UserBean userBean) {
   super.onCancelled(userBean);
   if (e != null) {
     Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
   }
 }
Exemplo n.º 4
0
    @Override
    protected void onPreExecute() {
      super.onPreExecute();
      Notification.Builder builder =
          new Notification.Builder(SendWeiboService.this)
              .setTicker(getString(R.string.sending))
              .setContentTitle(getString(R.string.sending))
              .setContentText(content)
              .setOnlyAlertOnce(true)
              .setOngoing(true)
              .setSmallIcon(R.drawable.upload_white);

      if (!TextUtils.isEmpty(picPath)) {
        builder.setProgress(0, 100, false);
      } else {
        builder.setProgress(0, 100, true);
      }

      notification = builder.getNotification();

      int notificationId = new Random().nextInt(Integer.MAX_VALUE);
      NotificationManager notificationManager =
          (NotificationManager) getApplicationContext().getSystemService(NOTIFICATION_SERVICE);
      notificationManager.notify(notificationId, notification);

      tasksNotifications.put(WeiboSendTask.this, notificationId);

      Toast.makeText(
              SendWeiboService.this, getString(R.string.background_sending), Toast.LENGTH_SHORT)
          .show();
    }
 @Override
 protected void onCancelled(Boolean aBoolean) {
   super.onCancelled(aBoolean);
   if (this.e != null) {
     Toast.makeText(BrowserWeiboMsgActivity.this, e.getError(), Toast.LENGTH_SHORT).show();
   }
 }
Exemplo n.º 6
0
 @Override
 protected void onPostExecute(UserBean o) {
   setValue();
   topicListTask = new TopicListTask();
   topicListTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
   super.onPostExecute(o);
 }
Exemplo n.º 7
0
 @Override
 protected void onCancelled(UserBean userBean) {
   super.onCancelled(userBean);
   if (Utility.isAllNotNull(getActivity(), this.e)) {
     Toast.makeText(getActivity(), e.getError(), Toast.LENGTH_SHORT).show();
   }
 }
Exemplo n.º 8
0
 @Override
 protected void onPostExecute(Void aVoid) {
   super.onPostExecute(aVoid);
   if (statusDraftBean != null) DraftDBManager.getInstance().remove(statusDraftBean.getId());
   Toast.makeText(
           SendWeiboService.this, getString(R.string.send_successfully), Toast.LENGTH_SHORT)
       .show();
   stopServiceIfTasksAreEnd(WeiboSendTask.this);
 }
 @Override
 protected void onPostExecute(UserBean o) {
   super.onPostExecute(o);
   Toast.makeText(
           getActivity(),
           getActivity().getString(R.string.unfollow_successfully),
           Toast.LENGTH_SHORT)
       .show();
   adapter.update(bean, o);
 }
Exemplo n.º 10
0
    @Override
    protected void onCancelled(Void aVoid) {
      super.onCancelled(aVoid);
      if (statusDraftBean != null) {
        DraftDBManager.getInstance().remove(statusDraftBean.getId());
        DraftDBManager.getInstance().insertStatus(content, geoBean, picPath, accountId);
      } else {
        DraftDBManager.getInstance().insertStatus(content, geoBean, picPath, accountId);
      }
      Toast.makeText(
              SendWeiboService.this,
              getString(R.string.send_failed_and_save_to_draft),
              Toast.LENGTH_SHORT)
          .show();

      stopServiceIfTasksAreEnd(WeiboSendTask.this);
    }
  public void finish() {
    if (mode != null) mode.finish();

    if (followOrUnfollowTask != null) followOrUnfollowTask.cancel(true);
  }
 @Override
 protected void onPreExecute() {
   super.onPreExecute();
 }