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