File tree Expand file tree Collapse file tree 2 files changed +6
-14
lines changed
app/src/main/java/it/niedermann/owncloud/notes Expand file tree Collapse file tree 2 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -291,10 +291,8 @@ protected void onCreate(Bundle savedInstanceState) {
291291 updateSortMethodIcon (methodOfCategory .second );
292292 activityBinding .sortingMethod .setOnClickListener ((v ) -> {
293293 if (methodOfCategory .first != null ) {
294- var newMethod = methodOfCategory .second ;
295- //Rotate for next method
296- newMethod = CategorySortingMethod .findById (newMethod .getId () + 1 );
297-
294+ //Rotate for next sorting method
295+ var newMethod = CategorySortingMethod .findById (methodOfCategory .second .getId () + 1 );
298296 final var modifyLiveData = mainViewModel .modifyCategoryOrder (methodOfCategory .first , newMethod );
299297 modifyLiveData .observe (this , (next ) -> modifyLiveData .removeObservers (this ));
300298 }
@@ -622,10 +620,8 @@ public boolean onSupportNavigateUp() {
622620 * Updates sorting method icon.
623621 */
624622 private void updateSortMethodIcon (CategorySortingMethod method ) {
625- if (method == null )
626- method = CategorySortingMethod .SORT_MODIFIED_DESC ;
627-
628- switch (method ){
623+ CategorySortingMethod newMethod = (method != null ) ? method : CategorySortingMethod .SORT_MODIFIED_DESC ;
624+ switch (newMethod ){
629625 case SORT_MODIFIED_DESC :
630626 activityBinding .sortingMethod .setImageResource (R .drawable .modification_desc );
631627 activityBinding .sortingMethod .setContentDescription (getString (R .string .sort_alphabetically ));
Original file line number Diff line number Diff line change @@ -45,14 +45,10 @@ public String getTitle() {
4545 * @return the corresponding enum item with the index (ordinal)
4646 */
4747 public static CategorySortingMethod findById (int id ) {
48- if (id < 0 )
49- id += values ().length ;
50-
51- if (id >= values ().length )
52- id = id % values ().length ;
48+ var newId = id % values ().length ;
5349
5450 for (final var csm : values ()) {
55- if (csm .getId () == id ) {
51+ if (csm .getId () == newId ) {
5652 return csm ;
5753 }
5854 }
You can’t perform that action at this time.
0 commit comments