Format all kotlin according to ktlint (#143390)
Entire pr generated with [ktlint](https://github.com/pinterest/ktlint) --format. First step before enabling linting as part of presubmit for kotlin changes.
This commit is contained in:
@@ -4,18 +4,13 @@
|
||||
|
||||
package dev.flutter.multipleflutters
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import io.flutter.FlutterInjector
|
||||
import io.flutter.embedding.android.FlutterFragment
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.embedding.engine.FlutterEngineCache
|
||||
import io.flutter.embedding.engine.dart.DartExecutor
|
||||
|
||||
@@ -25,10 +20,11 @@ class MainActivity : FragmentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val root = LinearLayout(this)
|
||||
root.layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
root.layoutParams =
|
||||
LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
)
|
||||
root.orientation = LinearLayout.VERTICAL
|
||||
root.weightSum = numberOfFlutters.toFloat()
|
||||
|
||||
@@ -39,21 +35,24 @@ class MainActivity : FragmentActivity() {
|
||||
val app = applicationContext as App
|
||||
val dartEntrypoint =
|
||||
DartExecutor.DartEntrypoint(
|
||||
FlutterInjector.instance().flutterLoader().findAppBundlePath(), "main"
|
||||
FlutterInjector.instance().flutterLoader().findAppBundlePath(),
|
||||
"main",
|
||||
)
|
||||
val engines = generateSequence(0) { it + 1 }
|
||||
.take(numberOfFlutters)
|
||||
.map { app.engines.createAndRunEngine(this, dartEntrypoint) }
|
||||
.toList()
|
||||
val engines =
|
||||
generateSequence(0) { it + 1 }
|
||||
.take(numberOfFlutters)
|
||||
.map { app.engines.createAndRunEngine(this, dartEntrypoint) }
|
||||
.toList()
|
||||
for (i in 0 until numberOfFlutters) {
|
||||
val flutterContainer = FrameLayout(this)
|
||||
root.addView(flutterContainer)
|
||||
flutterContainer.id = 12345 + i
|
||||
flutterContainer.layoutParams = LinearLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
1.0f
|
||||
)
|
||||
flutterContainer.layoutParams =
|
||||
LinearLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
1.0f,
|
||||
)
|
||||
val engine = engines[i]
|
||||
FlutterEngineCache.getInstance().put(i.toString(), engine)
|
||||
val flutterFragment =
|
||||
@@ -62,7 +61,7 @@ class MainActivity : FragmentActivity() {
|
||||
.beginTransaction()
|
||||
.add(
|
||||
12345 + i,
|
||||
flutterFragment
|
||||
flutterFragment,
|
||||
)
|
||||
.commit()
|
||||
}
|
||||
|
||||
@@ -11,28 +11,40 @@ import io.flutter.plugin.common.BinaryCodec
|
||||
import io.flutter.plugin.common.StandardMessageCodec
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
class MainActivity: FlutterActivity() {
|
||||
class MainActivity : FlutterActivity() {
|
||||
// We allow for the caching of a response in the binary channel case since
|
||||
// the reply requires a direct buffer, but the input is not a direct buffer.
|
||||
// We can't directly send the input back to the reply currently.
|
||||
private var byteBufferCache : ByteBuffer? = null
|
||||
private var byteBufferCache: ByteBuffer? = null
|
||||
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
val reset = BasicMessageChannel(flutterEngine.dartExecutor, "dev.flutter.echo.reset", StandardMessageCodec.INSTANCE)
|
||||
reset.setMessageHandler { message, reply -> run {
|
||||
byteBufferCache = null
|
||||
} }
|
||||
val basicStandard = BasicMessageChannel(flutterEngine.dartExecutor, "dev.flutter.echo.basic.standard", StandardMessageCodec.INSTANCE)
|
||||
reset.setMessageHandler { message, reply ->
|
||||
run {
|
||||
byteBufferCache = null
|
||||
}
|
||||
}
|
||||
val basicStandard =
|
||||
BasicMessageChannel(flutterEngine.dartExecutor, "dev.flutter.echo.basic.standard", StandardMessageCodec.INSTANCE)
|
||||
basicStandard.setMessageHandler { message, reply -> reply.reply(message) }
|
||||
val basicBinary = BasicMessageChannel(flutterEngine.dartExecutor, "dev.flutter.echo.basic.binary", BinaryCodec.INSTANCE_DIRECT)
|
||||
basicBinary.setMessageHandler { message, reply -> run {
|
||||
if (byteBufferCache == null) {
|
||||
byteBufferCache = ByteBuffer.allocateDirect(message!!.capacity())
|
||||
byteBufferCache!!.put(message)
|
||||
basicBinary.setMessageHandler { message, reply ->
|
||||
run {
|
||||
if (byteBufferCache == null) {
|
||||
byteBufferCache = ByteBuffer.allocateDirect(message!!.capacity())
|
||||
byteBufferCache!!.put(message)
|
||||
}
|
||||
reply.reply(byteBufferCache)
|
||||
}
|
||||
reply.reply(byteBufferCache)
|
||||
} }
|
||||
val taskQueue = flutterEngine.dartExecutor.getBinaryMessenger().makeBackgroundTaskQueue();
|
||||
val backgroundStandard = BasicMessageChannel(flutterEngine.dartExecutor, "dev.flutter.echo.background.standard", StandardMessageCodec.INSTANCE, taskQueue)
|
||||
}
|
||||
val taskQueue = flutterEngine.dartExecutor.getBinaryMessenger().makeBackgroundTaskQueue()
|
||||
val backgroundStandard =
|
||||
BasicMessageChannel(
|
||||
flutterEngine.dartExecutor,
|
||||
"dev.flutter.echo.background.standard",
|
||||
StandardMessageCodec.INSTANCE,
|
||||
taskQueue,
|
||||
)
|
||||
backgroundStandard.setMessageHandler { message, reply -> reply.reply(message) }
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user