有没有办法禁用警告
Jack需要支持java 8语言功能.
使用Retrolambda时?
我现在不想要杰克支持,因为它还没有编译我们的项目.
有没有办法反序列化json使用
sealed class Layer
data class ShapeLayer(var type: LayerType) : Layer
data class TextLayer(var type: LayerType) : Layer
data class ImageLayer(var type: LayerType) : Layer
Run Code Online (Sandbox Code Playgroud)
LayerType只是一些枚举,可用于区分此对象应具有的类型.
我以为我可以这样添加适配器:
class LayerAdapter{
@FromJson
fun fromJson(layerJson: LayerJson): Layer {
return when (layerJson.layerType) {
LayerType.SHAPE -> PreCompLayer()
LayerType.SOLID -> SolidLayer()
LayerType.Text -> TextLayer()
}
}
}
Run Code Online (Sandbox Code Playgroud)
其中LayerJson将是具有所有LayerTypes的所有可能字段的对象.
现在的问题是:
无法序列化抽象类com.example.models.layers.Layer
我可以尝试使用接口,但我不认为在这里使用空接口是正确的.
我正在使用 JetPack Compose 和可组合 NavHost。
我有一个场景,我需要一个连接蓝牙设备的启动屏幕,因此我将其设置为 NavHost 中的起始路线。
连接完成后,我想进入主屏幕,并且永远不会返回到启动屏幕。
因此,连接完成后启动屏幕我正在这样做:
navController.graph.setStartDestination(newHomeRoute)
navController.navigate(newHomeRoute) {
popUpTo(0)
launchSingleTop = true
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为我不断循环返回到 LaunchScreen 并前进到 Home。
那么也许我应该以其他方式做到这一点?
我找不到答案。我的应用程序需要定义参数--dart-define=ENVIRONMENT="$APP_ENV"
构建Android没有问题,但是如何在fastlane中构建ad-hoc时通过这些?我准备了运行的构建脚本:
flutter pub get
flutter build ios --config-only \
--flavor prod \
--dart-define=ENVIRONMENT="$APP_ENV"
cd ios
bundle exec fastlane build_app_prod_ad_hoc
Run Code Online (Sandbox Code Playgroud)
我的 fastlane 车道是:
lane :build_app_prod_ad_hoc do
cocoapods
gym(
configuration: "AdHoc-prod",
export_method: "ad-hoc",
scheme: "prod",
export_options: {
provisioningProfiles: {
...
},
},
)
end
Run Code Online (Sandbox Code Playgroud)
但是我可以看到我的结果没有正确设置环境。有任何想法吗?
我正在尝试使用最新版本的软件包启动新的 Firebase Functions 项目。
\n\n我已按照本教程进行操作https://youtu.be/DYfP-UIKxH0进行操作:
\n\nStarting @google-cloud/functions-emulator\n[2018-04-04T19:05:12.124Z] Parsing function triggers\n[2018-04-04T19:05:12.404Z] Error while deploying to emulator: TypeError: Cannot read property \'call\' of undefined\nTypeError: Cannot read property \'call\' of undefined\n at Promise (/usr/local/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:34:42)\n at getService.then (/usr/local/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:33:16)\n at process._tickDomainCallback (internal/process/next_tick.js:135:7)\n\xe2\x9a\xa0 functions: Failed to emulate helloWorld
我有最新的功能模拟器 *1.0.0-beta4。\n所有其他库都是最新版本...
\n\n我现在不知道如何更好地调试这个问题以及如何解决这个问题
\n我的用例比较复杂,但要保持简单:
class MockObject {
public function test($param1, callable $callback = null) {
return is_null($callback) ? $param1 : $callback($param1);
}
}
Run Code Online (Sandbox Code Playgroud)
我想使用returnMap为其他测试模拟该类。
$map = [
['a', null, 'a'],
['b', $WHAT_SHOULD_BE_HERE?, 'b']
];
$mock = $this->getMock('MockObject');
$mock->expects($this->atLeastOnce())->method('test')->willReturnMap($map);
$this->assertEquals('a', $mock->test('a')); // Works
$this->assertEquals('b', $mock->test('b', function($value){return $value})); // Doesn't work
Run Code Online (Sandbox Code Playgroud)