Created
January 10, 2022 10:42
-
-
Save kairos34/19d996c36fef582fa6324e8d590be871 to your computer and use it in GitHub Desktop.
Update old card values
This file contains hidden or 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
// We have RfidListener interface where you can get callback when a card is punched. | |
// This class has two methods: | |
// fun onRfidRead(rfidInfo : String) | |
// fun onRfidReadWithOldValue(rfidInfo : String, oldRfidInfo: String, useRfidStandardization: Boolean) | |
// onRfidRead method is used right now to get card value from SDK but due to some reasons such as supporting new card types etc... | |
// We have to update old card values with new ones using onRfidReadWithOldValue function | |
// Launcher applications are good place to handle with update process at least we update old values in that application. | |
// You have to override onRfidReadWithOldValue function in order to update old values and call | |
// super.onRfidReadWithOldValue function after update process | |
// I am sharing code snippet from our implementation | |
override fun onRfidReadWithOldValue(rfidInfo: String, oldRfidInfo: String, useRfidStandardization: Boolean) { | |
"onRfidReadWithOldValue new value = $rfidInfo, old value = $oldRfidInfo".log() | |
updateCardInfo(rfidInfo, oldRfidInfo) | |
super.onRfidReadWithOldValue(rfidInfo, oldRfidInfo, useRfidStandardization) | |
} | |
private fun updateCardInfo(rfidInfo: String, oldRfidInfo: String) { | |
val employee = RfidCard().getEmployee(rfidInfo) | |
// If employee is null which means card value is not updated | |
employee?.run { | |
val oldRegisteredEmployee: Employee? = RfidCard().getEmployee(oldRfidInfo) | |
// We have an employee which has old card value | |
if(oldRegisteredEmployee.isNotNull()) { | |
RfidCard().getCard(oldRfidInfo)?.apply { | |
number = rfidInfo | |
}?.update() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment