package com.overlook.android.fing.ui.main; import android.content.Context; import android.content.res.Resources; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; import androidx.cardview.widget.CardView; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.recyclerview.widget.RecyclerView; import com.huawei.hms.support.api.push.utils.common.base.PushConst; import com.overlook.android.fing.R; import com.overlook.android.fing.engine.services.netbox.m0; import com.overlook.android.fing.ui.base.j; import com.overlook.android.fing.ui.misc.h; import com.overlook.android.fing.vl.components.Header; import com.overlook.android.fing.vl.components.IconView; import com.overlook.android.fing.vl.components.MainButton; import com.overlook.android.fing.vl.components.PostView; import com.overlook.android.fing.vl.components.SectionFooter; import com.overlook.android.fing.vl.components.e1; import e.f.a.a.b.h.i; import e.f.a.a.b.j.k; import e.f.a.a.b.j.l; import h.c0; import h.e0; import h.f; import h.g; import h.i0; import h.k0; import java.io.IOException; import java.util.ArrayList; import java.util.List; import okhttp3.internal.connection.e; import org.json.JSONArray; import org.json.JSONObject; public class CommunityFragment extends j { public static final /* synthetic */ int m0 = 0; private Header c0; private IconView d0; private SectionFooter e0; private LinearLayout f0; private d g0; private final h h0 = new h(null); private final List<Post> i0 = new ArrayList(); private long j0 = 0; private CommunityUser k0; private RecyclerView l0; /* access modifiers changed from: private */ public static class CommunityUser implements Parcelable { public static final Parcelable.Creator<CommunityUser> CREATOR = new a(); /* renamed from: a reason: collision with root package name */ String f16919a; String b; /* renamed from: c reason: collision with root package name */ int f16920c; static class a implements Parcelable.Creator<CommunityUser> { a() { } /* Return type fixed from 'java.lang.Object' to match base method */ @Override // android.os.Parcelable.Creator public CommunityUser createFromParcel(Parcel parcel) { return new CommunityUser(parcel); } /* Return type fixed from 'java.lang.Object[]' to match base method */ @Override // android.os.Parcelable.Creator public CommunityUser[] newArray(int i2) { return new CommunityUser[i2]; } } CommunityUser() { } public int describeContents() { return 0; } public void writeToParcel(Parcel parcel, int i2) { parcel.writeString(this.f16919a); parcel.writeString(this.b); parcel.writeInt(this.f16920c); } CommunityUser(Parcel parcel) { this.f16919a = parcel.readString(); this.b = parcel.readString(); this.f16920c = parcel.readInt(); } } /* access modifiers changed from: private */ public static class Post implements Parcelable { public static final Parcelable.Creator<Post> CREATOR = new a(); /* renamed from: a reason: collision with root package name */ int f16921a; String b; /* renamed from: c reason: collision with root package name */ String f16922c; /* renamed from: d reason: collision with root package name */ String f16923d; /* renamed from: e reason: collision with root package name */ String f16924e; /* renamed from: f reason: collision with root package name */ String f16925f; /* renamed from: g reason: collision with root package name */ String f16926g; /* renamed from: h reason: collision with root package name */ int f16927h; /* renamed from: i reason: collision with root package name */ int f16928i; String j; String k; static class a implements Parcelable.Creator<Post> { a() { } /* Return type fixed from 'java.lang.Object' to match base method */ @Override // android.os.Parcelable.Creator public Post createFromParcel(Parcel parcel) { return new Post(parcel); } /* Return type fixed from 'java.lang.Object[]' to match base method */ @Override // android.os.Parcelable.Creator public Post[] newArray(int i2) { return new Post[i2]; } } Post() { } public int describeContents() { return 0; } public void writeToParcel(Parcel parcel, int i2) { parcel.writeInt(this.f16921a); parcel.writeString(this.b); parcel.writeString(this.f16922c); parcel.writeString(this.f16923d); parcel.writeString(this.f16924e); parcel.writeString(this.f16925f); parcel.writeString(this.f16926g); parcel.writeInt(this.f16927h); parcel.writeInt(this.f16928i); parcel.writeString(this.j); parcel.writeString(this.k); } Post(Parcel parcel) { this.f16921a = parcel.readInt(); this.b = parcel.readString(); this.f16922c = parcel.readString(); this.f16923d = parcel.readString(); this.f16924e = parcel.readString(); this.f16925f = parcel.readString(); this.f16926g = parcel.readString(); this.f16927h = parcel.readInt(); this.f16928i = parcel.readInt(); this.j = parcel.readString(); this.k = parcel.readString(); } } /* access modifiers changed from: package-private */ public class a implements g { a() { } /* JADX WARNING: Code restructure failed: missing block: B:20:0x0051, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:21:0x0052, code lost: if (r6 != null) goto L_0x0054; */ /* JADX WARNING: Code restructure failed: missing block: B:23:?, code lost: r6.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:24:0x0058, code lost: r6 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:25:0x0059, code lost: r5.addSuppressed(r6); */ /* JADX WARNING: Code restructure failed: missing block: B:26:0x005c, code lost: throw r0; */ @Override // h.g public void a(f fVar, i0 i0Var) { try { if (!i0Var.x()) { CommunityFragment.this.h0.k(); return; } try { k0 b = i0Var.b(); if (b == null) { CommunityFragment.this.h0.k(); if (b != null) { b.close(); return; } return; } JSONObject jSONObject = new JSONObject(b.i()); JSONArray jSONArray = jSONObject.getJSONArray("posts"); JSONObject jSONObject2 = null; if (jSONObject.has("user")) { jSONObject2 = jSONObject.getJSONObject("user"); } CommunityFragment.this.f2(new h0(this, jSONArray, jSONObject2)); b.close(); } catch (Exception unused) { CommunityFragment.this.h0.k(); } } catch (Exception e2) { int i2 = CommunityFragment.m0; Log.e("fing:community", "Failed to retrieve latest discussions JSON", e2); CommunityFragment.this.h0.k(); } } @Override // h.g public void b(f fVar, IOException iOException) { int i2 = CommunityFragment.m0; Log.e("fing:community", "Failed to retrieve latest discussions JSON", iOException); CommunityFragment.this.h0.k(); } } private static class b extends RecyclerView.x { b(CardView cardView) { super(cardView); } } private static class c extends RecyclerView.x { c(View view) { super(view); } } /* access modifiers changed from: private */ public class d extends e1 { d(a aVar) { } /* access modifiers changed from: protected */ @Override // com.overlook.android.fing.vl.components.e1 public int A(int i2) { return CommunityFragment.this.i0.size(); } /* access modifiers changed from: protected */ @Override // com.overlook.android.fing.vl.components.e1 public int B() { return 1; } /* access modifiers changed from: protected */ @Override // com.overlook.android.fing.vl.components.e1 public boolean F(int i2) { return false; } /* access modifiers changed from: protected */ @Override // com.overlook.android.fing.vl.components.e1 public boolean G(int i2) { return CommunityFragment.this.i0.size() > 0; } /* access modifiers changed from: protected */ @Override // com.overlook.android.fing.vl.components.e1 public void N(RecyclerView.x xVar, int i2, int i3) { if (CommunityFragment.this.m0() != null) { Post post = (Post) CommunityFragment.this.i0.get(i3); int dimensionPixelSize = CommunityFragment.this.w0().getDimensionPixelSize(R.dimen.spacing_small); PostView postView = (PostView) ((CardView) ((b) xVar).f1428a).getChildAt(0); if (postView != null) { postView.q().setTag(Integer.valueOf(e.e.a.a.a.a.g(i2, i3))); postView.n().setMaxLines(3); postView.n().setEllipsize(TextUtils.TruncateAt.END); postView.p().setText(post.f16922c); postView.r().setText(post.f16923d); postView.n().setText(post.f16924e); postView.o().setText(post.j); if (!TextUtils.isEmpty(post.b)) { e.f.a.a.b.h.d u = e.f.a.a.b.h.d.u(CommunityFragment.this.m0()); u.j(R.drawable.avatar_placeholder); u.t(new i(androidx.core.content.a.b(CommunityFragment.this.m0(), R.color.grey20))); u.r(post.b); u.s(postView.q()); u.a(); } postView.setPaddingRelative(dimensionPixelSize, dimensionPixelSize, dimensionPixelSize, dimensionPixelSize); postView.setOnClickListener(new k0(this, post)); } } } /* access modifiers changed from: protected */ @Override // com.overlook.android.fing.vl.components.e1 public void S(RecyclerView.x xVar) { if (CommunityFragment.this.m0() != null) { if (CommunityFragment.this.k0 != null) { if (CommunityFragment.this.k0.f16920c == 0) { CommunityFragment.this.e0.w(CommunityFragment.this.C0(R.string.community_no_notification)); } else if (CommunityFragment.this.k0.f16920c == 1) { CommunityFragment.this.e0.w(CommunityFragment.this.C0(R.string.community_one_notification)); } else { SectionFooter sectionFooter = CommunityFragment.this.e0; CommunityFragment communityFragment = CommunityFragment.this; sectionFooter.w(communityFragment.D0(R.string.community_multi_notification, String.valueOf(communityFragment.k0.f16920c))); } CommunityFragment.this.e0.t(new j0(this)); e.f.a.a.b.h.d u = e.f.a.a.b.h.d.u(CommunityFragment.this.m0()); u.r(CommunityFragment.this.k0.f16919a); u.t(new i(androidx.core.content.a.b(CommunityFragment.this.m0(), R.color.grey20))); u.i(new l0(this)); u.a(); return; } CommunityFragment.this.e0.v(R.string.fing_community_action); CommunityFragment.this.e0.t(new i0(this)); CommunityFragment.this.d0.setVisibility(8); } } /* access modifiers changed from: protected */ @Override // com.overlook.android.fing.vl.components.e1 public RecyclerView.x T(ViewGroup viewGroup, int i2) { int dimensionPixelSize = CommunityFragment.this.w0().getDimensionPixelSize(R.dimen.spacing_small); CardView cardView = new CardView(CommunityFragment.this.m0(), null); cardView.f((float) e.e.a.a.a.a.s(5.0f)); cardView.setElevation(0.0f); cardView.d(androidx.core.content.a.b(CommunityFragment.this.m0(), R.color.grey20)); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2); layoutParams.setMargins(dimensionPixelSize, 0, dimensionPixelSize, dimensionPixelSize); cardView.setLayoutParams(layoutParams); cardView.addView(new PostView(CommunityFragment.this.m0())); return new b(cardView); } /* access modifiers changed from: protected */ @Override // com.overlook.android.fing.vl.components.e1 public RecyclerView.x V(ViewGroup viewGroup, int i2) { Context m0 = CommunityFragment.this.m0(); Resources w0 = CommunityFragment.this.w0(); int dimensionPixelSize = w0.getDimensionPixelSize(R.dimen.spacing_small); int dimensionPixelSize2 = w0.getDimensionPixelSize(R.dimen.button_size_regular); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2); layoutParams.setMargins(dimensionPixelSize, dimensionPixelSize, dimensionPixelSize, dimensionPixelSize); MainButton mainButton = new MainButton(m0); mainButton.setBackgroundColor(androidx.core.content.a.b(m0, R.color.accent10)); int i3 = 0; mainButton.setPaddingRelative(dimensionPixelSize, 0, dimensionPixelSize, 0); mainButton.m(true); mainButton.l(0); mainButton.j(R.drawable.community_24); mainButton.k(androidx.core.content.a.b(m0, R.color.accent100)); if (!e.f.a.a.c.b.b.i()) { i3 = 8; } mainButton.q(i3); mainButton.o(CommunityFragment.this.C0(R.string.generic_seeall)); mainButton.p(androidx.core.content.a.b(m0, R.color.accent100)); mainButton.setOnClickListener(new m0(m0)); Header header = new Header(m0); header.setBackgroundColor(androidx.core.content.a.b(m0, R.color.background100)); header.setLayoutParams(layoutParams); header.C(CommunityFragment.this.C0(R.string.fing_community_latestdiscussions_title)); header.v(Header.b.TOP); header.u(Header.a.WRAP); header.t(mainButton, new ConstraintLayout.LayoutParams(-2, dimensionPixelSize2)); View view = new View(m0); view.setBackgroundColor(androidx.core.content.a.b(m0, R.color.backdrop100)); view.setLayoutParams(new ViewGroup.LayoutParams(-1, dimensionPixelSize)); LinearLayout linearLayout = new LinearLayout(m0); linearLayout.setBackgroundColor(androidx.core.content.a.b(m0, R.color.background100)); linearLayout.setLayoutParams(new ViewGroup.LayoutParams(-1, -2)); linearLayout.setOrientation(1); linearLayout.addView(view); linearLayout.addView(header); return new c(linearLayout); } } static void H2(CommunityFragment communityFragment, JSONArray jSONArray, JSONObject jSONObject) { if (communityFragment.m0() != null) { communityFragment.i0.clear(); for (int i2 = 0; i2 < jSONArray.length(); i2++) { JSONObject optJSONObject = jSONArray.optJSONObject(i2); if (optJSONObject != null && optJSONObject.has("title") && optJSONObject.has("url") && optJSONObject.has("author") && optJSONObject.has("body") && optJSONObject.has("dateInserted")) { String trim = optJSONObject.optString("body").replaceAll("<[^>]+>", "").replaceAll("\n", " ").trim(); if (!TextUtils.isEmpty(trim)) { Post post = new Post(); post.f16923d = optJSONObject.optString("title"); post.f16924e = trim.trim(); post.f16926g = optJSONObject.optString("url"); post.f16922c = optJSONObject.optString("author"); long optLong = optJSONObject.optLong("dateInserted"); k kVar = k.DATE_AND_TIME; l lVar = l.SHORT; post.j = e.f.a.a.b.j.j.b(optLong, kVar, lVar); if (optJSONObject.has("authorPhotoUrl")) { post.b = optJSONObject.optString("authorPhotoUrl"); } if (optJSONObject.has("dateLastComment")) { post.k = e.f.a.a.b.j.j.b(optJSONObject.optLong("dateLastComment"), kVar, lVar); } if (optJSONObject.has(PushConst.EXTRA_SELFSHOW_TYPE_KEY)) { post.f16925f = optJSONObject.optString(PushConst.EXTRA_SELFSHOW_TYPE_KEY); } if (optJSONObject.has("id")) { post.f16921a = optJSONObject.optInt("id"); } if (optJSONObject.has("totalComments")) { post.f16928i = optJSONObject.optInt("totalComments"); } if (optJSONObject.has("totalViews")) { post.f16927h = optJSONObject.optInt("totalViews"); } communityFragment.i0.add(post); if (((long) communityFragment.i0.size()) >= 12) { break; } } else { continue; } } } if (jSONObject == null) { communityFragment.k0 = null; } else { try { communityFragment.k0 = new CommunityUser(); if (jSONObject.has("photoUrl")) { communityFragment.k0.f16919a = jSONObject.optString("photoUrl"); } if (jSONObject.has("name")) { communityFragment.k0.b = jSONObject.optString("name"); } if (jSONObject.has("notifications")) { communityFragment.k0.f16920c = jSONObject.getJSONArray("notifications").length(); } } catch (Exception e2) { Log.e("fing:community", "Failed to retrieve user object", e2); } } communityFragment.j0 = System.currentTimeMillis(); communityFragment.g0.i(); } } private void M2() { if (A2() && m0() != null) { long currentTimeMillis = System.currentTimeMillis() - this.j0; if (!this.i0.isEmpty() && currentTimeMillis < 300000) { StringBuilder E = e.a.a.a.a.E("Not fetching community posts because last fetch happened "); E.append(currentTimeMillis / 1000); E.append(" seconds ago"); Log.d("fing:community", E.toString()); } else if (this.h0.f()) { Log.d("fing:community", "Not fetching community posts because we are still waiting for previous request to complete"); } else { Log.d("fing:community", "Fetching community posts..."); String str = "https://app.fing.com/forum/discussions/latest?level=3&max=20"; m0 m0Var = (m0) t2(); if (m0Var.S()) { StringBuilder G = e.a.a.a.a.G(str, "&ct="); G.append(m0Var.v()); str = G.toString(); } this.h0.j(5000, true); c0 c0Var = new c0(com.overlook.android.fing.engine.j.h.b.b()); e0.a aVar = new e0.a(); aVar.h(str); ((e) c0Var.A(aVar.b())).g(new a()); } } } @Override // com.overlook.android.fing.ui.base.j, androidx.fragment.app.Fragment public View Z0(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { super.Z0(layoutInflater, viewGroup, bundle); View inflate = layoutInflater.inflate(R.layout.fragment_community, viewGroup, false); if (bundle != null) { ArrayList parcelableArrayList = bundle.getParcelableArrayList("discussions"); if (parcelableArrayList != null) { this.i0.clear(); this.i0.addAll(parcelableArrayList); } this.k0 = (CommunityUser) bundle.getParcelable("community_user"); this.j0 = bundle.getLong("fetch_time"); } if (m0() != null) { Resources w0 = w0(); int dimensionPixelSize = w0.getDimensionPixelSize(R.dimen.spacing_small); int dimensionPixelSize2 = w0.getDimensionPixelSize(R.dimen.image_size_regular); IconView iconView = new IconView(m0()); this.d0 = iconView; iconView.p(true); this.d0.setVisibility(8); Header header = new Header(m0()); this.c0 = header; header.setBackgroundColor(androidx.core.content.a.b(m0(), R.color.background100)); this.c0.setLayoutParams(new LinearLayout.LayoutParams(-1, -2)); this.c0.setPaddingRelative(dimensionPixelSize, dimensionPixelSize, dimensionPixelSize, dimensionPixelSize); this.c0.C(C0(R.string.fing_community_title)); this.c0.E(0, (float) w0.getDimensionPixelSize(R.dimen.font_title)); this.c0.x(C0(R.string.fing_community_message)); this.c0.y(0); this.c0.u(Header.a.WRAP); this.c0.v(Header.b.TOP); this.c0.t(this.d0, new ConstraintLayout.LayoutParams(dimensionPixelSize2, dimensionPixelSize2)); SectionFooter sectionFooter = new SectionFooter(m0()); this.e0 = sectionFooter; sectionFooter.setLayoutParams(new LinearLayout.LayoutParams(-1, -2)); this.e0.setPaddingRelative(dimensionPixelSize, 0, dimensionPixelSize, dimensionPixelSize); LinearLayout linearLayout = new LinearLayout(m0()); this.f0 = linearLayout; linearLayout.setLayoutParams(new LinearLayout.LayoutParams(-1, -2)); this.f0.setOrientation(1); this.f0.addView(this.c0); this.f0.addView(this.e0); } if (m0() != null) { d dVar = new d(null); this.g0 = dVar; dVar.a0(this.f0); RecyclerView recyclerView = (RecyclerView) inflate.findViewById(R.id.list); this.l0 = recyclerView; recyclerView.B0(this.g0); } return inflate; } @Override // com.overlook.android.fing.ui.base.j, com.overlook.android.fing.ui.base.ServiceActivity.a public void a(boolean z) { M2(); this.g0.i(); } @Override // androidx.fragment.app.Fragment public void p1() { super.p1(); e.f.a.a.b.j.j.z(this, "Community_Teaser"); M2(); this.g0.i(); } @Override // com.overlook.android.fing.ui.base.j, androidx.fragment.app.Fragment public void q1(Bundle bundle) { bundle.putParcelableArrayList("discussions", new ArrayList<>(this.i0)); bundle.putParcelable("community_user", this.k0); bundle.putLong("fetch_time", this.j0); super.q1(bundle); } }