Skip to content

Commit

Permalink
issue(123867): format
Browse files Browse the repository at this point in the history
  • Loading branch information
feduke-nukem committed Dec 23, 2024
1 parent 9d35195 commit 7e81a6c
Show file tree
Hide file tree
Showing 32 changed files with 3,296 additions and 7,944 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v22.7.0), do not edit directly.
// Autogenerated from Pigeon, do not edit directly.
// See also: https://pub.dev/packages/pigeon

import static java.lang.annotation.ElementType.METHOD;
Expand All @@ -19,9 +19,7 @@
import java.lang.annotation.Target;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand All @@ -39,8 +37,7 @@ public static class FlutterError extends RuntimeException {
/** The error details. Must be a datatype supported by the api codec. */
public final Object details;

public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details)
{
public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) {
super(message);
this.code = code;
this.details = details;
Expand All @@ -59,14 +56,15 @@ protected static ArrayList<Object> wrapError(@NonNull Throwable exception) {
errorList.add(exception.toString());
errorList.add(exception.getClass().getSimpleName());
errorList.add(
"Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception));
"Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception));
}
return errorList;
}

@NonNull
protected static FlutterError createConnectionError(@NonNull String channelName) {
return new FlutterError("channel-error", "Unable to establish connection on channel: " + channelName + ".", "");
return new FlutterError(
"channel-error", "Unable to establish connection on channel: " + channelName + ".", "");
}

@Target(METHOD)
Expand Down Expand Up @@ -137,10 +135,17 @@ public void setData(@NonNull Map<String, String> setterArg) {

@Override
public boolean equals(Object o) {
if (this == o) { return true; }
if (o == null || getClass() != o.getClass()) { return false; }
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MessageData that = (MessageData) o;
return Objects.equals(name, that.name) && Objects.equals(description, that.description) && code.equals(that.code) && data.equals(that.data);
return Objects.equals(name, that.name)
&& Objects.equals(description, that.description)
&& code.equals(that.code)
&& data.equals(that.data);
}

@Override
Expand Down Expand Up @@ -224,10 +229,11 @@ private PigeonCodec() {}
@Override
protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) {
switch (type) {
case (byte) 129: {
Object value = readValue(buffer);
return value == null ? null : Code.values()[((Long) value).intValue()];
}
case (byte) 129:
{
Object value = readValue(buffer);
return value == null ? null : Code.values()[((Long) value).intValue()];
}
case (byte) 130:
return MessageData.fromList((ArrayList<Object>) readValue(buffer));
default:
Expand All @@ -249,7 +255,6 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) {
}
}


/** Asynchronous error handling return type for non-nullable API method returns. */
public interface Result<T> {
/** Success case callback method for handling returns. */
Expand Down Expand Up @@ -277,10 +282,10 @@ public interface VoidResult {
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
public interface ExampleHostApi {

@NonNull
@NonNull
String getHostLanguage();

@NonNull
@NonNull
Long add(@NonNull Long a, @NonNull Long b);

void sendMessage(@NonNull MessageData message, @NonNull Result<Boolean> result);
Expand All @@ -291,25 +296,31 @@ public interface ExampleHostApi {
static @NonNull MessageCodec<Object> getCodec() {
return PigeonCodec.INSTANCE;
}
/**Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`. */
/** Sets up an instance of `ExampleHostApi` to handle messages through the `binaryMessenger`. */
static void setUp(@NonNull BinaryMessenger binaryMessenger, @Nullable ExampleHostApi api) {
setUp(binaryMessenger, "", api);
}
static void setUp(@NonNull BinaryMessenger binaryMessenger, @NonNull String messageChannelSuffix, @Nullable ExampleHostApi api) {

static void setUp(
@NonNull BinaryMessenger binaryMessenger,
@NonNull String messageChannelSuffix,
@Nullable ExampleHostApi api) {
messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix;
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage" + messageChannelSuffix, getCodec());
binaryMessenger,
"dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.getHostLanguage"
+ messageChannelSuffix,
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<>();
try {
String output = api.getHostLanguage();
wrapped.add(0, output);
}
catch (Throwable exception) {
} catch (Throwable exception) {
wrapped = wrapError(exception);
}
reply.reply(wrapped);
Expand All @@ -321,7 +332,10 @@ static void setUp(@NonNull BinaryMessenger binaryMessenger, @NonNull String mess
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add" + messageChannelSuffix, getCodec());
binaryMessenger,
"dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.add"
+ messageChannelSuffix,
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
Expand All @@ -332,8 +346,7 @@ static void setUp(@NonNull BinaryMessenger binaryMessenger, @NonNull String mess
try {
Long output = api.add(aArg, bArg);
wrapped.add(0, output);
}
catch (Throwable exception) {
} catch (Throwable exception) {
wrapped = wrapError(exception);
}
reply.reply(wrapped);
Expand All @@ -345,7 +358,10 @@ static void setUp(@NonNull BinaryMessenger binaryMessenger, @NonNull String mess
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage" + messageChannelSuffix, getCodec());
binaryMessenger,
"dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessage"
+ messageChannelSuffix,
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
Expand Down Expand Up @@ -374,7 +390,10 @@ public void error(Throwable error) {
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, "dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessageModernAsync" + messageChannelSuffix, getCodec());
binaryMessenger,
"dev.flutter.pigeon.pigeon_example_package.ExampleHostApi.sendMessageModernAsync"
+ messageChannelSuffix,
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
Expand Down Expand Up @@ -410,40 +429,47 @@ public static class MessageFlutterApi {
public MessageFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) {
this(argBinaryMessenger, "");
}
public MessageFlutterApi(@NonNull BinaryMessenger argBinaryMessenger, @NonNull String messageChannelSuffix) {

public MessageFlutterApi(
@NonNull BinaryMessenger argBinaryMessenger, @NonNull String messageChannelSuffix) {
this.binaryMessenger = argBinaryMessenger;
this.messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix;
}

/**
* Public interface for sending reply.
* The codec used by MessageFlutterApi.
*/
/** Public interface for sending reply. The codec used by MessageFlutterApi. */
static @NonNull MessageCodec<Object> getCodec() {
return PigeonCodec.INSTANCE;
}

public void flutterMethod(@Nullable String aStringArg, @NonNull Result<String> result) {
final String channelName = "dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod" + messageChannelSuffix;
final String channelName =
"dev.flutter.pigeon.pigeon_example_package.MessageFlutterApi.flutterMethod"
+ messageChannelSuffix;
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger, channelName, getCodec());
new BasicMessageChannel<>(binaryMessenger, channelName, getCodec());
channel.send(
new ArrayList<>(Collections.singletonList(aStringArg)),
channelReply -> {
if (channelReply instanceof List) {
List<Object> listReply = (List<Object>) channelReply;
if (listReply.size() > 1) {
result.error(new FlutterError((String) listReply.get(0), (String) listReply.get(1), listReply.get(2)));
result.error(
new FlutterError(
(String) listReply.get(0), (String) listReply.get(1), listReply.get(2)));
} else if (listReply.get(0) == null) {
result.error(new FlutterError("null-error", "Flutter api returned null value for non-null return value.", ""));
result.error(
new FlutterError(
"null-error",
"Flutter api returned null value for non-null return value.",
""));
} else {
@SuppressWarnings("ConstantConditions")
String output = (String) listReply.get(0);
result.success(output);
}
} else {
} else {
result.error(createConnectionError(channelName));
}
}
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ private class PigeonApiImplementation : ExampleHostApi {
}

override suspend fun sendMessageModernAsync(message: MessageData): Boolean {
if (message.code == Code.ONE) {
throw FlutterError("code", "message", "details")
}
if (message.code == Code.ONE) {
throw FlutterError("code", "message", "details")
}

delay(2000)
delay(2000)

return true
return true
}
}
// #enddocregion kotlin-class
Expand Down Expand Up @@ -125,7 +125,10 @@ class MainActivity : FlutterActivity() {
super.configureFlutterEngine(flutterEngine)

val api = PigeonApiImplementation()
ExampleHostApi.setUp(flutterEngine.dartExecutor.binaryMessenger, api, coroutineScope = CoroutineScope(Dispatchers.Main + SupervisorJob()))
ExampleHostApi.setUp(
flutterEngine.dartExecutor.binaryMessenger,
api,
coroutineScope = CoroutineScope(Dispatchers.Main + SupervisorJob()))
// #docregion kotlin-init-event
val eventListener = EventListener()
StreamEventsStreamHandler.register(flutterEngine.dartExecutor.binaryMessenger, eventListener)
Expand Down
Loading

0 comments on commit 7e81a6c

Please sign in to comment.