正在查看: BetterTogether v3.0.0 应用的 ChatActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: BetterTogether v3.0.0 应用的 ChatActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.bettertogether.screens.chat.view;
import ae.k;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Toolbar;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.widget.ContentLoadingProgressBar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.c1;
import androidx.recyclerview.widget.k0;
import androidx.recyclerview.widget.t0;
import aq.i;
import cd.b;
import com.bettertogether.BetterTogetherApp;
import com.bettertogether.cache.preferences.PreferenceData;
import com.bettertogether.remote.model.common.ChatMessage;
import com.bettertogether.remote.model.common.GroupData;
import com.bettertogether.remote.model.common.SendMessageData;
import com.bettertogether.screens.chat.preview.ImagePreviewActivity;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.MobileAds;
import com.google.android.material.card.MaterialCardView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import dd.s;
import dd.v;
import fe.e;
import fe.q;
import fe.r;
import ge.f;
import h.r0;
import hd.c;
import he.a;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import js.g;
import k7.j;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.collections.CollectionsKt;
import kotlin.collections.e0;
import kotlin.collections.f0;
import kotlin.collections.w0;
import kotlin.collections.x0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.g0;
import lq.m;
import lq.n;
import lq.o;
import lq.x;
import md.l;
import s6.t;
import s8.h;
import xc.d;
import zc.u;
@Metadata
public final class ChatActivity extends u implements r, j, Toolbar.OnMenuItemClickListener, c, d {
public static final t V = new t(23, 0);
public static boolean W;
public final m M;
public final m N;
public File O;
public AdView P;
public boolean Q;
public boolean R;
public int S;
public a T;
public boolean U;
public boolean f4979e;
public final x f4980i = n.b(new e(this, 0));
public final String f4981v = "chat_android";
public final m f4982w;
public final m f4983x;
public final x f4984y;
public ChatActivity() {
o oVar = o.f13215d;
this.f4982w = n.a(oVar, new s(this, 9));
h s10 = com.google.firebase.messaging.e.s(this);
this.f4983x = n.a(oVar, new l(((ys.a) s10.a).a(com.google.firebase.messaging.e.o(), new xs.c(g0.a(ChatActivity.class))), new e(this, 2), 5));
this.f4984y = n.b(new e(this, 1));
this.M = n.a(oVar, new s(this, 10));
this.N = n.a(oVar, new s(this, 11));
}
public static String v(SendMessageData sendMessageData) {
String i10 = new en.o().i(sendMessageData);
Intrinsics.checkNotNullExpressionValue(i10, "Gson().toJson(message)");
return i10;
}
public static Point x(View view) {
Intrinsics.checkNotNullParameter(view, "view");
int[] iArr = new int[2];
view.getLocationOnScreen(iArr);
return new Point(iArr[0], iArr[1]);
}
public final void A() {
tf.o oVar = zf.d.f23195a;
if (!zf.d.f23196b) {
H();
return;
}
FrameLayout frameLayout = w().f4134h;
Intrinsics.checkNotNullExpressionValue(frameLayout, "binding.moPubLayout");
fs.d.t(frameLayout);
}
public final void B(int i10) {
int i11;
b w4 = w();
if (i10 == -1) {
f adapter = w4.f4137k.getAdapter();
Intrinsics.f(adapter, "null cannot be cast to non-null type com.bettertogether.screens.chat.view.adapter.ChatMessageAdapter");
i11 = adapter.r;
} else {
i11 = i10;
}
f adapter2 = w4.f4137k.getAdapter();
Intrinsics.f(adapter2, "null cannot be cast to non-null type com.bettertogether.screens.chat.view.adapter.ChatMessageAdapter");
adapter2.r = i10;
t0 adapter3 = w4.f4137k.getAdapter();
if (adapter3 != null) {
adapter3.notifyItemChanged(i11);
}
}
public final void C() {
int itemCount;
c1 layoutManager;
b w4 = w();
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(1);
linearLayoutManager.e1(true);
w4.f4137k.setLayoutManager(linearLayoutManager);
RecyclerView recyclerView = w4.f4137k;
Intrinsics.checkNotNullExpressionValue(recyclerView, "rvChat");
Intrinsics.checkNotNullParameter(recyclerView, "<this>");
t0 adapter = recyclerView.getAdapter();
if (adapter == null || (itemCount = adapter.getItemCount()) <= 1 || (layoutManager = recyclerView.getLayoutManager()) == null) {
return;
}
layoutManager.A0(recyclerView, itemCount - 1);
}
public final void D(long j10) {
b w4 = w();
f adapter = w4.f4137k.getAdapter();
Intrinsics.f(adapter, "null cannot be cast to non-null type com.bettertogether.screens.chat.view.adapter.ChatMessageAdapter");
Iterator it = CollectionsKt.x(adapter.p).iterator();
int i10 = -1;
int i11 = 0;
while (it.hasNext()) {
Object next = it.next();
if (i11 < 0) {
e0.j();
throw null;
}
he.f fVar = (he.f) next;
if ((fVar instanceof he.e) && ((he.e) fVar).f8660a.f8647d == j10) {
i10 = i11;
}
i11++;
}
if (i10 != -1) {
w4.f4137k.h0(i10);
}
}
public final void E(ChatMessage chatMessage) {
Intrinsics.checkNotNullParameter(chatMessage, "msg");
f adapter = w().f4137k.getAdapter();
Intrinsics.f(adapter, "null cannot be cast to non-null type com.bettertogether.screens.chat.view.adapter.ChatMessageAdapter");
f fVar = adapter;
Intrinsics.checkNotNullParameter(chatMessage, "msg");
et.d.c(a0.g0.g("replaceChatRecord : ", chatMessage.getId(), " position: }"), new Object[0]);
int c10 = f.c(fVar, chatMessage.getId());
if (c10 != -1) {
et.d.c("Check Reaction View actual message: " + chatMessage, new Object[0]);
String messageType = chatMessage.getMessageType();
String messageParams = chatMessage.getMessageParams();
ge.h hVar = fVar.n;
a h8 = hVar.h(hVar.a(messageType, messageParams), chatMessage);
et.d.c("Check Reaction View updated message: " + h8, new Object[0]);
Date H = pl.c1.H(h8.f8647d);
HashMap hashMap = fVar.o;
if (hashMap.containsKey(H)) {
Iterable<a> iterable = (Iterable) x0.h(H, hashMap);
ArrayList arrayList = new ArrayList(f0.k(iterable, 10));
for (a aVar : iterable) {
if (aVar.f8644a == h8.f8644a) {
aVar = h8;
}
arrayList.add(aVar);
}
hashMap.put(H, com.google.firebase.messaging.e.e(arrayList));
List list = (List) hashMap.get(H);
if (list != null) {
fr.t.k(fr.t.i(CollectionsKt.x(list), new ge.e(1, h8)));
}
TreeMap f10 = w0.f(hashMap, new ge.a(2));
ArrayList arrayList2 = fVar.p;
arrayList2.remove(c10);
for (Map.Entry entry : f10.entrySet()) {
Date date = (Date) entry.getKey();
if (Intrinsics.c(date, H)) {
arrayList2.add(c10, new he.e(h8));
}
}
}
fVar.notifyDataSetChanged();
}
}
public final void F(long j10) {
Date date = new Date(j10);
DateFormat dateFormat = zf.a.f23190a;
BetterTogetherApp betterTogetherApp = BetterTogetherApp.d;
DateFormat mediumDateFormat = android.text.format.DateFormat.getMediumDateFormat(s6.s.j());
Intrinsics.f(mediumDateFormat, "null cannot be cast to non-null type java.text.SimpleDateFormat");
((SimpleDateFormat) mediumDateFormat).format(date);
DateFormat dateFormat2 = zf.a.f23190a;
Intrinsics.f(dateFormat2, "null cannot be cast to non-null type java.text.SimpleDateFormat");
((SimpleDateFormat) dateFormat2).format(date);
}
public final void G(boolean z4) {
b w4 = w();
u2.m mVar = new u2.m();
mVar.d(w4.f4129c);
mVar.h(2131363170).f18365d.u = z4 ? 0.9f : 0.5f;
mVar.a(w4.f4129c);
MaterialCardView materialCardView = w4.f4138l.f4222b;
Intrinsics.checkNotNullExpressionValue(materialCardView, "sendMessageReply.root");
materialCardView.setVisibility(z4 ? 0 : 8);
w4.f4136j.setBackground(z2.h.getDrawable(this, z4 ? 2131230870 : 2131230892));
}
public final void H() {
b w4 = w();
MobileAds.initialize(this);
AdView adView = new AdView(this);
Intrinsics.checkNotNullParameter(adView, "<set-?>");
this.P = adView;
w4.f4134h.addView(y());
y().setAdUnitId("ca-app-pub-7371364009592949/1382411691");
AdRequest build = new AdRequest.Builder().build();
Intrinsics.checkNotNullExpressionValue(build, "Builder()\n //…TOR)\n .build()");
Display defaultDisplay = getWindowManager().getDefaultDisplay();
DisplayMetrics displayMetrics = new DisplayMetrics();
defaultDisplay.getMetrics(displayMetrics);
AdSize currentOrientationAnchoredAdaptiveBannerAdSize = AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(this, (int) (displayMetrics.widthPixels / displayMetrics.density));
et.d.a("ADVIEW_ADAPTIVE Adsize: " + currentOrientationAnchoredAdaptiveBannerAdSize, new Object[0]);
if (currentOrientationAnchoredAdaptiveBannerAdSize != null) {
y().setAdSize(currentOrientationAnchoredAdaptiveBannerAdSize);
}
y().removeAllViews();
runOnUiThread(new r0(28, this, build));
y().setAdListener(new fe.h(w4, 0));
}
@Override
public final String getAnalyticsScreenName() {
return this.f4981v;
}
public final PreferenceData getPreferenceData() {
return (PreferenceData) this.f4984y.getValue();
}
@Override
public final View getView() {
ConstraintLayout constraintLayout = w().f4127a;
Intrinsics.checkNotNullExpressionValue(constraintLayout, "binding.root");
return constraintLayout;
}
@Override
public final boolean hideKeyboardOnClickOutsideOfEditText() {
return false;
}
@Override
public final void hideLoadingDialog() {
enableViews();
w().f4135i.a();
}
@Override
public final void hideWeightRecordButton() {
w().f4132f.d(true);
}
@Override
public final void initViews() {
Bundle extras;
int i10 = 1;
W = true;
if (!kotlin.jvm.internal.o.M(getPreferenceData()) && (extras = getIntent().getExtras()) != null && extras.containsKey("ask notification permission") && extras.getBoolean("ask notification permission") && Build.VERSION.SDK_INT >= 33) {
jh.o.v(this, new fe.d(this, 1));
}
q z4 = z();
Intent intent = getIntent();
Intrinsics.checkNotNullExpressionValue(intent, "intent");
z4.i(intent);
w().f4139m.setOnRefreshListener(this);
int i11 = 0;
w().f4133g.setOnClickListener(new fe.a(this, i11));
w().f4140n.setOnClickListener(new fe.a(this, i10));
t(false);
((ImageView) w().f4130d.f4237c).setOnClickListener(new fe.a(this, 2));
((ImageView) w().f4130d.f4240f).setOnClickListener(new fe.a(this, 3));
((ImageView) w().f4130d.f4238d).setOnClickListener(new fe.a(this, 4));
((ImageView) w().f4130d.f4239e).setOnClickListener(new fe.a(this, 5));
if (getPreferenceData().c() || zf.d.f23196b) {
zf.d.f23196b = true;
et.d.c("UserSubscribed: setUpBillingManager true", new Object[0]);
tf.o oVar = tf.o.MONTHLY;
Intrinsics.checkNotNullParameter(oVar, "<set-?>");
zf.d.f23195a = oVar;
return;
}
et.d.c("BusinessUser UserSubscribed: " + getPreferenceData().c() + " Not Subscribed", new Object[0]);
zf.d.f23196b = false;
tf.o oVar2 = tf.o.NO_SUBSCRIPTION;
Intrinsics.checkNotNullParameter(oVar2, "<set-?>");
zf.d.f23195a = oVar2;
((wf.l) this.N.getValue()).e(this, new k0(this, i11));
}
@Override
public final void onActivityResult(int i10, int i11, Intent intent) {
File file;
if (i11 == -1) {
int i12 = 1;
if (i10 == 1450) {
String stringExtra = intent != null ? intent.getStringExtra("weeklyWeight") : null;
Float valueOf = intent != null ? Float.valueOf(intent.getFloatExtra("targetWeight", 0.0f)) : null;
int intExtra = intent != null ? intent.getIntExtra("currentWeek", 0) : 0;
this.S = intExtra;
boolean z4 = intExtra > 0 && valueOf != null && stringExtra != null && Float.parseFloat(stringExtra) <= valueOf.floatValue();
this.Q = z4;
this.f4979e = z4;
q z10 = z();
Intent intent2 = getIntent();
Intrinsics.checkNotNullExpressionValue(intent2, "intent");
z10.i(intent2);
}
if (i10 == 8493 && (file = this.O) != null) {
q z11 = z();
z11.getClass();
Intrinsics.checkNotNullParameter(file, "uploadImage");
((r) z11.f583a).showLoadingDialog();
i iVar = new i(new i(com.android.billingclient.api.a.h(Unit.f12192a, "just(view.showLoadingDialog())"), new a9.h(i12, new k(file, 2)), 1), new a9.h(2, new z8.r(16, z11, file)), 0);
Intrinsics.checkNotNullExpressionValue(iVar, "fun sendImage(uploadImag… .addDisposable()\n }");
aq.b bVar = new aq.b(1, kotlin.jvm.internal.o.D0(iVar), new fe.j(z11, 0));
Intrinsics.checkNotNullExpressionValue(bVar, "fun sendImage(uploadImag… .addDisposable()\n }");
com.bumptech.glide.d.m(z11, bVar);
}
} else if (i11 == 0 && i10 == 8493) {
this.O = null;
}
super.onActivityResult(i10, i11, intent);
}
@Override
public final void onBackPressed() {
z().h();
}
@Override
public final void onDestroy() {
W = false;
et.d.a("chat Logger : on Destroy chat activity called", new Object[0]);
super.onDestroy();
}
@Override
public final void onDialogDismiss() {
if (this.f4979e) {
boolean z4 = true;
char c10 = 1;
if (this.S == 1 && getSupportFragmentManager().D("RateUsDialog") == null) {
kotlin.jvm.internal.o.Q0(this, getPreferenceData(), this, new fe.f(this, z4, c10 == true ? 1 : 0));
}
}
}
@Override
public final void onImageFileReady(Pair pair) {
Intrinsics.checkNotNullParameter(pair, "result");
File file = (File) pair.f12191e;
if (file != null) {
this.O = file;
int i10 = ImagePreviewActivity.f4976i;
Intrinsics.checkNotNullParameter(this, "context");
Intrinsics.checkNotNullParameter(file, "file");
Intent intent = new Intent((Context) this, (Class<?>) ImagePreviewActivity.class);
intent.putExtra("param_mode", ee.b.SEND);
intent.putExtra("param_image_file", file);
startActivityForResult(intent, 8493);
}
}
@Override
public final boolean onMenuItemClick(MenuItem menuItem) {
Intrinsics.checkNotNullParameter(menuItem, "item");
return true;
}
@Override
public final void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
if (intent != null) {
z().i(intent);
}
}
@Override
public final void onPause() {
W = false;
et.d.a("chat Logger : on Pause chat activity called", new Object[0]);
super.onPause();
}
@Override
public final void onRefresh() {
w().f4139m.setRefreshing(false);
}
@Override
public final void onRequestPermissionsResult(int i10, String[] strArr, int[] iArr) {
Intrinsics.checkNotNullParameter(strArr, "permissions");
Intrinsics.checkNotNullParameter(iArr, "grantResults");
if (i10 == 1003) {
if ((!(iArr.length == 0)) && iArr[0] == 0) {
et.d.a("onRequestPermissionsResult NOTIFICATION_PERMISSION granted", new Object[0]);
}
}
super.onRequestPermissionsResult(i10, strArr, iArr);
}
@Override
public final void onResume() {
W = true;
et.d.a("chat Logger : on Resume chat activity called", new Object[0]);
super.onResume();
if (this.Q) {
this.Q = false;
new v().show(getSupportFragmentManager(), "WeeklyTargetWeightDialog");
}
et.d.a(og.m.i("chat Logger : on Resume chat activity called value ", this.U), new Object[0]);
if (this.U) {
q z4 = z();
GroupData groupData = z4.k;
Integer num = z4.l;
et.d.a("chat Logger : on Resume chat activity called group data " + groupData + " " + ((num == null || num.intValue() == -1) ? false : true), new Object[0]);
GroupData groupData2 = z4.k;
fe.i iVar = z4.c;
if (groupData2 != null) {
z4.g(iVar.k(groupData2), false);
} else {
Integer num2 = z4.l;
if (num2 != null && num2.intValue() != -1) {
Integer num3 = z4.l;
Intrinsics.e(num3);
z4.g(iVar.j(num3.intValue()), false);
}
}
this.U = false;
}
}
@Override
public final void onStop() {
et.d.a("chat Logger : on stop chat activity called", new Object[0]);
bb.r rVar = z().c.f7519k;
if (rVar != null) {
g gVar = (wr.r0) rVar.v;
if (gVar == null) {
Intrinsics.m("webSocket");
throw null;
}
gVar.b(1000, "Leaving chat ");
}
this.U = true;
super.onStop();
}
@Override
public final ad.a providePresenter() {
return z();
}
public final void s(ArrayList arrayList) {
Intrinsics.checkNotNullParameter(arrayList, "list");
b w4 = w();
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(1);
linearLayoutManager.e1(true);
w4.f4137k.setLayoutManager(linearLayoutManager);
et.d.a("list", new Object[0]);
f adapter = w4.f4137k.getAdapter();
Intrinsics.f(adapter, "null cannot be cast to non-null type com.bettertogether.screens.chat.view.adapter.ChatMessageAdapter");
adapter.a(arrayList);
}
@Override
public final void showLoadingDialog() {
b w4 = w();
w4.f4135i.b();
ContentLoadingProgressBar contentLoadingProgressBar = w4.f4135i;
Intrinsics.checkNotNullExpressionValue(contentLoadingProgressBar, "pbLoading");
fs.d.x(contentLoadingProgressBar);
disableViews();
}
@Override
public final void showWeightRecordButton(int i10, float f10, float f11, String str, boolean z4, String str2, Integer num, boolean z10) {
Intrinsics.checkNotNullParameter(str, "measureType");
FloatingActionButton floatingActionButton = w().f4132f;
Intrinsics.checkNotNullExpressionValue(floatingActionButton, "this");
fs.d.L(floatingActionButton, z10);
Intrinsics.checkNotNullParameter(floatingActionButton, "<this>");
floatingActionButton.setVisibility(4);
floatingActionButton.setOnClickListener(new fe.c(f10, f11, i10, 0, this, num, str, str2, z4));
}
public final void t(boolean z4) {
b w4 = w();
ConstraintLayout d10 = w4.f4130d.d();
Intrinsics.checkNotNullExpressionValue(d10, "chatOptionLayout.root");
d10.setVisibility(z4 ? 0 : 8);
ConstraintLayout c10 = w4.f4128b.c();
Intrinsics.checkNotNullExpressionValue(c10, "appBarInc.root");
c10.setVisibility(z4 ^ true ? 0 : 8);
}
public final void u() {
if (this.T != null) {
B(-1);
}
t(false);
}
public final b w() {
return (b) this.f4980i.getValue();
}
public final AdView y() {
AdView adView = this.P;
if (adView != null) {
return adView;
}
Intrinsics.m("mAdView");
throw null;
}
public final q z() {
return (q) this.f4983x.getValue();
}
}