@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 onCancelled(UserBean userBean) {
   super.onCancelled(userBean);
   if (e != null) {
     Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
   }
 }
 @Override
 protected void onCancelled(String s) {
   super.onCancelled(s);
   progressFragment.dismissAllowingStateLoss();
   if (e != null)
     Toast.makeText(WriteWeiboActivity.this, e.getError(), Toast.LENGTH_SHORT).show();
 }
    @Override
    protected void onPostExecute(GroupListBean groupListBean) {
      GroupDBManager.getInstance()
          .updateGroupInfo(groupListBean, GlobalContext.getInstance().getCurrentAccountId());
      GlobalContext.getInstance().setGroup(groupListBean);

      super.onPostExecute(groupListBean);
    }
Beispiel #5
0
    @Override
    public void onCancel(DialogInterface dialog) {

      if (asyncTask != null) {
        asyncTask.cancel(true);
      }

      super.onCancel(dialog);
    }
Beispiel #6
0
 @Override
 protected void onCancelled(DBResult dbResult) {
   super.onCancelled(dbResult);
   if (progressFragment != null) {
     progressFragment.dismissAllowingStateLoss();
   }
   if (e != null) Toast.makeText(OAuthActivity.this, e.getError(), Toast.LENGTH_SHORT).show();
   webView.loadUrl(getWeiboOAuthUrl());
 }
 @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);
 }
 @Override
 protected void onPostExecute(String s) {
   progressFragment.dismissAllowingStateLoss();
   savaDraft();
   finish();
   Toast.makeText(
           WriteWeiboActivity.this, getString(R.string.send_successfully), Toast.LENGTH_SHORT)
       .show();
   super.onPostExecute(s);
 }
    @Override
    protected void onPreExecute() {
      super.onPreExecute();
      if (username.getText().toString().length() == 0) {
        username.setError("用户名不能为空");
        cancel(true);
      }

      if (password.getText().toString().length() == 0) {
        password.setError("密码不能为空");
        cancel(true);
      }
    }
  @Override
  protected void onProgressUpdate(Integer... values) {
    super.onProgressUpdate(values);
    if (this.getStatus() == Status.RUNNING) {
      pb.setVisibility(View.VISIBLE);
      pb.setIndeterminate(false);

      Integer progress = values[0];
      Integer max = values[1];

      pb.setMax(max);
      pb.setProgress(progress);
    }
  }
 @Override
 protected void onPostExecute(Object o) {
   pullToRefreshListView.setVisibility(View.VISIBLE);
   timeLineAdapter.notifyDataSetChanged();
   refreshLayout(bean);
   super.onPostExecute(o);
   /**
    * when this account first open app,if he don't have any data in database,fetch data from
    * server automally
    */
   if (bean.getSize() == 0) {
     pullToRefreshListView.startRefreshNow();
   }
 }
    @Override
    protected void onPostExecute(MessageListBean newValue) {
      super.onPostExecute(newValue);

      if (newTask != null && newTask.getStatus() != MyAsyncTask.Status.FINISHED) {
        return;
      }

      if (oldTask != null && oldTask.getStatus() != MyAsyncTask.Status.FINISHED) {
        return;
      }

      if (middleTask != null && middleTask.getStatus() != MyAsyncTask.Status.FINISHED) {
        return;
      }

      if (newValue == null || newValue.getSize() == 0 || getActivity() == null || isListViewFling())
        return;

      int firstPosition = getListView().getFirstVisiblePosition();

      int size = newValue.getSize();

      if (newValue.getItemList().size() < AppConfig.DEFAULT_MSG_NUMBERS) {
        // for speed, add old data after new data
        newValue.getItemList().addAll(getList().getItemList());
      } else {
        // null is flag means this position has some old messages which dont appear
        if (getList().getSize() > 0) {
          newValue.getItemList().add(null);
        }
        newValue.getItemList().addAll(getList().getItemList());
      }
      int index = getListView().getFirstVisiblePosition();
      clearAndReplaceValue(newValue);
      View v = getListView().getChildAt(1);
      int top = (v == null) ? 0 : v.getTop();

      timeLineAdapter.notifyDataSetChanged();
      int ss = index + size;

      //            if (firstPosition == 0) {
      ////
      //            } else {
      getListView().setSelectionFromTop(ss + 1, top);
      //            }
      //            getListView().setLayoutTransition(null);
    }
 @Override
 protected void onPostExecute(String s) {
   Toast.makeText(WriteWeiboActivity.this, s, Toast.LENGTH_SHORT).show();
   location = s;
   super.onPostExecute(s);
 }
 @Override
 protected void onPreExecute() {
   super.onPreExecute();
   pullToRefreshListView.setVisibility(View.INVISIBLE);
 }
Beispiel #15
0
 @Override
 protected void onPreExecute() {
   super.onPreExecute();
   Toast.makeText(getActivity(), getString(R.string.remove_ing), Toast.LENGTH_SHORT).show();
 }
 @Override
 protected void onCancelled(String bitmap) {
   pb.setVisibility(View.INVISIBLE);
   super.onCancelled(bitmap);
 }
 @Override
 protected void onPreExecute() {
   super.onPreExecute();
   if (isListViewFling()) cancel(true);
 }
 @Override
 protected void onCancelled(String s) {
   super.onCancelled(s);
   if (e != null)
     Toast.makeText(BlackMagicActivity.this, e.getError(), Toast.LENGTH_SHORT).show();
 }
 @Override
 protected void onPreExecute() {
   super.onPreExecute();
 }
 @Override
 protected void onPostExecute(String s) {
   super.onPostExecute(s);
   setResult(RESULT_OK, null);
   finish();
 }
  public void finish() {
    if (mode != null) mode.finish();

    if (followOrUnfollowTask != null) followOrUnfollowTask.cancel(true);
  }