Search in sources :

Example 1 with AnnouncementsModel

use of org.edx.mobile.model.api.AnnouncementsModel in project edx-app-android by edx.

the class CourseCombinedInfoFragment method populateAnnouncements.

private void populateAnnouncements(@NonNull List<AnnouncementsModel> announcementsList) {
    errorNotification.hideError();
    StringBuilder buff = WebViewUtil.getIntialWebviewBuffer(getActivity(), logger);
    buff.append("<body>");
    for (AnnouncementsModel model : announcementsList) {
        buff.append("<div class=\"header\">");
        buff.append(model.getDate());
        buff.append("</div>");
        buff.append("<div class=\"separator\"></div>");
        buff.append("<div>");
        buff.append(model.getContent());
        buff.append("</div>");
    }
    buff.append("</body>");
    announcementWebView.clearCache(true);
    announcementWebView.loadDataWithBaseURL(environment.getConfig().getApiHostURL(), buff.toString(), "text/html", StandardCharsets.UTF_8.name(), null);
}
Also used : AnnouncementsModel(org.edx.mobile.model.api.AnnouncementsModel)

Example 2 with AnnouncementsModel

use of org.edx.mobile.model.api.AnnouncementsModel in project edx-app-android by edx.

the class ApiTests method testGetAnnouncement.

// TODO: Debug and fix test failure
@Ignore
@Test
public void testGetAnnouncement() throws Exception {
    login();
    // get a course id for this test
    List<EnrolledCoursesResponse> courses = executeStrict(courseAPI.getEnrolledCourses());
    assertTrue("Must have enrolled to at least one course", courses != null && courses.size() > 0);
    String updatesUrl = courses.get(0).getCourse().getCourse_updates();
    List<AnnouncementsModel> res = executeStrict(new TypeToken<List<AnnouncementsModel>>() {
    }, okHttpClient.newCall(new Request.Builder().url(updatesUrl).get().build()));
    assertTrue(res != null);
    for (AnnouncementsModel r : res) {
        print(r.getDate());
    }
}
Also used : EnrolledCoursesResponse(org.edx.mobile.model.api.EnrolledCoursesResponse) Request(okhttp3.Request) AnnouncementsModel(org.edx.mobile.model.api.AnnouncementsModel) ArrayList(java.util.ArrayList) List(java.util.List) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

AnnouncementsModel (org.edx.mobile.model.api.AnnouncementsModel)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Request (okhttp3.Request)1 EnrolledCoursesResponse (org.edx.mobile.model.api.EnrolledCoursesResponse)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1