Android: Convert DolphinVibratorManagerCompat to Kotlin

This commit is contained in:
Charles Lombardo 2023-06-10 05:14:20 -04:00
parent 1ff6a3788e
commit 29adbb4394
2 changed files with 24 additions and 35 deletions

View File

@ -1,35 +0,0 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.input.model;
import android.os.Vibrator;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
public final class DolphinVibratorManagerCompat implements DolphinVibratorManager
{
private final Vibrator mVibrator;
private final int[] mIds;
public DolphinVibratorManagerCompat(@Nullable Vibrator vibrator)
{
mVibrator = vibrator;
mIds = vibrator != null && vibrator.hasVibrator() ? new int[]{0} : new int[]{};
}
@Override @NonNull
public Vibrator getVibrator(int vibratorId)
{
if (vibratorId > mIds.length)
throw new IndexOutOfBoundsException();
return mVibrator;
}
@Override @NonNull
public int[] getVibratorIds()
{
return mIds;
}
}

View File

@ -0,0 +1,24 @@
// SPDX-License-Identifier: GPL-2.0-or-later
package org.dolphinemu.dolphinemu.features.input.model
import android.os.Vibrator
class DolphinVibratorManagerCompat(vibrator: Vibrator) : DolphinVibratorManager {
private val vibrator: Vibrator
private val vibratorIds: IntArray
init {
this.vibrator = vibrator
vibratorIds = if (vibrator.hasVibrator()) intArrayOf(0) else intArrayOf()
}
override fun getVibrator(vibratorId: Int): Vibrator {
if (vibratorId > vibratorIds.size)
throw IndexOutOfBoundsException()
return vibrator
}
override fun getVibratorIds(): IntArray = vibratorIds
}