Format code

This commit is contained in:
Ming Ming 2023-08-04 01:25:47 +08:00
parent 88cda20582
commit 924a7c9105
2 changed files with 20 additions and 12 deletions

View file

@ -6,7 +6,11 @@ import android.os.Bundle
import androidx.annotation.NonNull import androidx.annotation.NonNull
import com.google.android.gms.maps.MapsInitializer import com.google.android.gms.maps.MapsInitializer
import com.google.android.gms.maps.OnMapsSdkInitializedCallback import com.google.android.gms.maps.OnMapsSdkInitializedCallback
import com.nkming.nc_photos.plugin.* import com.nkming.nc_photos.plugin.NcPhotosPlugin
import com.nkming.nc_photos.plugin.UriUtil
import com.nkming.nc_photos.plugin.logD
import com.nkming.nc_photos.plugin.logE
import com.nkming.nc_photos.plugin.logI
import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.EventChannel import io.flutter.plugin.common.EventChannel
@ -61,14 +65,18 @@ class MainActivity : FlutterActivity(), MethodChannel.MethodCallHandler,
} }
override fun onNewIntent(intent: Intent) { override fun onNewIntent(intent: Intent) {
if (intent.action == NcPhotosPlugin.ACTION_SHOW_IMAGE_PROCESSOR_RESULT) { when (intent.action) {
NcPhotosPlugin.ACTION_SHOW_IMAGE_PROCESSOR_RESULT -> {
val route = getRouteFromImageProcessorResult(intent) ?: return val route = getRouteFromImageProcessorResult(intent) ?: return
logI(TAG, "Navigate to route: $route") logI(TAG, "Navigate to route: $route")
flutterEngine?.navigationChannel?.pushRoute(route) flutterEngine?.navigationChannel?.pushRoute(route)
} else { }
else -> {
super.onNewIntent(intent) super.onNewIntent(intent)
} }
} }
}
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) { override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
when (call.method) { when (call.method) {
@ -91,6 +99,7 @@ class MainActivity : FlutterActivity(), MethodChannel.MethodCallHandler,
logD(TAG, "Using new map renderer") logD(TAG, "Using new map renderer")
true true
} }
MapsInitializer.Renderer.LEGACY -> { MapsInitializer.Renderer.LEGACY -> {
logD(TAG, "Using legacy map renderer") logD(TAG, "Using legacy map renderer")
false false
@ -99,8 +108,7 @@ class MainActivity : FlutterActivity(), MethodChannel.MethodCallHandler,
} }
private fun getRouteFromImageProcessorResult(intent: Intent): String? { private fun getRouteFromImageProcessorResult(intent: Intent): String? {
val resultUri = val resultUri = intent.getParcelableExtra<Uri>(
intent.getParcelableExtra<Uri>(
NcPhotosPlugin.EXTRA_IMAGE_RESULT_URI NcPhotosPlugin.EXTRA_IMAGE_RESULT_URI
) )
if (resultUri == null) { if (resultUri == null) {