139 lines
7.2 KiB
Java
139 lines
7.2 KiB
Java
package com.discord.widgets.guilds.list;
|
|
|
|
import android.graphics.Canvas;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.view.View;
|
|
import androidx.core.graphics.drawable.DrawableCompat;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import com.discord.widgets.guilds.list.GuildListViewHolder;
|
|
import d0.z.d.m;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: FolderItemDecoration.kt */
|
|
public final class FolderItemDecoration extends RecyclerView.ItemDecoration {
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int EXTRA_PADDING_PX = 200;
|
|
private final Drawable drawableNoChildren;
|
|
private final Drawable drawableWithChildren;
|
|
private final int halfSize;
|
|
private final Drawable tintableDrawableNoChildren;
|
|
|
|
/* compiled from: FolderItemDecoration.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
public FolderItemDecoration(Drawable drawable, Drawable drawable2, Drawable drawable3, int i) {
|
|
m.checkNotNullParameter(drawable, "drawableNoChildren");
|
|
m.checkNotNullParameter(drawable2, "tintableDrawableNoChildren");
|
|
m.checkNotNullParameter(drawable3, "drawableWithChildren");
|
|
this.drawableNoChildren = drawable;
|
|
this.tintableDrawableNoChildren = drawable2;
|
|
this.drawableWithChildren = drawable3;
|
|
this.halfSize = i / 2;
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:16:0x0045 */
|
|
private final int drawBackgroundForInitialFolder(Canvas canvas, RecyclerView recyclerView) {
|
|
int i;
|
|
boolean z2 = false;
|
|
View childAt = recyclerView.getChildAt(0);
|
|
RecyclerView.ViewHolder childViewHolder = recyclerView.getChildViewHolder(childAt);
|
|
if (childViewHolder instanceof GuildListViewHolder.GuildViewHolder) {
|
|
GuildListViewHolder.GuildViewHolder guildViewHolder = (GuildListViewHolder.GuildViewHolder) childViewHolder;
|
|
if (guildViewHolder.getFolderId() != null) {
|
|
Long folderId = guildViewHolder.getFolderId();
|
|
boolean z3 = true;
|
|
i = 1;
|
|
while (z3 && i < recyclerView.getChildCount()) {
|
|
RecyclerView.ViewHolder childViewHolder2 = recyclerView.getChildViewHolder(recyclerView.getChildAt(i));
|
|
if (!(childViewHolder2 instanceof GuildListViewHolder.GuildViewHolder) || !m.areEqual(((GuildListViewHolder.GuildViewHolder) childViewHolder2).getFolderId(), folderId)) {
|
|
z3 = false;
|
|
} else {
|
|
i++;
|
|
z3 = true;
|
|
}
|
|
}
|
|
if (i > 0) {
|
|
m.checkNotNullExpressionValue(childAt, "firstView");
|
|
int left = (childAt.getLeft() + childAt.getRight()) / 2;
|
|
int top = (childAt.getTop() + childAt.getBottom()) / 2;
|
|
boolean z4 = recyclerView.getChildCount() == i;
|
|
RecyclerView.ViewHolder childViewHolder3 = recyclerView.getChildViewHolder(recyclerView.getChildAt(recyclerView.getChildCount() - 1));
|
|
if (z4 && (childViewHolder3 instanceof GuildListViewHolder.GuildViewHolder) && m.areEqual(((GuildListViewHolder.GuildViewHolder) childViewHolder3).isLastGuildInFolder(), Boolean.FALSE)) {
|
|
z2 = true;
|
|
}
|
|
int height = childAt.getHeight();
|
|
int i2 = this.halfSize;
|
|
int i3 = ((i - 1) * height) + top + i2;
|
|
if (z2) {
|
|
i3 += 200;
|
|
}
|
|
this.drawableWithChildren.setBounds(left - i2, (top - i2) - 200, left + i2, i3);
|
|
this.drawableWithChildren.draw(canvas);
|
|
}
|
|
return i;
|
|
}
|
|
}
|
|
i = 0;
|
|
if (i > 0) {
|
|
}
|
|
return i;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.ItemDecoration
|
|
public void onDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.State state) {
|
|
Drawable drawable;
|
|
m.checkNotNullParameter(canvas, "c");
|
|
m.checkNotNullParameter(recyclerView, "parent");
|
|
m.checkNotNullParameter(state, "state");
|
|
if (recyclerView.getChildCount() >= 1) {
|
|
int childCount = recyclerView.getChildCount();
|
|
for (int drawBackgroundForInitialFolder = drawBackgroundForInitialFolder(canvas, recyclerView); drawBackgroundForInitialFolder < childCount; drawBackgroundForInitialFolder++) {
|
|
View childAt = recyclerView.getChildAt(drawBackgroundForInitialFolder);
|
|
RecyclerView.ViewHolder childViewHolder = recyclerView.getChildViewHolder(childAt);
|
|
if (childViewHolder instanceof GuildListViewHolder.FolderViewHolder) {
|
|
GuildListViewHolder.FolderViewHolder folderViewHolder = (GuildListViewHolder.FolderViewHolder) childViewHolder;
|
|
if (folderViewHolder.shouldDrawDecoration()) {
|
|
m.checkNotNullExpressionValue(childAt, "view");
|
|
int left = (childAt.getLeft() + childAt.getRight()) / 2;
|
|
int top = (childAt.getTop() + childAt.getBottom()) / 2;
|
|
int numChildren = folderViewHolder.getNumChildren();
|
|
if (numChildren == 0) {
|
|
Integer color = folderViewHolder.getColor();
|
|
if (color != null) {
|
|
DrawableCompat.setTint(this.tintableDrawableNoChildren, color.intValue());
|
|
drawable = this.tintableDrawableNoChildren;
|
|
} else {
|
|
drawable = this.drawableNoChildren;
|
|
}
|
|
int i = this.halfSize;
|
|
drawable.setBounds(left - i, top - i, left + i, top + i);
|
|
drawable.draw(canvas);
|
|
} else {
|
|
int height = (childAt.getHeight() * numChildren) + this.halfSize + top;
|
|
Drawable drawable2 = this.drawableWithChildren;
|
|
int i2 = this.halfSize;
|
|
drawable2.setBounds(left - i2, top - i2, left + i2, height);
|
|
this.drawableWithChildren.draw(canvas);
|
|
}
|
|
}
|
|
}
|
|
if ((childViewHolder instanceof GuildListViewHolder.GuildViewHolder) && ((GuildListViewHolder.GuildViewHolder) childViewHolder).isTargetedForFolderCreation()) {
|
|
m.checkNotNullExpressionValue(childAt, "view");
|
|
int left2 = (childAt.getLeft() + childAt.getRight()) / 2;
|
|
int top2 = (childAt.getTop() + childAt.getBottom()) / 2;
|
|
Drawable drawable3 = this.drawableNoChildren;
|
|
int i3 = this.halfSize;
|
|
drawable3.setBounds(left2 - i3, top2 - i3, left2 + i3, top2 + i3);
|
|
this.drawableNoChildren.draw(canvas);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|