forked from penguin86/nextcloud-maps-client
Sorting by category
This commit is contained in:
+6
@@ -55,6 +55,8 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
|
||||
public static final int SORT_BY_TITLE = 0;
|
||||
public static final int SORT_BY_CREATED = 1;
|
||||
public static final int SORT_BY_CATEGORY = 2;
|
||||
public static final int SORT_BY_DISTANCE = 3;
|
||||
|
||||
private Context context;
|
||||
private ItemClickListener itemClickListener;
|
||||
@@ -207,6 +209,10 @@ public class GeofavoriteAdapter extends RecyclerView.Adapter<GeofavoriteAdapter.
|
||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByTitleAZ);
|
||||
} else if (sortRule == SORT_BY_CREATED) {
|
||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByLastCreated);
|
||||
} else if (sortRule == SORT_BY_CATEGORY) {
|
||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByCategory);
|
||||
} else if (sortRule == SORT_BY_DISTANCE) {
|
||||
Collections.sort(geofavoriteListFiltered, Geofavorite.ByDistance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -289,6 +289,12 @@ public class MainActivity extends AppCompatActivity implements OnSortingOrderLis
|
||||
case SORT_BY_CREATED:
|
||||
sortButton.setImageResource(R.drawable.ic_modification_asc);
|
||||
break;
|
||||
case SORT_BY_CATEGORY:
|
||||
sortButton.setImageResource(R.drawable.ic_category_asc);
|
||||
break;
|
||||
case SORT_BY_DISTANCE:
|
||||
sortButton.setImageResource(R.drawable.ic_distance_asc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-1
@@ -91,13 +91,14 @@ public class SortingOrderDialogFragment extends DialogFragment {
|
||||
|
||||
/**
|
||||
* find all relevant UI elements and set their values.
|
||||
* TODO: this is REALLY ugly.
|
||||
*
|
||||
* @param view the parent view
|
||||
*/
|
||||
private void setupDialogElements(View view) {
|
||||
mCancel = view.findViewById(R.id.cancel);
|
||||
|
||||
mTaggedViews = new View[4];
|
||||
mTaggedViews = new View[8];
|
||||
mTaggedViews[0] = view.findViewById(R.id.sortByTitleAscending);
|
||||
mTaggedViews[0].setTag(GeofavoriteAdapter.SORT_BY_TITLE);
|
||||
mTaggedViews[1] = view.findViewById(R.id.sortByTitleAscendingText);
|
||||
@@ -106,6 +107,14 @@ public class SortingOrderDialogFragment extends DialogFragment {
|
||||
mTaggedViews[2].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
|
||||
mTaggedViews[3] = view.findViewById(R.id.sortByCreationDateDescendingText);
|
||||
mTaggedViews[3].setTag(GeofavoriteAdapter.SORT_BY_CREATED);
|
||||
mTaggedViews[4] = view.findViewById(R.id.sortByCategoryAscending);
|
||||
mTaggedViews[4].setTag(GeofavoriteAdapter.SORT_BY_CATEGORY);
|
||||
mTaggedViews[5] = view.findViewById(R.id.sortByCategoryAscendingText);
|
||||
mTaggedViews[5].setTag(GeofavoriteAdapter.SORT_BY_CATEGORY);
|
||||
mTaggedViews[6] = view.findViewById(R.id.sortByDistanceAscending);
|
||||
mTaggedViews[6].setTag(GeofavoriteAdapter.SORT_BY_DISTANCE);
|
||||
mTaggedViews[7] = view.findViewById(R.id.sortByDistanceAscendingText);
|
||||
mTaggedViews[7].setTag(GeofavoriteAdapter.SORT_BY_DISTANCE);
|
||||
|
||||
setupActiveOrderSelection();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user