use of com.tevinjeffrey.rutgersct.rutgersapi.model.Request 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);
}
use of com.tevinjeffrey.rutgersct.rutgersapi.model.Request in project Rutgers-Course-Tracker by tevjef.
the class DatabaseReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
RutgersCTApp.getObjectGraph(context).inject(this);
Request request = intent.getParcelableExtra(TrackedSectionsView.REQUEST);
Course.Section section = intent.getParcelableExtra(CourseInfoView.SELECTED_SECTION);
if (request != null && section != null) {
//Removes section from databse
mDatabaseHandler.removeSectionFromDb(request);
//Notify user with a toast.
notifyUser(context, section);
//Remove notification from notification panel
removeNotification(context, request);
}
}
use of com.tevinjeffrey.rutgersct.rutgersapi.model.Request in project Rutgers-Course-Tracker by tevjef.
the class TrackedSectionsFragmentTest method testRecyclerItemClickAndRemoveSection.
@Test
public void testRecyclerItemClickAndRemoveSection() {
Request expected = RutgersApiConts.getPrimarySemesterRequest();
databaseHandler.addSectionToDb(expected);
onView(withId(R.id.tsf_list)).perform(actionOnItemAtPosition(0, click()));
onView(withId(R.id.add_courses_fab)).perform(click());
databaseHandler.removeSectionFromDb(expected);
}
Aggregations