From 2fd9589aaf17bb4d3c796a3b5bc1c38b19457e10 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Thu, 3 Sep 2020 18:49:41 +0900 Subject: [PATCH] Put redundant code in parent viewmodel --- .../fragments/main/viewmodels/BasePostViewModel.java | 10 ++++++++++ .../main/viewmodels/DiscoverItemViewModel.java | 11 ----------- .../fragments/main/viewmodels/FeedViewModel.java | 12 ------------ .../fragments/main/viewmodels/PostsViewModel.java | 11 ----------- 4 files changed, 10 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/BasePostViewModel.java b/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/BasePostViewModel.java index 8aecc190..88264b4a 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/BasePostViewModel.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/BasePostViewModel.java @@ -1,9 +1,19 @@ package awais.instagrabber.fragments.main.viewmodels; +import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.ViewModel; +import java.util.List; + import awais.instagrabber.models.BasePostModel; public class BasePostViewModel extends ViewModel { + private MutableLiveData> list; + public MutableLiveData> getList() { + if (list == null) { + list = new MutableLiveData<>(); + } + return list; + } } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/DiscoverItemViewModel.java b/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/DiscoverItemViewModel.java index cd73a2b9..566c3643 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/DiscoverItemViewModel.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/DiscoverItemViewModel.java @@ -1,18 +1,7 @@ package awais.instagrabber.fragments.main.viewmodels; -import androidx.lifecycle.MutableLiveData; - -import java.util.List; - import awais.instagrabber.models.DiscoverItemModel; public class DiscoverItemViewModel extends BasePostViewModel { - private MutableLiveData> list; - public MutableLiveData> getList() { - if (list == null) { - list = new MutableLiveData<>(); - } - return list; - } } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/FeedViewModel.java b/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/FeedViewModel.java index 23565be4..9f4e6eca 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/FeedViewModel.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/FeedViewModel.java @@ -1,19 +1,7 @@ package awais.instagrabber.fragments.main.viewmodels; -import androidx.lifecycle.MutableLiveData; - -import java.util.Collections; -import java.util.List; - import awais.instagrabber.models.FeedModel; public class FeedViewModel extends BasePostViewModel { - private MutableLiveData> list; - public MutableLiveData> getList() { - if (list == null) { - list = new MutableLiveData<>(Collections.emptyList()); - } - return list; - } } \ No newline at end of file diff --git a/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/PostsViewModel.java b/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/PostsViewModel.java index fd6e3866..00581198 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/PostsViewModel.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/viewmodels/PostsViewModel.java @@ -1,18 +1,7 @@ package awais.instagrabber.fragments.main.viewmodels; -import androidx.lifecycle.MutableLiveData; - -import java.util.List; - import awais.instagrabber.models.PostModel; public class PostsViewModel extends BasePostViewModel { - private MutableLiveData> list; - public MutableLiveData> getList() { - if (list == null) { - list = new MutableLiveData<>(); - } - return list; - } } \ No newline at end of file