View PayloadBinding.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onBindViewHolder(holder: ViewHolder, | |
position: Int, | |
payloads: MutableList<Any>) { | |
if (!payloads.isEmpty()) { | |
// Because these updates can be batched, | |
// there can be multiple payloads for a single bind | |
when (payloads[0]) { | |
Payload.FAVORITE_CHANGE -> { | |
// Change only the "favorite" icon, | |
// leave background image alone: |
View Encryptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Encryptor(private val sharedPreferences: SharedPreferences) { | |
private val ANDROID_KEY_STORE = "AndroidKeyStore" | |
private var initVector: ByteArray? = null | |
private var encryption: ByteArray? = null | |
private val TRANSFORMATION = "AES/GCM/NoPadding" | |
@Throws(Exception::class) | |
fun encryptTextWithAES(alias: String, textToEncrypt: String): ByteArray? { | |
var alias = alias |
View Decryptor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Decryptor(private val storage: SharedPreferences) { | |
private val ANDROID_KEY_STORE = "AndroidKeyStore" | |
private val TRANSFORMATION = "AES/GCM/NoPadding" | |
private var keyStore: KeyStore? = null | |
init { | |
initKeyStore() | |
} |