mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-12-18 16:42:17 +03:00
Fix value reassgin
Signed-off-by: Kornél Szekeres <szekereskornel@gmail.com>
This commit is contained in:
parent
3f2161fe96
commit
c5a9d0b862
2 changed files with 6 additions and 14 deletions
|
@ -291,10 +291,8 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A
|
||||||
updateSortMethodIcon(methodOfCategory.second);
|
updateSortMethodIcon(methodOfCategory.second);
|
||||||
activityBinding.sortingMethod.setOnClickListener((v) -> {
|
activityBinding.sortingMethod.setOnClickListener((v) -> {
|
||||||
if (methodOfCategory.first != null) {
|
if (methodOfCategory.first != null) {
|
||||||
var newMethod = methodOfCategory.second;
|
//Rotate for next sorting method
|
||||||
//Rotate for next method
|
var newMethod = CategorySortingMethod.findById(methodOfCategory.second.getId() + 1);
|
||||||
newMethod = CategorySortingMethod.findById(newMethod.getId() + 1);
|
|
||||||
|
|
||||||
final var modifyLiveData = mainViewModel.modifyCategoryOrder(methodOfCategory.first, newMethod);
|
final var modifyLiveData = mainViewModel.modifyCategoryOrder(methodOfCategory.first, newMethod);
|
||||||
modifyLiveData.observe(this, (next) -> modifyLiveData.removeObservers(this));
|
modifyLiveData.observe(this, (next) -> modifyLiveData.removeObservers(this));
|
||||||
}
|
}
|
||||||
|
@ -622,10 +620,8 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A
|
||||||
* Updates sorting method icon.
|
* Updates sorting method icon.
|
||||||
*/
|
*/
|
||||||
private void updateSortMethodIcon(CategorySortingMethod method) {
|
private void updateSortMethodIcon(CategorySortingMethod method) {
|
||||||
if (method == null)
|
CategorySortingMethod newMethod = (method != null) ? method: CategorySortingMethod.SORT_MODIFIED_DESC;
|
||||||
method = CategorySortingMethod.SORT_MODIFIED_DESC;
|
switch (newMethod){
|
||||||
|
|
||||||
switch (method){
|
|
||||||
case SORT_MODIFIED_DESC :
|
case SORT_MODIFIED_DESC :
|
||||||
activityBinding.sortingMethod.setImageResource(R.drawable.modification_desc);
|
activityBinding.sortingMethod.setImageResource(R.drawable.modification_desc);
|
||||||
activityBinding.sortingMethod.setContentDescription(getString(R.string.sort_alphabetically));
|
activityBinding.sortingMethod.setContentDescription(getString(R.string.sort_alphabetically));
|
||||||
|
|
|
@ -45,14 +45,10 @@ public enum CategorySortingMethod {
|
||||||
* @return the corresponding enum item with the index (ordinal)
|
* @return the corresponding enum item with the index (ordinal)
|
||||||
*/
|
*/
|
||||||
public static CategorySortingMethod findById(int id) {
|
public static CategorySortingMethod findById(int id) {
|
||||||
if (id < 0)
|
var newId = id % values().length;
|
||||||
id += values().length;
|
|
||||||
|
|
||||||
if (id >= values().length)
|
|
||||||
id = id % values().length;
|
|
||||||
|
|
||||||
for (final var csm : values()) {
|
for (final var csm : values()) {
|
||||||
if (csm.getId() == id) {
|
if (csm.getId() == newId) {
|
||||||
return csm;
|
return csm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue