Search in sources :

Example 1 with FavAsyncTask

use of org.qii.weiciyuan.ui.task.FavAsyncTask in project weiciyuan by qii.

the class StatusSingleChoiceModeListener method onActionItemClicked.

@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
    if (listView.getCheckedItemCount() == 0) {
        return true;
    }
    Intent intent;
    long[] ids = listView.getCheckedItemIds();
    switch(item.getItemId()) {
        case R.id.menu_repost:
            intent = new Intent(getActivity(), WriteRepostActivity.class);
            intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
            intent.putExtra("id", String.valueOf(ids[0]));
            intent.putExtra("msg", bean);
            getActivity().startActivity(intent);
            listView.clearChoices();
            mode.finish();
            break;
        case R.id.menu_comment:
            intent = new Intent(getActivity(), WriteCommentActivity.class);
            intent.putExtra("token", GlobalContext.getInstance().getSpecialToken());
            intent.putExtra("id", String.valueOf(ids[0]));
            intent.putExtra("msg", bean);
            getActivity().startActivity(intent);
            listView.clearChoices();
            mode.finish();
            break;
        case R.id.menu_fav:
            if (Utility.isTaskStopped(favTask) && Utility.isTaskStopped(unFavTask)) {
                favTask = new FavAsyncTask(GlobalContext.getInstance().getSpecialToken(), bean.getId());
                favTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
            }
            listView.clearChoices();
            mode.finish();
            break;
        case R.id.menu_unfav:
            if (Utility.isTaskStopped(favTask) && Utility.isTaskStopped(unFavTask)) {
                unFavTask = new UnFavAsyncTask(GlobalContext.getInstance().getSpecialToken(), bean.getId());
                unFavTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
            }
            listView.clearChoices();
            mode.finish();
            break;
        case R.id.menu_remove:
            int position = listView.getCheckedItemPosition() - listView.getHeaderViewsCount();
            RemoveDialog dialog = new RemoveDialog(position);
            dialog.setTargetFragment(fragment, 0);
            dialog.show(fragment.getFragmentManager(), "");
            break;
        case R.id.menu_share:
            if (fragment.getActivity() != null) {
                Utility.setShareIntent(fragment.getActivity(), mShareActionProvider, bean);
            }
            mShareActionProvider.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {

                @Override
                public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
                    finish();
                    return false;
                }
            });
            break;
        case R.id.menu_copy:
            ClipboardManager cm = (ClipboardManager) fragment.getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
            cm.setPrimaryClip(ClipData.newPlainText("sinaweibo", bean.getText()));
            Toast.makeText(fragment.getActivity(), fragment.getString(R.string.copy_successfully), Toast.LENGTH_SHORT).show();
            mode.finish();
            break;
    }
    return true;
}
Also used : UnFavAsyncTask(org.qii.weiciyuan.ui.task.UnFavAsyncTask) ClipboardManager(android.content.ClipboardManager) WriteRepostActivity(org.qii.weiciyuan.ui.send.WriteRepostActivity) UnFavAsyncTask(org.qii.weiciyuan.ui.task.UnFavAsyncTask) FavAsyncTask(org.qii.weiciyuan.ui.task.FavAsyncTask) Intent(android.content.Intent) ShareActionProvider(android.widget.ShareActionProvider) WriteCommentActivity(org.qii.weiciyuan.ui.send.WriteCommentActivity)

Example 2 with FavAsyncTask

use of org.qii.weiciyuan.ui.task.FavAsyncTask in project weiciyuan by qii.

the class BrowserWeiboMsgActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case android.R.id.home:
            Intent intent = MainTimeLineActivity.newIntent();
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
            return true;
        case R.id.menu_repost:
            intent = new Intent(this, WriteRepostActivity.class);
            intent.putExtra("token", getToken());
            intent.putExtra("id", getMsg().getId());
            intent.putExtra("msg", getMsg());
            startActivity(intent);
            return true;
        case R.id.menu_comment:
            intent = new Intent(this, WriteCommentActivity.class);
            intent.putExtra("token", getToken());
            intent.putExtra("id", getMsg().getId());
            intent.putExtra("msg", getMsg());
            startActivity(intent);
            return true;
        case R.id.menu_share:
            buildShareActionMenu();
            return true;
        case R.id.menu_copy:
            ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            cm.setPrimaryClip(ClipData.newPlainText("sinaweibo", getMsg().getText()));
            Toast.makeText(this, getString(R.string.copy_successfully), Toast.LENGTH_SHORT).show();
            return true;
        case R.id.menu_fav:
            if (Utility.isTaskStopped(favTask) && Utility.isTaskStopped(unFavTask)) {
                favTask = new FavAsyncTask(getToken(), msg.getId());
                favTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
            }
            return true;
        case R.id.menu_unfav:
            if (Utility.isTaskStopped(favTask) && Utility.isTaskStopped(unFavTask)) {
                unFavTask = new UnFavAsyncTask(getToken(), msg.getId());
                unFavTask.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
            }
            return true;
        case R.id.menu_delete:
            RemoveWeiboMsgDialog dialog = new RemoveWeiboMsgDialog(msg.getId());
            dialog.show(getFragmentManager(), "");
            return true;
    }
    return false;
}
Also used : ClipboardManager(android.content.ClipboardManager) UnFavAsyncTask(org.qii.weiciyuan.ui.task.UnFavAsyncTask) WriteRepostActivity(org.qii.weiciyuan.ui.send.WriteRepostActivity) UnFavAsyncTask(org.qii.weiciyuan.ui.task.UnFavAsyncTask) FavAsyncTask(org.qii.weiciyuan.ui.task.FavAsyncTask) Intent(android.content.Intent) WriteCommentActivity(org.qii.weiciyuan.ui.send.WriteCommentActivity)

Aggregations

ClipboardManager (android.content.ClipboardManager)2 Intent (android.content.Intent)2 WriteCommentActivity (org.qii.weiciyuan.ui.send.WriteCommentActivity)2 WriteRepostActivity (org.qii.weiciyuan.ui.send.WriteRepostActivity)2 FavAsyncTask (org.qii.weiciyuan.ui.task.FavAsyncTask)2 UnFavAsyncTask (org.qii.weiciyuan.ui.task.UnFavAsyncTask)2 ShareActionProvider (android.widget.ShareActionProvider)1