Search in sources :

Example 6 with TaskMessageCallback

use of org.edx.mobile.view.common.TaskMessageCallback in project edx-app-android by edx.

the class CourseDetailFragment method populateAboutThisCourse.

/**
 * Makes a call the the course details api and sets the overview if given. If there is no
 * overview, remove the courseAbout view.
 */
private void populateAboutThisCourse() {
    getCourseDetailCall = courseApi.getCourseDetail(courseDetail.course_id);
    final Activity activity = getActivity();
    final TaskProgressCallback pCallback = activity instanceof TaskProgressCallback ? (TaskProgressCallback) activity : null;
    final TaskMessageCallback mCallback = activity instanceof TaskMessageCallback ? (TaskMessageCallback) activity : null;
    getCourseDetailCall.enqueue(new ErrorHandlingCallback<CourseDetail>(getActivity(), pCallback, mCallback, CallTrigger.LOADING_CACHED) {

        @Override
        protected void onResponse(@NonNull final CourseDetail courseDetail) {
            if (courseDetail.overview != null && !courseDetail.overview.isEmpty()) {
                populateAboutThisCourse(courseDetail.overview);
            } else {
                courseAbout.setVisibility(View.GONE);
            }
        }
    });
}
Also used : TaskProgressCallback(org.edx.mobile.view.common.TaskProgressCallback) CourseDetail(org.edx.mobile.course.CourseDetail) Activity(android.app.Activity) TaskMessageCallback(org.edx.mobile.view.common.TaskMessageCallback)

Example 7 with TaskMessageCallback

use of org.edx.mobile.view.common.TaskMessageCallback in project edx-app-android by edx.

the class CourseDiscussionResponsesFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    final Activity activity = getActivity();
    responsesLoader = new ResponsesLoader(activity, discussionThread.getIdentifier(), discussionThread.getType() == DiscussionThread.ThreadType.QUESTION);
    courseDiscussionResponsesAdapter = new CourseDiscussionResponsesAdapter(activity, this, this, discussionThread, courseData);
    controller = InfiniteScrollUtils.configureRecyclerViewWithInfiniteList(discussionResponsesRecyclerView, courseDiscussionResponsesAdapter, responsesLoader);
    discussionResponsesRecyclerView.setAdapter(courseDiscussionResponsesAdapter);
    responsesLoader.freeze();
    if (getAndReadThreadCall != null) {
        getAndReadThreadCall.cancel();
    }
    final TaskMessageCallback mCallback = activity instanceof TaskMessageCallback ? (TaskMessageCallback) activity : null;
    getAndReadThreadCall = discussionService.setThreadRead(discussionThread.getIdentifier(), new ReadBody(true));
    // Setting a thread's "read" state gives us back the updated Thread object.
    getAndReadThreadCall.enqueue(new ErrorHandlingCallback<DiscussionThread>(activity, null, mCallback, CallTrigger.LOADING_UNCACHED) {

        @Override
        protected void onResponse(@NonNull final DiscussionThread discussionThread) {
            courseDiscussionResponsesAdapter.updateDiscussionThread(discussionThread);
            responsesLoader.unfreeze();
            EventBus.getDefault().post(new DiscussionThreadUpdatedEvent(discussionThread));
        }
    });
    DiscussionUtils.setStateOnTopicClosed(discussionThread.isClosed(), addResponseTextView, R.string.discussion_responses_add_response_button, R.string.discussion_add_response_disabled_title, addResponseLayout, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            router.showCourseDiscussionAddResponse(activity, discussionThread);
        }
    });
    addResponseLayout.setEnabled(!courseData.isDiscussionBlackedOut());
}
Also used : ReadBody(org.edx.mobile.discussion.DiscussionService.ReadBody) CourseDiscussionResponsesAdapter(org.edx.mobile.view.adapters.CourseDiscussionResponsesAdapter) BaseFragmentActivity(org.edx.mobile.base.BaseFragmentActivity) Activity(android.app.Activity) View(android.view.View) InjectView(roboguice.inject.InjectView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) DiscussionThread(org.edx.mobile.discussion.DiscussionThread) DiscussionThreadUpdatedEvent(org.edx.mobile.discussion.DiscussionThreadUpdatedEvent) TaskMessageCallback(org.edx.mobile.view.common.TaskMessageCallback)

Aggregations

TaskMessageCallback (org.edx.mobile.view.common.TaskMessageCallback)7 Activity (android.app.Activity)6 Page (org.edx.mobile.model.Page)3 View (android.view.View)2 BaseFragmentActivity (org.edx.mobile.base.BaseFragmentActivity)2 CourseDetail (org.edx.mobile.course.CourseDetail)2 DiscussionThread (org.edx.mobile.discussion.DiscussionThread)2 TaskProgressCallback (org.edx.mobile.view.common.TaskProgressCallback)2 NonNull (android.support.annotation.NonNull)1 RecyclerView (android.support.v7.widget.RecyclerView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 DiscussionComment (org.edx.mobile.discussion.DiscussionComment)1 ReadBody (org.edx.mobile.discussion.DiscussionService.ReadBody)1 DiscussionThreadUpdatedEvent (org.edx.mobile.discussion.DiscussionThreadUpdatedEvent)1 ErrorHandlingCallback (org.edx.mobile.http.callback.ErrorHandlingCallback)1 FormDescription (org.edx.mobile.user.FormDescription)1 GetProfileFormDescriptionTask (org.edx.mobile.user.GetProfileFormDescriptionTask)1 AccountDataUpdatedCallback (org.edx.mobile.user.UserAPI.AccountDataUpdatedCallback)1 InvalidLocaleException (org.edx.mobile.util.InvalidLocaleException)1