Skip to content

Commit 91ffbdd

Browse files
committed
chore(share_plus): melos run format for ONLY share_plus
melos run format caused changes throughout the monorepo. This commit includes only those formatting changes within the share_plus folder.
1 parent a0cd910 commit 91ffbdd

10 files changed

Lines changed: 468 additions & 487 deletions

File tree

‎packages/share_plus/share_plus/android/src/main/kotlin/dev/fluttercommunity/plus/share/MethodCallHandler.kt‎

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,45 @@ import android.os.Build
44
import io.flutter.plugin.common.MethodCall
55
import io.flutter.plugin.common.MethodChannel
66

7-
/** Handles the method calls for the plugin. */
7+
/** Handles the method calls for the plugin. */
88
internal class MethodCallHandler(
99
private val share: Share,
1010
private val manager: ShareSuccessManager,
1111
) : MethodChannel.MethodCallHandler {
1212

13-
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
14-
expectMapArguments(call)
15-
16-
// We don't attempt to return a result if the current API version doesn't support it
17-
val isWithResult =
18-
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
19-
20-
if (isWithResult)
21-
manager.setCallback(result)
22-
23-
try {
24-
when (call.method) {
25-
"share" -> {
26-
share.share(
27-
arguments = call.arguments<Map<String, Any>>()!!,
28-
withResult = isWithResult,
29-
)
30-
success(isWithResult, result)
31-
}
32-
else -> result.notImplemented()
33-
}
34-
} catch (e: Throwable) {
35-
manager.clear()
36-
result.error("Share failed", e.message, e)
37-
}
38-
}
13+
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
14+
expectMapArguments(call)
15+
16+
// We don't attempt to return a result if the current API version doesn't support it
17+
val isWithResult = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1
3918

40-
private fun success(
41-
isWithResult: Boolean,
42-
result: MethodChannel.Result
43-
) {
44-
if (!isWithResult) {
45-
result.success("dev.fluttercommunity.plus/share/unavailable")
19+
if (isWithResult) manager.setCallback(result)
20+
21+
try {
22+
when (call.method) {
23+
"share" -> {
24+
share.share(
25+
arguments = call.arguments<Map<String, Any>>()!!,
26+
withResult = isWithResult,
27+
)
28+
success(isWithResult, result)
4629
}
30+
else -> result.notImplemented()
31+
}
32+
} catch (e: Throwable) {
33+
manager.clear()
34+
result.error("Share failed", e.message, e)
4735
}
36+
}
4837

49-
@Throws(IllegalArgumentException::class)
50-
private fun expectMapArguments(call: MethodCall) {
51-
require(call.arguments is Map<*, *>) { "Map arguments expected" }
38+
private fun success(isWithResult: Boolean, result: MethodChannel.Result) {
39+
if (!isWithResult) {
40+
result.success("dev.fluttercommunity.plus/share/unavailable")
5241
}
42+
}
43+
44+
@Throws(IllegalArgumentException::class)
45+
private fun expectMapArguments(call: MethodCall) {
46+
require(call.arguments is Map<*, *>) { "Map arguments expected" }
47+
}
5348
}

0 commit comments

Comments
 (0)