|
|
@@ -25,6 +25,7 @@ import com.alibaba.baichuan.android.trade.AlibcTradeSDK; |
|
|
|
import com.alibaba.baichuan.android.trade.callback.AlibcTradeInitCallback; |
|
|
|
import com.alibaba.baichuan.trade.common.utils.AlibcLogger; |
|
|
|
|
|
|
|
import io.flutter.plugin.common.PluginRegistry; |
|
|
|
import io.flutter.plugin.common.PluginRegistry.Registrar; |
|
|
|
import io.flutter.plugin.common.MethodChannel.Result; |
|
|
|
import io.flutter.plugin.common.MethodCall; |
|
|
@@ -49,14 +50,16 @@ public class FlutterAlibcHandle { |
|
|
|
|
|
|
|
private static FlutterAlibcHandle handle; |
|
|
|
private static Registrar register; |
|
|
|
private static boolean isFirst = true; |
|
|
|
private static Result result; |
|
|
|
|
|
|
|
//第一次调用getInstance register不能为空 |
|
|
|
public static FlutterAlibcHandle getInstance(Registrar register) { |
|
|
|
|
|
|
|
synchronized (FlutterAlibcHandle.class) { |
|
|
|
handle = new FlutterAlibcHandle(); |
|
|
|
FlutterAlibcHandle.register = register; |
|
|
|
} |
|
|
|
synchronized (FlutterAlibcHandle.class) { |
|
|
|
handle = new FlutterAlibcHandle(); |
|
|
|
FlutterAlibcHandle.register = register; |
|
|
|
} |
|
|
|
return handle; |
|
|
|
} |
|
|
|
|
|
|
@@ -169,6 +172,7 @@ public class FlutterAlibcHandle { |
|
|
|
intent.putExtra("url", url); |
|
|
|
intent.putExtra("arguments", map); |
|
|
|
register.activity().startActivity(intent); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -180,12 +184,35 @@ public class FlutterAlibcHandle { |
|
|
|
public void openByUrl(MethodCall call, Result result) { |
|
|
|
AlibcShowParams showParams = new AlibcShowParams(); |
|
|
|
AlibcTaokeParams taokeParams = new AlibcTaokeParams("", "", ""); |
|
|
|
|
|
|
|
FlutterAlibcHandle.result=result; |
|
|
|
showParams.setBackUrl(call.argument(key_BackUrl)); |
|
|
|
|
|
|
|
///渠道授权 |
|
|
|
if ((Boolean) call.argument(login_And_Auth)) { |
|
|
|
///先APP授权 |
|
|
|
if(isFirst){ |
|
|
|
isFirst=false; |
|
|
|
register.addActivityResultListener(new PluginRegistry.ActivityResultListener() { |
|
|
|
@Override |
|
|
|
public boolean onActivityResult(int requestCode, int resultCode, Intent data) { |
|
|
|
if (FlutterAlibcHandle.result == null) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
if (requestCode == 1111) { |
|
|
|
if (resultCode == 222222) { |
|
|
|
FlutterAlibcHandle.result.success(true); |
|
|
|
} else if (resultCode == 111111) { |
|
|
|
FlutterAlibcHandle.result.success(false); |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} else { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
if (!AlibcLogin.getInstance().isLogin()) { |
|
|
|
|
|
|
@@ -195,7 +222,8 @@ public class FlutterAlibcHandle { |
|
|
|
Log.d("阿里百川打开WebView", "webview"); |
|
|
|
Intent intent = new Intent(register.context(), WebActivity.class); |
|
|
|
intent.putExtra("url", (String) call.argument("url")); |
|
|
|
register.activity().startActivity(intent); |
|
|
|
register.activity().startActivityForResult(intent, 1111); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@@ -207,7 +235,7 @@ public class FlutterAlibcHandle { |
|
|
|
Log.d("阿里百川打开WebView", "webview"); |
|
|
|
Intent intent = new Intent(register.context(), WebActivity.class); |
|
|
|
intent.putExtra("url", (String) call.argument("url")); |
|
|
|
register.activity().startActivity(intent); |
|
|
|
register.activity().startActivityForResult(intent, 1111); |
|
|
|
} |
|
|
|
///后渠道信息 |
|
|
|
return; |
|
|
|