use of com.tevinjeffrey.rutgersct.rutgersapi.model.Subject in project Rutgers-Course-Tracker by tevjef.
the class SubjectPresenterImpl method loadSubjects.
@Override
public void loadSubjects(boolean pullToRefresh) {
if (getView() != null)
getView().showLoading(pullToRefresh);
cancePreviousSubscription();
Subscriber<List<Subject>> mSubscriber = new Subscriber<List<Subject>>() {
@Override
public void onCompleted() {
if (getView() != null)
getView().showLoading(false);
}
@Override
public void onError(Throwable e) {
//Lets the view decide what to display depending on what type of exception it is.
if (getView() != null)
getView().showError(e);
//Removes the animated loading drawable
if (getView() != null) {
getView().showLoading(false);
}
}
@Override
public void onNext(List<Subject> subjectList) {
if (getView() != null) {
getView().setData(subjectList);
if (subjectList.size() == 0)
getView().showError(new RutgersDataIOException());
if (subjectList.size() > 0)
getView().showLayout(View.LayoutType.LIST);
}
}
};
mSubscription = mRetroRutgers.getSubjects(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.Subject in project Rutgers-Course-Tracker by tevjef.
the class RetroRutgers method getSubjectFromJson.
public Subject getSubjectFromJson(String code) {
List<Subject> subjectsList = mSubjectsList;
Subject temp;
for (int i = 0, size = subjectsList.size(); i < size; i++) {
temp = subjectsList.get(i);
if (temp.getCode().equals(code)) {
return temp;
}
}
return null;
}
use of com.tevinjeffrey.rutgersct.rutgersapi.model.Subject in project Rutgers-Course-Tracker by tevjef.
the class SubjectPresenterImplTest method LoadSubjects_CompletesWithList.
@Test
public void LoadSubjects_CompletesWithList() throws Exception {
subjectPresenterImpl.attachView(subjectView);
databaseHandler.addSectionToDb(TestConts.getPrimarySemesterRequest());
when(retroRutgers.getSubjects(any(Request.class))).thenReturn(Observable.just(new Subject()).toList());
subjectPresenterImpl.loadSubjects(true);
verify(subjectView).showLoading(true);
verify(subjectView).showLoading(false);
verify(subjectView).setData(anyListOf(Subject.class));
}
use of com.tevinjeffrey.rutgersct.rutgersapi.model.Subject in project Rutgers-Course-Tracker by tevjef.
the class SubjectFragmentAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final SubjectVH holder, int position) {
final Subject subject = subjectList.get(position);
holder.setSubjectTitle(subject);
holder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
itemClickListener.onItemClicked(subject, v);
}
});
}
use of com.tevinjeffrey.rutgersct.rutgersapi.model.Subject in project Rutgers-Course-Tracker by tevjef.
the class CourseFragment method setToolbarTitle.
private void setToolbarTitle() {
Subject selectedSubject = getArguments().getParcelable(SubjectView.SELECTED_SUBJECT);
super.setToolbarTitle(mToolbar, (selectedSubject != null ? selectedSubject.getCode() : "") + " | " + WordUtils.capitalize(selectedSubject != null ? selectedSubject.getDescription().toLowerCase() : ""));
}
Aggregations