discord-jadx/app/src/main/java/com/discord/widgets/voice/feedback/FeedbackView.java

184 lines
9.7 KiB
Java

package com.discord.widgets.voice.feedback;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.LayoutRes;
import androidx.cardview.widget.CardView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.discord.databinding.FeedbackViewBinding;
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple;
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
import d0.o;
import d0.t.h0;
import d0.z.d.m;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
/* compiled from: FeedbackView.kt */
public final class FeedbackView extends LinearLayout {
private final FeedbackViewBinding binding;
private final IssuesAdapter issuesAdapter;
private final Map<View, FeedbackRating> viewToFeedbackRatingMap;
/* compiled from: FeedbackView.kt */
public static final class IssueViewHolder extends MGRecyclerViewHolder<IssuesAdapter, FeedbackIssue> {
private final TextView issueItem;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public IssueViewHolder(@LayoutRes int i, IssuesAdapter issuesAdapter) {
super(i, issuesAdapter);
m.checkNotNullParameter(issuesAdapter, "adapter");
View view = this.itemView;
Objects.requireNonNull(view, "null cannot be cast to non-null type android.widget.TextView");
this.issueItem = (TextView) view;
}
public static final /* synthetic */ IssuesAdapter access$getAdapter$p(IssueViewHolder issueViewHolder) {
return (IssuesAdapter) issueViewHolder.adapter;
}
public void onConfigure(int i, FeedbackIssue feedbackIssue) {
m.checkNotNullParameter(feedbackIssue, "data");
super.onConfigure(i, (int) feedbackIssue);
TextView textView = this.issueItem;
textView.setText(textView.getResources().getString(feedbackIssue.getReasonStringRes()));
this.issueItem.setOnClickListener(new FeedbackView$IssueViewHolder$onConfigure$1(this, feedbackIssue));
}
}
/* compiled from: FeedbackView.kt */
public static final class IssuesAdapter extends MGRecyclerAdapterSimple<FeedbackIssue> {
private Function1<? super FeedbackIssue, Unit> onIssueClick = FeedbackView$IssuesAdapter$onIssueClick$1.INSTANCE;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public IssuesAdapter(RecyclerView recyclerView) {
super(recyclerView, false, 2, null);
m.checkNotNullParameter(recyclerView, "recyclerView");
}
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function1<? super com.discord.widgets.voice.feedback.FeedbackIssue, kotlin.Unit>, kotlin.jvm.functions.Function1<com.discord.widgets.voice.feedback.FeedbackIssue, kotlin.Unit> */
public final Function1<FeedbackIssue, Unit> getOnIssueClick() {
return this.onIssueClick;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public MGRecyclerViewHolder<IssuesAdapter, FeedbackIssue> onCreateViewHolder(ViewGroup viewGroup, int i) {
m.checkNotNullParameter(viewGroup, "parent");
return new IssueViewHolder(2131558656, this);
}
public final void setOnIssueClick(Function1<? super FeedbackIssue, Unit> function1) {
m.checkNotNullParameter(function1, "<set-?>");
this.onIssueClick = function1;
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public FeedbackView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(attributeSet, "attrs");
View inflate = LayoutInflater.from(context).inflate(2131558504, (ViewGroup) this, false);
addView(inflate);
int i = 2131363228;
ImageButton imageButton = (ImageButton) inflate.findViewById(2131363228);
if (imageButton != null) {
i = 2131363229;
TextView textView = (TextView) inflate.findViewById(2131363229);
if (textView != null) {
i = 2131363230;
CardView cardView = (CardView) inflate.findViewById(2131363230);
if (cardView != null) {
i = 2131363231;
RecyclerView recyclerView = (RecyclerView) inflate.findViewById(2131363231);
if (recyclerView != null) {
i = 2131363232;
ImageButton imageButton2 = (ImageButton) inflate.findViewById(2131363232);
if (imageButton2 != null) {
i = 2131363233;
ConstraintLayout constraintLayout = (ConstraintLayout) inflate.findViewById(2131363233);
if (constraintLayout != null) {
i = 2131363234;
TextView textView2 = (TextView) inflate.findViewById(2131363234);
if (textView2 != null) {
i = 2131363235;
ImageView imageView = (ImageView) inflate.findViewById(2131363235);
if (imageView != null) {
FeedbackViewBinding feedbackViewBinding = new FeedbackViewBinding((LinearLayout) inflate, imageButton, textView, cardView, recyclerView, imageButton2, constraintLayout, textView2, imageView);
m.checkNotNullExpressionValue(feedbackViewBinding, "FeedbackViewBinding.infl…rom(context), this, true)");
this.binding = feedbackViewBinding;
this.viewToFeedbackRatingMap = h0.mapOf(o.to(imageView, FeedbackRating.BAD), o.to(imageButton2, FeedbackRating.NEUTRAL), o.to(imageButton, FeedbackRating.GOOD));
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
m.checkNotNullExpressionValue(recyclerView, "binding.feedbackIssuesRecycler");
this.issuesAdapter = (IssuesAdapter) companion.configure(new IssuesAdapter(recyclerView));
recyclerView.setHasFixedSize(false);
return;
}
}
}
}
}
}
}
}
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
}
public final void updateView(String str, FeedbackRating feedbackRating, Function0<Unit> function0, Function0<Unit> function02, Function0<Unit> function03, String str2, List<? extends FeedbackIssue> list, Function1<? super FeedbackIssue, Unit> function1) {
m.checkNotNullParameter(feedbackRating, "selectedFeedbackRating");
m.checkNotNullParameter(function0, "onSadRatingClick");
m.checkNotNullParameter(function02, "onNeutralRatingClick");
m.checkNotNullParameter(function03, "onHappyRatingClick");
m.checkNotNullParameter(str2, "issuesHeaderText");
m.checkNotNullParameter(list, "feedbackIssues");
m.checkNotNullParameter(function1, "onIssueClick");
int i = 0;
boolean z2 = str != null;
ConstraintLayout constraintLayout = this.binding.g;
m.checkNotNullExpressionValue(constraintLayout, "binding.feedbackRatingContainer");
constraintLayout.setVisibility(z2 ? 0 : 8);
TextView textView = this.binding.h;
m.checkNotNullExpressionValue(textView, "binding.feedbackRatingSummaryPrompt");
textView.setText(str);
this.binding.i.setOnClickListener(new FeedbackView$updateView$1(function0));
this.binding.f.setOnClickListener(new FeedbackView$updateView$2(function02));
this.binding.b.setOnClickListener(new FeedbackView$updateView$3(function03));
Iterator<T> it = this.viewToFeedbackRatingMap.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
((View) entry.getKey()).setSelected(feedbackRating == ((FeedbackRating) entry.getValue()));
}
boolean z3 = !list.isEmpty();
TextView textView2 = this.binding.f1609c;
m.checkNotNullExpressionValue(textView2, "binding.feedbackIssueSectionHeader");
textView2.setText(str2);
TextView textView3 = this.binding.f1609c;
m.checkNotNullExpressionValue(textView3, "binding.feedbackIssueSectionHeader");
textView3.setVisibility(z3 ? 0 : 8);
CardView cardView = this.binding.d;
m.checkNotNullExpressionValue(cardView, "binding.feedbackIssuesCard");
cardView.setVisibility(z3 ? 0 : 8);
RecyclerView recyclerView = this.binding.e;
m.checkNotNullExpressionValue(recyclerView, "binding.feedbackIssuesRecycler");
if (!z3) {
i = 8;
}
recyclerView.setVisibility(i);
this.issuesAdapter.setOnIssueClick(function1);
this.issuesAdapter.setData(list);
}
}