Skip to content

Commit

Permalink
Merge pull request #53 from chenenyu/dev
Browse files Browse the repository at this point in the history
1.2.6
  • Loading branch information
Half Stack committed Sep 30, 2017
2 parents 290b92c + fcc6c56 commit a12a1eb
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 29 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2017.09.30

`router: 1.2.6`:

1. Fix bug in `AbsImplicitMatcher`.
2. Add some api for Intent.

## 2017.09.12

`router-gradle-plugin: 1.2.5.1`:
Expand Down
7 changes: 4 additions & 3 deletions Sample/app/src/main/java/com/chenenyu/router/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.app.Application;

import com.chenenyu.router.AptHub;
import com.chenenyu.router.Router;

/**
Expand All @@ -17,12 +18,12 @@ public void onCreate() {
Router.setDebuggable(true);
}

// The next comment line show how to process aar module.
// AptHub.registerModules("your-aar-module-name");
// The next line shows how to process modules (e.g. aar modules).
AptHub.registerModules("module1", "module2");

// init
Router.initialize(this);

Router.addGlobalInterceptor(new GlobalInterceptor());
// Router.addGlobalInterceptor(new GlobalInterceptor());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class GlobalInterceptor implements RouteInterceptor {
@Override
public boolean intercept(Context context, RouteRequest routeRequest) {
Log.d("GlobalInterceptor", String.format("Intercepted: {uri: %s, interceptor: %s}",
Log.d("GlobalInterceptor", String.format("{uri: %s, interceptor: %s}",
routeRequest.getUri().toString(), GlobalInterceptor.class.getName()));
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions VERSION.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# router gradle plugin version
GRADLE_PLUGIN_VERSION=1.2.5.1
GRADLE_PLUGIN_VERSION=1.2.6
# router library version
ROUTER_VERSION=1.2.5
ROUTER_VERSION=1.2.6
# compiler library version
COMPILER_VERSION=1.2.5
COMPILER_VERSION=1.2.6
# annotation library version
ANNOTATION_VERSION=0.3.0
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 {
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta4'
classpath 'com.android.tools.build:gradle:3.0.0-beta6'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class RouterPlugin implements Plugin<Project> {
}
}
} else { // remote
String routerVersion = "1.2.5"
String compilerVersion = "1.2.5"
String routerVersion = "1.2.6"
String compilerVersion = "1.2.6"
// org.gradle.api.internal.plugins.DefaultExtraPropertiesExtension
ExtraPropertiesExtension ext = project.rootProject.ext
if (ext.has("routerVersion")) {
Expand Down
32 changes: 25 additions & 7 deletions router/src/main/java/com/chenenyu/router/AbsRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ public IRouter requestCode(int requestCode) {
return this;
}

@Override
@Deprecated
public IRouter extras(Bundle bundle) {
mRouteRequest.setExtras(bundle);
return this;
}

@Override
public IRouter with(Bundle bundle) {
if (bundle != null && !bundle.isEmpty()) {
Expand Down Expand Up @@ -174,6 +167,31 @@ public IRouter addFlags(int flags) {
return this;
}

@Override
public IRouter setData(Uri data) {
mRouteRequest.setData(data);
return this;
}

@Override
public IRouter setType(String type) {
mRouteRequest.setType(type);
return this;
}

@Override
public IRouter setDataAndType(Uri data, String type) {
mRouteRequest.setData(data);
mRouteRequest.setType(type);
return this;
}

@Override
public IRouter setAction(String action) {
mRouteRequest.setAction(action);
return this;
}

@Override
public IRouter anim(@AnimRes int enterAnim, @AnimRes int exitAnim) {
mRouteRequest.setEnterAnim(enterAnim);
Expand Down
26 changes: 20 additions & 6 deletions router/src/main/java/com/chenenyu/router/IRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ public interface IRouter {
*/
IRouter requestCode(int requestCode);

/**
* Deprecated. Use {@link #with(Bundle)} instead.
*/
@Deprecated
IRouter extras(Bundle bundle);

/**
* @see Bundle#putAll(Bundle)
*/
Expand All @@ -52,6 +46,26 @@ public interface IRouter {
*/
IRouter addFlags(int flags);

/**
* @see Intent#setData(Uri)
*/
IRouter setData(Uri data);

/**
* @see Intent#setType(String)
*/
IRouter setType(String type);

/**
* @see Intent#setDataAndType(Uri, String)
*/
IRouter setDataAndType(Uri data, String type);

/**
* @see Intent#setAction(String)
*/
IRouter setAction(String action);

/**
* @see android.app.Activity#overridePendingTransition(int, int)
*/
Expand Down
9 changes: 9 additions & 0 deletions router/src/main/java/com/chenenyu/router/RealRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@ private void assembleIntent(Intent intent) {
if (mRouteRequest.getFlags() != 0) {
intent.addFlags(mRouteRequest.getFlags());
}
if (mRouteRequest.getData() != null) {
intent.setData(mRouteRequest.getData());
}
if (mRouteRequest.getType() != null) {
intent.setType(mRouteRequest.getType());
}
if (mRouteRequest.getAction() != null) {
intent.setAction(mRouteRequest.getAction());
}
}

/**
Expand Down
27 changes: 27 additions & 0 deletions router/src/main/java/com/chenenyu/router/RouteRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class RouteRequest implements Serializable {
private Uri uri;
private Bundle extras;
private int flags;
private Uri data;
private String type;
private String action;
// skip all the interceptors
private boolean skipInterceptors;
// skip some interceptors temporarily
Expand Down Expand Up @@ -70,6 +73,30 @@ public void addFlags(int flags) {
this.flags |= flags;
}

public Uri getData() {
return data;
}

public void setData(Uri data) {
this.data = data;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getAction() {
return action;
}

public void setAction(String action) {
this.action = action;
}

public boolean isSkipInterceptors() {
return skipInterceptors;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.chenenyu.router.matcher;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
Expand All @@ -19,11 +18,7 @@ public AbsImplicitMatcher(int priority) {

@Override
public Object generate(Context context, Uri uri, @Nullable Class<?> target) {
if (target != null && Activity.class.isAssignableFrom(target)) {
return new Intent(Intent.ACTION_VIEW, uri);
} else {
return null;
}
return new Intent(Intent.ACTION_VIEW, uri);
}

}

0 comments on commit a12a1eb

Please sign in to comment.