use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class InboxManager method getConversation.
public static void getConversation(long conversationId, boolean forceNetwork, StatusCallback<Conversation> callback) {
if (isTesting() || mTesting) {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
InboxManager_Test.getConversation(adapter, callback, params, conversationId);
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withPerPageQueryParam(false).withShouldIgnoreToken(false).withForceReadFromNetwork(forceNetwork).build();
InboxApi.getConversation(adapter, callback, params, conversationId);
}
}
use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class InboxManager method addMessage.
public static void addMessage(long conversationId, String message, List<String> recipientIds, long[] includedMessageIds, long[] attachmentIds, StatusCallback<Conversation> callback) {
if (isTesting() || mTesting) {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(false).build();
InboxManager_Test.addMessage(adapter, callback, params, conversationId, recipientIds, message, includedMessageIds, attachmentIds);
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(false).build();
InboxApi.addMessage(adapter, callback, params, conversationId, recipientIds, message, includedMessageIds, attachmentIds);
}
}
use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class InboxManager method deleteMessages.
public static void deleteMessages(long conversationId, List<Long> messageIds, StatusCallback<Conversation> callback) {
if (isTesting() || mTesting) {
InboxManager_Test.deleteMessages(conversationId, messageIds, callback);
} else {
RestBuilder adapter = new RestBuilder(callback);
RestParams params = new RestParams.Builder().withShouldIgnoreToken(false).withPerPageQueryParam(false).build();
InboxApi.deleteMessages(adapter, callback, params, conversationId, messageIds);
}
}
use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class NotificationListFragment method addFragmentForStreamItem.
public static DialogFragment addFragmentForStreamItem(StreamItem streamItem, FragmentActivity activity, boolean fromWidget) {
ParentFragment fragment = null;
if (streamItem == null || activity == null) {
return null;
}
String unsupportedLabel = null;
switch(streamItem.getType()) {
case SUBMISSION:
if (streamItem.getAssignment() == null && streamItem.getCanvasContext() instanceof Course) {
fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle(streamItem.getCanvasContext(), streamItem.getAssignmentId()));
} else if (streamItem.getAssignment() != null && streamItem.getCanvasContext() instanceof Course) {
// add an empty submission with the grade to the assignment so that we can see the score.
Submission emptySubmission = new Submission();
emptySubmission.setGrade(streamItem.getGrade());
streamItem.getAssignment().setSubmission(emptySubmission);
fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle((Course) streamItem.getCanvasContext(), streamItem.getAssignment()));
}
break;
case ANNOUNCEMENT:
if (streamItem.getCanvasContext() != null) {
fragment = FragUtils.getFrag(DiscussionDetailsFragment.class, DiscussionDetailsFragment.makeBundle(streamItem.getCanvasContext(), streamItem.getDiscussionTopicId(), true));
}
break;
case CONVERSATION:
Conversation conversation = streamItem.getConversation();
if (conversation != null) {
// Check to see if the conversation has been deleted.
if (conversation.isDeleted()) {
Toast.makeText(activity, R.string.deleteConversation, Toast.LENGTH_SHORT).show();
return null;
}
Bundle extras = InboxConversationFragment.createBundle(conversation, 0, null);
fragment = FragUtils.getFrag(InboxConversationFragment.class, extras);
}
break;
case DISCUSSION_TOPIC:
if (streamItem.getCanvasContext() != null) {
fragment = FragUtils.getFrag(DiscussionDetailsFragment.class, DiscussionDetailsFragment.makeBundle(streamItem.getCanvasContext(), streamItem.getDiscussionTopicId(), false));
}
break;
case MESSAGE:
if (streamItem.getAssignmentId() > 0) {
if (streamItem.getCanvasContext() != null) {
fragment = FragUtils.getFrag(AssignmentFragment.class, AssignmentFragment.Companion.createBundle(activity, streamItem.getCanvasContext(), streamItem.getAssignmentId(), streamItem));
}
} else {
fragment = FragUtils.getFrag(UnknownItemFragment.class, UnknownItemFragment.createBundle(streamItem.getCanvasContext(), streamItem));
}
break;
case COLLABORATION:
if (streamItem.getCanvasContext() != null) {
unsupportedLabel = activity.getString(R.string.collaborations);
fragment = UnSupportedTabFragment.createFragment(UnSupportedTabFragment.class, UnSupportedTabFragment.createBundle(streamItem.getCanvasContext(), Tab.COLLABORATIONS_ID, R.string.collaborations));
}
break;
case CONFERENCE:
if (streamItem.getCanvasContext() != null) {
unsupportedLabel = activity.getString(R.string.conferences);
fragment = UnSupportedTabFragment.createFragment(UnSupportedTabFragment.class, UnSupportedTabFragment.createBundle(streamItem.getCanvasContext(), Tab.CONFERENCES_ID, R.string.conferences));
}
break;
default:
if (streamItem.getCanvasContext() != null) {
unsupportedLabel = streamItem.getType().toString();
fragment = FragUtils.getFrag(UnSupportedFeatureFragment.class, UnSupportedFeatureFragment.createBundle(streamItem.getCanvasContext(), unsupportedLabel, streamItem.getUrl()));
}
break;
}
if (unsupportedLabel != null) {
if (activity instanceof Navigation) {
((Navigation) activity).addFragment(fragment);
}
} else {
if (activity instanceof Navigation && fragment != null) {
((Navigation) activity).addFragment(fragment);
}
if (fromWidget) {
if (streamItem.getUrl() != null) {
RouterUtils.routeUrl(activity, streamItem.getUrl(), false);
} else {
RouterUtils.routeUrl(activity, streamItem.getHtmlUrl(), false);
}
}
}
return null;
}
use of com.instructure.canvasapi2.models.Conversation in project instructure-android by instructure.
the class InboxManager_Test method getConversations.
public static void getConversations(@NonNull InboxApi.Scope scope, @NonNull RestBuilder adapter, @NonNull StatusCallback<List<Conversation>> callback, @NonNull RestParams params) {
// TODO:
Response response = new Response.Builder().code(200).message("todo").protocol(Protocol.HTTP_1_0).body(ResponseBody.create(MediaType.parse("application/json"), "todo".getBytes())).addHeader("content-type", "application/json").build();
List<Conversation> conversations = new ArrayList<>();
retrofit2.Response<List<Conversation>> response1 = retrofit2.Response.success(conversations, response);
callback.onResponse(response1, new LinkHeaders(), ApiType.CACHE);
}
Aggregations