history
This commit is contained in:
parent
a49aab14f8
commit
dd57975908
@ -156,7 +156,7 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
historyItem.setDate(formatDate(transactionDate));
|
||||
historyItem.setAmount((long) amountValue);
|
||||
historyItem.setChannelName(formatChannelName(channelCode));
|
||||
historyItem.setStatus(status);
|
||||
historyItem.setStatus(status.toUpperCase()); // Ensure uppercase for consistency
|
||||
historyItem.setReferenceId(referenceId);
|
||||
historyItem.setFullDate(transactionDate);
|
||||
historyItem.setChannelCode(channelCode);
|
||||
@ -194,17 +194,21 @@ public class HistoryActivity extends AppCompatActivity {
|
||||
JSONObject item = dataArray.getJSONObject(i);
|
||||
|
||||
String amount = item.getString("amount");
|
||||
String status = item.getString("status");
|
||||
|
||||
// Parse amount safely
|
||||
double amountValue = 0;
|
||||
try {
|
||||
amountValue = Double.parseDouble(amount);
|
||||
} catch (NumberFormatException e) {
|
||||
amountValue = 0;
|
||||
// Only count if status is settlement or success
|
||||
if ("SETTLEMENT".equalsIgnoreCase(status) || "SUCCESS".equalsIgnoreCase(status)) {
|
||||
// Parse amount safely
|
||||
double amountValue = 0;
|
||||
try {
|
||||
amountValue = Double.parseDouble(amount);
|
||||
} catch (NumberFormatException e) {
|
||||
amountValue = 0;
|
||||
}
|
||||
|
||||
totalAmount += (long) amountValue;
|
||||
totalTransactions++;
|
||||
}
|
||||
|
||||
totalAmount += (long) amountValue;
|
||||
totalTransactions++;
|
||||
}
|
||||
|
||||
final long finalTotalAmount = totalAmount;
|
||||
@ -509,20 +513,26 @@ class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.HistoryViewHold
|
||||
holder.tvAmount.setText("Rp. " + formatCurrency(item.getAmount()));
|
||||
holder.tvChannel.setText(item.getChannelName());
|
||||
|
||||
// Set status color and text
|
||||
// Set status color and text based on API response
|
||||
String status = item.getStatus();
|
||||
if ("SUCCESS".equals(status)) {
|
||||
holder.tvStatus.setText("Berhasil");
|
||||
if ("SETTLEMENT".equalsIgnoreCase(status)) {
|
||||
holder.tvStatus.setText("Success");
|
||||
holder.tvStatus.setTextColor(Color.parseColor("#4CAF50")); // Green
|
||||
} else if ("FAILED".equals(status)) {
|
||||
holder.tvStatus.setText("Gagal");
|
||||
} else if ("SUCCESS".equalsIgnoreCase(status)) {
|
||||
holder.tvStatus.setText("Success");
|
||||
holder.tvStatus.setTextColor(Color.parseColor("#4CAF50")); // Green
|
||||
} else if ("EXPIRE".equalsIgnoreCase(status)) {
|
||||
holder.tvStatus.setText("Expired");
|
||||
holder.tvStatus.setTextColor(Color.parseColor("#F44336")); // Red
|
||||
} else if ("FAILED".equalsIgnoreCase(status)) {
|
||||
holder.tvStatus.setText("Failed");
|
||||
holder.tvStatus.setTextColor(Color.parseColor("#F44336")); // Red
|
||||
} else {
|
||||
holder.tvStatus.setText("Tertunda");
|
||||
holder.tvStatus.setTextColor(Color.parseColor("#FF9800")); // Orange
|
||||
holder.tvStatus.setText("Pending");
|
||||
holder.tvStatus.setTextColor(Color.parseColor("#3141FF")); // Blue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return historyList != null ? historyList.size() : 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user