Skip to content

Commit

Permalink
Merge pull request #45 from wyjsonGo/develop
Browse files Browse the repository at this point in the history
publish v2.5.0
优化跳转
  • Loading branch information
wyjsonGo authored Feb 2, 2024
2 parents 15ab0f2 + a89cb12 commit 0aa4604
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 52 deletions.
54 changes: 21 additions & 33 deletions GoRouter-Api/src/main/java/com/wyjson/router/GoRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,7 @@ private void runInMainThread(Runnable runnable) {
}

public Card build(String path) {
return build(path, null);
}

public Card build(String path, Bundle bundle) {
return new Card(path, bundle);
return new Card(path, null);
}

public Card build(Uri uri) {
Expand Down Expand Up @@ -373,12 +369,10 @@ public Object go(Context context, Card card, int requestCode, ActivityResultLaun
return null;
}

runInMainThread(() -> {
logger.debug(null, "[go] [onFound] " + card);
if (callback != null) {
callback.onFound(card);
}
});
logger.debug(null, "[go] [onFound] " + card);
if (callback != null) {
runInMainThread(() -> callback.onFound(card));
}

if (isDebug() && card.isDeprecated()) {
logger.warning(null, "[go] This page has been marked as deprecated. path[" + card.getPath() + "]");
Expand All @@ -399,11 +393,9 @@ public void onContinue(Card card) {

@Override
public void onInterrupt(Card card, @NonNull Throwable exception) {
runInMainThread(() -> {
if (callback != null) {
callback.onInterrupt(card, exception);
}
});
if (callback != null) {
runInMainThread(() -> callback.onInterrupt(card, exception));
}
}
});
} else {
Expand All @@ -417,19 +409,17 @@ public void onInterrupt(Card card, @NonNull Throwable exception) {
}

private void onLost(Context context, Card card, GoCallback callback) {
runInMainThread(() -> {
logger.error(null, "[onLost] There is no route. path[" + card.getPath() + "]");
if (callback != null) {
callback.onLost(card);
logger.error(null, "[onLost] There is no route. path[" + card.getPath() + "]");
if (callback != null) {
runInMainThread(() -> callback.onLost(card));
} else {
IDegradeService degradeService = getService(IDegradeService.class);
if (degradeService != null) {
runInMainThread(() -> degradeService.onLost(context, card));
} else {
IDegradeService degradeService = getService(IDegradeService.class);
if (degradeService != null) {
degradeService.onLost(context, card);
} else {
logger.warning(null, "[onLost] This [IDegradeService] was not found!");
}
logger.warning(null, "[onLost] This [IDegradeService] was not found!");
}
});
}
}

@SuppressLint("WrongConstant")
Expand Down Expand Up @@ -484,12 +474,10 @@ private Object goFragment(Card card, GoCallback callback) {
if (instance instanceof Fragment) {
((Fragment) instance).setArguments(card.getExtras());
}
runInMainThread(() -> {
logger.debug(null, "[goFragment] [onArrival] Complete!");
if (callback != null) {
callback.onArrival(card);
}
});
logger.debug(null, "[goFragment] [onArrival] Complete!");
if (callback != null) {
runInMainThread(() -> callback.onArrival(card));
}
return instance;
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ public static synchronized void assembleRouteCard(@NonNull Card card) throws NoF
card.setCardMeta(cardMeta.getType(), cardMeta.getPathClass(), cardMeta.getTag(), cardMeta.isDeprecated());
card.withString(ROUTER_CURRENT_PATH, card.getPath());

Map<String, ParamMeta> paramsType = cardMeta.getParamsType();
Uri rawUri = card.getUri();
if (rawUri != null) {
Map<String, String> resultMap = TextUtils.splitQueryParameters(rawUri);
Map<String, ParamMeta> paramsType = cardMeta.getParamsType();
if (MapUtils.isNotEmpty(paramsType)) {
Map<String, String> resultMap = TextUtils.splitQueryParameters(rawUri);
// 按类型设置值
for (Map.Entry<String, ParamMeta> params : paramsType.entrySet()) {
setValue(card,
Expand Down
11 changes: 7 additions & 4 deletions GoRouter-Api/src/main/java/com/wyjson/router/model/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void setUri(Uri uri) {
setPath(uri.getPath());
}

@Nullable
public Uri getUri() {
return uri;
}
Expand Down Expand Up @@ -168,7 +169,9 @@ public int getFlags() {
* @return
*/
public Card withObject(@Nullable String key, @Nullable Object value) {
jsonService = GoRouter.getInstance().getService(IJsonService.class);
if (jsonService == null) {
jsonService = GoRouter.getInstance().getService(IJsonService.class);
}
if (jsonService == null) {
throw new RouterException("To use withObject() method, you need to implement IJsonService");
}
Expand Down Expand Up @@ -394,13 +397,13 @@ public String toString() {
", mBundle=" + mBundle +
", flags=" + flags +
", greenChannel=" + greenChannel +
", action='" + action + '\'' +
", action=" + (TextUtils.isEmpty(action) ? null : '\'' + action + '\'') +
", context=" + (context != null ? context.getClass().getSimpleName() : null) +
", optionsCompat=" + activityOptionsCompat +
", enterAnim=" + enterAnim +
", exitAnim=" + exitAnim +
", activityOptionsCompat=" + activityOptionsCompat +
", interceptorException=" + interceptorException +
", timeout=" + timeout +
", timeout=" + timeout + "s" +
'}';
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.wyjson.router.model;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.wyjson.router.GoRouter;
import com.wyjson.router.core.RouteCenter;
Expand Down Expand Up @@ -36,7 +35,6 @@ public CardMeta(String path, RouteType type, Class<?> pathClass, int tag, boolea
this.paramsType = paramsType;
}

@Nullable
public String getPath() {
return path;
}
Expand Down Expand Up @@ -265,15 +263,18 @@ public ArrayList<Integer> getTagExistList(int... itemList) {
}

@NonNull
@Override
public String toString() {
if (!GoRouter.isDebug()) {
return "";
}
return "CardMeta{" +
"path='" + path + '\'' +
", group='" + group + '\'' +
", type=" + type +
", pathClass=" + pathClass +
", tag=" + tag +
", deprecated=" + deprecated +
", paramsType=" + paramsType +
'}';
}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencyResolutionManagement {
}
dependencies {
api 'com.github.wyjsonGo.GoRouter:GoRouter-Api:2.4.9'
api 'com.github.wyjsonGo.GoRouter:GoRouter-Api:2.5.0'
}
// Kotlin配置参见8-1
```
Expand All @@ -89,7 +89,7 @@ android {
}
dependencies {
annotationProcessor 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.4.9'
annotationProcessor 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.5.0'
}
```

Expand Down Expand Up @@ -157,7 +157,7 @@ pluginManagement {
// 项目根目录下的build.gradle
buildscript {
dependencies {
classpath 'com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:2.4.9'
classpath 'com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:2.5.0'
}
}
```
Expand Down Expand Up @@ -894,7 +894,7 @@ kapt {
}

dependencies {
kapt 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.4.9'
kapt 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.5.0'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath "com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:${VERSION}"
// classpath "com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:${VERSION}"
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ android.nonTransitiveRClass=true
# org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

GROUP_ID=com.github.wyjsonGo.GoRouter
VERSION=2.4.9
VERSION=2.5.0
10 changes: 5 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ dependencyResolutionManagement {

rootProject.name = "GoRouter"

include ':app'
include ':module_main'
include ':module_user'
include ':module_kotlin'
include ':module_common'
//include ':app'
//include ':module_main'
//include ':module_user'
//include ':module_kotlin'
//include ':module_common'

include ':GoRouter-Api'
include ':GoRouter-Annotation'
Expand Down

0 comments on commit 0aa4604

Please sign in to comment.