|
|
@ -44,6 +44,8 @@ public class DeepLinkCore { |
|
|
|
|
|
|
|
|
|
|
|
private String pendingURL; |
|
|
|
private String pendingURL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final List<DeepLinkPrepare> deepLinkPrepareList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
private final List<DeepLink> deepLinkList = new ArrayList<>(); |
|
|
|
private final List<DeepLink> deepLinkList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
private boolean isDesignerStartupCompleted = false; |
|
|
|
private boolean isDesignerStartupCompleted = false; |
|
|
@ -51,6 +53,9 @@ public class DeepLinkCore { |
|
|
|
public void register(DeepLink deepLink) { |
|
|
|
public void register(DeepLink deepLink) { |
|
|
|
if (deepLink != null) { |
|
|
|
if (deepLink != null) { |
|
|
|
deepLinkList.add(deepLink); |
|
|
|
deepLinkList.add(deepLink); |
|
|
|
|
|
|
|
if (deepLink instanceof DeepLinkPrepare) { |
|
|
|
|
|
|
|
deepLinkPrepareList.add((DeepLinkPrepare) deepLink); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -129,6 +134,11 @@ public class DeepLinkCore { |
|
|
|
|
|
|
|
|
|
|
|
private void acceptNewURL(String url) { |
|
|
|
private void acceptNewURL(String url) { |
|
|
|
this.pendingURL = url; |
|
|
|
this.pendingURL = url; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UrlBean urlBean = UrlBean.create(this.pendingURL); |
|
|
|
|
|
|
|
for (DeepLinkPrepare deepLinkPrepare : deepLinkPrepareList) { |
|
|
|
|
|
|
|
deepLinkPrepare.prepare(urlBean.getUrl(), urlBean.getHost(), urlBean.getPath(), urlBean.getParams()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean canConsumePendingURL() { |
|
|
|
private boolean canConsumePendingURL() { |
|
|
@ -148,32 +158,11 @@ public class DeepLinkCore { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void consumePendingURL() { |
|
|
|
private void consumePendingURL() { |
|
|
|
String host = null; |
|
|
|
|
|
|
|
String path = null; |
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
URL url = null; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
url = new URL(null, this.pendingURL, new URLStreamHandler() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected URLConnection openConnection(URL u) throws IOException { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (MalformedURLException ignored) {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (url != null) { |
|
|
|
|
|
|
|
host = url.getHost(); |
|
|
|
|
|
|
|
path = url.getPath(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<NameValuePair> pairs = URLUtils.parse(url.getQuery()); |
|
|
|
UrlBean urlBean = UrlBean.create(this.pendingURL); |
|
|
|
for (NameValuePair pair: pairs) { |
|
|
|
|
|
|
|
params.put(pair.getName(), pair.getValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().info("consume deep link: " + this.pendingURL); |
|
|
|
FineLoggerFactory.getLogger().info("consume deep link: " + this.pendingURL); |
|
|
|
performDeepLinks(this.pendingURL, host, path, params); |
|
|
|
performDeepLinks(urlBean.getUrl(), urlBean.getHost(), urlBean.getPath(), urlBean.getParams()); |
|
|
|
|
|
|
|
|
|
|
|
markPendingURLConsumed(); |
|
|
|
markPendingURLConsumed(); |
|
|
|
} |
|
|
|
} |
|
|
@ -194,4 +183,67 @@ public class DeepLinkCore { |
|
|
|
private void markPendingURLConsumed() { |
|
|
|
private void markPendingURLConsumed() { |
|
|
|
this.pendingURL = null; |
|
|
|
this.pendingURL = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class UrlBean { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String url; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String host; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String path; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> params; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UrlBean(String url, String host, String path, Map<String, Object> params) { |
|
|
|
|
|
|
|
this.url = url; |
|
|
|
|
|
|
|
this.host = host; |
|
|
|
|
|
|
|
this.path = path; |
|
|
|
|
|
|
|
this.params = params; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getUrl() { |
|
|
|
|
|
|
|
return url; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getHost() { |
|
|
|
|
|
|
|
return host; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getPath() { |
|
|
|
|
|
|
|
return path; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String, Object> getParams() { |
|
|
|
|
|
|
|
return params; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static UrlBean create(String pendingUrl) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String host = null; |
|
|
|
|
|
|
|
String path = null; |
|
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
URL url = null; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
url = new URL(null, pendingUrl, new URLStreamHandler() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected URLConnection openConnection(URL u) throws IOException { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} catch (MalformedURLException ignored) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (url != null) { |
|
|
|
|
|
|
|
host = url.getHost(); |
|
|
|
|
|
|
|
path = url.getPath(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<NameValuePair> pairs = URLUtils.parse(url.getQuery()); |
|
|
|
|
|
|
|
for (NameValuePair pair : pairs) { |
|
|
|
|
|
|
|
params.put(pair.getName(), pair.getValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new UrlBean(pendingUrl, host, path, params); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|