Deduplicate card history entries
This commit is contained in:
@ -623,7 +623,7 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = "Emoney Info/Emoney Info.entitlements";
|
CODE_SIGN_ENTITLEMENTS = "Emoney Info/Emoney Info.entitlements";
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 11;
|
CURRENT_PROJECT_VERSION = 12;
|
||||||
DEVELOPMENT_TEAM = 6S5573WXX4;
|
DEVELOPMENT_TEAM = 6S5573WXX4;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
@ -643,7 +643,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.2;
|
MARKETING_VERSION = 1.0.3;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.iiyh.emoneyinfo;
|
PRODUCT_BUNDLE_IDENTIFIER = com.iiyh.emoneyinfo;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
@ -666,7 +666,7 @@
|
|||||||
CODE_SIGN_ENTITLEMENTS = "Emoney Info/Emoney Info.entitlements";
|
CODE_SIGN_ENTITLEMENTS = "Emoney Info/Emoney Info.entitlements";
|
||||||
CODE_SIGN_IDENTITY = "Apple Development";
|
CODE_SIGN_IDENTITY = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 11;
|
CURRENT_PROJECT_VERSION = 12;
|
||||||
DEVELOPMENT_TEAM = 6S5573WXX4;
|
DEVELOPMENT_TEAM = 6S5573WXX4;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
@ -686,7 +686,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 1.0.2;
|
MARKETING_VERSION = 1.0.3;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.iiyh.emoneyinfo;
|
PRODUCT_BUNDLE_IDENTIFIER = com.iiyh.emoneyinfo;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||||
|
|||||||
@ -39,6 +39,7 @@ public class MandiriEmoneyApi : UnifiedNfcApi {
|
|||||||
debugLog(response.getData().hexEncodedString())
|
debugLog(response.getData().hexEncodedString())
|
||||||
let balance = response.getData().hexEncodedString().subString(from: 0, to: 8)
|
let balance = response.getData().hexEncodedString().subString(from: 0, to: 8)
|
||||||
self.emoney.setBalance(self.getRealBalance(reverseHexa: balance))
|
self.emoney.setBalance(self.getRealBalance(reverseHexa: balance))
|
||||||
|
self.resetHistoryState()
|
||||||
// self.updateScreen()
|
// self.updateScreen()
|
||||||
if (self.cardType! == 131){
|
if (self.cardType! == 131){
|
||||||
self.getLogStep01(index: self.start)
|
self.getLogStep01(index: self.start)
|
||||||
@ -64,7 +65,7 @@ public class MandiriEmoneyApi : UnifiedNfcApi {
|
|||||||
} else {
|
} else {
|
||||||
self.parseNewLog()
|
self.parseNewLog()
|
||||||
self.start = 0
|
self.start = 0
|
||||||
self.riwayatList = self.riwayatList.sorted(by: { $0.getTransationTime()?.compare($1.getTransationTime()!) == .orderedDescending })
|
self.finalizeHistory()
|
||||||
self.emoney.setRiwayatList(self.riwayatList)
|
self.emoney.setRiwayatList(self.riwayatList)
|
||||||
self.emoney.setTampilRiwayat(true)
|
self.emoney.setTampilRiwayat(true)
|
||||||
self.updateScreen()
|
self.updateScreen()
|
||||||
@ -74,7 +75,7 @@ public class MandiriEmoneyApi : UnifiedNfcApi {
|
|||||||
} else {
|
} else {
|
||||||
self.parseNewLog()
|
self.parseNewLog()
|
||||||
self.start = 0
|
self.start = 0
|
||||||
self.riwayatList = self.riwayatList.sorted(by: { $0.getTransationTime()?.compare($1.getTransationTime()!) == .orderedDescending })
|
self.finalizeHistory()
|
||||||
self.emoney.setRiwayatList(self.riwayatList)
|
self.emoney.setRiwayatList(self.riwayatList)
|
||||||
self.emoney.setTampilRiwayat(true)
|
self.emoney.setTampilRiwayat(true)
|
||||||
self.updateScreen()
|
self.updateScreen()
|
||||||
@ -125,7 +126,7 @@ public class MandiriEmoneyApi : UnifiedNfcApi {
|
|||||||
} else {
|
} else {
|
||||||
self.parseOldLog()
|
self.parseOldLog()
|
||||||
self.start = 0
|
self.start = 0
|
||||||
self.riwayatList = self.riwayatList.sorted(by: { $0.getTransationTime()?.compare($1.getTransationTime()!) == .orderedDescending })
|
self.finalizeHistory()
|
||||||
self.emoney.setRiwayatList(self.riwayatList)
|
self.emoney.setRiwayatList(self.riwayatList)
|
||||||
self.emoney.setTampilRiwayat(true)
|
self.emoney.setTampilRiwayat(true)
|
||||||
self.updateScreen()
|
self.updateScreen()
|
||||||
@ -135,7 +136,7 @@ public class MandiriEmoneyApi : UnifiedNfcApi {
|
|||||||
} else {
|
} else {
|
||||||
self.parseOldLog()
|
self.parseOldLog()
|
||||||
self.start = 0
|
self.start = 0
|
||||||
self.riwayatList = self.riwayatList.sorted(by: { $0.getTransationTime()?.compare($1.getTransationTime()!) == .orderedDescending })
|
self.finalizeHistory()
|
||||||
self.emoney.setRiwayatList(self.riwayatList)
|
self.emoney.setRiwayatList(self.riwayatList)
|
||||||
self.emoney.setTampilRiwayat(true)
|
self.emoney.setTampilRiwayat(true)
|
||||||
self.updateScreen()
|
self.updateScreen()
|
||||||
@ -198,6 +199,16 @@ public class MandiriEmoneyApi : UnifiedNfcApi {
|
|||||||
self.apduRunner.callback?.complete(emoney: self.emoney)
|
self.apduRunner.callback?.complete(emoney: self.emoney)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func resetHistoryState() {
|
||||||
|
riwayatList.removeAll()
|
||||||
|
mapv1 = ""
|
||||||
|
start = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
private func finalizeHistory() {
|
||||||
|
riwayatList = riwayatList.sorted(by: { $0.getTransationTime()?.compare($1.getTransationTime()!) == .orderedDescending })
|
||||||
|
}
|
||||||
|
|
||||||
func riwayatCard(_ bArr: [UInt8]) -> RiwayatCard? {
|
func riwayatCard(_ bArr: [UInt8]) -> RiwayatCard? {
|
||||||
var str: String
|
var str: String
|
||||||
|
|||||||
@ -668,7 +668,7 @@ extension HomeViewController: ApduCallback {
|
|||||||
self.updateCardNumberDisplay()
|
self.updateCardNumberDisplay()
|
||||||
|
|
||||||
if (emoney.isTampilRiwayat()){
|
if (emoney.isTampilRiwayat()){
|
||||||
let riwayat = emoney.getRiwayatList()
|
let riwayat = self.deduplicateHistory(emoney.getRiwayatList())
|
||||||
if let first = riwayat.first {
|
if let first = riwayat.first {
|
||||||
let dateFmt = DateFormatter()
|
let dateFmt = DateFormatter()
|
||||||
dateFmt.dateFormat = "dd MMM yyyy, HH:mm"
|
dateFmt.dateFormat = "dd MMM yyyy, HH:mm"
|
||||||
@ -707,6 +707,22 @@ private extension HomeViewController {
|
|||||||
formatter.minimumFractionDigits = 0
|
formatter.minimumFractionDigits = 0
|
||||||
return formatter
|
return formatter
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
func deduplicateHistory(_ items: [RiwayatCard]) -> [RiwayatCard] {
|
||||||
|
var seen = Set<String>()
|
||||||
|
return items.filter { item in
|
||||||
|
let key = historyKey(for: item)
|
||||||
|
return seen.insert(key).inserted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func historyKey(for item: RiwayatCard) -> String {
|
||||||
|
let timestamp = item.getTransationTime()?.timeIntervalSince1970 ?? 0
|
||||||
|
let locationId = item.getLocationId() ?? ""
|
||||||
|
let locationName = item.getLocationName() ?? ""
|
||||||
|
let title = item.getTitle() ?? ""
|
||||||
|
return "\(timestamp)|\(item.getAmount())|\(item.getProsesTipe())|\(locationId)|\(locationName)|\(title)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - UILabel letter spacing helper
|
// MARK: - UILabel letter spacing helper
|
||||||
|
|||||||
Reference in New Issue
Block a user