|
|
@@ -23,7 +23,9 @@ import retrofit2.http.Query;
|
|
|
|
|
|
public class CourseRepository {
|
|
|
private CourseDao courseDao = RetrofitClient.courseDao;
|
|
|
+ private final MutableLiveData<LoadState> stateData = new MutableLiveData<>();
|
|
|
private final MutableLiveData<Course> courseData = new MutableLiveData<>();
|
|
|
+ private final MutableLiveData<List<Course>> courseListData = new MutableLiveData<>();
|
|
|
private static CourseRepository uniqueInstance = null;
|
|
|
private Integer currentPage = 1;
|
|
|
|
|
|
@@ -41,7 +43,12 @@ public class CourseRepository {
|
|
|
public Integer getCurrentPage(){
|
|
|
return currentPage;
|
|
|
}
|
|
|
-
|
|
|
+ public MutableLiveData<List<Course>> getCourseListLiveData(){
|
|
|
+ return courseListData;
|
|
|
+ }
|
|
|
+ public MutableLiveData<LoadState> getStateDataLiveData(){
|
|
|
+ return stateData;
|
|
|
+ }
|
|
|
|
|
|
public MutableLiveData<Course> getCourseData(Integer courseId){
|
|
|
String uid = null;
|
|
|
@@ -69,7 +76,7 @@ public class CourseRepository {
|
|
|
return courseData;
|
|
|
|
|
|
}
|
|
|
- public void getCourseListData(Integer currentPageNum, String uid,String queryKey,MutableLiveData<List<Course>> courseListData,MutableLiveData<LoadState> stateData){
|
|
|
+ public void getCourseListData(Integer currentPageNum, String uid,String queryKey){
|
|
|
stateData.setValue(LoadState.LOADING);
|
|
|
Call<PageInfo<Course>> courseCall = courseDao.getAllCourses(currentPageNum, uid, queryKey);
|
|
|
// 异步调用
|
|
|
@@ -98,11 +105,7 @@ public class CourseRepository {
|
|
|
currentPage--;
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|