Search in sources :

Example 1 with Course

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);
        }
    });
}
Also used : Course(com.tevinjeffrey.rutgersct.rutgersapi.model.Course) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 2 with Course

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);
}
Also used : Action0(rx.functions.Action0) Subscriber(rx.Subscriber) List(java.util.List) Course(com.tevinjeffrey.rutgersct.rutgersapi.model.Course)

Example 3 with Course

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));
}
Also used : Request(com.tevinjeffrey.rutgersct.rutgersapi.model.Request) Course(com.tevinjeffrey.rutgersct.rutgersapi.model.Course) Test(org.junit.Test)

Aggregations

Course (com.tevinjeffrey.rutgersct.rutgersapi.model.Course)3 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 Request (com.tevinjeffrey.rutgersct.rutgersapi.model.Request)1 List (java.util.List)1 Test (org.junit.Test)1 Subscriber (rx.Subscriber)1 Action0 (rx.functions.Action0)1