package android.app.src.main.kotlin.com.hongyegroup.app24ifm;

import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

//import androidx.core.splashscreen.SplashScreen;

import io.flutter.embedding.android.FlutterActivity;
import io.flutter.embedding.android.FlutterFragmentActivity;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.plugin.common.MethodChannel;
import android.os.Build;

public class MainActivity extends FlutterFragmentActivity {

//    private SplashScreen mSplashScreen;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
//        mSplashScreen = SplashScreen.installSplashScreen(this);
//        mSplashScreen.setKeepOnScreenCondition(() -> true);

        super.onCreate(savedInstanceState);
    }

    @Override
    public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
        super.configureFlutterEngine(flutterEngine);

        MethodChannel methodChannel = new MethodChannel(flutterEngine.getDartExecutor(), "com.room/opapp");

        methodChannel.setMethodCallHandler((call, result) -> {
            //返回安卓版本
           if (call.method.equals("getAndroidSdkInt")) {
               result.success(Build.VERSION.SDK_INT);

            } else if (call.method.equals("getNativeRouterName")) {
                // 获取当前需要跳转的子路由
                Log.d("MainActivity", "执行 methodChannel -> getNativeRouterName");
//                result.success(RouterActivity.ROUTER_NAME);
                result.success("");

            } else if (call.method.equals("clearNativeRouterName")) {
                // 清除当前需要跳转的子路由
                Log.d("MainActivity", "执行 methodChannel -> clearNativeRouterName");
//                RouterActivity.ROUTER_NAME = "";
                result.success(true);
            } else if (call.method.equals("appleLogin")) {
                // 苹果登录-Android空实现
                result.success(null);
            } else if (call.method.equals("skipAndroidSplashScreen")) {
                // 跳过Android的SplashScreen
                Log.d("MainActivity", "执行 methodChannel -> skipAndroidSplashScreen");
//                if (mSplashScreen != null) {
//                    mSplashScreen.setKeepOnScreenCondition(() -> false);
//                }
                result.success(true);
            } else {
                result.notImplemented();
            }
        });

    }

}
