Search in sources :

Example 1 with IntConsumer

use of java.util.function.IntConsumer in project j2objc by google.

the class IntPipeline method forEachWithCancel.

@Override
public final void forEachWithCancel(Spliterator<Integer> spliterator, Sink<Integer> sink) {
    Spliterator.OfInt spl = adapt(spliterator);
    IntConsumer adaptedSink = adapt(sink);
    do {
    } while (!sink.cancellationRequested() && spl.tryAdvance(adaptedSink));
}
Also used : Spliterator(java.util.Spliterator) IntConsumer(java.util.function.IntConsumer) ObjIntConsumer(java.util.function.ObjIntConsumer)

Example 2 with IntConsumer

use of java.util.function.IntConsumer in project j2objc by google.

the class IntConsumerTest method testAndThen_null.

public void testAndThen_null() throws Exception {
    IntConsumer one = s -> {
    };
    try {
        one.andThen(null);
        fail();
    } catch (NullPointerException expected) {
    }
}
Also used : IntConsumer(java.util.function.IntConsumer) TestCase(junit.framework.TestCase) IntConsumer(java.util.function.IntConsumer)

Example 3 with IntConsumer

use of java.util.function.IntConsumer in project j2objc by google.

the class IntConsumerTest method testAndThen.

public void testAndThen() throws Exception {
    StringBuilder sb = new StringBuilder();
    IntConsumer one = i -> sb.append("one:" + i + ",");
    IntConsumer two = i -> sb.append("two:" + i);
    one.andThen(two).accept(1);
    assertEquals("one:1,two:1", sb.toString());
}
Also used : IntConsumer(java.util.function.IntConsumer) TestCase(junit.framework.TestCase) IntConsumer(java.util.function.IntConsumer)

Example 4 with IntConsumer

use of java.util.function.IntConsumer in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class TrustedCredentialsSettings method onActivityResult.

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_CONFIRM_CREDENTIALS) {
        int userId = mConfirmingCredentialUser;
        IntConsumer listener = mConfirmingCredentialListener;
        // reset them before calling the listener because the listener may call back to start
        // activity again. (though it should never happen.)
        mConfirmingCredentialUser = UserHandle.USER_NULL;
        mConfirmingCredentialListener = null;
        if (resultCode == Activity.RESULT_OK) {
            mConfirmedCredentialUsers.add(userId);
            if (listener != null) {
                listener.accept(userId);
            }
        }
    }
}
Also used : IntConsumer(java.util.function.IntConsumer)

Example 5 with IntConsumer

use of java.util.function.IntConsumer in project MantaroBot by Mantaro.

the class AudioRequester method onSearchResult.

private void onSearchResult(AudioPlaylist playlist) {
    EmbedBuilder builder = new EmbedBuilder().setColor(Color.CYAN).setTitle("Song selection." + (MantaroData.db().getGuild(event.getGuild()).getData().isReactionMenus() ? "React to the desired number to select a song." : "Type the song number to continue."), null).setThumbnail("http://www.clipartbest.com/cliparts/jix/6zx/jix6zx4dT.png").setFooter("This timeouts in 10 seconds.", null);
    java.util.List<AudioTrack> tracks = playlist.getTracks();
    StringBuilder b = new StringBuilder();
    for (int i = 0; i < 4 && i < tracks.size(); i++) {
        AudioTrack at = tracks.get(i);
        b.append(i + 1).append(".** [").append(at.getInfo().title).append("](").append(at.getInfo().uri).append(")**" + " (").append(Utils.getDurationMinutes(at.getInfo().length)).append(")").append("\n");
    }
    builder.setDescription(b);
    if (!event.getGuild().getSelfMember().hasPermission(event.getChannel(), Permission.MESSAGE_ADD_REACTION) || !MantaroData.db().getGuild(event.getGuild()).getData().isReactionMenus()) {
        event.getChannel().sendMessage(builder.setDescription(b.toString()).build()).queue();
        IntConsumer consumer = (c) -> loadSingle(playlist.getTracks().get(c - 1), false);
        DiscordUtils.selectInt(event, 5, consumer);
        return;
    }
    //just in case someone else uses play before timing out
    long id = event.getAuthor().getIdLong();
    ReactionOperations.create(event.getChannel().sendMessage(builder.build()).complete(), 15, (e) -> {
        if (e.getUser().getIdLong() != id)
            return false;
        int i = e.getReactionEmote().getName().charAt(0) - '0';
        if (i < 1 || i > 4)
            return false;
        loadSingle(playlist.getTracks().get(i - 1), false);
        event.getChannel().getMessageById(e.getMessageIdLong()).queue(m -> m.clearReactions().queue());
        return true;
    }, "1⃣", "2⃣", "3⃣", "4⃣");
}
Also used : FriendlyException(com.sedmelluq.discord.lavaplayer.tools.FriendlyException) Color(java.awt.Color) Utils(net.kodehawa.mantarobot.utils.Utils) IntConsumer(java.util.function.IntConsumer) DiscordUtils(net.kodehawa.mantarobot.utils.DiscordUtils) AudioPlaylist(com.sedmelluq.discord.lavaplayer.track.AudioPlaylist) ReactionOperations(net.kodehawa.mantarobot.core.listeners.operations.ReactionOperations) AudioLoadResultHandler(com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) TimeUnit(java.util.concurrent.TimeUnit) Slf4j(lombok.extern.slf4j.Slf4j) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) Permission(net.dv8tion.jda.core.Permission) DBGuild(net.kodehawa.mantarobot.data.entities.DBGuild) YoutubeAudioSourceManager(com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager) GuildData(net.kodehawa.mantarobot.data.entities.helpers.GuildData) EmoteReference(net.kodehawa.mantarobot.utils.commands.EmoteReference) MantaroData(net.kodehawa.mantarobot.data.MantaroData) Optional(java.util.Optional) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) AudioTrackInfo(com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) AudioTrack(com.sedmelluq.discord.lavaplayer.track.AudioTrack) IntConsumer(java.util.function.IntConsumer)

Aggregations

IntConsumer (java.util.function.IntConsumer)7 Spliterator (java.util.Spliterator)2 ObjIntConsumer (java.util.function.ObjIntConsumer)2 TestCase (junit.framework.TestCase)2 AudioLoadResultHandler (com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler)1 YoutubeAudioSourceManager (com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager)1 FriendlyException (com.sedmelluq.discord.lavaplayer.tools.FriendlyException)1 AudioPlaylist (com.sedmelluq.discord.lavaplayer.track.AudioPlaylist)1 AudioTrack (com.sedmelluq.discord.lavaplayer.track.AudioTrack)1 AudioTrackInfo (com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo)1 Color (java.awt.Color)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 Slf4j (lombok.extern.slf4j.Slf4j)1 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)1 Permission (net.dv8tion.jda.core.Permission)1 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)1 ReactionOperations (net.kodehawa.mantarobot.core.listeners.operations.ReactionOperations)1 MantaroData (net.kodehawa.mantarobot.data.MantaroData)1 DBGuild (net.kodehawa.mantarobot.data.entities.DBGuild)1