Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
package com.alibaba.android.arouter.launcher;
import android.app.Application;
import android.content.Context;
import android.net.Uri;
import com.alibaba.android.arouter.exception.InitException;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.callback.NavigationCallback;
import com.alibaba.android.arouter.facade.template.ILogger;
/* loaded from: classes.dex */
public final class ARouter {
private static volatile ARouter a = null;
private static volatile boolean b = false;
public static ILogger c;
private ARouter() {
}
public static void a(Application application) {
if (b) {
return;
}
ILogger iLogger = _ARouter.a;
c = iLogger;
iLogger.d("ARouter::", "ARouter init start.");
b = _ARouter.a(application);
if (b) {
_ARouter.b();
}
_ARouter.a.d("ARouter::", "ARouter init over.");
}
public static ARouter b() {
if (!b) {
throw new InitException("ARouter::Init::Invoke init(context) first!");
}
if (a == null) {
synchronized (ARouter.class) {
if (a == null) {
a = new ARouter();
}
}
}
return a;
}
public static boolean a() {
return _ARouter.c();
}
public void a(Object obj) {
_ARouter.a(obj);
}
public Postcard a(String str) {
return _ARouter.d().a(str);
}
public Postcard a(Uri uri) {
return _ARouter.d().a(uri);
}
public <T> T a(Class<? extends T> cls) {
return (T) _ARouter.d().a((Class) cls);
}
public Object a(Context context, Postcard postcard, int i, NavigationCallback navigationCallback) {
return _ARouter.d().a(context, postcard, i, navigationCallback);
}
}

View File

@@ -0,0 +1,308 @@
package com.alibaba.android.arouter.launcher;
import android.app.Activity;
import android.app.Application;
import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.widget.Toast;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import com.alibaba.android.arouter.core.LogisticsCenter;
import com.alibaba.android.arouter.exception.HandlerException;
import com.alibaba.android.arouter.exception.InitException;
import com.alibaba.android.arouter.exception.NoRouteFoundException;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.callback.InterceptorCallback;
import com.alibaba.android.arouter.facade.callback.NavigationCallback;
import com.alibaba.android.arouter.facade.enums.RouteType;
import com.alibaba.android.arouter.facade.service.AutowiredService;
import com.alibaba.android.arouter.facade.service.DegradeService;
import com.alibaba.android.arouter.facade.service.InterceptorService;
import com.alibaba.android.arouter.facade.service.PathReplaceService;
import com.alibaba.android.arouter.facade.template.ILogger;
import com.alibaba.android.arouter.thread.DefaultPoolExecutor;
import com.alibaba.android.arouter.utils.DefaultLogger;
import com.alibaba.android.arouter.utils.TextUtils;
import java.util.concurrent.ThreadPoolExecutor;
/* loaded from: classes.dex */
final class _ARouter {
static ILogger a = new DefaultLogger("ARouter::");
private static volatile boolean b = false;
private static volatile _ARouter c = null;
private static volatile boolean d = false;
private static volatile ThreadPoolExecutor e = DefaultPoolExecutor.a();
private static Handler f;
private static Context g;
private static InterceptorService h;
/* renamed from: com.alibaba.android.arouter.launcher._ARouter$4, reason: invalid class name */
static /* synthetic */ class AnonymousClass4 {
static final /* synthetic */ int[] a = new int[RouteType.values().length];
static {
try {
a[RouteType.ACTIVITY.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
a[RouteType.PROVIDER.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
a[RouteType.BOARDCAST.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
a[RouteType.CONTENT_PROVIDER.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
a[RouteType.FRAGMENT.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
a[RouteType.METHOD.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
a[RouteType.SERVICE.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
}
}
private _ARouter() {
}
private String b(String str) {
if (TextUtils.a(str) || !str.startsWith("/")) {
throw new HandlerException("ARouter::Extract the default group failed, the path must be start with '/' and contain more than 2 '/'!");
}
try {
String substring = str.substring(1, str.indexOf("/", 1));
if (TextUtils.a(substring)) {
throw new HandlerException("ARouter::Extract the default group failed! There's nothing between 2 '/'!");
}
return substring;
} catch (Exception e2) {
a.c("ARouter::", "Failed to extract default group! " + e2.getMessage());
return null;
}
}
static boolean c() {
return b;
}
protected static _ARouter d() {
if (!d) {
throw new InitException("ARouterCore::Init::Invoke init(context) first!");
}
if (c == null) {
synchronized (_ARouter.class) {
if (c == null) {
c = new _ARouter();
}
}
}
return c;
}
protected static synchronized boolean a(Application application) {
synchronized (_ARouter.class) {
g = application;
LogisticsCenter.a(g, e);
a.d("ARouter::", "ARouter init success!");
d = true;
f = new Handler(Looper.getMainLooper());
}
return true;
}
static void b() {
h = (InterceptorService) ARouter.b().a("/arouter/service/interceptor").t();
}
/* JADX INFO: Access modifiers changed from: private */
public Object b(Context context, final Postcard postcard, final int i, final NavigationCallback navigationCallback) {
if (context == null) {
context = g;
}
final Context context2 = context;
int i2 = AnonymousClass4.a[postcard.g().ordinal()];
if (i2 == 1) {
final Intent intent = new Intent(context2, postcard.a());
intent.putExtras(postcard.k());
int l = postcard.l();
if (-1 != l) {
intent.setFlags(l);
} else if (!(context2 instanceof Activity)) {
intent.setFlags(268435456);
}
String h2 = postcard.h();
if (!TextUtils.a(h2)) {
intent.setAction(h2);
}
a(new Runnable() { // from class: com.alibaba.android.arouter.launcher._ARouter.3
@Override // java.lang.Runnable
public void run() {
_ARouter.this.a(i, context2, intent, postcard, navigationCallback);
}
});
return null;
}
if (i2 == 2) {
return postcard.n();
}
if (i2 == 3 || i2 == 4 || i2 == 5) {
try {
Object newInstance = postcard.a().getConstructor(new Class[0]).newInstance(new Object[0]);
if (newInstance instanceof Fragment) {
((Fragment) newInstance).setArguments(postcard.k());
} else if (newInstance instanceof androidx.fragment.app.Fragment) {
((androidx.fragment.app.Fragment) newInstance).setArguments(postcard.k());
}
return newInstance;
} catch (Exception e2) {
a.b("ARouter::", "Fetch fragment instance error, " + TextUtils.a(e2.getStackTrace()));
}
}
return null;
}
static void a(Object obj) {
AutowiredService autowiredService = (AutowiredService) ARouter.b().a("/arouter/service/autowired").t();
if (autowiredService != null) {
autowiredService.a(obj);
}
}
protected Postcard a(String str) {
if (!TextUtils.a(str)) {
PathReplaceService pathReplaceService = (PathReplaceService) ARouter.b().a(PathReplaceService.class);
if (pathReplaceService != null) {
str = pathReplaceService.a(str);
}
return a(str, b(str));
}
throw new HandlerException("ARouter::Parameter is invalid!");
}
protected Postcard a(Uri uri) {
if (uri != null && !TextUtils.a(uri.toString())) {
PathReplaceService pathReplaceService = (PathReplaceService) ARouter.b().a(PathReplaceService.class);
if (pathReplaceService != null) {
uri = pathReplaceService.a(uri);
}
return new Postcard(uri.getPath(), b(uri.getPath()), uri, null);
}
throw new HandlerException("ARouter::Parameter invalid!");
}
protected Postcard a(String str, String str2) {
if (!TextUtils.a(str) && !TextUtils.a(str2)) {
PathReplaceService pathReplaceService = (PathReplaceService) ARouter.b().a(PathReplaceService.class);
if (pathReplaceService != null) {
str = pathReplaceService.a(str);
}
return new Postcard(str, str2);
}
throw new HandlerException("ARouter::Parameter is invalid!");
}
protected <T> T a(Class<? extends T> cls) {
try {
Postcard a2 = LogisticsCenter.a(cls.getName());
if (a2 == null) {
a2 = LogisticsCenter.a(cls.getSimpleName());
}
if (a2 == null) {
return null;
}
LogisticsCenter.a(a2);
return (T) a2.n();
} catch (NoRouteFoundException e2) {
a.c("ARouter::", e2.getMessage());
return null;
}
}
protected Object a(final Context context, final Postcard postcard, final int i, final NavigationCallback navigationCallback) {
try {
LogisticsCenter.a(postcard);
if (navigationCallback != null) {
navigationCallback.a(postcard);
}
if (!postcard.s()) {
h.a(postcard, new InterceptorCallback() { // from class: com.alibaba.android.arouter.launcher._ARouter.2
@Override // com.alibaba.android.arouter.facade.callback.InterceptorCallback
public void a(Postcard postcard2) {
_ARouter.this.b(context, postcard2, i, navigationCallback);
}
@Override // com.alibaba.android.arouter.facade.callback.InterceptorCallback
public void a(Throwable th) {
NavigationCallback navigationCallback2 = navigationCallback;
if (navigationCallback2 != null) {
navigationCallback2.c(postcard);
}
_ARouter.a.d("ARouter::", "Navigation failed, termination by interceptor : " + th.getMessage());
}
});
return null;
}
return b(context, postcard, i, navigationCallback);
} catch (NoRouteFoundException e2) {
a.c("ARouter::", e2.getMessage());
if (c()) {
a(new Runnable(this) { // from class: com.alibaba.android.arouter.launcher._ARouter.1
@Override // java.lang.Runnable
public void run() {
Toast.makeText(_ARouter.g, "There's no route matched!\n Path = [" + postcard.e() + "]\n Group = [" + postcard.c() + "]", 1).show();
}
});
}
if (navigationCallback != null) {
navigationCallback.b(postcard);
} else {
DegradeService degradeService = (DegradeService) ARouter.b().a(DegradeService.class);
if (degradeService != null) {
degradeService.a(context, postcard);
}
}
return null;
}
}
private void a(Runnable runnable) {
if (Looper.getMainLooper().getThread() != Thread.currentThread()) {
f.post(runnable);
} else {
runnable.run();
}
}
/* JADX INFO: Access modifiers changed from: private */
public void a(int i, Context context, Intent intent, Postcard postcard, NavigationCallback navigationCallback) {
if (i >= 0) {
if (context instanceof Activity) {
ActivityCompat.a((Activity) context, intent, i, postcard.m());
} else {
a.c("ARouter::", "Must use [navigation(activity, ...)] to support [startActivityForResult]");
}
} else {
ContextCompat.a(context, intent, postcard.m());
}
if (-1 != postcard.i() && -1 != postcard.j() && (context instanceof Activity)) {
((Activity) context).overridePendingTransition(postcard.i(), postcard.j());
}
if (navigationCallback != null) {
navigationCallback.d(postcard);
}
}
}