vendredi 12 juillet 2019

How to print one thing if a condition is true and another if its not. Altering the same TextView

I'm trying to print out a list of arrays which are events: event date and event title. Some events are just one day and others are a couple days, I want to represent that with the simple date (ex: 10) for one day and this (ex: 5 - 9) for a long event.

I'm getting the info from a table in my database, I thought this would be a straightforward if statement but maybe my logic is flawed?

if (funt.formatDateToDay(currentItem.init_date) == funt.formatDateToDay(currentItem.end_date)) {
                holder.mTextViewDate.setText(funt.formatDateToDay(currentItem.init_date));
                holder.mTextViewTitle.setText(currentItem.title);
            } else {
                holder.mTextViewDate.setText
                        (funt.formatDateToDay(currentItem.init_date) + " - " + funt.formatDateToDay(currentItem.end_date));
                holder.mTextViewTitle.setText(currentItem.title);
            }

Right now they're all print the same way startDate - EndDate, which is fine for the long events but for the day events it's printing the same date twice (since startDate and endDate are the same) like this (5 - 5).

I want the events to look like this

3 event

5-9 event

Right now they look like this

3-3 event

5-9 event

Aucun commentaire:

Enregistrer un commentaire