Swiggy v4.51.1版本的 MD5 值为:5af7ec91512a0a8c1510e3f8bac20b8b
以下内容为反编译后的 LocationPermissionFragmentViewModel.java 源代码,内容仅作参考
package in.swiggy.android.onboarding.viewmodel;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.location.Location;
import android.location.LocationManager;
import androidx.databinding.ObservableField;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.y;
import in.swiggy.android.R;
import in.swiggy.android.commons.utils.DispatchProviderKt;
import in.swiggy.android.commons.utils.GeneralUtilsKt;
import in.swiggy.android.commons.utils.x;
import in.swiggy.android.compass.defaulting.AppDefaultingContext;
import in.swiggy.android.dls.compose.superbutton.g;
import in.swiggy.android.eventMigration.EventPauseResumeUseCase;
import in.swiggy.android.mvvm.aarch.CoreViewModel;
import in.swiggy.android.onboarding.ProgressAnimation;
import in.swiggy.android.onboarding.c;
import in.swiggy.android.permission.e;
import in.swiggy.android.tejas.feature.address.model.Address;
import in.swiggy.android.tejas.feature.discovery.pageskeleton.model.PageSkeletonParams;
import in.swiggy.android.tejas.feature.discovery.pageskeleton.usecase.PageSkeletonUseCase;
import in.swiggy.android.utils.GeneralExtensionsKt;
import in.swiggy.android.utils.l0;
import io.reactivex.processors.BehaviorProcessor;
import java.util.Iterator;
import java.util.List;
import kotlin.Unit;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.FunctionReferenceImpl;
import kotlinx.coroutines.a2;
import kotlinx.coroutines.f0;
import kotlinx.coroutines.q1;
import kotlinx.coroutines.v0;
public final class LocationPermissionFragmentViewModel extends CoreViewModel {
public static final a T = new a(null);
public static final int U = 8;
private static int V = 15;
private final String A;
private final kotlin.j B;
private boolean C;
private boolean D;
public in.swiggy.android.repositories.interfaces.d E;
private boolean F;
private boolean G;
private final y<in.swiggy.android.commons.utils.l<in.swiggy.android.onboarding.c>> H;
private final LiveData<in.swiggy.android.commons.utils.l<in.swiggy.android.onboarding.c>> I;
private final y<ProgressAnimation.Progress> J;
private final y<ProgressAnimation.Progress> K;
private final kotlin.j L;
private final y<Boolean> M;
private final LiveData<Boolean> N;
private final y<Boolean> O;
private final LiveData<Boolean> P;
private q1 Q;
private final Function1<Boolean, Unit> R;
private final Function1<Location, Unit> S;
private final in.swiggy.android.swiggylocation.services.a e;
private final AppDefaultingContext f;
private final dagger.a<in.swiggy.android.commons.featureFlags.d> g;
private boolean h;
private io.reactivex.disposables.a i;
private q1 j;
public in.swiggy.android.mvvm.services.s k;
public in.swiggy.android.analytics.interfaces.c l;
public in.swiggy.android.swiggylocation.location.j m;
public SharedPreferences n;
public in.swiggy.android.repositories.interfaces.e o;
public in.swiggy.koordinates.compass.core.b p;
public in.swiggy.android.compass.utils.a q;
public in.swiggy.android.commons.utils.contextservice.h r;
public LocationManager s;
public in.swiggy.android.discovery.pageskeleton.datamanager.b t;
public BehaviorProcessor<in.swiggy.android.activities.c> u;
public PageSkeletonUseCase v;
public in.swiggy.android.analytics.newrelic.a w;
public EventPauseResumeUseCase x;
private final String y;
private final ObservableField<Integer> z;
public static final class a {
public a(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final int a() {
return LocationPermissionFragmentViewModel.V;
}
public final void b(int i) {
LocationPermissionFragmentViewModel.V = i;
}
private a() {
}
}
public static final class b extends kotlin.coroutines.a implements f0 {
public b(f0.a aVar) {
super(aVar);
}
@Override
public void L(CoroutineContext coroutineContext, Throwable th) {
x.i("LocPermissionFragmentVm", th);
}
}
public LocationPermissionFragmentViewModel(in.swiggy.android.swiggylocation.services.a locationComponentService, AppDefaultingContext appDefaultingContext, dagger.a<in.swiggy.android.commons.featureFlags.d> featureFlags) {
kotlin.j b2;
kotlin.j b3;
kotlin.jvm.internal.o.k(locationComponentService, "locationComponentService");
kotlin.jvm.internal.o.k(appDefaultingContext, "appDefaultingContext");
kotlin.jvm.internal.o.k(featureFlags, "featureFlags");
this.e = locationComponentService;
this.f = appDefaultingContext;
this.g = featureFlags;
this.i = new io.reactivex.disposables.a();
this.y = "https://media-assets.swiggy.com/swiggy/raw/upload/v1669042143/lottie/location_permission_lottie_updated.zip";
this.z = new ObservableField<>(-1);
this.A = kotlin.jvm.internal.r.b(LocationPermissionFragmentViewModel.class).g();
b2 = kotlin.l.b(new Function0<Drawable>() {
{
super(0);
}
@Override
public final Drawable invoke() {
return LocationPermissionFragmentViewModel.this.E7().c(R.drawable.location_request_image);
}
});
this.B = b2;
y<in.swiggy.android.commons.utils.l<in.swiggy.android.onboarding.c>> yVar = new y<>();
this.H = yVar;
this.I = yVar;
y<ProgressAnimation.Progress> yVar2 = new y<>(ProgressAnimation.Progress.THREE);
this.J = yVar2;
this.K = yVar2;
b3 = kotlin.l.b(new Function0<kotlinx.coroutines.flow.i<in.swiggy.android.onboarding.models.a>>() {
public class AnonymousClass1 extends FunctionReferenceImpl implements Function0<Unit> {
AnonymousClass1(Object obj) {
super(0, obj, LocationPermissionFragmentViewModel.class, "fetchLocation", "fetchLocation()V", 0);
}
public final void h() {
((LocationPermissionFragmentViewModel) this.receiver).l7();
}
@Override
public Unit invoke() {
h();
return Unit.a;
}
}
{
super(0);
}
@Override
public final kotlinx.coroutines.flow.i<in.swiggy.android.onboarding.models.a> invoke() {
return kotlinx.coroutines.flow.t.a(new in.swiggy.android.onboarding.models.a(LocationPermissionFragmentViewModel.this.E7().getString(R.string.allow_location_permission), LocationPermissionFragmentViewModel.this.E7().getString(R.string.allow_location_permission), g.c.b, new AnonymousClass1(LocationPermissionFragmentViewModel.this)));
}
});
this.L = b3;
Boolean bool = Boolean.FALSE;
y<Boolean> yVar3 = new y<>(bool);
this.M = yVar3;
kotlin.jvm.internal.o.i(yVar3, "null cannot be cast to non-null type androidx.lifecycle.LiveData<kotlin.Boolean>");
this.N = yVar3;
y<Boolean> yVar4 = new y<>(bool);
this.O = yVar4;
kotlin.jvm.internal.o.i(yVar4, "null cannot be cast to non-null type androidx.lifecycle.LiveData<kotlin.Boolean>");
this.P = yVar4;
this.R = new Function1<Boolean, Unit>() {
{
super(1);
}
public final void a(boolean z) {
boolean z2;
z2 = LocationPermissionFragmentViewModel.this.h;
if (!z2 && !z) {
LocationPermissionFragmentViewModel.this.h = true;
LocationPermissionFragmentViewModel.J7(LocationPermissionFragmentViewModel.this, false, 1, null);
}
}
@Override
public Unit invoke(Boolean bool2) {
a(bool2.booleanValue());
return Unit.a;
}
};
this.S = new Function1<Location, Unit>() {
public final void a(Location it) {
kotlin.jvm.internal.o.k(it, "it");
}
@Override
public Unit invoke(Location location) {
a(location);
return Unit.a;
}
};
}
private final void H7() {
this.H.o(new in.swiggy.android.commons.utils.l<>(c.h.a));
this.H.r(new in.swiggy.android.commons.utils.l<>(c.e0.a));
}
public static void J7(LocationPermissionFragmentViewModel locationPermissionFragmentViewModel, boolean z, int i, Object obj) {
if ((i & 1) != 0) {
z = false;
}
locationPermissionFragmentViewModel.I7(z);
}
private final void N7(String str) {
v7().b(v7().h("location-permission", str, "-", 9999));
}
private final void O7() {
this.h = false;
}
private final void P7() {
if (!this.h) {
I7(!l0.a.b(this.e.c(), V));
}
}
private final void Q7() {
q1 d;
this.h = true;
q1 q1Var = this.j;
if (q1Var != null) {
q1.a.a(q1Var, null, 1, null);
}
d = kotlinx.coroutines.i.d(androidx.lifecycle.l0.a(this), v0.b().Q(new b(f0.v0)), null, new LocationPermissionFragmentViewModel$requestCurrentLocation$2(this, null), 2, null);
this.j = d;
}
public final Object R7(in.swiggy.koordinates.compass.core.dataModels.a aVar, kotlin.coroutines.c<? super Unit> cVar) {
LocationPermissionFragmentViewModel$setCurrentLocation$1 locationPermissionFragmentViewModel$setCurrentLocation$1;
Object f;
int i;
boolean z;
in.swiggy.koordinates.core.f fVar;
Object obj;
in.swiggy.koordinates.core.a aVar2;
LocationPermissionFragmentViewModel locationPermissionFragmentViewModel;
a2 c;
LocationPermissionFragmentViewModel$setCurrentLocation$3 locationPermissionFragmentViewModel$setCurrentLocation$3;
if (cVar instanceof LocationPermissionFragmentViewModel$setCurrentLocation$1) {
locationPermissionFragmentViewModel$setCurrentLocation$1 = (LocationPermissionFragmentViewModel$setCurrentLocation$1) cVar;
int i2 = locationPermissionFragmentViewModel$setCurrentLocation$1.e;
if ((i2 & Integer.MIN_VALUE) != 0) {
locationPermissionFragmentViewModel$setCurrentLocation$1.e = i2 - Integer.MIN_VALUE;
Object obj2 = locationPermissionFragmentViewModel$setCurrentLocation$1.c;
f = kotlin.coroutines.intrinsics.b.f();
i = locationPermissionFragmentViewModel$setCurrentLocation$1.e;
if (i == 0) {
if (i != 1) {
if (i != 2) {
if (i == 3) {
kotlin.n.b(obj2);
} else {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
} else {
fVar = (in.swiggy.koordinates.core.f) locationPermissionFragmentViewModel$setCurrentLocation$1.b;
locationPermissionFragmentViewModel = (LocationPermissionFragmentViewModel) locationPermissionFragmentViewModel$setCurrentLocation$1.a;
kotlin.n.b(obj2);
c = v0.c();
locationPermissionFragmentViewModel$setCurrentLocation$3 = new LocationPermissionFragmentViewModel$setCurrentLocation$3((in.swiggy.koordinates.addressDefaulting.models.b) obj2, locationPermissionFragmentViewModel, fVar, null);
locationPermissionFragmentViewModel$setCurrentLocation$1.a = null;
locationPermissionFragmentViewModel$setCurrentLocation$1.b = null;
locationPermissionFragmentViewModel$setCurrentLocation$1.e = 3;
if (kotlinx.coroutines.g.g(c, locationPermissionFragmentViewModel$setCurrentLocation$3, locationPermissionFragmentViewModel$setCurrentLocation$1) == f) {
return f;
}
}
} else {
kotlin.n.b(obj2);
return Unit.a;
}
} else {
kotlin.n.b(obj2);
if (aVar != null && this.f.o(aVar)) {
z = false;
} else {
z = true;
}
if (aVar != null) {
fVar = aVar.b();
} else {
fVar = null;
}
if (!z && fVar != null && !in.swiggy.koordinates.compass.utils.c.a.d(fVar)) {
String string = u7().getString("last_delivered_address_id", null);
List<Address> I = w7().I();
kotlin.jvm.internal.o.j(I, "getAddresses(...)");
Iterator<T> it = I.iterator();
while (true) {
if (it.hasNext()) {
obj = it.next();
if (kotlin.jvm.internal.o.f(((Address) obj).getId(), string)) {
break;
}
} else {
obj = null;
break;
}
}
Address address = (Address) obj;
AppDefaultingContext appDefaultingContext = this.f;
in.swiggy.koordinates.compass.core.b E = E();
List<Address> I2 = w7().I();
kotlin.jvm.internal.o.j(I2, "getAddresses(...)");
List<in.swiggy.koordinates.core.a> e = in.swiggy.android.swiggylocation.location.defaulting.a.e(I2);
if (address != null) {
aVar2 = in.swiggy.android.swiggylocation.location.defaulting.a.d(address);
} else {
aVar2 = null;
}
locationPermissionFragmentViewModel$setCurrentLocation$1.a = this;
locationPermissionFragmentViewModel$setCurrentLocation$1.b = fVar;
locationPermissionFragmentViewModel$setCurrentLocation$1.e = 2;
obj2 = appDefaultingContext.p(E, e, aVar2, false, locationPermissionFragmentViewModel$setCurrentLocation$1);
if (obj2 == f) {
return f;
}
locationPermissionFragmentViewModel = this;
c = v0.c();
locationPermissionFragmentViewModel$setCurrentLocation$3 = new LocationPermissionFragmentViewModel$setCurrentLocation$3((in.swiggy.koordinates.addressDefaulting.models.b) obj2, locationPermissionFragmentViewModel, fVar, null);
locationPermissionFragmentViewModel$setCurrentLocation$1.a = null;
locationPermissionFragmentViewModel$setCurrentLocation$1.b = null;
locationPermissionFragmentViewModel$setCurrentLocation$1.e = 3;
if (kotlinx.coroutines.g.g(c, locationPermissionFragmentViewModel$setCurrentLocation$3, locationPermissionFragmentViewModel$setCurrentLocation$1) == f) {
}
} else {
a2 c2 = v0.c();
LocationPermissionFragmentViewModel$setCurrentLocation$2 locationPermissionFragmentViewModel$setCurrentLocation$2 = new LocationPermissionFragmentViewModel$setCurrentLocation$2(this, null);
locationPermissionFragmentViewModel$setCurrentLocation$1.e = 1;
if (kotlinx.coroutines.g.g(c2, locationPermissionFragmentViewModel$setCurrentLocation$2, locationPermissionFragmentViewModel$setCurrentLocation$1) == f) {
return f;
}
return Unit.a;
}
}
return Unit.a;
}
}
locationPermissionFragmentViewModel$setCurrentLocation$1 = new LocationPermissionFragmentViewModel$setCurrentLocation$1(this, cVar);
Object obj22 = locationPermissionFragmentViewModel$setCurrentLocation$1.c;
f = kotlin.coroutines.intrinsics.b.f();
i = locationPermissionFragmentViewModel$setCurrentLocation$1.e;
if (i == 0) {
}
return Unit.a;
}
private final void h7(in.swiggy.koordinates.core.f fVar) {
y7().e("nux_location_screen");
i7();
this.Q = kotlinx.coroutines.flow.f.D(kotlinx.coroutines.flow.f.I(kotlinx.coroutines.flow.f.C(kotlinx.coroutines.flow.f.K(z7().invoke(new PageSkeletonParams(fVar.a(), fVar.b())), new LocationPermissionFragmentViewModel$callPageSkeletonApi$1(this, null)), DispatchProviderKt.b().n1()), new LocationPermissionFragmentViewModel$callPageSkeletonApi$2(this, fVar, null)), androidx.lifecycle.l0.a(this));
}
private final void i7() {
GeneralUtilsKt.f(this.Q);
}
public final void j7(in.swiggy.koordinates.core.f fVar) {
if ((u7().getString("deferred_deeplink", null) == null && n7().x0() == null) || fVar == null) {
K7();
} else {
h7(fVar);
}
}
private final void k7(boolean z) {
if (z) {
p7().setValue(in.swiggy.android.onboarding.models.a.b(p7().getValue(), null, null, g.b.b, null, 3, null));
} else {
p7().setValue(in.swiggy.android.onboarding.models.a.b(p7().getValue(), null, null, g.c.b, new LocationPermissionFragmentViewModel$enableLoader$1(this), 3, null));
}
}
public final void l7() {
N7("click-allow-location-access");
if (this.h) {
k7(false);
return;
}
V++;
this.M.r(Boolean.TRUE);
}
public final Drawable A7() {
return (Drawable) this.B.getValue();
}
public final y<ProgressAnimation.Progress> B7() {
return this.K;
}
public final LiveData<Boolean> C7() {
return this.P;
}
public final LiveData<Boolean> D7() {
return this.N;
}
public final in.swiggy.koordinates.compass.core.b E() {
in.swiggy.koordinates.compass.core.b bVar = this.p;
if (bVar != null) {
return bVar;
}
kotlin.jvm.internal.o.C("locationContext");
return null;
}
@Override
public void E6(int i, int i2, Intent intent) {
super.E6(i, i2, intent);
if (i == 151 && i2 == -1) {
if (!G().s()) {
L7(this.C);
} else {
H7();
}
}
}
public final in.swiggy.android.mvvm.services.s E7() {
in.swiggy.android.mvvm.services.s sVar = this.k;
if (sVar != null) {
return sVar;
}
kotlin.jvm.internal.o.C("resourceService");
return null;
}
public final void F7(boolean z) {
if (z) {
k7(true);
Q7();
}
this.R.invoke(Boolean.valueOf(z));
}
public final in.swiggy.android.commons.utils.contextservice.h G() {
in.swiggy.android.commons.utils.contextservice.h hVar = this.r;
if (hVar != null) {
return hVar;
}
kotlin.jvm.internal.o.C("contextService");
return null;
}
public final void G7(in.swiggy.android.permission.e permissionState) {
kotlin.jvm.internal.o.k(permissionState, "permissionState");
if (permissionState instanceof e.b) {
this.O.r(Boolean.TRUE);
} else if (permissionState instanceof e.c) {
P7();
} else if (permissionState instanceof e.d) {
P7();
}
}
public final void I7(boolean z) {
k7(false);
N7("click-enter-location-manually");
this.H.r(new in.swiggy.android.commons.utils.l<>(new c.l(this.C, z, false, 4, null)));
}
public final void K7() {
if (this.F && !this.G) {
this.G = true;
u7().edit().remove("nuxLocationSetupInProgress").apply();
if (true ^ G().s()) {
L7(this.C);
} else {
H7();
}
}
}
public final void L7(boolean z) {
this.H.r(new in.swiggy.android.commons.utils.l<>(new c.n("location_permission", z)));
}
@Override
public void M6() {
super.M6();
GeneralExtensionsKt.c(this.i);
}
public final void M7() {
i7();
J7(this, false, 1, null);
}
@Override
public void Q6() {
super.Q6();
this.F = true;
if (this.i.isDisposed()) {
this.i = new io.reactivex.disposables.a();
}
O7();
G().d(LocationPermissionFragmentViewModel.class, E7().getString(R.string.announce_showing_location_permission_page_content_description));
}
@Override
public void S6() {
super.S6();
this.F = false;
}
public final void S7(boolean z) {
this.D = z;
}
public final void T7(boolean z) {
this.C = z;
}
@Override
public void U6() {
v7().m("location-permission");
}
@Override
public void init() {
super.init();
u7().edit().putBoolean("nuxLocationSetupInProgress", true).apply();
}
public final in.swiggy.android.compass.utils.a m7() {
in.swiggy.android.compass.utils.a aVar = this.q;
if (aVar != null) {
return aVar;
}
kotlin.jvm.internal.o.C("checkForLocationFetchUtil");
return null;
}
public final BehaviorProcessor<in.swiggy.android.activities.c> n7() {
BehaviorProcessor<in.swiggy.android.activities.c> behaviorProcessor = this.u;
if (behaviorProcessor != null) {
return behaviorProcessor;
}
kotlin.jvm.internal.o.C("deeplinkProcessor");
return null;
}
public final EventPauseResumeUseCase o7() {
EventPauseResumeUseCase eventPauseResumeUseCase = this.x;
if (eventPauseResumeUseCase != null) {
return eventPauseResumeUseCase;
}
kotlin.jvm.internal.o.C("eventPauseResumeUseCase");
return null;
}
public final kotlinx.coroutines.flow.i<in.swiggy.android.onboarding.models.a> p7() {
return (kotlinx.coroutines.flow.i) this.L.getValue();
}
public final String q7() {
return this.y;
}
public final LiveData<in.swiggy.android.commons.utils.l<in.swiggy.android.onboarding.c>> r7() {
return this.I;
}
public final ObservableField<Integer> s7() {
return this.z;
}
public final String t7() {
return this.A;
}
public final SharedPreferences u7() {
SharedPreferences sharedPreferences = this.n;
if (sharedPreferences != null) {
return sharedPreferences;
}
kotlin.jvm.internal.o.C("mSharedPreferences");
return null;
}
public final in.swiggy.android.analytics.interfaces.c v7() {
in.swiggy.android.analytics.interfaces.c cVar = this.l;
if (cVar != null) {
return cVar;
}
kotlin.jvm.internal.o.C("mSwiggyEventHandler");
return null;
}
public final in.swiggy.android.repositories.interfaces.d w7() {
in.swiggy.android.repositories.interfaces.d dVar = this.E;
if (dVar != null) {
return dVar;
}
kotlin.jvm.internal.o.C("mUser");
return null;
}
public final in.swiggy.android.analytics.newrelic.a x7() {
in.swiggy.android.analytics.newrelic.a aVar = this.w;
if (aVar != null) {
return aVar;
}
kotlin.jvm.internal.o.C("newrelicPerformanceUtils");
return null;
}
public final in.swiggy.android.discovery.pageskeleton.datamanager.b y7() {
in.swiggy.android.discovery.pageskeleton.datamanager.b bVar = this.t;
if (bVar != null) {
return bVar;
}
kotlin.jvm.internal.o.C("pageSkeletonDataManager");
return null;
}
public final PageSkeletonUseCase z7() {
PageSkeletonUseCase pageSkeletonUseCase = this.v;
if (pageSkeletonUseCase != null) {
return pageSkeletonUseCase;
}
kotlin.jvm.internal.o.C("pageSkeletonUseCase");
return null;
}
}