I want to change the background drawable of a specific table row based on their status compared to their updated date/time with the current time and check if it has been 24h since last update date/time and set a different background drawable.
What I got so far works but I can't figure out how to check if its been 24h and not just greater then the current time
JobRepository jobRepository = new JobRepository(a.getApplication());
jobRepository.findEnquiry().observe(getViewLifecycleOwner(), jobsEnquiry -> {
TableRow[] tableRows = new TableRow[jobsEnquiry.size()];
for (int i=0; i<jobsEnquiry.size(); i++) {
Job job = jobsEnquiry.get(i).job;
tableRows[i] = new TableRow(a);
tableRows[i].setId(i + 1);
tableRows[i].setPadding(0,20,0,20);
if(job.getStatus().equals("Left message/Awaiting reply")){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd H:m:s");
Date updatedDate = job.getUpdatedAt();
Date date = job.getDate();
Date currentTime = Calendar.getInstance().getTime();
tableRows[i].setBackgroundResource(android.R.drawable.list_selector_background);
tableRows[i].setBackgroundResource(R.drawable.table_outline);
if (updatedDate.getTime() < currentTime.getTime()){
tableRows[i].setBackgroundResource(android.R.drawable.list_selector_background);
tableRows[i].setBackgroundResource(R.drawable.table_outline_status);
}
}
else if(job.getStatus().equals("Action required")){
tableRows[i].setBackgroundResource(android.R.drawable.list_selector_background);
tableRows[i].setBackgroundResource(R.drawable.table_outline_status);
}