package com.linksure.browser.view.home; import android.content.Context; import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; import com.alibaba.fastjson.JSONArray; import com.appara.feed.constant.TTParam; import com.linksure.api.utils.j; import com.linksure.api.utils.l; import com.linksure.browser.bean.InputRecentItem; import com.sdk.plus.data.manager.RalDataManager; import com.wifi.link.wfys.R; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import kotlin.i; import kotlin.jvm.internal.e; import kotlin.jvm.internal.g; import kotlin.jvm.internal.k; @i /* compiled from: SearchCategoryView.kt */ public final class SearchCategoryView extends LinearLayout { public static final Companion Companion = new Companion(null); private static final SearchCategoryItem[] array = {new SearchCategoryItem("https://tophub.today/", "热榜"), new SearchCategoryItem("video", "视频"), new SearchCategoryItem("xsp", "小视频"), new SearchCategoryItem("tieba", "贴吧"), new SearchCategoryItem("novel", "小说"), new SearchCategoryItem("app", "应用")}; private static final int column = 3; private HashMap _$_findViewCache; public SearchCategoryView(Context context) { this(context, null, 0, 6, null); } public SearchCategoryView(Context context, AttributeSet attributeSet) { this(context, attributeSet, 0, 4, null); } public static final ArrayList<InputRecentItem> getSearchCategoryList(SearchCategoryItem searchCategoryItem) { return Companion.getSearchCategoryList(searchCategoryItem); } public static final String getSearchCategoryUrl(SearchCategoryItem searchCategoryItem) { return Companion.getSearchCategoryUrl(searchCategoryItem); } public static final String getSearchHint(SearchCategoryItem searchCategoryItem) { return Companion.getSearchHint(searchCategoryItem); } public static final void saveSearchCategory(SearchCategoryItem searchCategoryItem, String str) { Companion.saveSearchCategory(searchCategoryItem, str); } public final void _$_clearFindViewByIdCache() { HashMap hashMap = this._$_findViewCache; if (hashMap != null) { hashMap.clear(); } } public final View _$_findCachedViewById(int i) { if (this._$_findViewCache == null) { this._$_findViewCache = new HashMap(); } View view = (View) this._$_findViewCache.get(Integer.valueOf(i)); if (view != null) { return view; } View findViewById = findViewById(i); this._$_findViewCache.put(Integer.valueOf(i), findViewById); return findViewById; } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ SearchCategoryView(Context context, AttributeSet attributeSet, int i, int i2, e eVar) { this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i); } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public SearchCategoryView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); g.b(context, "context"); setOrientation(1); View categoryView = getCategoryView(); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2); layoutParams.setMargins(getResources().getDimensionPixelOffset(R.dimen.dp_20), getResources().getDimensionPixelOffset(R.dimen.dp_15), getResources().getDimensionPixelOffset(R.dimen.dp_20), getResources().getDimensionPixelOffset(R.dimen.dp_10)); addView(categoryView, layoutParams); } @i /* compiled from: SearchCategoryView.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(e eVar) { this(); } public final SearchCategoryItem[] getArray() { return SearchCategoryView.array; } public final int getColumn() { return SearchCategoryView.column; } public final String getSearchHint(SearchCategoryItem searchCategoryItem) { g.b(searchCategoryItem, TTParam.KEY_item); String action = searchCategoryItem.getAction(); switch (action.hashCode()) { case 96801: if (action.equals("app")) { String b2 = j.b(R.string.search_hint_app); g.a((Object) b2, "ResourceUtils.getString(R.string.search_hint_app)"); return b2; } break; case 118997: if (action.equals("xsp")) { String b3 = j.b(R.string.search_hint_xsp); g.a((Object) b3, "ResourceUtils.getString(R.string.search_hint_xsp)"); return b3; } break; case 105010748: if (action.equals("novel")) { String b4 = j.b(R.string.search_hint_novel); g.a((Object) b4, "ResourceUtils.getString(…string.search_hint_novel)"); return b4; } break; case 110356687: if (action.equals("tieba")) { String b5 = j.b(R.string.search_hint_tieba); g.a((Object) b5, "ResourceUtils.getString(…string.search_hint_tieba)"); return b5; } break; case 112202875: if (action.equals("video")) { String b6 = j.b(R.string.search_hint_video); g.a((Object) b6, "ResourceUtils.getString(…string.search_hint_video)"); return b6; } break; } String b7 = j.b(R.string.input_search_website); g.a((Object) b7, "ResourceUtils.getString(…ing.input_search_website)"); return b7; } public final String getSearchCategoryUrl(SearchCategoryItem searchCategoryItem) { g.b(searchCategoryItem, TTParam.KEY_item); k kVar = k.f8957a; String format = String.format("https://m.baidu.com/sf/vsearch?pd=%s&atn=index&tn=vsearch&word=%s&key=TGFudGVybkJyb3dzZXI=", Arrays.copyOf(new Object[]{searchCategoryItem.getAction(), "%s"}, 2)); g.a((Object) format, "java.lang.String.format(format, *args)"); return format; } public final void saveSearchCategory(SearchCategoryItem searchCategoryItem, String str) { JSONArray jSONArray; g.b(searchCategoryItem, "searchCategoryItem"); g.b(str, RalDataManager.DB_KEY); try { String a2 = l.a(searchCategoryItem.getAction()); if (!TextUtils.isEmpty(a2)) { jSONArray = JSONArray.parseArray(a2); g.a((Object) jSONArray, "JSONArray.parseArray(value)"); int size = jSONArray.size(); int i = -1; for (int i2 = 0; i2 < size; i2++) { if (jSONArray.getString(i2).equals(str)) { i = i2; } } if (i != -1) { jSONArray.remove(i); } } else { jSONArray = new JSONArray(); } jSONArray.add(str); l.a(searchCategoryItem.getAction(), jSONArray.toJSONString()); } catch (Exception unused) { } } public final ArrayList<InputRecentItem> getSearchCategoryList(SearchCategoryItem searchCategoryItem) { g.b(searchCategoryItem, "searchCategoryItem"); ArrayList<InputRecentItem> arrayList = new ArrayList<>(); try { JSONArray parseArray = JSONArray.parseArray(l.a(searchCategoryItem.getAction())); int size = parseArray.size(); for (int i = 0; i < size; i++) { InputRecentItem inputRecentItem = new InputRecentItem(); inputRecentItem.setContent(parseArray.getString(i)); arrayList.add(inputRecentItem); } } catch (Exception unused) { } return arrayList; } } public final View getCategoryView() { LinearLayout linearLayout = new LinearLayout(getContext()); linearLayout.setOrientation(1); int length = array.length; LinearLayout linearLayout2 = null; for (int i = 0; i < length; i++) { if (i % column == 0) { linearLayout2 = new LinearLayout(getContext()); linearLayout2.setOrientation(0); linearLayout2.setGravity(16); linearLayout.addView(linearLayout2); } if (!(i % column == 0 || linearLayout2 == null)) { View view = new View(getContext()); view.setBackgroundColor(j.a((int) R.color.base_line_color)); linearLayout2.addView(view, new LinearLayout.LayoutParams(1, j.d(R.dimen.dp_20))); } if (linearLayout2 != null) { View categoryItemView = getCategoryItemView(array[i]); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2); layoutParams.weight = 1.0f; linearLayout2.addView(categoryItemView, layoutParams); } } return linearLayout; } public final View getCategoryItemView(SearchCategoryItem searchCategoryItem) { g.b(searchCategoryItem, TTParam.KEY_item); TextView textView = new TextView(getContext()); textView.setText(searchCategoryItem.getValue()); textView.setTextSize(0, j.c(R.dimen.text_size16)); textView.setTextColor(j.a((int) R.color.search_category_title_color)); textView.setHeight(j.d(R.dimen.dp_48)); textView.setGravity(17); textView.setPadding(j.d(R.dimen.dp_15), 0, j.d(R.dimen.dp_15), 0); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setMaxLines(1); textView.setOnClickListener(new SearchCategoryView$getCategoryItemView$$inlined$apply$lambda$1(textView, searchCategoryItem)); return textView; } @i /* compiled from: SearchCategoryView.kt */ public static final class SearchCategoryItem implements Serializable { private final String action; private final String value; public static /* synthetic */ SearchCategoryItem copy$default(SearchCategoryItem searchCategoryItem, String str, String str2, int i, Object obj) { if ((i & 1) != 0) { str = searchCategoryItem.action; } if ((i & 2) != 0) { str2 = searchCategoryItem.value; } return searchCategoryItem.copy(str, str2); } public final String component1() { return this.action; } public final String component2() { return this.value; } public final SearchCategoryItem copy(String str, String str2) { g.b(str, TTParam.KEY_action); g.b(str2, RalDataManager.DB_VALUE); return new SearchCategoryItem(str, str2); } public final boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof SearchCategoryItem)) { return false; } SearchCategoryItem searchCategoryItem = (SearchCategoryItem) obj; return g.a(this.action, searchCategoryItem.action) && g.a(this.value, searchCategoryItem.value); } public final int hashCode() { String str = this.action; int i = 0; int hashCode = (str != null ? str.hashCode() : 0) * 31; String str2 = this.value; if (str2 != null) { i = str2.hashCode(); } return hashCode + i; } public final String toString() { return "SearchCategoryItem(action=" + this.action + ", value=" + this.value + ")"; } public SearchCategoryItem(String str, String str2) { g.b(str, TTParam.KEY_action); g.b(str2, RalDataManager.DB_VALUE); this.action = str; this.value = str2; } public final String getAction() { return this.action; } public final String getValue() { return this.value; } } }