I have the next java class I use to reduce drag sensitivity in a pager:
@Metadata(
mv = {1, 6, 0},
k = 1,
d1 = {"\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0014\u0010\u0003\u001a\u00020\u0004*\u00020\u00052\b\b\u0002\u0010\u0006\u001a\u00020\u0007¨\u0006\b"},
d2 = {"Lcom/testmepracticetool/toeflsatactexamprep/ui/activities/main/KTest;", "", "()V", "reduceDragSensitivity", "", "Landroidx/viewpager2/widget/ViewPager2;", "f", "", "android_testme.app"}
)
public final class ViewPagerSensitivity {
public static void reduceDragSensitivity(@NotNull ViewPager2 $this$reduceDragSensitivity, int f) throws NoSuchFieldException, IllegalAccessException {
Intrinsics.checkNotNullParameter($this$reduceDragSensitivity, "$this$reduceDragSensitivity");
Field recyclerViewField = ViewPager2.class.getDeclaredField("mRecyclerView");
Intrinsics.checkNotNullExpressionValue(recyclerViewField, "recyclerViewField");
recyclerViewField.setAccessible(true);
Object var10000 = recyclerViewField.get($this$reduceDragSensitivity);
if (var10000 == null) {
throw new NullPointerException("null cannot be cast to non-null type androidx.recyclerview.widget.RecyclerView");
} else {
RecyclerView recyclerView = (RecyclerView)var10000;
Field touchSlopField = RecyclerView.class.getDeclaredField("mTouchSlop");
Intrinsics.checkNotNullExpressionValue(touchSlopField, "touchSlopField");
touchSlopField.setAccessible(true);
var10000 = touchSlopField.get(recyclerView);
if (var10000 == null) {
throw new NullPointerException("null cannot be cast to non-null type kotlin.Int");
} else {
int touchSlop = (Integer)var10000;
touchSlopField.set(recyclerView, touchSlop * f);
}
}
}
}
After Kotlin migration with Android Studio the class ended like this:
@Metadata(
mv = [1, 6, 0],
k = 1,
d1 = ["\u0000\u001c\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0014\u0010\u0003\u001a\u00020\u0004*\u00020\u00052\b\b\u0002\u0010\u0006\u001a\u00020\u0007¨\u0006\b"],
d2 = ["Lcom/xxx/xxx/ui/activities/main/KTest;", "", "()V", "reduceDragSensitivity", "", "Landroidx/viewpager2/widget/ViewPager2;", "f", "", "android_xxx.app"]
)
object ViewPagerSensitivity {
@Throws(NoSuchFieldException::class, IllegalAccessException::class)
fun reduceDragSensitivity(`$this$reduceDragSensitivity`: ViewPager2, f: Int) {
Intrinsics.checkNotNullParameter(
`$this$reduceDragSensitivity`,
"\$this\$reduceDragSensitivity"
)
val recyclerViewField = ViewPager2::class.java.getDeclaredField("mRecyclerView")
Intrinsics.checkNotNullExpressionValue(recyclerViewField, "recyclerViewField")
recyclerViewField.isAccessible = true
var var10000 = recyclerViewField[`$this$reduceDragSensitivity`]
if (var10000 == null) {
throw NullPointerException("null cannot be cast to non-null type androidx.recyclerview.widget.RecyclerView")
} else {
val recyclerView = var10000 as RecyclerView
val touchSlopField = RecyclerView::class.java.getDeclaredField("mTouchSlop")
Intrinsics.checkNotNullExpressionValue(touchSlopField, "touchSlopField")
touchSlopField.isAccessible = true
var10000 = touchSlopField[recyclerView]
if (var10000 == null) {
throw NullPointerException("null cannot be cast to non-null type kotlin.Int")
} else {
val touchSlop = var10000 as Int
touchSlopField[recyclerView] = touchSlop * f
}
}
}
}
but
What shall I do to correctly convert this class to Kotlin?
Edit 1:
I can't say what is that Metadata tag for exactly, as this is a class I've downloaded from the Internet, maybe I can just remove it, not sure. Haven't tested it yet because I'm in the process of migrating my app to Kotlin.
Ok, this is not exactly an answer, but the closest to it. I've commented the @Metadata tag and the app is working fine and the pager is less sensitive, which makes me think that Metadata is useless.