Search in sources :

Example 1 with BasicUser

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);
}
Also used : BasicUser(com.instructure.canvasapi2.models.BasicUser) Message(com.instructure.canvasapi2.models.Message) Conversation(com.instructure.canvasapi2.models.Conversation) AddMessagePresenterFactory(com.instructure.teacher.factory.AddMessagePresenterFactory)

Example 2 with BasicUser

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;
}
Also used : BasicUser(com.instructure.canvasapi2.models.BasicUser) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) RecipientEditTextView(com.android.ex.chips.RecipientEditTextView) TextView(android.widget.TextView) AddMessageView(com.instructure.teacher.viewinterface.AddMessageView) AttachmentView(com.instructure.pandautils.views.AttachmentView) ScrollView(android.widget.ScrollView) ViewTreeObserver(android.view.ViewTreeObserver) CompoundButton(android.widget.CompoundButton) Nullable(android.support.annotation.Nullable)

Example 3 with BasicUser

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));
}
Also used : BasicUser(com.instructure.canvasapi2.models.BasicUser) Enrollment(com.instructure.canvasapi2.models.Enrollment) View(android.view.View) HashSet(java.util.HashSet)

Aggregations

BasicUser (com.instructure.canvasapi2.models.BasicUser)3 View (android.view.View)2 Nullable (android.support.annotation.Nullable)1 ViewTreeObserver (android.view.ViewTreeObserver)1 AdapterView (android.widget.AdapterView)1 CompoundButton (android.widget.CompoundButton)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1 RecipientEditTextView (com.android.ex.chips.RecipientEditTextView)1 Conversation (com.instructure.canvasapi2.models.Conversation)1 Enrollment (com.instructure.canvasapi2.models.Enrollment)1 Message (com.instructure.canvasapi2.models.Message)1 AttachmentView (com.instructure.pandautils.views.AttachmentView)1 AddMessagePresenterFactory (com.instructure.teacher.factory.AddMessagePresenterFactory)1 AddMessageView (com.instructure.teacher.viewinterface.AddMessageView)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1