5package io.flutter.embedding.engine.systemchannels;
7import android.annotation.TargetApi;
9import androidx.annotation.NonNull;
10import androidx.annotation.Nullable;
11import androidx.annotation.RequiresApi;
12import io.flutter.Build.API_LEVELS;
14import io.flutter.embedding.engine.dart.DartExecutor;
15import io.flutter.plugin.common.MethodCall;
16import io.flutter.plugin.common.MethodChannel;
17import io.flutter.plugin.common.StandardMethodCodec;
18import java.util.Arrays;
19import java.util.HashMap;
30 private static final String TAG =
"BackGestureChannel";
48 private final MethodChannel.MethodCallHandler defaultHandler =
63 @TargetApi(API_LEVELS.API_34)
64 @RequiresApi(API_LEVELS.API_34)
66 Log.
v(
TAG,
"Sending message to start back gesture");
80 Log.
v(
TAG,
"Sending message to update back gesture progress");
93 Log.
v(
TAG,
"Sending message to commit back gesture");
105 Log.
v(
TAG,
"Sending message to cancel back gesture");
120 private Map<String, Object> backEventToJsonMap(@NonNull BackEvent backEvent) {
121 Map<String, Object>
message =
new HashMap<>(3);
122 final float x = backEvent.getTouchX();
123 final float y = backEvent.getTouchY();
124 final Object touchOffset = (Float.isNaN(
x) || Float.isNaN(
y)) ?
null : Arrays.asList(
x,
y);
125 message.put(
"touchOffset", touchOffset);
126 message.put(
"progress", backEvent.getProgress());
127 message.put(
"swipeEdge", backEvent.getSwipeEdge());
static void v(@NonNull String tag, @NonNull String message)
final MethodChannel channel
BackGestureChannel(@NonNull DartExecutor dartExecutor)
void updateBackGestureProgress(@NonNull BackEvent backEvent)
void startBackGesture(@NonNull BackEvent backEvent)
void setMethodCallHandler(@Nullable MethodChannel.MethodCallHandler handler)
void setMethodCallHandler(final @Nullable MethodCallHandler handler)
void invokeMethod(@NonNull String method, @Nullable Object arguments)
static final StandardMethodCodec INSTANCE