Skip to content

Commit

Permalink
修复因为format导致的闪退
Browse files Browse the repository at this point in the history
  • Loading branch information
beautifulSoup committed Aug 19, 2017
1 parent ec51b4c commit aedee26
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' // Add this line

Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Thu Dec 29 09:49:10 CST 2016
#Fri Jun 23 10:54:06 CST 2017

4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Mar 01 17:05:50 CST 2017
#Fri Jun 23 10:58:51 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
2 changes: 1 addition & 1 deletion router/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ group='com.github.campusappcn'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion '25.0.0'



Expand Down
18 changes: 15 additions & 3 deletions router/src/main/java/cn/campusapp/router/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ public static synchronized void initActivityRouter(Context context, String ... s
}

public static boolean open(String url, Object ... params){
String temp = String.format(Locale.ENGLISH, url, params);
String temp = formatUrl(url, params);
return RouterManager.getSingleton().open(temp);
}

public static boolean open(Context context, String url, Object ... params){
String temp = String.format(Locale.ENGLISH, url, params);
String temp = formatUrl(url, params);
return RouterManager.getSingleton().open(context, temp);
}

Expand All @@ -78,7 +78,7 @@ public static void setDebugMode(boolean debug){
* @return
*/
public static IRoute getRoute(String url, Object ... params){
String temp = String.format(Locale.ENGLISH, url, params);
String temp = formatUrl(url, params);
return RouterManager.getSingleton().getRoute(temp);
}

Expand All @@ -95,4 +95,16 @@ public static void setInterceptor(Interceptor interceptor){
RouterManager.getSingleton().setInterceptor(interceptor);
}

private static String formatUrl(String url, Object ... params) {
String formatted = url;
try {
formatted = String.format(Locale.ENGLISH, url, params);
} catch (Exception e) {
Timber.e("ops", e);
}

return formatted;

}

}
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
buildToolsVersion '25.0.0'

defaultConfig {
applicationId "cn.campusapp.router.sample"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void onClick(View v) {
btn9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Router.open(MainActivity.this, "http://www.souhu.com");
Router.open(MainActivity.this, "https://yue.laobai.com/react/search/?q=%E9%A1%BA%E4%B8%B0%E4%BC%98%E9%80%89");
}
});

Expand Down

0 comments on commit aedee26

Please sign in to comment.