82 lines
2.7 KiB
Java
82 lines
2.7 KiB
Java
package com.discord.views.segmentedcontrol;
|
|
|
|
import android.content.Context;
|
|
import android.util.AttributeSet;
|
|
import android.view.View;
|
|
import android.widget.LinearLayout;
|
|
import androidx.core.view.ViewGroupKt;
|
|
import d0.t.n;
|
|
import d0.z.d.m;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
/* compiled from: SegmentedControlContainer.kt */
|
|
public final class SegmentedControlContainer extends LinearLayout {
|
|
public static final /* synthetic */ int i = 0;
|
|
public Function1<? super Integer, Unit> j;
|
|
|
|
/* compiled from: SegmentedControlContainer.kt */
|
|
public static final class a implements View.OnClickListener {
|
|
public final /* synthetic */ int i;
|
|
public final /* synthetic */ SegmentedControlContainer j;
|
|
|
|
public a(int i, SegmentedControlContainer segmentedControlContainer) {
|
|
this.i = i;
|
|
this.j = segmentedControlContainer;
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public final void onClick(View view) {
|
|
Function1<? super Integer, Unit> function1 = this.j.j;
|
|
if (function1 != null) {
|
|
function1.invoke(Integer.valueOf(this.i));
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public SegmentedControlContainer(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
m.checkNotNullParameter(context, "context");
|
|
}
|
|
|
|
public final void a(int i2) {
|
|
int i3 = 0;
|
|
for (View view : ViewGroupKt.getChildren(this)) {
|
|
int i4 = i3 + 1;
|
|
if (i3 < 0) {
|
|
n.throwIndexOverflow();
|
|
}
|
|
View view2 = view;
|
|
if (view2 instanceof c.a.y.n0.a) {
|
|
view2.setOnClickListener(new a(i3, this));
|
|
i3 = i4;
|
|
} else {
|
|
throw new IllegalStateException("All children must be SegmentedControlSegments.".toString());
|
|
}
|
|
}
|
|
setSelectedIndex(i2);
|
|
}
|
|
|
|
public final void setOnSegmentSelectedChangeListener(Function1<? super Integer, Unit> function1) {
|
|
m.checkNotNullParameter(function1, "listener");
|
|
this.j = function1;
|
|
}
|
|
|
|
public final void setSelectedIndex(int i2) {
|
|
int i3 = 0;
|
|
for (View view : ViewGroupKt.getChildren(this)) {
|
|
int i4 = i3 + 1;
|
|
if (i3 < 0) {
|
|
n.throwIndexOverflow();
|
|
}
|
|
View view2 = view;
|
|
if (view2 instanceof c.a.y.n0.a) {
|
|
((c.a.y.n0.a) view2).a(i3 == i2);
|
|
i3 = i4;
|
|
} else {
|
|
throw new IllegalStateException("All children must be SegmentedControlSegments.".toString());
|
|
}
|
|
}
|
|
}
|
|
}
|