Commit c97512be authored by 李增强's avatar 李增强

m

parent fd4f72d4
......@@ -49,5 +49,6 @@ android {
dependencies{
//implementation files('src/libs/jdmasdk.jar')
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation files('src/libs/JDSDK_h.jar')
implementation files('src/libs/cps_1.0.0.jar')
}
......@@ -7,7 +7,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.jd.kepler.res.ApkResources;
//import com.jd.kepler.res.ApkResources;
import com.kepler.jd.Listener.AsyncInitListener;
import com.kepler.jd.Listener.OpenAppAction;
import com.kepler.jd.login.KeplerApiManager;
......@@ -27,18 +27,16 @@ public class JDHelper {
private static JDHelper jdHelper;
private PluginRegistry.Registrar register;
private ActivityPluginBinding binding;
Activity activity;
KelperTask mKelperTask;
Handler mHandler = new Handler();
KeplerAttachParameter mKeplerAttachParameter = new KeplerAttachParameter();//这个是即时性参数 可以设置
LoadingDialog dialog;
private Activity getActivity(){
if(null != register){
private Activity getActivity() {
if (null != register) {
return register.activity();
}else if(null != binding){
} else if (null != binding) {
return binding.getActivity();
}
return null;
......@@ -47,27 +45,15 @@ public class JDHelper {
OpenAppAction mOpenAppAction = new OpenAppAction() {
@Override
public void onStatus(final int status, final String url) {
public void onStatus(final int status) {
mHandler.post(new Runnable() {
@Override
public void run() {
if (status == OpenAppAction.OpenAppAction_start) {//开始状态未必一定执行,
dialogShow();
}else {
mKelperTask = null;
} else {
dialogDiss();
}
if(status == OpenAppAction.OpenAppAction_result_NoJDAPP) {
// Toast.makeText(getActivity(), "您未安装京东app,你可以手动打开以下链接地址:"+url+" ,code="+status, Toast.LENGTH_SHORT).show();
}else if(status == OpenAppAction.OpenAppAction_result_BlackUrl){
// Toast.makeText(getActivity(), "url不在白名单,你可以手动打开以下链接地址:"+url+" ,code="+status, Toast.LENGTH_SHORT).show();
}else if(status == OpenAppAction.OpenAppAction_result_ErrorScheme){
// Toast.makeText(getActivity(), "呼起协议异常"+" ,code="+status, Toast.LENGTH_SHORT).show();
}else if(status == OpenAppAction.OpenAppAction_result_APP){
}else if(status == OpenAppAction.OpenAppAction_result_NetError){
// Toast.makeText(getActivity(), ApkResources.getSingleton().getString("kepler_check_net")+" ,code="+status+" ,url="+url,Toast.LENGTH_SHORT).show();
}
}
});
}
......@@ -76,31 +62,24 @@ public class JDHelper {
private void dialogShow() {
if (dialog == null) {
dialog = new LoadingDialog(getActivity());
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
if (mKelperTask != null) {//取消
mKelperTask.setCancel(true);
}
}
});
}
dialog.show();
}
private void dialogDiss() {
if(dialog!=null)
if (dialog != null)
dialog.dismiss();
}
//第一次调用getInstance register不能为空
public static JDHelper getInstance(PluginRegistry.Registrar register){
if (jdHelper == null){
synchronized (JDHelper.class){
public static JDHelper getInstance(PluginRegistry.Registrar register) {
if (jdHelper == null) {
synchronized (JDHelper.class) {
jdHelper = new JDHelper();
if(null != register){
if (null != register) {
jdHelper.register = register;
}
}
......@@ -109,11 +88,11 @@ public class JDHelper {
}
//第一次调用getInstance register不能为空
public static JDHelper getInstance(ActivityPluginBinding binding){
if (jdHelper == null){
synchronized (JDHelper.class){
public static JDHelper getInstance(ActivityPluginBinding binding) {
if (jdHelper == null) {
synchronized (JDHelper.class) {
jdHelper = new JDHelper();
if(null != binding){
if (null != binding) {
jdHelper.binding = binding;
}
}
......@@ -122,17 +101,16 @@ public class JDHelper {
}
/**
* 初始化开普勒
*
* @param call
* @param result
*/
public void initKepler(MethodCall call, MethodChannel.Result result){
public void initKepler(MethodCall call, MethodChannel.Result result) {
String appKey = call.argument("appKey");
String appSecret = call.argument("appSecret");
Log.d("flutter-taoke","initKepler"+getActivity());
Log.d("flutter-taoke", "initKepler" + getActivity());
KeplerApiManager.asyncInitSdk(getActivity().getApplication(), appKey, appSecret, new AsyncInitListener() {
@Override
public void onSuccess() {
......@@ -151,18 +129,21 @@ public class JDHelper {
/**
* 通过URL方式打开
*
* @param call
* @param result
*/
public void openUrl(MethodCall call, MethodChannel.Result result){
public void openUrl(MethodCall call, MethodChannel.Result result) {
String url = call.argument("url");
if(TextUtils.isEmpty(url)){
if (TextUtils.isEmpty(url)) {
return;
}
mKelperTask = KeplerApiManager.getWebViewService().openAppWebViewPage(getActivity(),
url,
mKeplerAttachParameter,
mOpenAppAction);
// mKelperTask = KeplerApiManager.getWebViewService().openAppWebViewPage(getActivity(),
// url,
// mKeplerAttachParameter,
// mOpenAppAction);
KeplerApiManager.getWebViewService().openJDUrlWebViewPage( url,
mKeplerAttachParameter);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment