Example usage for twitter4j Twitter createMute

List of usage examples for twitter4j Twitter createMute

Introduction

In this page you can find the example usage for twitter4j Twitter createMute.

Prototype

User createMute(long userId) throws TwitterException;

Source Link

Document

Mutes the user specified in the ID parameter as the authenticating user.

Usage

From source file:com.github.moko256.twitlatte.ShowUserActivity.java

License:Apache License

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    ThrowableFunc throwableFunc = null;/*from  w  w w.  j  a  v a 2 s  .c om*/
    @StringRes
    int didAction = -1;
    Twitter twitter = GlobalApplication.twitter;

    switch (item.getItemId()) {
    case R.id.action_share:
        startActivity(Intent.createChooser(new Intent().setAction(Intent.ACTION_SEND).setType("text/plain")
                .putExtra(Intent.EXTRA_TEXT, getShareUrl()), getString(R.string.share)));
        break;
    case R.id.action_open_in_browser:
        AppCustomTabsKt.launchChromeCustomTabs(this, getShareUrl());
        break;
    case R.id.action_create_follow:
        throwableFunc = () -> twitter.createFriendship(user.getId());
        didAction = R.string.did_follow;
        break;
    case R.id.action_destroy_follow:
        throwableFunc = () -> twitter.destroyFriendship(user.getId());
        didAction = R.string.did_unfollow;
        break;
    case R.id.action_create_mute:
        throwableFunc = () -> twitter.createMute(user.getId());
        didAction = R.string.did_mute;
        break;
    case R.id.action_destroy_mute:
        throwableFunc = () -> twitter.destroyMute(user.getId());
        didAction = R.string.did_unmute;
        break;
    case R.id.action_create_block:
        throwableFunc = () -> twitter.createBlock(user.getId());
        didAction = R.string.did_block;
        break;
    case R.id.action_destroy_block:
        throwableFunc = () -> twitter.destroyBlock(user.getId());
        didAction = R.string.did_unblock;
        break;
    case R.id.action_destroy_follow_follower:
        throwableFunc = () -> {
            twitter.createBlock(user.getId());
            twitter.destroyBlock(user.getId());
        };
        didAction = R.string.did_destroy_ff;
        break;
    case R.id.action_spam_report:
        throwableFunc = () -> GlobalApplication.twitter.reportSpam(user.getId());
        break;
    }

    if (throwableFunc != null && didAction != -1) {
        ThrowableFunc finalThrowableFunc = throwableFunc;
        int finalDidAction = didAction;
        confirmDialog(item.getTitle(), getString(R.string.confirm_message),
                () -> runAsWorkerThread(finalThrowableFunc, finalDidAction));
    }

    return super.onOptionsItemSelected(item);
}