From 009dd597cb14fd96e1e1e98159c67348575ea96d Mon Sep 17 00:00:00 2001 From: enricocid Date: Wed, 14 Nov 2018 13:11:38 +0100 Subject: [PATCH] Code refactoring Signed-off-by: enricocid --- .../com/iven/musicplayergo/MainActivity.java | 4 +-- .../loaders/ArtistViewModel.java | 28 ------------------- .../app/src/main/res/values-v27/styles.xml | 2 ++ project/app/src/main/res/values/styles.xml | 27 ++++++++++-------- 4 files changed, 20 insertions(+), 41 deletions(-) delete mode 100644 project/app/src/main/java/com/iven/musicplayergo/loaders/ArtistViewModel.java diff --git a/project/app/src/main/java/com/iven/musicplayergo/MainActivity.java b/project/app/src/main/java/com/iven/musicplayergo/MainActivity.java index c99b46c3c..43ba22e9d 100644 --- a/project/app/src/main/java/com/iven/musicplayergo/MainActivity.java +++ b/project/app/src/main/java/com/iven/musicplayergo/MainActivity.java @@ -41,7 +41,7 @@ import com.iven.musicplayergo.indexbar.IndexBarRecyclerView; import com.iven.musicplayergo.indexbar.IndexBarView; import com.iven.musicplayergo.loaders.ArtistProvider; -import com.iven.musicplayergo.loaders.ArtistViewModel; +import com.iven.musicplayergo.loaders.ArtistsViewModel; import com.iven.musicplayergo.loaders.SongProvider; import com.iven.musicplayergo.models.Album; import com.iven.musicplayergo.models.Artist; @@ -466,7 +466,7 @@ private void initializeColorsSettings() { } private void onPermissionGranted() { - final ArtistViewModel model = ViewModelProviders.of(this).get(ArtistViewModel.class); + final ArtistsViewModel model = ViewModelProviders.of(this).get(ArtistsViewModel.class); final List artists = model.getArtists(this).getValue(); if (artists != null) { diff --git a/project/app/src/main/java/com/iven/musicplayergo/loaders/ArtistViewModel.java b/project/app/src/main/java/com/iven/musicplayergo/loaders/ArtistViewModel.java deleted file mode 100644 index 8e4ea5e83..000000000 --- a/project/app/src/main/java/com/iven/musicplayergo/loaders/ArtistViewModel.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.iven.musicplayergo.loaders; - -import android.content.Context; - -import com.iven.musicplayergo.models.Artist; - -import java.util.List; - -import androidx.annotation.NonNull; -import androidx.lifecycle.LiveData; -import androidx.lifecycle.MutableLiveData; -import androidx.lifecycle.ViewModel; - -public class ArtistViewModel extends ViewModel { - private MutableLiveData> artists; - - public LiveData> getArtists(@NonNull final Context context) { - if (artists == null) { - artists = new MutableLiveData<>(); - loadUsers(context); - } - return artists; - } - - private void loadUsers(@NonNull Context context) { - artists.setValue(ArtistProvider.getAllArtists(context)); - } -} \ No newline at end of file diff --git a/project/app/src/main/res/values-v27/styles.xml b/project/app/src/main/res/values-v27/styles.xml index ed33e679c..2269c34a7 100644 --- a/project/app/src/main/res/values-v27/styles.xml +++ b/project/app/src/main/res/values-v27/styles.xml @@ -9,6 +9,7 @@ @color/white @style/AlertDialogStyle @color/white + @color/gray_900 true @@ -20,6 +21,7 @@ false @color/black @color/black + @color/gray_900 @style/AlertDialogStyle true diff --git a/project/app/src/main/res/values/styles.xml b/project/app/src/main/res/values/styles.xml index 2269c34a7..799b5878e 100644 --- a/project/app/src/main/res/values/styles.xml +++ b/project/app/src/main/res/values/styles.xml @@ -1,28 +1,33 @@ - + + +