use of com.tevinjeffrey.rutgersct.rutgersapi.model.Course in project Rutgers-Course-Tracker by tevjef.
the class CourseFragmentAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final CourseVH holder, int position) {
final Course course = courseList.get(position);
holder.setCourseTitle(course);
holder.setSectionsInfo(course);
holder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
itemClickListener.onItemClicked(course, v);
}
});
}
use of com.tevinjeffrey.rutgersct.rutgersapi.model.Course in project Rutgers-Course-Tracker by tevjef.
the class CoursePresenterImpl method loadCourses.
@Override
public void loadCourses(boolean pullToRefresh) {
if (getView() != null)
getView().showLoading(pullToRefresh);
cancePreviousSubscription();
Subscriber<List<Course>> mSubscriber = new Subscriber<List<Course>>() {
@Override
public void onCompleted() {
if (getView() != null)
getView().showLoading(false);
}
@Override
public void onError(Throwable e) {
//Removes the animated loading drawable
if (getView() != null)
getView().showLoading(false);
//Lets the view decide what to display depending on what type of exception it is.
if (getView() != null)
getView().showError(e);
}
@Override
public void onNext(List<Course> courseList) {
if (getView() != null)
getView().setData(courseList);
if (courseList.size() > 0) {
if (getView() != null)
getView().showLayout(View.LayoutType.LIST);
}
}
};
mSubscription = mRetroRutgers.getCourses(mRequest).doOnSubscribe(new Action0() {
@Override
public void call() {
isLoading = true;
}
}).doOnTerminate(new Action0() {
@Override
public void call() {
isLoading = false;
}
}).subscribeOn(mBackgroundThread).observeOn(mMainThread).subscribe(mSubscriber);
}
use of com.tevinjeffrey.rutgersct.rutgersapi.model.Course in project Rutgers-Course-Tracker by tevjef.
the class CoursePresenterImplTest method LoadCourses_CompletesWithList.
@Test
public void LoadCourses_CompletesWithList() throws Exception {
coursePresenterImpl.attachView(courseView);
databaseHandler.addSectionToDb(TestConts.getPrimarySemesterRequest());
when(retroRutgers.getCourses(any(Request.class))).thenReturn(Observable.just(new Course()).toList());
coursePresenterImpl.loadCourses(true);
verify(courseView).showLoading(true);
verify(courseView).showLoading(false);
verify(courseView).setData(anyListOf(Course.class));
}
Aggregations