Rabbit-R1/switch port/java/sources/androidx/recyclerview/widget/ItemTouchUIUtilImpl.java
2024-05-21 17:08:36 -04:00

60 lines
2.2 KiB
Java

package androidx.recyclerview.widget;
import android.graphics.Canvas;
import android.view.View;
import androidx.core.view.ViewCompat;
import androidx.recyclerview.R;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes2.dex */
public class ItemTouchUIUtilImpl implements ItemTouchUIUtil {
static final ItemTouchUIUtil INSTANCE = new ItemTouchUIUtilImpl();
@Override // androidx.recyclerview.widget.ItemTouchUIUtil
public void onDrawOver(Canvas canvas, RecyclerView recyclerView, View view, float f, float f2, int i, boolean z) {
}
@Override // androidx.recyclerview.widget.ItemTouchUIUtil
public void onSelected(View view) {
}
ItemTouchUIUtilImpl() {
}
@Override // androidx.recyclerview.widget.ItemTouchUIUtil
public void onDraw(Canvas canvas, RecyclerView recyclerView, View view, float f, float f2, int i, boolean z) {
if (z && view.getTag(R.id.item_touch_helper_previous_elevation) == null) {
Float valueOf = Float.valueOf(ViewCompat.getElevation(view));
ViewCompat.setElevation(view, findMaxElevation(recyclerView, view) + 1.0f);
view.setTag(R.id.item_touch_helper_previous_elevation, valueOf);
}
view.setTranslationX(f);
view.setTranslationY(f2);
}
private static float findMaxElevation(RecyclerView recyclerView, View view) {
int childCount = recyclerView.getChildCount();
float f = 0.0f;
for (int i = 0; i < childCount; i++) {
View childAt = recyclerView.getChildAt(i);
if (childAt != view) {
float elevation = ViewCompat.getElevation(childAt);
if (elevation > f) {
f = elevation;
}
}
}
return f;
}
@Override // androidx.recyclerview.widget.ItemTouchUIUtil
public void clearView(View view) {
Object tag = view.getTag(R.id.item_touch_helper_previous_elevation);
if (tag instanceof Float) {
ViewCompat.setElevation(view, ((Float) tag).floatValue());
}
view.setTag(R.id.item_touch_helper_previous_elevation, null);
view.setTranslationX(0.0f);
view.setTranslationY(0.0f);
}
}