From 9bed2275efb75ecf89c15fa692dc7e7df6a228f8 Mon Sep 17 00:00:00 2001 From: CappielloAntonio Date: Tue, 24 Aug 2021 12:59:37 +0200 Subject: [PATCH] Code refactor --- .../play/repository/AlbumRepository.java | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/cappielloantonio/play/repository/AlbumRepository.java b/app/src/main/java/com/cappielloantonio/play/repository/AlbumRepository.java index 4cc4fb8a..92a5dbd9 100644 --- a/app/src/main/java/com/cappielloantonio/play/repository/AlbumRepository.java +++ b/app/src/main/java/com/cappielloantonio/play/repository/AlbumRepository.java @@ -265,23 +265,21 @@ public class AlbumRepository { public MutableLiveData> getDecades() { MutableLiveData> decades = new MutableLiveData<>(); - getFirstAlbum(first -> { - getLastAlbum(last -> { - if(first != -1 && last != -1) { - List decadeList = new ArrayList(); + getFirstAlbum(first -> getLastAlbum(last -> { + if(first != -1 && last != -1) { + List decadeList = new ArrayList(); - int startDecade = first - (first % 10); - int lastDecade = last - (last % 10); + int startDecade = first - (first % 10); + int lastDecade = last - (last % 10); - while (startDecade <= lastDecade) { - decadeList.add(startDecade); - startDecade = startDecade + 10; - } - - decades.setValue(decadeList); + while (startDecade <= lastDecade) { + decadeList.add(startDecade); + startDecade = startDecade + 10; } - }); - }); + + decades.setValue(decadeList); + } + })); return decades; }