fix #42, display day of the week in some views

This commit is contained in:
tibbi 2016-11-07 22:55:50 +01:00
parent 445e768730
commit 989d3ecf83
3 changed files with 13 additions and 6 deletions

View File

@ -11,6 +11,7 @@ public class Formatter {
public static final String DAYCODE_PATTERN = "YYYYMMdd";
public static final String YEAR_PATTERN = "YYYY";
private static final String DAY_PATTERN = "d";
private static final String DAY_OF_WEEK_PATTERN = "EEE";
private static final String EVENT_DATE_PATTERN = "d YYYY"; // MMMM doesn't give the proper month name in some languages
private static final String EVENT_TIME_PATTERN = "HH:mm";
@ -27,8 +28,14 @@ public class Formatter {
}
public static String getEventDate(Context context, DateTime dateTime) {
final String dayYear = dateTime.toString(EVENT_DATE_PATTERN);
return getMonthName(context, dateTime.getMonthOfYear() - 1) + " " + dayYear;
return getDayTitle(context, getDayCodeFromDateTime(dateTime));
}
public static String getDayTitle(Context context, String dayCode) {
String date = getEventDate(context, dayCode);
final DateTime dateTime = getDateTimeFromCode(dayCode);
final String day = dateTime.toString(DAY_OF_WEEK_PATTERN);
return date + " (" + day + ")";
}
public static String getEventTime(DateTime dateTime) {

View File

@ -42,15 +42,15 @@ class DayFragment : Fragment(), DBHelper.EventsListener, AdapterView.OnItemClick
val DELETED_ID = "deleted_id"
}
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater!!.inflate(R.layout.day_fragment, container, false)
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.day_fragment, container, false)
mRes = resources
mHolder = view.day_holder
mConfig = Config.newInstance(context)
mDayCode = arguments.getString(Constants.DAY_CODE)
val day = Formatter.getEventDate(activity.applicationContext, mDayCode)
val day = Formatter.getDayTitle(activity.applicationContext, mDayCode)
mHolder.top_value.text = day
mHolder.top_value.setOnClickListener { pickDay() }
mToBeDeleted = ArrayList<Int>()

View File

@ -65,7 +65,7 @@ class EventListFragment : Fragment(), DBHelper.GetEventsListener, AdapterView.On
sorted.forEach {
val code = Formatter.getDayCodeFromTS(it.startTS)
if (code != prevCode) {
val day = Formatter.getEventDate(context, code)
val day = Formatter.getDayTitle(context, code)
mListItems.add(ListSection(day, false))
prevCode = code
}