Search in sources :

Example 1 with Section

use of com.tevinjeffrey.rutgersct.rutgersapi.model.Course.Section in project Rutgers-Course-Tracker by tevjef.

the class TrackedSectionsPresenterImpl method loadTrackedSections.

public void loadTrackedSections(final boolean pullToRefresh) {
    if (getView() != null)
        getView().showLoading(pullToRefresh);
    cancePreviousSubscription();
    trackedSectinsSubscriber = new Subscriber<List<Section>>() {

        @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<Section> sectionList) {
            if (getView() != null) {
                getView().setData(sectionList);
            }
        }
    };
    mSubscription = mDatabaseHandler.getObservableSections().flatMap(new Func1<List<Request>, Observable<Section>>() {

        @Override
        public Observable<Section> call(List<Request> requests) {
            return mRetroRutgers.getTrackedSections(requests);
        }
    }).doOnSubscribe(new Action0() {

        @Override
        public void call() {
            isLoading = true;
        }
    }).doOnTerminate(new Action0() {

        @Override
        public void call() {
            isLoading = false;
        }
    }).toSortedList().subscribeOn(mBackgroundThread).observeOn(mMainThread).subscribe(trackedSectinsSubscriber);
}
Also used : Action0(rx.functions.Action0) Request(com.tevinjeffrey.rutgersct.rutgersapi.model.Request) List(java.util.List) Func1(rx.functions.Func1) Section(com.tevinjeffrey.rutgersct.rutgersapi.model.Course.Section)

Example 2 with Section

use of com.tevinjeffrey.rutgersct.rutgersapi.model.Course.Section in project Rutgers-Course-Tracker by tevjef.

the class TrackedSectionsFragmentAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final TrackedSectionVH holder, int position) {
    final Section section = sectionList.get(position);
    holder.setCourseTitle(section.getCourse());
    holder.setOpenStatus(section);
    holder.setSectionNumber(section);
    holder.setInstructors(section);
    holder.setTimes(section);
    holder.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            itemClickListener.onItemClicked(section, v);
        }
    });
}
Also used : Section(com.tevinjeffrey.rutgersct.rutgersapi.model.Course.Section) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 3 with Section

use of com.tevinjeffrey.rutgersct.rutgersapi.model.Course.Section in project Rutgers-Course-Tracker by tevjef.

the class CourseInfoFragmentAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == TYPE_HEADER && position == 0) {
        HeaderVH headerVH = (HeaderVH) holder;
        headerVH.setHeaders(mHeaders);
    } else if (holder.getItemViewType() == TYPE_ITEM) {
        CourseInfoVH courseInfoVH = (CourseInfoVH) holder;
        final Section section = sectionList.get(position - 1);
        courseInfoVH.setOpenStatus(section);
        courseInfoVH.setSectionNumber(section);
        courseInfoVH.setInstructors(section);
        courseInfoVH.setTimes(section);
        courseInfoVH.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                itemClickListener.onItemClicked(section, v);
            }
        });
    }
}
Also used : Section(com.tevinjeffrey.rutgersct.rutgersapi.model.Course.Section) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) HeaderVH(com.tevinjeffrey.rutgersct.ui.utils.HeaderVH)

Aggregations

Section (com.tevinjeffrey.rutgersct.rutgersapi.model.Course.Section)3 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 Request (com.tevinjeffrey.rutgersct.rutgersapi.model.Request)1 HeaderVH (com.tevinjeffrey.rutgersct.ui.utils.HeaderVH)1 List (java.util.List)1 Action0 (rx.functions.Action0)1 Func1 (rx.functions.Func1)1