use of org.fossasia.openevent.common.utils.SortOrder in project open-event-android by fossasia.
the class ScheduleFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.action_sort:
final AlertDialog.Builder dialogSort = new AlertDialog.Builder(context).setTitle(R.string.dialog_sort_title).setSingleChoiceItems(R.array.session_sort, sortType, (dialog, which) -> {
sortType = which;
SharedPreferencesUtil.putInt(ConstantStrings.PREF_SORT_SCHEDULE, which);
notifyUpdate(-1, selectedTracks);
}).setPositiveButton(R.string.ascending, (dialog, which) -> {
sortOrder = SortOrder.SORT_ORDER_ASCENDING;
SharedPreferencesUtil.putInt(ConstantStrings.PREF_SORT_ORDER, sortOrder);
notifyUpdate(-1, selectedTracks);
dialog.dismiss();
}).setNegativeButton(R.string.descending, (dialog, which) -> {
sortOrder = SortOrder.SORT_ORDER_DESCENDING;
SharedPreferencesUtil.putInt(ConstantStrings.PREF_SORT_ORDER, sortOrder);
notifyUpdate(-1, selectedTracks);
dialog.dismiss();
});
AlertDialog dialog = dialogSort.show();
dialog.getButton(sortOrder == SortOrder.SORT_ORDER_ASCENDING ? AlertDialog.BUTTON_NEGATIVE : AlertDialog.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(context, android.R.color.darker_gray));
dialog.getButton(sortOrder == SortOrder.SORT_ORDER_ASCENDING ? AlertDialog.BUTTON_POSITIVE : AlertDialog.BUTTON_NEGATIVE);
dialog.show();
break;
default:
}
return super.onOptionsItemSelected(item);
}
Aggregations