Swiggy v4.51.1版本的 MD5 值为:5af7ec91512a0a8c1510e3f8bac20b8b
以下内容为反编译后的 a.java 源代码,内容仅作参考
package in.swiggy.android.searchutils;
import android.content.SharedPreferences;
import android.net.Uri;
import com.google.gson.Gson;
import com.newrelic.agent.android.instrumentation.GsonInstrumentation;
import com.newrelic.agent.android.instrumentation.Instrumented;
import com.newrelic.agent.android.instrumentation.JSONObjectInstrumentation;
import in.swiggy.android.commons.extension.KotlinExtensionsKt;
import in.swiggy.android.commons.utils.f0;
import in.swiggy.android.commons.utils.i0;
import in.swiggy.android.commons.utils.x;
import in.swiggy.android.constants.b;
import in.swiggy.android.repositories.interfaces.e;
import in.swiggy.android.searchutils.analytics.d;
import in.swiggy.android.tejas.TejasConstants;
import in.swiggy.android.tejas.feature.listing.cta.model.CTA;
import in.swiggy.android.tejas.feature.listing.dish.model.ListingMenuItem;
import in.swiggy.android.tejas.feature.listing.rig.model.SRPOfferVariantType;
import in.swiggy.android.tejas.oldapi.models.KeySeparator;
import in.swiggy.android.tejas.oldapi.models.intdef.TrackOrderState;
import in.swiggy.android.tejas.oldapi.models.restaurant.DishOrderedCount;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Map;
import kotlin.NoWhenBranchMatchedException;
import kotlin.jvm.internal.o;
import kotlin.text.StringsKt__StringsKt;
import org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDLayoutAttributeObject;
import org.json.JSONException;
import org.json.JSONObject;
@Instrumented
public final class a {
public static final a a = new a();
private static boolean b;
private static boolean c;
public class C0850a {
public static final int[] a;
static {
int[] iArr = new int[DishOrderedCount.values().length];
try {
iArr[DishOrderedCount.ORDERED_COUNT_1.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_2.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_3.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_4.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_5.ordinal()] = 5;
} catch (NoSuchFieldError unused5) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_6.ordinal()] = 6;
} catch (NoSuchFieldError unused6) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_7.ordinal()] = 7;
} catch (NoSuchFieldError unused7) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_8.ordinal()] = 8;
} catch (NoSuchFieldError unused8) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_9.ordinal()] = 9;
} catch (NoSuchFieldError unused9) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_FREQUENT.ordinal()] = 10;
} catch (NoSuchFieldError unused10) {
}
try {
iArr[DishOrderedCount.ORDERED_COUNT_INVALID.ordinal()] = 11;
} catch (NoSuchFieldError unused11) {
}
a = iArr;
}
}
private a() {
}
private final String A(String str, String str2) {
try {
return new JSONObject(str).getString(str2);
} catch (JSONException e) {
x.i("SearchUtils", e);
return null;
}
}
private final String O(String str, String str2, String str3) {
try {
JSONObject jSONObject = new JSONObject(str);
jSONObject.remove(str2);
jSONObject.put(str2, str3);
String jSONObjectInstrumentation = JSONObjectInstrumentation.toString(jSONObject);
o.h(jSONObjectInstrumentation);
return jSONObjectInstrumentation;
} catch (JSONException e) {
x.i("SearchUtils", e);
return str;
}
}
private final String c(String str, String str2, int i) {
try {
JSONObject jSONObject = new JSONObject(str);
jSONObject.put(str2, i);
String jSONObjectInstrumentation = JSONObjectInstrumentation.toString(jSONObject);
o.h(jSONObjectInstrumentation);
return jSONObjectInstrumentation;
} catch (JSONException e) {
x.i("SearchUtils", e);
return str;
}
}
private final String d(String str, String str2, String str3) {
try {
JSONObject jSONObject = new JSONObject(str);
jSONObject.put(str2, str3);
String jSONObjectInstrumentation = JSONObjectInstrumentation.toString(jSONObject);
o.h(jSONObjectInstrumentation);
return jSONObjectInstrumentation;
} catch (JSONException e) {
x.i("SearchUtils", e);
return str;
}
}
public static String s(a aVar, d dVar, Object obj, int i, Object obj2) {
if ((i & 2) != 0) {
obj = null;
}
return aVar.r(dVar, obj);
}
public final String B(String query, String trackingId) {
o.k(query, "query");
o.k(trackingId, "trackingId");
return "swiggy://explore?query=" + query + "&randomTrackingId=" + trackingId + "&submitAction=VOICE_SEARCH";
}
public final boolean C(SharedPreferences sharedPreferences) {
o.k(sharedPreferences, "sharedPreferences");
return KotlinExtensionsKt.r(b.b("as_revamp_animation_enabled", TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT, sharedPreferences), false, 1, null);
}
public final boolean D(SharedPreferences sharedPreferences, e xpExperimentContext) {
o.k(sharedPreferences, "sharedPreferences");
o.k(xpExperimentContext, "xpExperimentContext");
boolean r = KotlinExtensionsKt.r(b.b("android_enable_as_revamp_search", TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT, sharedPreferences), false, 1, null);
boolean f = o.f(xpExperimentContext.H("search_as_revamp", TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), "true");
if (!r || !f) {
return false;
}
return true;
}
public final boolean E(String ctaLink) {
boolean U;
o.k(ctaLink, "ctaLink");
U = StringsKt__StringsKt.U(ctaLink, "swiggydiners://", false, 2, null);
return U;
}
public final boolean F(SharedPreferences sharedPreferences, e xpExperimentContext) {
o.k(sharedPreferences, "sharedPreferences");
o.k(xpExperimentContext, "xpExperimentContext");
boolean r = KotlinExtensionsKt.r(b.b("android_enable_dineout_native_search", TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT, sharedPreferences), false, 1, null);
boolean f = o.f(xpExperimentContext.H("dineout_migration", "RN-Old"), "Native-New");
if (!r || !f) {
return false;
}
return true;
}
public final boolean G(in.swiggy.android.commons.featureFlags.d featureFlags) {
o.k(featureFlags, "featureFlags");
return KotlinExtensionsKt.q(featureFlags.a("android_dynamic_placeholder_enable"), false);
}
public final boolean H(String screenName, CTA cta) {
boolean U;
boolean U2;
o.k(screenName, "screenName");
o.k(cta, "cta");
if (!o.f(screenName, "explore") && !o.f(screenName, "presearch")) {
return false;
}
String link = cta.getLink();
if (link != null) {
U2 = StringsKt__StringsKt.U(link, "swiggy://search", false, 2, null);
}
String link2 = cta.getLink();
if (link2 != null) {
U = StringsKt__StringsKt.U(link2, "swiggy://explore", false, 2, null);
if (!U) {
return false;
}
return true;
}
return false;
}
public final boolean I(String ctaLink) {
boolean U;
o.k(ctaLink, "ctaLink");
U = StringsKt__StringsKt.U(ctaLink, "swiggy://stores/go", false, 2, null);
return U;
}
public final boolean J(String ctaLink) {
boolean U;
o.k(ctaLink, "ctaLink");
U = StringsKt__StringsKt.U(ctaLink, "swiggy://stores/instamart?v=1", false, 2, null);
return U;
}
public final boolean K(SharedPreferences sharedPreferences, e xpExperimentContext) {
o.k(sharedPreferences, "sharedPreferences");
o.k(xpExperimentContext, "xpExperimentContext");
boolean r = KotlinExtensionsKt.r(b.b("android_enable_im_modular_search", TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT, sharedPreferences), false, 1, null);
boolean f = o.f(xpExperimentContext.H("search_modular_config", TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), "true");
if (!r || !f) {
return false;
}
return true;
}
public final boolean L(e xpExperimentContext) {
o.k(xpExperimentContext, "xpExperimentContext");
return KotlinExtensionsKt.r(xpExperimentContext.H("search_fliptext", TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), false, 1, null);
}
public final boolean M(SRPOfferVariantType variant) {
o.k(variant, "variant");
if (variant == SRPOfferVariantType.DISH_SRP_OFFER_VARIANT_TYPE_DEFAULT) {
return true;
}
return false;
}
public final String N(String json, String key, String value) {
o.k(json, "json");
o.k(key, "key");
o.k(value, "value");
return O(json, key, value);
}
public final void P(boolean z) {
b = z;
}
public final void Q(boolean z) {
c = z;
}
public final boolean R(in.swiggy.android.commons.featureFlags.d featureFlags, e xpExperimentContext) {
o.k(featureFlags, "featureFlags");
o.k(xpExperimentContext, "xpExperimentContext");
boolean r = KotlinExtensionsKt.r(featureFlags.a("android_enable_skip_to_dish_page"), false, 1, null);
boolean f = o.f(xpExperimentContext.H("search_skip_dish_add", "dish_page"), "menu_page_with_cross_sell");
if (!r || !f) {
return false;
}
return true;
}
public final boolean S(in.swiggy.android.commons.featureFlags.d featureFlags, e xpExperimentContext) {
o.k(featureFlags, "featureFlags");
o.k(xpExperimentContext, "xpExperimentContext");
boolean r = KotlinExtensionsKt.r(featureFlags.a("android_enable_skip_to_dish_page"), false, 1, null);
boolean z = !o.f(xpExperimentContext.H("search_skip_dish_add", "dish_page"), "dish_page");
if (!r || !z) {
return false;
}
return true;
}
public final void T(SharedPreferences sharedPreferences) {
o.k(sharedPreferences, "sharedPreferences");
sharedPreferences.edit().putString("as_revamp_animation_count", String.valueOf(KotlinExtensionsKt.x(b.b("as_revamp_animation_count", PDLayoutAttributeObject.GLYPH_ORIENTATION_VERTICAL_ZERO_DEGREES, sharedPreferences), 0, 1, null) + 1)).apply();
}
public final String a(String json, boolean z) {
o.k(json, "json");
return d(json, "adFlag", String.valueOf(z));
}
public final String b(String json, boolean z) {
o.k(json, "json");
return d(json, "imageFlag", String.valueOf(z));
}
public final String e(String json, String key, int i) {
o.k(json, "json");
o.k(key, "key");
return c(json, key, i);
}
public final String f(String json, String key, String value) {
o.k(json, "json");
o.k(key, "key");
o.k(value, "value");
return d(json, key, value);
}
public final String g(String json, String source) {
o.k(json, "json");
o.k(source, "source");
return d(json, "clickTilePosition", source);
}
public final String h(String json, String source) {
o.k(json, "json");
o.k(source, "source");
return d(json, "Source", source);
}
public final String i(String json, String trackingId) {
o.k(json, "json");
o.k(trackingId, "trackingId");
return d(json, "trackingId", trackingId);
}
public final String j(String json, String key, String value) {
o.k(json, "json");
o.k(key, "key");
o.k(value, "value");
try {
JSONObject jSONObject = new JSONObject(json);
jSONObject.put(key, value);
String jSONObjectInstrumentation = JSONObjectInstrumentation.toString(jSONObject);
o.h(jSONObjectInstrumentation);
return jSONObjectInstrumentation;
} catch (JSONException e) {
x.i("SearchUtils", e);
return json;
}
}
public final String k(d dVar, String str) {
String json;
Iterator<Map.Entry<String, String>> it;
Boolean bool;
Map.Entry<String, String> next;
Map<String, String> a2;
if (str != null && str.length() != 0) {
if (dVar != null && (a2 = dVar.a()) != null) {
it = a2.entrySet().iterator();
} else {
it = null;
}
while (true) {
if (it != null) {
bool = Boolean.valueOf(it.hasNext());
} else {
bool = null;
}
if (KotlinExtensionsKt.h(bool)) {
if (it != null && (next = it.next()) != null) {
str = a.N(str, next.getKey(), next.getValue());
}
} else {
return str;
}
}
} else {
try {
Gson g = i0.g();
if (!(g instanceof Gson)) {
json = g.toJson(dVar);
} else {
json = GsonInstrumentation.toJson(g, dVar);
}
o.h(json);
return json;
} catch (Exception e) {
x.i("SearchUtils", e);
if (str == null) {
str = "";
}
return str;
}
}
}
public final String l(String ctaLink, String queryParam) {
boolean U;
o.k(ctaLink, "ctaLink");
o.k(queryParam, "queryParam");
String str = "?";
U = StringsKt__StringsKt.U(ctaLink, "?", false, 2, null);
if (U) {
str = KeySeparator.AMP;
}
return (ctaLink + str) + queryParam;
}
public final String m(String cta, String placeholder) {
boolean U;
o.k(cta, "cta");
o.k(placeholder, "placeholder");
U = StringsKt__StringsKt.U(cta, "contextualSearch", false, 2, null);
if (U) {
return l(cta, "placeholder=" + placeholder);
}
return cta;
}
public final String n(String ctaLink, String trackingId) {
boolean U;
o.k(ctaLink, "ctaLink");
o.k(trackingId, "trackingId");
String str = "?";
U = StringsKt__StringsKt.U(ctaLink, "?", false, 2, null);
if (U) {
str = KeySeparator.AMP;
}
return ctaLink + (str + "randomTrackingId=" + trackingId);
}
public final boolean o(SharedPreferences sharedPreferences) {
o.k(sharedPreferences, "sharedPreferences");
if (KotlinExtensionsKt.x(b.b("as_revamp_animation_count", PDLayoutAttributeObject.GLYPH_ORIENTATION_VERTICAL_ZERO_DEGREES, sharedPreferences), 0, 1, null) >= KotlinExtensionsKt.x(b.b("as_revamp_animation_max_count", TrackOrderState.ORDER_PICKED_UP, sharedPreferences), 0, 1, null)) {
return false;
}
return true;
}
public final String p(String json, String key, String value) {
boolean U;
o.k(json, "json");
o.k(key, "key");
o.k(value, "value");
try {
JSONObject jSONObject = new JSONObject(json);
String jSONObjectInstrumentation = JSONObjectInstrumentation.toString(jSONObject);
o.j(jSONObjectInstrumentation, "toString(...)");
U = StringsKt__StringsKt.U(jSONObjectInstrumentation, key, false, 2, null);
if (!U) {
jSONObject.put(key, value);
String jSONObjectInstrumentation2 = JSONObjectInstrumentation.toString(jSONObject);
o.j(jSONObjectInstrumentation2, "toString(...)");
return jSONObjectInstrumentation2;
}
return jSONObjectInstrumentation;
} catch (JSONException e) {
x.i("SearchUtils", e);
return json;
}
}
public final boolean q() {
return b;
}
public final String r(d dVar, Object obj) {
String json;
String json2;
if (obj != null) {
try {
Gson g = i0.g();
if (!(g instanceof Gson)) {
json = g.toJson(obj);
} else {
json = GsonInstrumentation.toJson(g, obj);
}
} catch (Exception e) {
x.i("SearchUtils", e);
json = "";
}
} else {
json = null;
}
try {
Gson g2 = i0.g();
if (!(g2 instanceof Gson)) {
json2 = g2.toJson(dVar);
} else {
json2 = GsonInstrumentation.toJson(g2, dVar);
}
if (dVar != null && json != null) {
json2 = k(dVar, json);
} else if (dVar == null) {
if (json == null) {
json2 = "";
} else {
json2 = json;
}
}
o.h(json2);
return json2;
} catch (Exception e2) {
x.i("SearchUtils", e2);
if (json == null) {
return "";
}
return json;
}
}
public final String t(ListingMenuItem item) {
o.k(item, "item");
switch (C0850a.a[item.getMenuItem().dishPersonalisationMarker.getOrderedCount().ordinal()]) {
case 1:
return "1";
case 2:
return "2";
case 3:
return TrackOrderState.ORDER_PICKED_UP;
case 4:
return "4";
case 5:
return TrackOrderState.ORDER_CANCELLED;
case 6:
return TrackOrderState.ORDER_OTHER_ERROR;
case 7:
return "7";
case 8:
return "8";
case 9:
return "9";
case 10:
return "frequently";
case 11:
return "";
default:
throw new NoWhenBranchMatchedException();
}
}
public final String u(SharedPreferences sharedPreferences) {
o.k(sharedPreferences, "sharedPreferences");
String string = sharedPreferences.getString("android_im_modular_search_url", "https://stores.swiggy.com/instamart/search?custom_back=true&globalSearch=true");
if (string == null) {
return "";
}
return string;
}
public final String v(String link) {
String host;
o.k(link, "link");
Uri parse = Uri.parse(link);
if (parse == null || (host = parse.getHost()) == null || !f0.f(parse.getQueryParameter("query")) || f0.e(host)) {
return null;
}
if (!o.f(host, "explore") && !o.f(host, "search")) {
return null;
}
return parse.getQueryParameter("query");
}
public final boolean w() {
return c;
}
public final String x(String query) {
o.k(query, "query");
String encode = URLEncoder.encode(query);
return "swiggy://search?query=" + encode;
}
public final long y(SharedPreferences sharedPreferences) {
o.k(sharedPreferences, "sharedPreferences");
return KotlinExtensionsKt.z(b.b("delay_srp_to_menu", "500", sharedPreferences), 0L, 1, null);
}
public final String z(String json) {
o.k(json, "json");
return A(json, "trackingId");
}
}