Swiggy v4.51.1版本的 MD5 值为:5af7ec91512a0a8c1510e3f8bac20b8b
以下内容为反编译后的 DinersOneModule.java 源代码,内容仅作参考
package in.swiggy.android.reactnative.dinersone;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Handler;
import android.webkit.CookieManager;
import androidx.appcompat.app.AppCompatActivity;
import com.facebook.network.connectionclass.ConnectionQuality;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.newrelic.agent.android.NewRelic;
import in.swiggy.android.commons.extension.KotlinExtensionsKt;
import in.swiggy.android.commons.extension.StringExtensionsKt;
import in.swiggy.android.commons.utils.i0;
import in.swiggy.android.commons.utils.x;
import in.swiggy.android.payment.behaviour.b;
import in.swiggy.android.reactnative.n;
import in.swiggy.android.swiggylynx.plugin.SwiggyLynxPluginData;
import in.swiggy.android.swiggylynx.ui.LynxActivity;
import in.swiggy.android.swiggylynx.ui.LynxData;
import in.swiggy.android.tejas.TejasConstants;
import in.swiggy.android.tejas.feature.home.model.FrequencyCapping;
import in.swiggy.android.tejas.feature.home.model.pageconfig.HomePopUpWidget;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import kotlin.Unit;
import kotlin.collections.p0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.o;
import kotlin.text.Regex;
import kotlin.text.StringsKt__StringsKt;
import kotlin.text.q;
public final class DinersOneModule extends ReactContextBaseJavaModule {
private final in.swiggy.android.deeplink.b deepLinkHandler;
private final in.swiggy.android.swiggylynx.headers.a defaultHeaders;
private Long dinersAppStartTime;
private final l dinersFragmentHandler;
private final ReactContext mReactContext;
private final String moduleName;
private final in.swiggy.android.commonsFeature.f navigation;
private String newRelicAPIErrorEventName;
private String newRelicAPILoadEventName;
private String newRelicAPITableName;
private String newRelicTagName;
private in.swiggy.android.analytics.newrelic.a newrelicPerformanceUtils;
private final SharedPreferences sharedPreferences;
private final in.swiggy.android.analytics.interfaces.c swiggyEventHandler;
private final in.swiggy.android.analytics.generated.e swiggyEventLogger;
private boolean traceEventFired;
private final in.swiggy.android.repositories.interfaces.d user;
private final in.swiggy.android.repositories.interfaces.e xpExperimentContext;
public static final class a implements Runnable {
final String a;
final DinersOneModule b;
final Activity c;
public a(String str, DinersOneModule dinersOneModule, Activity activity) {
this.a = str;
this.b = dinersOneModule;
this.c = activity;
}
@Override
public final void run() {
AppCompatActivity appCompatActivity;
String str = this.a;
if (str != null) {
Intent intent = new Intent();
intent.setAction("android.intent.action.VIEW");
intent.setData(Uri.parse(str));
intent.addFlags(603979776);
in.swiggy.android.deeplink.b bVar = this.b.deepLinkHandler;
if (bVar != null) {
Activity activity = this.c;
if (activity instanceof AppCompatActivity) {
appCompatActivity = (AppCompatActivity) activity;
} else {
appCompatActivity = null;
}
bVar.a(intent, appCompatActivity, true);
}
}
}
}
public static final class b implements in.swiggy.android.payment.behaviour.b {
b() {
}
public void a(Context context) {
b.a.a(this, context);
}
}
public DinersOneModule(ReactApplicationContext reactContext, in.swiggy.android.commonsFeature.f fVar, in.swiggy.android.deeplink.b bVar, in.swiggy.android.swiggylynx.headers.a aVar, in.swiggy.android.analytics.interfaces.c cVar, in.swiggy.android.analytics.generated.e eVar, SharedPreferences sharedPreferences, l lVar, in.swiggy.android.repositories.interfaces.d user, in.swiggy.android.repositories.interfaces.e xpExperimentContext) {
super(reactContext);
o.k(reactContext, "reactContext");
o.k(user, "user");
o.k(xpExperimentContext, "xpExperimentContext");
this.navigation = fVar;
this.deepLinkHandler = bVar;
this.defaultHeaders = aVar;
this.swiggyEventHandler = cVar;
this.swiggyEventLogger = eVar;
this.sharedPreferences = sharedPreferences;
this.dinersFragmentHandler = lVar;
this.user = user;
this.xpExperimentContext = xpExperimentContext;
this.moduleName = "DinersOneModule";
this.newRelicAPITableName = "dineout_custom_client_event";
this.newRelicAPILoadEventName = "api_load";
this.newRelicAPIErrorEventName = "api_error";
this.newRelicTagName = "NewrelicPerformanceUtils";
this.mReactContext = reactContext;
this.newrelicPerformanceUtils = new in.swiggy.android.analytics.newrelic.c(reactContext, "true");
this.dinersAppStartTime = Long.valueOf(System.currentTimeMillis());
}
private final void clearFoodCartCookie(String str) {
CookieManager cookieManager;
String cookie;
CharSequence k1;
if (str != null && (cookie = (cookieManager = CookieManager.getInstance()).getCookie(str)) != null) {
for (String str2 : (String[]) new Regex(";").k(cookie, 0).toArray(new String[0])) {
String[] strArr = (String[]) new Regex("=").k(str2, 0).toArray(new String[0]);
k1 = StringsKt__StringsKt.k1(strArr[0]);
if (o.f(k1.toString(), "x-web-checkout-flow")) {
cookieManager.setCookie(str, strArr[0] + "=;");
return;
}
}
}
}
@ReactMethod
public final void enableDineoutLiteMode(Promise promise) {
o.k(promise, "promise");
if (KotlinExtensionsKt.r(this.xpExperimentContext.H("xp_experiment_dineout_lite", TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), false, 1, null)) {
promise.resolve(Boolean.valueOf(DinersOneUtils.a.g(this.mReactContext)));
} else {
promise.resolve(Boolean.FALSE);
}
}
@ReactMethod
public final void fetchCurrentLocation(final Callback callback) {
o.k(callback, "callback");
l lVar = this.dinersFragmentHandler;
if (lVar != null) {
lVar.b4(new Function1<WritableMap, Unit>() {
{
super(1);
}
public final void a(WritableMap it) {
o.k(it, "it");
Callback.this.invoke(it);
}
@Override
public Unit invoke(WritableMap writableMap) {
a(writableMap);
return Unit.a;
}
});
}
}
@ReactMethod
public final void getConnectionQuality(Promise promise) {
o.k(promise, "promise");
ConnectionQuality b2 = in.swiggy.android.commons.utils.imageutil.b.d().b(this.mReactContext);
o.j(b2, "getCurrentBandwidthQuality(...)");
promise.resolve(b2.name());
}
@Override
public String getName() {
return this.moduleName;
}
public final in.swiggy.android.analytics.newrelic.a getNewrelicPerformanceUtils() {
return this.newrelicPerformanceUtils;
}
@ReactMethod
public final void handleAppRestartOnCodepush() {
l lVar = this.dinersFragmentHandler;
if (lVar != null) {
lVar.i0();
}
}
@ReactMethod
public final void hideSplashScreen() {
l lVar = this.dinersFragmentHandler;
if (lVar != null) {
lVar.u();
}
}
@ReactMethod
public final void isNetworkAvailable(Promise promise) {
o.k(promise, "promise");
promise.resolve(Boolean.valueOf(i0.p(this.mReactContext)));
}
@ReactMethod
public final void launchApplyCoupon(String str, Double d) {
Activity currentActivity = getCurrentActivity();
if (currentActivity != null && d != null) {
double doubleValue = d.doubleValue();
in.swiggy.android.commonsFeature.f fVar = this.navigation;
if (fVar != null) {
fVar.G(currentActivity, 3, "cart", str, doubleValue, Boolean.TRUE);
}
}
}
@ReactMethod
public final void launchDeeplink(String str) {
Activity currentActivity = getCurrentActivity();
if (currentActivity == null) {
return;
}
new Handler(currentActivity.getMainLooper()).post(new a(str, this, currentActivity));
}
@ReactMethod
public final void launchSuperV3LandingPage(String str) {
in.swiggy.android.commonsFeature.f fVar;
Activity currentActivity = getCurrentActivity();
if (currentActivity != null && str != null && (fVar = this.navigation) != null) {
fVar.c(currentActivity, str);
}
}
@ReactMethod
public final void logAPIErrorPerfMonitor(String str, String str2, String str3) {
if (str != null && str.length() != 0 && str2 != null && str2.length() != 0 && str3 != null && str3.length() != 0 && !in.swiggy.android.analytics.newrelic.newrelichelper.a.a.c(str3)) {
try {
HashMap hashMap = new HashMap();
hashMap.put("status", str3);
hashMap.put("screen", str);
hashMap.put("query_name", str2);
NewRelic.recordCustomEvent(this.newRelicAPITableName, this.newRelicAPIErrorEventName, hashMap);
} catch (Throwable th) {
x.i(this.newRelicTagName, th);
}
}
}
@ReactMethod
public final void logAPILoadPerfMonitor(String str, String str2, String str3) {
if (str != null && str.length() != 0 && str2 != null && str2.length() != 0 && str3 != null && str3.length() != 0) {
try {
HashMap hashMap = new HashMap();
hashMap.put("screen", str);
hashMap.put("query_name", str2);
hashMap.put("time_in_millis", Long.valueOf(Long.parseLong(str3)));
NewRelic.recordCustomEvent(this.newRelicAPITableName, this.newRelicAPILoadEventName, hashMap);
} catch (Throwable th) {
x.i(this.newRelicTagName, th);
}
}
}
@ReactMethod
public final void logClevertapEvent(String str, ReadableMap readableMap) {
Iterator<Map.Entry<String, Object>> it;
HashMap<String, Object> hashMap = new HashMap<>();
if (readableMap != null) {
it = readableMap.getEntryIterator();
} else {
it = null;
}
if (it != null) {
while (it.hasNext()) {
Map.Entry<String, Object> next = it.next();
String key = next.getKey();
if (o.f(key, "bookingSlot") || o.f(key, "dealBookingSlot")) {
Date d = n.d(next.getValue());
if (d != null) {
hashMap.put(next.getKey(), d);
}
} else {
hashMap.put(next.getKey(), next.getValue());
}
}
Object o0 = this.user.o0();
if (o0 == null) {
o0 = "NULL";
}
String upperCase = o0.toString().toUpperCase(Locale.ROOT);
o.j(upperCase, "toUpperCase(...)");
hashMap.put("Is Super", upperCase);
}
in.swiggy.android.analytics.generated.e eVar = this.swiggyEventLogger;
if (eVar != null) {
eVar.E(hashMap, str);
}
}
@ReactMethod
public final void logClickEvent(String str, String str2, String str3, Integer num, String str4, String str5) {
if (str5 != null) {
in.swiggy.android.analytics.gtm.e.x(str5);
}
if (num != null) {
int intValue = num.intValue();
in.swiggy.android.analytics.interfaces.c cVar = this.swiggyEventHandler;
if (cVar != null) {
cVar.b(cVar.q(str, str2, str3, intValue, str4));
}
}
}
@ReactMethod
public final void logImpression(String str, String str2, String str3, Integer num, String str4, String str5) {
if (str5 != null) {
in.swiggy.android.analytics.gtm.e.x(str5);
}
if (num != null) {
int intValue = num.intValue();
in.swiggy.android.analytics.interfaces.c cVar = this.swiggyEventHandler;
if (cVar != null) {
cVar.j(cVar.q(str, str2, str3, intValue, str4));
}
}
}
@ReactMethod
public final void logScreenViewed(String str) {
in.swiggy.android.analytics.interfaces.c cVar = this.swiggyEventHandler;
if (cVar != null) {
cVar.m(str);
}
}
@ReactMethod
public final void onRestaurantFavoriteEvent(String str, Boolean bool) {
boolean z;
if (str != null) {
if (bool != null) {
z = bool.booleanValue();
} else {
z = false;
}
in.swiggy.android.commons.rxjava.h.b(new in.swiggy.android.apputils.models.d(str, z, false, 4, null));
}
}
@ReactMethod
public final void openExternalWidget(ReadableMap card, String screenName) {
o.k(card, "card");
o.k(screenName, "screenName");
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
try {
HomePopUpWidget c = n.a.c(card);
if (c != null) {
c.setPage(screenName);
in.swiggy.android.commonsFeature.f fVar = this.navigation;
if (fVar != null) {
fVar.I(currentActivity, c);
Unit unit = Unit.a;
}
}
} catch (Exception e) {
x.i("DinersOne", e);
Unit unit2 = Unit.a;
}
}
}
@ReactMethod
public final void openLocationSearch() {
in.swiggy.android.commonsFeature.f fVar;
Activity currentActivity = getCurrentActivity();
if (currentActivity != null && (fVar = this.navigation) != null) {
fVar.E(currentActivity);
}
}
@ReactMethod
public final void openPaymentWebView(ReadableMap readableMap) {
Iterator<Map.Entry<String, Object>> it;
Set d;
String str;
String str2;
boolean P;
String str3;
boolean C;
String string;
HashMap<String, String> a2;
HashMap hashMap = new HashMap();
in.swiggy.android.swiggylynx.headers.a aVar = this.defaultHeaders;
if (aVar != null && (a2 = aVar.a()) != null) {
hashMap.putAll(a2);
}
if (readableMap != null) {
it = readableMap.getEntryIterator();
} else {
it = null;
}
if (it != null) {
while (it.hasNext()) {
Map.Entry<String, Object> next = it.next();
hashMap.put(next.getKey(), next.getValue().toString());
}
}
d = p0.d(new SwiggyLynxPluginData.PaymentLynxPluginData(null));
SharedPreferences sharedPreferences = this.sharedPreferences;
if (sharedPreferences == null || (string = sharedPreferences.getString("web_payment_url", "")) == null) {
str = "";
} else {
str = string;
}
if (StringExtensionsKt.e(str)) {
str2 = str;
} else {
str2 = "https://payments.swiggy.com";
}
P = q.P(str2, "https://payments-staging.swiggy.com", false, 2, null);
if (P) {
SharedPreferences sharedPreferences2 = this.sharedPreferences;
if (sharedPreferences2 != null) {
str3 = sharedPreferences2.getString("payment-secret-key", "");
} else {
str3 = null;
}
if (str3 != null) {
C = q.C(str3);
if (!C) {
hashMap.put("payment-secret-key", str3);
}
}
}
LynxData lynxData = new LynxData(str2, false, 1, hashMap, d, null, false, 96, null);
clearFoodCartCookie(str);
Activity currentActivity = this.mReactContext.getCurrentActivity();
if (currentActivity != null) {
new b().a(currentActivity);
}
Activity currentActivity2 = this.mReactContext.getCurrentActivity();
if (currentActivity2 != null) {
int requestCode = lynxData.getRequestCode();
Intent intent = new Intent(currentActivity2, LynxActivity.class);
intent.putExtras(new in.swiggy.android.swiggylynx.ui.k(lynxData, false, null, null, null, null, null, 126, null).h());
if (requestCode == -9) {
currentActivity2.startActivity(intent, null);
} else {
currentActivity2.startActivityForResult(intent, requestCode, null);
}
}
}
@ReactMethod
public final void openStaticWebView(String str) {
in.swiggy.android.commonsFeature.f fVar;
if (str != null && (fVar = this.navigation) != null) {
fVar.x(this.mReactContext, str);
}
}
@ReactMethod
public final void openWebView(String str) {
if (str != null) {
LynxData lynxData = new LynxData(str, true, 2, null, null, null, false, 120, null);
Activity currentActivity = getCurrentActivity();
if (currentActivity != null) {
o.h(currentActivity);
int requestCode = lynxData.getRequestCode();
Intent intent = new Intent(currentActivity, LynxActivity.class);
intent.putExtras(new in.swiggy.android.swiggylynx.ui.k(lynxData, false, null, null, null, null, null, 126, null).h());
if (requestCode == -9) {
currentActivity.startActivity(intent, null);
} else {
currentActivity.startActivityForResult(intent, requestCode, null);
}
}
}
}
@ReactMethod
public final void refreshSwiggyHome() {
l lVar = this.dinersFragmentHandler;
if (lVar != null) {
lVar.h4();
}
}
public final void setNewrelicPerformanceUtils(in.swiggy.android.analytics.newrelic.a aVar) {
o.k(aVar, "<set-?>");
this.newrelicPerformanceUtils = aVar;
}
@ReactMethod
public final void startPerfMonitor(String str, String str2) {
this.newrelicPerformanceUtils.d(String.valueOf(str), String.valueOf(str2));
}
@ReactMethod
public final void stopInitialLoadTrace(String screenName, String str) {
o.k(screenName, "screenName");
if (!this.traceEventFired && str != null) {
long currentTimeMillis = System.currentTimeMillis();
Long l = this.dinersAppStartTime;
if (l != null) {
this.newrelicPerformanceUtils.j(str, currentTimeMillis - l.longValue(), new LinkedHashMap());
this.traceEventFired = true;
}
}
}
@ReactMethod
public final void stopPerfMonitor(String str, String str2) {
this.newrelicPerformanceUtils.l(String.valueOf(str), String.valueOf(str2));
}
@ReactMethod
public final void toggleBottomBar(boolean z) {
l lVar = this.dinersFragmentHandler;
if (lVar != null) {
lVar.N1(z);
}
}
@ReactMethod
public final void toggleStatusBar(boolean z) {
l lVar = this.dinersFragmentHandler;
if (lVar != null) {
lVar.f0(z);
}
}
@ReactMethod
public final void trackFrequencyCapping(String journeyId, int i, String entityId, String entityType, boolean z, String cappingMode) {
o.k(journeyId, "journeyId");
o.k(entityId, "entityId");
o.k(entityType, "entityType");
o.k(cappingMode, "cappingMode");
in.swiggy.android.repositories.interfaces.d dVar = this.user;
if (dVar != null) {
dVar.i0(journeyId);
}
l lVar = this.dinersFragmentHandler;
if (lVar != null) {
lVar.Q0(i, new in.swiggy.android.cappingsdk.b(entityId, entityType, new FrequencyCapping(z, cappingMode), false, 8, null));
}
}
@ReactMethod
public final void unMountActivity() {
l lVar = this.dinersFragmentHandler;
if (lVar != null) {
lVar.g();
}
}
}