private void unfollowQuestion() { if (unfollowTask != null && unfollowTask.getStatus() == AsyncTask.Status.RUNNING) { unfollowTask.cancel(true); } unfollowTask = new UnfollowTask(); unfollowTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, question.getId()); }
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); switch (id) { case R.id.action_follow_question: followQuestion(); break; case R.id.action_unfollow_question: unfollowQuestion(); break; case R.id.action_open_in_browser: if (!TextUtils.isEmpty(question.getUrl())) { MobclickAgent.onEvent(this, Mob.Event_Open_Question_In_Browser); UrlCheckUtil.openWithBrowser(question.getUrl()); } break; case R.id.action_share_to_wechat_circle: MobclickAgent.onEvent(this, Mob.Event_Share_Question_To_Wechat_Circle); ShareUtil.shareToWeiXinCircle( this, question.getUrl(), question.getTitle(), question.getSummary(), null); break; case R.id.action_share_to_wechat_friends: MobclickAgent.onEvent(this, Mob.Event_Share_Question_To_Wechat_friend); ShareUtil.shareToWeiXinFriends( this, question.getUrl(), question.getTitle(), question.getSummary(), null); break; case R.id.action_share_to_weibo: MobclickAgent.onEvent(this, Mob.Event_Share_Question_To_Weibo); ShareUtil.shareToWeibo( this, question.getUrl(), question.getTitle(), question.getSummary(), null); break; } return super.onOptionsItemSelected(item); }