Skip to content

Instantly share code, notes, and snippets.

@AtulYadav01

AtulYadav01/otp Secret

Created November 5, 2020 06:06
Show Gist options
  • Save AtulYadav01/411337dd1e93c1121684b20e536d9365 to your computer and use it in GitHub Desktop.
Save AtulYadav01/411337dd1e93c1121684b20e536d9365 to your computer and use it in GitHub Desktop.
pinview.setPinViewEventListener(Pinview.PinViewEventListener { pinview, fromUser ->
val comotp: String? = pinview.value
if (strings.contains(comotp)) {
val intent = Intent(this@otpforgot, changePassword::class.java)
intent.putExtra("app_key",mobilenumber.toString())
intent.putExtra("mobile",mobilenumber.toString())
startActivity(intent)
overridePendingTransition(R.anim.fadein, R.anim.fadeout)
}
else {
val va = getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
va.vibrate(VibrationEffect.createOneShot(500, VibrationEffect.DEFAULT_AMPLITUDE))
} else {
va.vibrate(500)
}
val shake = AnimationUtils.loadAnimation(this@otpforgot, R.anim.shake)
pinview.startAnimation(shake)
Toast.makeText(this, "Invalid OTP", Toast.LENGTH_SHORT).show();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment