use of com.instructure.canvasapi2.models.BasicUser 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.BasicUser in project instructure-android by instructure.
the class AddMessageFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_add_message, container, false);
ButterKnife.bind(this, view);
isNewMessage = getArguments().getBoolean(Const.COMPOSE_FRAGMENT);
mIsPersonalMessage = getArguments().getBoolean(MESSAGE_STUDENTS_WHO_CONTEXT_IS_PERSONAL);
mIsMessageStudentsWho = getArguments().getBoolean(MESSAGE_STUDENTS_WHO);
if (savedInstanceState != null && !isNewMessage) {
} else if (isNewMessage) {
// composing a new message
mSpinnerWrapper.setVisibility(View.VISIBLE);
mRecipientWrapper.setVisibility(View.GONE);
mSubject.setVisibility(View.GONE);
mEditSubject.setVisibility(View.VISIBLE);
mSendIndividualWrapper.setVisibility(View.VISIBLE);
ViewStyler.themeSwitch(getContext(), mSendIndividualSwitch, ThemePrefs.getBrandColor());
mSendIndividualSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
mSendIndividually = isChecked;
}
});
if (savedInstanceState != null && savedInstanceState.containsKey(SELECTED_COURSE)) {
mSelectedCourse = savedInstanceState.getParcelable(SELECTED_COURSE);
}
} else {
mCurrentMessage = getArguments().getParcelable(Const.MESSAGE_TO_USER);
ViewTreeObserver vto = mChipsTextView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (getPresenter().isReply()) {
if (mCurrentMessage != null) {
addInitialRecipients(mCurrentMessage.getParticipatingUserIds());
} else {
addInitialRecipients(getPresenter().getConversation().getAudience());
}
} else if (mIsMessageStudentsWho) {
ArrayList<BasicUser> participants = getArguments().getParcelableArrayList(KEY_PARTICIPANTS);
List<Long> ids = new ArrayList<>();
if (participants != null) {
for (BasicUser user : participants) {
ids.add(user.getId());
}
}
addInitialRecipients(ids);
}
ViewTreeObserver obs = mChipsTextView.getViewTreeObserver();
obs.removeOnGlobalLayoutListener(this);
}
});
}
return view;
}
use of com.instructure.canvasapi2.models.BasicUser in project instructure-android by instructure.
the class UserBinder method bind.
public static void bind(final Context context, final User user, final AdapterToFragmentCallback<User> adapterToFragmentCallback, final UserViewHolder holder, final int position) {
// Set student avatar
BasicUser basicUser = new BasicUser();
basicUser.setName(user.getName());
basicUser.setAvatarUrl(user.getAvatarUrl());
ProfileUtils.loadAvatarForUser(holder.studentAvatar, basicUser);
// Set student name
holder.userName.setText(user.getName());
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
adapterToFragmentCallback.onRowClicked(user, position);
}
});
// List enrollmentApiModel type(s)
// get a list of strings of the enrollments
// Use hashSet to prevent duplicate enrollments
HashSet<String> enrollments = new HashSet<>();
for (Enrollment enrollment : user.getEnrollments()) {
enrollments.add(enrollment.getType());
}
holder.userRole.setText(android.text.TextUtils.join(", ", enrollments));
}
Aggregations