Search in sources :

Example 1 with SortOrder

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);
}
Also used : AlertDialog(android.app.AlertDialog) Context(android.content.Context) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) LinearLayout(android.widget.LinearLayout) ConstantStrings(org.fossasia.openevent.common.ConstantStrings) Arrays(java.util.Arrays) Bundle(android.os.Bundle) KeyEvent(android.view.KeyEvent) SnackbarUtil(org.fossasia.openevent.common.ui.SnackbarUtil) Utils(org.fossasia.openevent.common.utils.Utils) ImageView(android.widget.ImageView) ViewPager(android.support.v4.view.ViewPager) NonNull(android.support.annotation.NonNull) OnClick(butterknife.OnClick) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) BindView(butterknife.BindView) TabLayout(android.support.design.widget.TabLayout) Track(org.fossasia.openevent.data.Track) ZoneOffset(org.threeten.bp.ZoneOffset) Instant(org.threeten.bp.Instant) View(android.view.View) ZoneId(org.threeten.bp.ZoneId) R(org.fossasia.openevent.R) ActionBar(android.support.v7.app.ActionBar) BookmarkStatus(org.fossasia.openevent.core.bookmark.BookmarkStatus) StrategyRegistry(org.fossasia.openevent.config.StrategyRegistry) FloatingActionButton(android.support.design.widget.FloatingActionButton) LayoutInflater(android.view.LayoutInflater) ContextCompat(android.support.v4.content.ContextCompat) BaseFragment(org.fossasia.openevent.common.ui.base.BaseFragment) DateConverter(org.fossasia.openevent.common.date.DateConverter) AppCompatActivity(android.support.v7.app.AppCompatActivity) ViewGroup(android.view.ViewGroup) SharedPreferencesUtil(org.fossasia.openevent.common.utils.SharedPreferencesUtil) AlertDialog(android.app.AlertDialog) ViewModelProviders(android.arch.lifecycle.ViewModelProviders) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) TextView(android.widget.TextView) OnBookmarkSelectedListener(org.fossasia.openevent.core.bookmark.OnBookmarkSelectedListener) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) SortOrder(org.fossasia.openevent.common.utils.SortOrder)

Aggregations

AlertDialog (android.app.AlertDialog)1 ViewModelProviders (android.arch.lifecycle.ViewModelProviders)1 Context (android.content.Context)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)1 FloatingActionButton (android.support.design.widget.FloatingActionButton)1 Snackbar (android.support.design.widget.Snackbar)1 TabLayout (android.support.design.widget.TabLayout)1 ContextCompat (android.support.v4.content.ContextCompat)1 ViewPager (android.support.v4.view.ViewPager)1 ActionBar (android.support.v7.app.ActionBar)1 AppCompatActivity (android.support.v7.app.AppCompatActivity)1 KeyEvent (android.view.KeyEvent)1 LayoutInflater (android.view.LayoutInflater)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1