-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Android + Foundation generation and Dart implementation * Add ios project to example * Remove ios * Add ios to example * Add iOS native implementation * Add Android native implementation * Bump version * Fix formatting * Expose NSObject and JavaObject * Fix formatting * Added foundation-implementation to umbrella file, updated FLTObject to use super init, not self init (#17) --------- Co-authored-by: Jan-Derk de Vries <[email protected]>
- Loading branch information
1 parent
4a409eb
commit 2da5a5d
Showing
28 changed files
with
1,399 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
182 changes: 182 additions & 0 deletions
182
android/src/main/java/com/baseflow/instancemanager/AndroidInstanceManagerPigeon.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
// 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 (v11.0.1), do not edit directly. | ||
// See also: https://pub.dev/packages/pigeon | ||
|
||
package com.baseflow.instancemanager; | ||
|
||
import android.util.Log; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import io.flutter.plugin.common.BasicMessageChannel; | ||
import io.flutter.plugin.common.BinaryMessenger; | ||
import io.flutter.plugin.common.MessageCodec; | ||
import io.flutter.plugin.common.StandardMessageCodec; | ||
import java.io.ByteArrayOutputStream; | ||
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; | ||
|
||
/** Generated class from Pigeon. */ | ||
@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression", "serial"}) | ||
public class AndroidInstanceManagerPigeon { | ||
|
||
/** Error class for passing custom error details to Flutter via a thrown PlatformException. */ | ||
public static class FlutterError extends RuntimeException { | ||
|
||
/** The error code. */ | ||
public final String code; | ||
|
||
/** 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) | ||
{ | ||
super(message); | ||
this.code = code; | ||
this.details = details; | ||
} | ||
} | ||
|
||
@NonNull | ||
protected static ArrayList<Object> wrapError(@NonNull Throwable exception) { | ||
ArrayList<Object> errorList = new ArrayList<Object>(3); | ||
if (exception instanceof FlutterError) { | ||
FlutterError error = (FlutterError) exception; | ||
errorList.add(error.code); | ||
errorList.add(error.getMessage()); | ||
errorList.add(error.details); | ||
} else { | ||
errorList.add(exception.toString()); | ||
errorList.add(exception.getClass().getSimpleName()); | ||
errorList.add( | ||
"Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); | ||
} | ||
return errorList; | ||
} | ||
/** | ||
* Host API for managing the native `InstanceManager`. | ||
* | ||
* Generated interface from Pigeon that represents a handler of messages from Flutter. | ||
*/ | ||
public interface AndroidInstanceManagerHostApi { | ||
/** | ||
* Clear the native `InstanceManager`. | ||
* | ||
* This is typically only used after a hot restart. | ||
*/ | ||
void clear(); | ||
|
||
/** The codec used by AndroidInstanceManagerHostApi. */ | ||
static @NonNull MessageCodec<Object> getCodec() { | ||
return new StandardMessageCodec(); | ||
} | ||
/**Sets up an instance of `AndroidInstanceManagerHostApi` to handle messages through the `binaryMessenger`. */ | ||
static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable AndroidInstanceManagerHostApi api) { | ||
{ | ||
BasicMessageChannel<Object> channel = | ||
new BasicMessageChannel<>( | ||
binaryMessenger, "dev.flutter.pigeon.flutter_instance_manager.AndroidInstanceManagerHostApi.clear", getCodec()); | ||
if (api != null) { | ||
channel.setMessageHandler( | ||
(message, reply) -> { | ||
ArrayList<Object> wrapped = new ArrayList<Object>(); | ||
try { | ||
api.clear(); | ||
wrapped.add(0, null); | ||
} | ||
catch (Throwable exception) { | ||
ArrayList<Object> wrappedError = wrapError(exception); | ||
wrapped = wrappedError; | ||
} | ||
reply.reply(wrapped); | ||
}); | ||
} else { | ||
channel.setMessageHandler(null); | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* Handles methods calls to the native Java Object class. | ||
* | ||
* Also handles calls to remove the reference to an instance with `dispose`. | ||
* | ||
* See https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html. | ||
* | ||
* Generated interface from Pigeon that represents a handler of messages from Flutter. | ||
*/ | ||
public interface JavaObjectHostApi { | ||
|
||
void dispose(@NonNull String identifier); | ||
|
||
/** The codec used by JavaObjectHostApi. */ | ||
static @NonNull MessageCodec<Object> getCodec() { | ||
return new StandardMessageCodec(); | ||
} | ||
/**Sets up an instance of `JavaObjectHostApi` to handle messages through the `binaryMessenger`. */ | ||
static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable JavaObjectHostApi api) { | ||
{ | ||
BasicMessageChannel<Object> channel = | ||
new BasicMessageChannel<>( | ||
binaryMessenger, "dev.flutter.pigeon.flutter_instance_manager.JavaObjectHostApi.dispose", getCodec()); | ||
if (api != null) { | ||
channel.setMessageHandler( | ||
(message, reply) -> { | ||
ArrayList<Object> wrapped = new ArrayList<Object>(); | ||
ArrayList<Object> args = (ArrayList<Object>) message; | ||
String identifierArg = (String) args.get(0); | ||
try { | ||
api.dispose(identifierArg); | ||
wrapped.add(0, null); | ||
} | ||
catch (Throwable exception) { | ||
ArrayList<Object> wrappedError = wrapError(exception); | ||
wrapped = wrappedError; | ||
} | ||
reply.reply(wrapped); | ||
}); | ||
} else { | ||
channel.setMessageHandler(null); | ||
} | ||
} | ||
} | ||
} | ||
/** | ||
* Handles callbacks methods for the native Java Object class. | ||
* | ||
* See https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html. | ||
* | ||
* Generated class from Pigeon that represents Flutter messages that can be called from Java. | ||
*/ | ||
public static class JavaObjectFlutterApi { | ||
private final @NonNull BinaryMessenger binaryMessenger; | ||
|
||
public JavaObjectFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { | ||
this.binaryMessenger = argBinaryMessenger; | ||
} | ||
|
||
/** Public interface for sending reply. */ | ||
@SuppressWarnings("UnknownNullness") | ||
public interface Reply<T> { | ||
void reply(T reply); | ||
} | ||
/** The codec used by JavaObjectFlutterApi. */ | ||
static @NonNull MessageCodec<Object> getCodec() { | ||
return new StandardMessageCodec(); | ||
} | ||
public void dispose(@NonNull String identifierArg, @NonNull Reply<Void> callback) { | ||
BasicMessageChannel<Object> channel = | ||
new BasicMessageChannel<>( | ||
binaryMessenger, "dev.flutter.pigeon.flutter_instance_manager.JavaObjectFlutterApi.dispose", getCodec()); | ||
channel.send( | ||
new ArrayList<Object>(Collections.singletonList(identifierArg)), | ||
channelReply -> callback.reply(null)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
android/src/main/java/com/baseflow/instancemanager/JavaObjectHostApiImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// 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. | ||
|
||
package com.baseflow.instancemanager; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.baseflow.instancemanager.AndroidInstanceManagerPigeon.JavaObjectHostApi; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* A pigeon Host API implementation that handles creating {@link Object}s and invoking its static | ||
* and instance methods. | ||
* | ||
* <p>{@link Object} instances created by {@link JavaObjectHostApiImpl} are used to intercommunicate | ||
* with a paired Dart object. | ||
*/ | ||
public class JavaObjectHostApiImpl implements JavaObjectHostApi { | ||
private final InstanceManager instanceManager; | ||
|
||
/** | ||
* Constructs a {@link JavaObjectHostApiImpl}. | ||
* | ||
* @param instanceManager maintains instances stored to communicate with Dart objects | ||
*/ | ||
public JavaObjectHostApiImpl(@NonNull InstanceManager instanceManager) { | ||
this.instanceManager = instanceManager; | ||
} | ||
|
||
@Override | ||
public void dispose(@NonNull String identifier) { | ||
instanceManager.remove(UUID.fromString(identifier)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.