discord-jadx/app/src/main/java/com/discord/utilities/views/SwipeableItemTouchHelper.java

122 lines
5.6 KiB
Java

package com.discord.utilities.views;
import android.graphics.Canvas;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.view.View;
import androidx.annotation.ColorInt;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
import d0.z.d.m;
import kotlin.jvm.internal.DefaultConstructorMarker;
/* compiled from: SwipeableItemTouchHelper.kt */
public abstract class SwipeableItemTouchHelper extends ItemTouchHelper.SimpleCallback {
private final ColorDrawable background;
private final SwipeRevealConfiguration endConfiguration;
private final SwipeRevealConfiguration startConfiguration;
/* compiled from: SwipeableItemTouchHelper.kt */
public static final class SwipeRevealConfiguration {
private final int backgroundColor;
private final Drawable icon;
private final int padding;
public SwipeRevealConfiguration() {
this(0, null, 0, 7, null);
}
public SwipeRevealConfiguration(@ColorInt int i, Drawable drawable, int i2) {
this.backgroundColor = i;
this.icon = drawable;
this.padding = i2;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ SwipeRevealConfiguration(int i, Drawable drawable, int i2, int i3, DefaultConstructorMarker defaultConstructorMarker) {
this((i3 & 1) != 0 ? 0 : i, (i3 & 2) != 0 ? null : drawable, (i3 & 4) != 0 ? 0 : i2);
}
public final int getBackgroundColor() {
return this.backgroundColor;
}
public final Drawable getIcon() {
return this.icon;
}
public final int getPadding() {
return this.padding;
}
}
public SwipeableItemTouchHelper() {
this(0, 0, null, null, 15, null);
}
public SwipeableItemTouchHelper(int i, int i2, SwipeRevealConfiguration swipeRevealConfiguration, SwipeRevealConfiguration swipeRevealConfiguration2) {
super(i, i2);
this.startConfiguration = swipeRevealConfiguration;
this.endConfiguration = swipeRevealConfiguration2;
this.background = new ColorDrawable();
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ SwipeableItemTouchHelper(int i, int i2, SwipeRevealConfiguration swipeRevealConfiguration, SwipeRevealConfiguration swipeRevealConfiguration2, int i3, DefaultConstructorMarker defaultConstructorMarker) {
this((i3 & 1) != 0 ? 0 : i, (i3 & 2) != 0 ? 12 : i2, (i3 & 4) != 0 ? null : swipeRevealConfiguration, (i3 & 8) != 0 ? null : swipeRevealConfiguration2);
}
public final SwipeRevealConfiguration getEndConfiguration() {
return this.endConfiguration;
}
public final SwipeRevealConfiguration getStartConfiguration() {
return this.startConfiguration;
}
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
public void onChildDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float f, float f2, int i, boolean z2) {
m.checkNotNullParameter(canvas, "c");
m.checkNotNullParameter(recyclerView, "recyclerView");
m.checkNotNullParameter(viewHolder, "viewHolder");
View view = viewHolder.itemView;
m.checkNotNullExpressionValue(view, "viewHolder.itemView");
float f3 = (float) 0;
if (f > f3 && this.startConfiguration != null) {
int left = view.getLeft();
int left2 = view.getLeft() + ((int) f);
this.background.setColor(this.startConfiguration.getBackgroundColor());
this.background.setBounds(left, view.getTop(), left2, view.getBottom());
this.background.draw(canvas);
Drawable icon = this.startConfiguration.getIcon();
if (icon != null) {
int min = Math.min(this.startConfiguration.getPadding() + icon.getIntrinsicWidth() + left, left2);
int height = ((view.getHeight() - icon.getIntrinsicHeight()) / 2) + view.getTop();
icon.setBounds(min - icon.getIntrinsicWidth(), height, min, icon.getIntrinsicHeight() + height);
icon.draw(canvas);
}
} else if (f < f3 && this.endConfiguration != null) {
int right = view.getRight() + ((int) f);
int right2 = view.getRight();
this.background.setColor(this.endConfiguration.getBackgroundColor());
this.background.setBounds(right, view.getTop(), right2, view.getBottom());
this.background.draw(canvas);
Drawable icon2 = this.endConfiguration.getIcon();
if (icon2 != null) {
int min2 = right2 - Math.min((int) Math.abs(f), this.endConfiguration.getPadding() + icon2.getIntrinsicWidth());
int height2 = ((view.getHeight() - icon2.getIntrinsicHeight()) / 2) + view.getTop();
icon2.setBounds(min2, height2, icon2.getIntrinsicWidth() + min2, icon2.getIntrinsicHeight() + height2);
icon2.draw(canvas);
}
}
super.onChildDraw(canvas, recyclerView, viewHolder, f, f2, i, z2);
}
@Override // androidx.recyclerview.widget.ItemTouchHelper.Callback
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder viewHolder2) {
m.checkNotNullParameter(recyclerView, "recyclerView");
m.checkNotNullParameter(viewHolder, "viewHolder");
m.checkNotNullParameter(viewHolder2, "target");
return false;
}
}