Rabbit-R1/android (non root)/java/sources/androidx/navigation/Navigation.java
2024-05-21 17:08:36 -04:00

130 lines
7 KiB
Java

package androidx.navigation;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import androidx.core.app.ActivityCompat;
import java.lang.ref.WeakReference;
import kotlin.Metadata;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.Intrinsics;
import kotlin.sequences.SequencesKt;
/* compiled from: Navigation.kt */
@Metadata(d1 = {"\u0000B\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0002\\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0007J\u001e\u0010\u0003\u001a\u00020\u00042\b\b\u0001\u0010\u0007\u001a\u00020\b2\n\b\u0002\u0010\t\u001a\u0004\u0018\u00010\nH\u0007J\u001a\u0010\u000b\u001a\u00020\f2\u0006\u0010\r\u001a\u00020\u000e2\b\b\u0001\u0010\u000f\u001a\u00020\bH\u0007J\u0010\u0010\u000b\u001a\u00020\f2\u0006\u0010\u0010\u001a\u00020\u0011H\u0007J\u0012\u0010\u0012\u001a\u0004\u0018\u00010\f2\u0006\u0010\u0010\u001a\u00020\u0011H\u0002J\u0012\u0010\u0013\u001a\u0004\u0018\u00010\f2\u0006\u0010\u0010\u001a\u00020\u0011H\u0002J\u001a\u0010\u0014\u001a\u00020\u00152\u0006\u0010\u0010\u001a\u00020\u00112\b\u0010\u0016\u001a\u0004\u0018\u00010\fH\u0007¨\u0006\u0017"}, d2 = {"Landroidx/navigation/Navigation;", "", "()V", "createNavigateOnClickListener", "Landroid/view/View$OnClickListener;", "directions", "Landroidx/navigation/NavDirections;", "resId", "", "args", "Landroid/os/Bundle;", "findNavController", "Landroidx/navigation/NavController;", "activity", "Landroid/app/Activity;", "viewId", "view", "Landroid/view/View;", "findViewNavController", "getViewNavController", "setViewNavController", "", "controller", "navigation-runtime_release"}, k = 1, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes2.dex */
public final class Navigation {
public static final Navigation INSTANCE = new Navigation();
@JvmStatic
public static final View.OnClickListener createNavigateOnClickListener(int i) {
return createNavigateOnClickListener$default(i, null, 2, null);
}
private Navigation() {
}
@JvmStatic
public static final NavController findNavController(Activity activity, int viewId) {
Intrinsics.checkNotNullParameter(activity, "activity");
View requireViewById = ActivityCompat.requireViewById(activity, viewId);
Intrinsics.checkNotNullExpressionValue(requireViewById, "requireViewById<View>(activity, viewId)");
NavController findViewNavController = INSTANCE.findViewNavController(requireViewById);
if (findViewNavController != null) {
return findViewNavController;
}
throw new IllegalStateException("Activity " + activity + " does not have a NavController set on " + viewId);
}
@JvmStatic
public static final NavController findNavController(View view) {
Intrinsics.checkNotNullParameter(view, "view");
NavController findViewNavController = INSTANCE.findViewNavController(view);
if (findViewNavController != null) {
return findViewNavController;
}
throw new IllegalStateException("View " + view + " does not have a NavController set");
}
public static /* synthetic */ View.OnClickListener createNavigateOnClickListener$default(int i, Bundle bundle, int i2, Object obj) {
if ((i2 & 2) != 0) {
bundle = null;
}
return createNavigateOnClickListener(i, bundle);
}
@JvmStatic
public static final View.OnClickListener createNavigateOnClickListener(final int resId, final Bundle args) {
return new View.OnClickListener() { // from class: androidx.navigation.Navigation$$ExternalSyntheticLambda1
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
Navigation.createNavigateOnClickListener$lambda$0(resId, args, view);
}
};
}
/* JADX INFO: Access modifiers changed from: private */
public static final void createNavigateOnClickListener$lambda$0(int i, Bundle bundle, View view) {
Intrinsics.checkNotNullExpressionValue(view, "view");
findNavController(view).navigate(i, bundle);
}
@JvmStatic
public static final View.OnClickListener createNavigateOnClickListener(final NavDirections directions) {
Intrinsics.checkNotNullParameter(directions, "directions");
return new View.OnClickListener() { // from class: androidx.navigation.Navigation$$ExternalSyntheticLambda0
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
Navigation.createNavigateOnClickListener$lambda$1(NavDirections.this, view);
}
};
}
/* JADX INFO: Access modifiers changed from: private */
public static final void createNavigateOnClickListener$lambda$1(NavDirections directions, View view) {
Intrinsics.checkNotNullParameter(directions, "$directions");
Intrinsics.checkNotNullExpressionValue(view, "view");
findNavController(view).navigate(directions);
}
@JvmStatic
public static final void setViewNavController(View view, NavController controller) {
Intrinsics.checkNotNullParameter(view, "view");
view.setTag(R.id.nav_controller_view_tag, controller);
}
private final NavController findViewNavController(View view) {
return (NavController) SequencesKt.firstOrNull(SequencesKt.mapNotNull(SequencesKt.generateSequence(view, new Function1<View, View>() { // from class: androidx.navigation.Navigation$findViewNavController$1
@Override // kotlin.jvm.functions.Function1
public final View invoke(View it) {
Intrinsics.checkNotNullParameter(it, "it");
Object parent = it.getParent();
if (parent instanceof View) {
return (View) parent;
}
return null;
}
}), new Function1<View, NavController>() { // from class: androidx.navigation.Navigation$findViewNavController$2
@Override // kotlin.jvm.functions.Function1
public final NavController invoke(View it) {
NavController viewNavController;
Intrinsics.checkNotNullParameter(it, "it");
viewNavController = Navigation.INSTANCE.getViewNavController(it);
return viewNavController;
}
}));
}
/* JADX INFO: Access modifiers changed from: private */
public final NavController getViewNavController(View view) {
Object tag = view.getTag(R.id.nav_controller_view_tag);
if (tag instanceof WeakReference) {
return (NavController) ((WeakReference) tag).get();
}
if (tag instanceof NavController) {
return (NavController) tag;
}
return null;
}
}