Skip to content

Commit 0aa4604

Browse files
authored
Merge pull request #45 from wyjsonGo/develop
publish v2.5.0 优化跳转
2 parents 15ab0f2 + a89cb12 commit 0aa4604

File tree

8 files changed

+44
-52
lines changed

8 files changed

+44
-52
lines changed

GoRouter-Api/src/main/java/com/wyjson/router/GoRouter.java

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,7 @@ private void runInMainThread(Runnable runnable) {
241241
}
242242

243243
public Card build(String path) {
244-
return build(path, null);
245-
}
246-
247-
public Card build(String path, Bundle bundle) {
248-
return new Card(path, bundle);
244+
return new Card(path, null);
249245
}
250246

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

376-
runInMainThread(() -> {
377-
logger.debug(null, "[go] [onFound] " + card);
378-
if (callback != null) {
379-
callback.onFound(card);
380-
}
381-
});
372+
logger.debug(null, "[go] [onFound] " + card);
373+
if (callback != null) {
374+
runInMainThread(() -> callback.onFound(card));
375+
}
382376

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

400394
@Override
401395
public void onInterrupt(Card card, @NonNull Throwable exception) {
402-
runInMainThread(() -> {
403-
if (callback != null) {
404-
callback.onInterrupt(card, exception);
405-
}
406-
});
396+
if (callback != null) {
397+
runInMainThread(() -> callback.onInterrupt(card, exception));
398+
}
407399
}
408400
});
409401
} else {
@@ -417,19 +409,17 @@ public void onInterrupt(Card card, @NonNull Throwable exception) {
417409
}
418410

419411
private void onLost(Context context, Card card, GoCallback callback) {
420-
runInMainThread(() -> {
421-
logger.error(null, "[onLost] There is no route. path[" + card.getPath() + "]");
422-
if (callback != null) {
423-
callback.onLost(card);
412+
logger.error(null, "[onLost] There is no route. path[" + card.getPath() + "]");
413+
if (callback != null) {
414+
runInMainThread(() -> callback.onLost(card));
415+
} else {
416+
IDegradeService degradeService = getService(IDegradeService.class);
417+
if (degradeService != null) {
418+
runInMainThread(() -> degradeService.onLost(context, card));
424419
} else {
425-
IDegradeService degradeService = getService(IDegradeService.class);
426-
if (degradeService != null) {
427-
degradeService.onLost(context, card);
428-
} else {
429-
logger.warning(null, "[onLost] This [IDegradeService] was not found!");
430-
}
420+
logger.warning(null, "[onLost] This [IDegradeService] was not found!");
431421
}
432-
});
422+
}
433423
}
434424

435425
@SuppressLint("WrongConstant")
@@ -484,12 +474,10 @@ private Object goFragment(Card card, GoCallback callback) {
484474
if (instance instanceof Fragment) {
485475
((Fragment) instance).setArguments(card.getExtras());
486476
}
487-
runInMainThread(() -> {
488-
logger.debug(null, "[goFragment] [onArrival] Complete!");
489-
if (callback != null) {
490-
callback.onArrival(card);
491-
}
492-
});
477+
logger.debug(null, "[goFragment] [onArrival] Complete!");
478+
if (callback != null) {
479+
runInMainThread(() -> callback.onArrival(card));
480+
}
493481
return instance;
494482
} catch (Exception e) {
495483
e.printStackTrace();

GoRouter-Api/src/main/java/com/wyjson/router/core/RouteCenter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ public static synchronized void assembleRouteCard(@NonNull Card card) throws NoF
244244
card.setCardMeta(cardMeta.getType(), cardMeta.getPathClass(), cardMeta.getTag(), cardMeta.isDeprecated());
245245
card.withString(ROUTER_CURRENT_PATH, card.getPath());
246246

247-
Map<String, ParamMeta> paramsType = cardMeta.getParamsType();
248247
Uri rawUri = card.getUri();
249248
if (rawUri != null) {
250-
Map<String, String> resultMap = TextUtils.splitQueryParameters(rawUri);
249+
Map<String, ParamMeta> paramsType = cardMeta.getParamsType();
251250
if (MapUtils.isNotEmpty(paramsType)) {
251+
Map<String, String> resultMap = TextUtils.splitQueryParameters(rawUri);
252252
// 按类型设置值
253253
for (Map.Entry<String, ParamMeta> params : paramsType.entrySet()) {
254254
setValue(card,

GoRouter-Api/src/main/java/com/wyjson/router/model/Card.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public void setUri(Uri uri) {
5050
setPath(uri.getPath());
5151
}
5252

53+
@Nullable
5354
public Uri getUri() {
5455
return uri;
5556
}
@@ -168,7 +169,9 @@ public int getFlags() {
168169
* @return
169170
*/
170171
public Card withObject(@Nullable String key, @Nullable Object value) {
171-
jsonService = GoRouter.getInstance().getService(IJsonService.class);
172+
if (jsonService == null) {
173+
jsonService = GoRouter.getInstance().getService(IJsonService.class);
174+
}
172175
if (jsonService == null) {
173176
throw new RouterException("To use withObject() method, you need to implement IJsonService");
174177
}
@@ -394,13 +397,13 @@ public String toString() {
394397
", mBundle=" + mBundle +
395398
", flags=" + flags +
396399
", greenChannel=" + greenChannel +
397-
", action='" + action + '\'' +
400+
", action=" + (TextUtils.isEmpty(action) ? null : '\'' + action + '\'') +
398401
", context=" + (context != null ? context.getClass().getSimpleName() : null) +
399-
", optionsCompat=" + activityOptionsCompat +
400402
", enterAnim=" + enterAnim +
401403
", exitAnim=" + exitAnim +
404+
", activityOptionsCompat=" + activityOptionsCompat +
402405
", interceptorException=" + interceptorException +
403-
", timeout=" + timeout +
406+
", timeout=" + timeout + "s" +
404407
'}';
405408
}
406409
}

GoRouter-Api/src/main/java/com/wyjson/router/model/CardMeta.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.wyjson.router.model;
22

33
import androidx.annotation.NonNull;
4-
import androidx.annotation.Nullable;
54

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

39-
@Nullable
4038
public String getPath() {
4139
return path;
4240
}
@@ -265,15 +263,18 @@ public ArrayList<Integer> getTagExistList(int... itemList) {
265263
}
266264

267265
@NonNull
266+
@Override
268267
public String toString() {
269268
if (!GoRouter.isDebug()) {
270269
return "";
271270
}
272271
return "CardMeta{" +
273272
"path='" + path + '\'' +
273+
", group='" + group + '\'' +
274274
", type=" + type +
275275
", pathClass=" + pathClass +
276276
", tag=" + tag +
277+
", deprecated=" + deprecated +
277278
", paramsType=" + paramsType +
278279
'}';
279280
}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ dependencyResolutionManagement {
6969
}
7070
7171
dependencies {
72-
api 'com.github.wyjsonGo.GoRouter:GoRouter-Api:2.4.9'
72+
api 'com.github.wyjsonGo.GoRouter:GoRouter-Api:2.5.0'
7373
}
7474
// Kotlin配置参见8-1
7575
```
@@ -89,7 +89,7 @@ android {
8989
}
9090
9191
dependencies {
92-
annotationProcessor 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.4.9'
92+
annotationProcessor 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.5.0'
9393
}
9494
```
9595

@@ -157,7 +157,7 @@ pluginManagement {
157157
// 项目根目录下的build.gradle
158158
buildscript {
159159
dependencies {
160-
classpath 'com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:2.4.9'
160+
classpath 'com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:2.5.0'
161161
}
162162
}
163163
```
@@ -894,7 +894,7 @@ kapt {
894894
}
895895

896896
dependencies {
897-
kapt 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.4.9'
897+
kapt 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.5.0'
898898
}
899899
```
900900

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
33
dependencies {
4-
classpath "com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:${VERSION}"
4+
// classpath "com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:${VERSION}"
55
}
66
}
77

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ android.nonTransitiveRClass=true
2525
# org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
2626

2727
GROUP_ID=com.github.wyjsonGo.GoRouter
28-
VERSION=2.4.9
28+
VERSION=2.5.0

settings.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ dependencyResolutionManagement {
1818

1919
rootProject.name = "GoRouter"
2020

21-
include ':app'
22-
include ':module_main'
23-
include ':module_user'
24-
include ':module_kotlin'
25-
include ':module_common'
21+
//include ':app'
22+
//include ':module_main'
23+
//include ':module_user'
24+
//include ':module_kotlin'
25+
//include ':module_common'
2626

2727
include ':GoRouter-Api'
2828
include ':GoRouter-Annotation'

0 commit comments

Comments
 (0)