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));
}
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) {
}
}
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());
}
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);
}
}
}
}
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⃣");
}
Aggregations