Skip to content

Commit

Permalink
downgrade minSDK to 7 with UriCompact
Browse files Browse the repository at this point in the history
  • Loading branch information
mzule committed Jun 2, 2016
1 parent d459124 commit 26ccfa0
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ app project build.gradle
apply plugin: 'android-apt'
dependencies {
compile 'com.github.mzule.activityrouter:activityrouter:1.1.1'
compile 'com.github.mzule.activityrouter:activityrouter:1.1.2'
apt 'com.github.mzule.activityrouter:compiler:1.1.1'
}
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ buildscript {
apply plugin: 'android-apt'
dependencies {
compile 'com.github.mzule.activityrouter:activityrouter:1.1.1'
compile 'com.github.mzule.activityrouter:activityrouter:1.1.2'
apt 'com.github.mzule.activityrouter:compiler:1.1.1'
}
Expand Down
4 changes: 2 additions & 2 deletions activityrouter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ext {
siteUrl = 'https://github.com/mzule/ActivityRouter/'
gitUrl = 'https://github.com/mzule/ActivityRouter.git'

libraryVersion = '1.1.1'
libraryVersion = '1.1.2'

developerId = 'mzule'
developerName = 'Cao Dongping'
Expand All @@ -33,7 +33,7 @@ android {
buildToolsVersion "23.0.2"

defaultConfig {
minSdkVersion 11
minSdkVersion 7
targetSdkVersion 23
versionCode 1
versionName "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Bundle parseExtras(Uri uri) {
y = y.next();
}
// parameter
Set<String> names = uri.getQueryParameterNames();
Set<String> names = UriCompact.getQueryParameterNames(uri);
for (String name : names) {
String value = uri.getQueryParameter(name);
put(bundle, name, value);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.github.mzule.activityrouter.router;

import android.net.Uri;

import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;

/**
* Created by CaoDongping on 6/1/16.
*/
public class UriCompact {

/**
* Uri#getQueryParameterNames() 不支持 11 以下版本,这个方法提供兼容.
*
* @param uri Uri
* @return Set
*/
public static Set<String> getQueryParameterNames(Uri uri) {
String query = uri.getEncodedQuery();
if (query == null) {
return Collections.emptySet();
}

Set<String> names = new LinkedHashSet<String>();
int start = 0;
do {
int next = query.indexOf('&', start);
int end = (next == -1) ? query.length() : next;

int separator = query.indexOf('=', start);
if (separator > end || separator == -1) {
separator = end;
}

String name = query.substring(start, separator);
names.add(Uri.decode(name));
// Move start to end of name.
start = end + 1;
} while (start < query.length());

return Collections.unmodifiableSet(names);
}

}

0 comments on commit 26ccfa0

Please sign in to comment.