Commit f6567808 authored by Jidong Chen's avatar Jidong Chen

1,delete unnecessary ”query“.

2,Add map params.
parent cd39f6ab
...@@ -149,7 +149,7 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl ...@@ -149,7 +149,7 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
ctx = sInstance.mPlatform.getApplication(); ctx = sInstance.mPlatform.getApplication();
} }
sInstance.mPlatform.startActivity(ctx, concatUrl(url, params), requestCode); sInstance.mPlatform.startActivity(ctx, url ,params, requestCode);
} }
public static void openPage(Context context, String url, final Map params, int requestCode,PageResultHandler handler) { public static void openPage(Context context, String url, final Map params, int requestCode,PageResultHandler handler) {
...@@ -193,29 +193,7 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl ...@@ -193,29 +193,7 @@ public class FlutterBoostPlugin implements MethodChannel.MethodCallHandler, Appl
sInstance.mMediator.removeHandler(key); sInstance.mMediator.removeHandler(key);
} }
private static String concatUrl(String url, Map params) {
if (params == null || params.isEmpty()) return url;
Uri uri = Uri.parse(url);
Uri.Builder builder = uri.buildUpon();
for (Object key : params.keySet()) {
Object value = params.get(key);
if (value != null) {
String str;
if (value instanceof Map || value instanceof List) {
try {
str = URLEncoder.encode(JSON.toJSONString(value), "utf-8");
} catch (UnsupportedEncodingException e) {
str = value.toString();
}
} else {
str = value.toString();
}
builder.appendQueryParameter(String.valueOf(key), str);
}
}
return builder.build().toString();
}
@Override @Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) { public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
......
...@@ -38,10 +38,18 @@ ...@@ -38,10 +38,18 @@
private boolean onCall(MessageResult<Boolean> result,String pageName,Map params,Boolean animated){ private boolean onCall(MessageResult<Boolean> result,String pageName,Map params,Boolean animated){
int requestCode = 0;
if(params != null && params.get("requestCode") != null) {
requestCode = (int) params.get("requestCode");
}
FlutterBoostPlugin.openPage(null,pageName,params,0); FlutterBoostPlugin.openPage(null,pageName,params,0);
if(result != null){ if(result != null){
result.success(true); result.success(true);
} }
return true; return true;
} }
......
...@@ -59,7 +59,7 @@ public interface IPlatform { ...@@ -59,7 +59,7 @@ public interface IPlatform {
* @param requestCode * @param requestCode
* @return * @return
*/ */
boolean startActivity(Context context,String url,int requestCode); boolean startActivity(Context context,String url,Map params,int requestCode);
/** /**
......
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