mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-18 04:37:30 +00:00
Put redundant code in parent viewmodel
This commit is contained in:
parent
daa5a110f2
commit
2fd9589aaf
@ -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<T extends BasePostModel> extends ViewModel {
|
||||
private MutableLiveData<List<T>> list;
|
||||
|
||||
public MutableLiveData<List<T>> getList() {
|
||||
if (list == null) {
|
||||
list = new MutableLiveData<>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
@ -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<DiscoverItemModel> {
|
||||
private MutableLiveData<List<DiscoverItemModel>> list;
|
||||
|
||||
public MutableLiveData<List<DiscoverItemModel>> getList() {
|
||||
if (list == null) {
|
||||
list = new MutableLiveData<>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
@ -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<FeedModel> {
|
||||
private MutableLiveData<List<FeedModel>> list;
|
||||
|
||||
public MutableLiveData<List<FeedModel>> getList() {
|
||||
if (list == null) {
|
||||
list = new MutableLiveData<>(Collections.emptyList());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
@ -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<PostModel> {
|
||||
private MutableLiveData<List<PostModel>> list;
|
||||
|
||||
public MutableLiveData<List<PostModel>> getList() {
|
||||
if (list == null) {
|
||||
list = new MutableLiveData<>();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user