use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class NotificationListRecyclerAdapter method populateActivityStreamAdapter.
public void populateActivityStreamAdapter() {
if (mIsNoNetwork) {
// workaround for the multiple callbacks, which mess up the generic solution
getAdapterToRecyclerViewCallback().setDisplayNoConnection(true);
getAdapterToRecyclerViewCallback().setIsEmpty(size() == 0);
}
// wait until all calls return;
if (mCourseMap == null || mGroupMap == null || mStreamItems == null) {
return;
}
for (final StreamItem streamItem : mStreamItems) {
streamItem.setCanvasContextFromMap(mCourseMap, mGroupMap);
// load conversations if needed
if (streamItem.getType() == StreamItem.Type.CONVERSATION && ApiPrefs.getUser() != null) {
InboxManager.getConversation(streamItem.getConversationId(), false, new StatusCallback<Conversation>() {
@Override
public void onResponse(@NonNull Response<Conversation> response, @NonNull LinkHeaders linkHeaders, @NonNull ApiType type) {
// need to make sure the user isn't null
if (ApiPrefs.getUser() != null) {
streamItem.setConversation(getContext(), response.body(), ApiPrefs.getUser().getId(), getContext().getString(R.string.monologue));
notifyDataSetChanged();
}
}
@Override
public void onFail(@Nullable Call<Conversation> call, @NonNull Throwable error, @Nullable Response response) {
// Show crouton if it's a network error
if (!APIHelper.hasNetworkConnection()) {
mAdapterToFragmentCallback.onShowErrorCrouton(R.string.noDataConnection);
} else // Otherwise show that it's been deleted if we have a valid user
if (ApiPrefs.getUser() != null) {
Conversation conversation = new Conversation();
conversation.setDeleted(true);
conversation.setDeletedString(getContext().getString(R.string.deleted));
streamItem.setConversation(getContext(), conversation, ApiPrefs.getUser().getId(), getContext().getString(R.string.monologue));
notifyDataSetChanged();
}
}
});
}
// make sure there's something there
if (streamItem.getUpdatedAtDate() == null) {
continue;
}
addOrUpdateItem(DateHelper.getCleanDate(streamItem.getUpdatedAtDate().getTime()), streamItem);
}
mStreamItems = null;
// update count in dashboard
if (mOnNotificationCountInvalidated != null) {
mOnNotificationCountInvalidated.invalidateNotificationsCount();
}
}
use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class AddMessageFragment method onReadySetGo.
@Override
protected void onReadySetGo(AddMessagePresenter presenter) {
setupToolbar();
// Set conversation subject
if (!isNewMessage && !mIsMessageStudentsWho) {
mSubject.setText(presenter.getConversation().getSubject());
} else if (mIsMessageStudentsWho) {
if (mIsPersonalMessage) {
mSubject.setVisibility(View.GONE);
mEditSubject.setVisibility(View.VISIBLE);
mEditSubject.setText(getArguments().getString(MESSAGE_STUDENTS_WHO_SUBJECT));
} else {
mSubject.setText(getArguments().getString(MESSAGE_STUDENTS_WHO_SUBJECT));
}
}
// Set up recipients view
mChipsTextView.setTokenizer(new Rfc822Tokenizer());
if (mChipsAdapter == null) {
mChipsAdapter = new RecipientAdapter(getContext());
}
if (mChipsTextView.getAdapter() == null) {
mChipsTextView.setAdapter(mChipsAdapter);
}
if (getPresenter().getCourse().getId() != 0) {
mChipsAdapter.getCanvasRecipientManager().setCanvasContext(getPresenter().getCourse());
} else if (mSelectedCourse != null) {
courseWasSelected();
mChipsAdapter.getCanvasRecipientManager().setCanvasContext(mSelectedCourse);
}
ColorUtils.colorIt(ThemePrefs.getButtonColor(), mContactsButton);
// don't show the contacts button if there is no selected course and there is no context_code from the conversation (shouldn't happen, but it does)
if (mSelectedCourse == null && getPresenter().getCourse() != null && getPresenter().getCourse().getId() == 0) {
mContactsButton.setVisibility(View.INVISIBLE);
}
mContactsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CanvasContext canvasContext;
if (getPresenter().getCourse() != null && getPresenter().getCourse().getId() == 0) {
// presenter doesn't know what the course is, use the mSelectedCourse instead
canvasContext = mSelectedCourse;
} else {
canvasContext = getPresenter().getCourse();
}
RouteMatcher.route(getContext(), new Route(ChooseRecipientsFragment.class, canvasContext, ChooseRecipientsFragment.createBundle(canvasContext, getRecipientsFromRecipientEntries())));
}
});
// Ensure attachments are up to date
refreshAttachments();
// get courses and groups if this is a new compose message
if (isNewMessage) {
getPresenter().getAllCoursesAndGroups(true);
}
}
use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class AddMessageFragment method getPresenterFactory.
@Override
protected PresenterFactory<AddMessagePresenter> getPresenterFactory() {
Conversation conversation = getArguments().getParcelable(Const.CONVERSATION);
ArrayList<BasicUser> participants = getArguments().getParcelableArrayList(KEY_PARTICIPANTS);
ArrayList<Message> messages = getArguments().getParcelableArrayList(Const.MESSAGE);
boolean isReply = getArguments().getBoolean(KEY_IS_REPLY, false);
return new AddMessagePresenterFactory(conversation, participants, messages, isReply);
}
use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class ConversationTest method getWorkflowState_read.
@Test
public void getWorkflowState_read() {
Conversation conversation = new Conversation();
conversation.setWorkflowState("read");
assertEquals(Conversation.WorkflowState.READ, conversation.getWorkflowState());
}
use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class ConversationTest method hasAttachments.
@Test
public void hasAttachments() {
Conversation conversation = new Conversation();
ArrayList<String> properties = new ArrayList<>();
properties.add("attachments");
conversation.setProperties(properties);
assertEquals(true, conversation.hasAttachments());
}
Aggregations