Skip to content

Commit

Permalink
Merge pull request #84 from chenenyu/dev
Browse files Browse the repository at this point in the history
1.4.2
  • Loading branch information
Half Stack committed May 18, 2018
2 parents 567c716 + 274dbde commit 7deb946
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2018.05.18

`router:1.4.2`:

1. Ordered interceptors.

## 2018.04.03

`router:1.4.1`:
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/chenenyu/Router.svg?branch=master)](https://travis-ci.org/chenenyu/Router) ![license](https://img.shields.io/badge/license-Apache%202-yellow.svg) ![PullRequest](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)
![Build Status](https://travis-ci.org/chenenyu/Router.svg?branch=master) ![license](https://img.shields.io/badge/license-Apache%202-yellow.svg) ![PullRequest](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)

# Router

Expand All @@ -24,6 +24,7 @@ android {
dependencies {
implementation 'com.chenenyu.router:router:版本号'
// 每个使用了@Router注解的module都要添加该注解处理器
annotationProcessor 'com.chenenyu.router:compiler:版本号'
}
```
Expand Down Expand Up @@ -107,7 +108,7 @@ Router.build("test").getFragment();

## 进阶用法

Please refer to the [wiki](https://github.com/chenenyu/Router/wiki) for more informations.
Please refer to the [wiki](https://github.com/chenenyu/Router/wiki) for more information.

## ProGuard

Expand All @@ -121,9 +122,9 @@ Please refer to the [wiki](https://github.com/chenenyu/Router/wiki) for more inf

QQ group: 271849001

## Donate
## Donate ❤️

![donate_wechat](static/donate_wechat.png)
[Click here](https://github.com/chenenyu/Router/wiki/Donate).

## License

Expand Down
1 change: 0 additions & 1 deletion Sample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ dependencies {
implementation project(':module1')
implementation project(':module2')
testImplementation 'junit:junit:4.12'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation project(':router')
annotationProcessor project(':compiler')
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
* <p>
* Created by Cheney on 2017/3/6.
*/
@Interceptor("SampleInterceptor")
public class SampleInterceptor implements RouteInterceptor {
@Interceptor("AInterceptor")
public class AInterceptor implements RouteInterceptor {
@Override
public boolean intercept(Object source, RouteRequest routeRequest) {
Toast.makeText((Context) source, String.format("Intercepted: {uri: %s, interceptor: %s}",
routeRequest.getUri().toString(), SampleInterceptor.class.getName()),
routeRequest.getUri().toString(), AInterceptor.class.getName()),
Toast.LENGTH_LONG).show();
return true;
}
Expand Down
23 changes: 23 additions & 0 deletions Sample/app/src/main/java/com/chenenyu/router/app/BInterceptor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.chenenyu.router.app;

import android.content.Context;
import android.widget.Toast;

import com.chenenyu.router.RouteInterceptor;
import com.chenenyu.router.RouteRequest;
import com.chenenyu.router.annotation.Interceptor;


/**
* Created by chenenyu on 2018/5/18.
*/
@Interceptor("BInterceptor")
public class BInterceptor implements RouteInterceptor {
@Override
public boolean intercept(Object source, RouteRequest routeRequest) {
Toast.makeText((Context) source, String.format("Intercepted: {uri: %s, interceptor: %s}",
routeRequest.getUri().toString(), BInterceptor.class.getName()),
Toast.LENGTH_LONG).show();
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import com.chenenyu.router.annotation.Route;

@Route(value = "intercepted", interceptors = "SampleInterceptor")
@Route(value = "intercepted", interceptors = {"AInterceptor", "BInterceptor"})
//@Route(value = "intercepted", interceptors = {"BInterceptor", "AInterceptor"})
public class InterceptedActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ public void callback(RouteResult state, Uri uri, String message) {
} else if (v == btn9) {
Router.build("intercepted").go(this);
} else if (v == btn10) {
Router.build("intercepted").skipInterceptors("SampleInterceptor").go(this);
Router.build("intercepted").skipInterceptors("AInterceptor").go(this);
} else if (v == btn11) {
Router.build("test").addInterceptors("SampleInterceptor").go(this);
Router.build("test").addInterceptors("AInterceptor").go(this);
}
}

Expand Down
2 changes: 1 addition & 1 deletion VERSION.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# router library version
ROUTER_VERSION=1.4.1
ROUTER_VERSION=1.4.2
# compiler library version
COMPILER_VERSION=1.4.0
# annotation library version
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext.kotlin_version = '1.2.10'
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
Expand All @@ -32,5 +32,5 @@ ext {
minSdkVersion = 14
targetSdkVersion = 27

supportVersion = "27.1.0"
supportVersion = "27.1.1"
}
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 @@
#Mon Sep 04 12:31:05 CST 2017
#Fri May 18 12:39:21 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
5 changes: 3 additions & 2 deletions router/src/main/java/com/chenenyu/router/AptHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
Expand All @@ -26,15 +27,15 @@ class AptHub {
// Uri -> Activity/Fragment
static Map<String, Class<?>> routeTable = new HashMap<>();
// Activity/Fragment -> interceptorTable' name
static Map<Class<?>, String[]> targetInterceptors = new HashMap<>();
static Map<Class<?>, String[]> targetInterceptors = new LinkedHashMap<>();
// interceptor's name -> interceptor
static Map<String, Class<? extends RouteInterceptor>> interceptorTable = new HashMap<>();
static Map<String, RouteInterceptor> interceptorInstances = new HashMap<>();
// injector's name -> injector
static Map<String, Class<ParamInjector>> injectors = new HashMap<>();

/**
* This method offers an ability to register extra modules for developers.
* This method offers an ability to register modules for developers.
*
* @param modules extra modules' name
*/
Expand Down
4 changes: 2 additions & 2 deletions router/src/main/java/com/chenenyu/router/RealRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.lang.reflect.Constructor;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -278,7 +278,7 @@ private Set<String> assembleClassInterceptors(@Nullable Class<?> target) {
return null;
}
// Assemble final interceptors
Set<String> finalInterceptors = new HashSet<>();
Set<String> finalInterceptors = new LinkedHashSet<>();
if (target != null) {
// 1. Add original interceptors in Map
String[] baseInterceptors = AptHub.targetInterceptors.get(target);
Expand Down

0 comments on commit 7deb946

Please sign in to comment.