Search in sources :

Example 71 with User

use of com.meisolsson.githubsdk.model.User in project gh4a by slapperwan.

the class IssueEditActivity method showAssigneesDialog.

private void showAssigneesDialog() {
    if (mAllAssignee == null) {
        loadPotentialAssignees();
    } else {
        final String[] assigneeNames = new String[mAllAssignee.size()];
        final boolean[] selection = new boolean[mAllAssignee.size()];
        final List<User> oldAssigneeList = mEditIssue.assignees() != null ? mEditIssue.assignees() : new ArrayList<>();
        List<String> assigneeLogins = new ArrayList<>();
        for (User assignee : oldAssigneeList) {
            assigneeLogins.add(assignee.login());
        }
        for (int i = 0; i < mAllAssignee.size(); i++) {
            String login = mAllAssignee.get(i).login();
            assigneeNames[i] = login;
            selection[i] = assigneeLogins.contains(login);
        }
        DialogInterface.OnMultiChoiceClickListener selectCb = (dialogInterface, which, isChecked) -> selection[which] = isChecked;
        DialogInterface.OnClickListener okCb = (dialog, which) -> {
            List<User> newAssigneeList = new ArrayList<>();
            for (int i = 0; i < selection.length; i++) {
                if (selection[i]) {
                    newAssigneeList.add(mAllAssignee.get(i));
                }
            }
            mEditIssue = mEditIssue.toBuilder().assignees(newAssigneeList).build();
            updateOptionViews();
            dialog.dismiss();
        };
        new AlertDialog.Builder(this).setCancelable(true).setTitle(R.string.issue_assignee_hint).setMultiChoiceItems(assigneeNames, selection, selectCb).setPositiveButton(R.string.ok, okCb).setNegativeButton(R.string.cancel, null).show();
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Bundle(android.os.Bundle) ImageView(android.widget.ImageView) IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) TextInputLayout(android.support.design.widget.TextInputLayout) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) IssueState(com.meisolsson.githubsdk.model.IssueState) Label(com.meisolsson.githubsdk.model.Label) Locale(java.util.Locale) ContentType(com.meisolsson.githubsdk.model.ContentType) Issue(com.meisolsson.githubsdk.model.Issue) View(android.view.View) StringUtils(com.gh4a.utils.StringUtils) FloatingActionButton(android.support.design.widget.FloatingActionButton) ContextCompat(android.support.v4.content.ContextCompat) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) ViewGroup(android.view.ViewGroup) RepositoryContentService(com.meisolsson.githubsdk.service.repositories.RepositoryContentService) List(java.util.List) TextView(android.widget.TextView) RxUtils(com.gh4a.utils.RxUtils) Optional(com.gh4a.utils.Optional) Nullable(android.support.annotation.Nullable) Typeface(android.graphics.Typeface) Context(android.content.Context) AppBarLayout(android.support.design.widget.AppBarLayout) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) MarkdownButtonsBar(com.gh4a.widget.MarkdownButtonsBar) BasePagerActivity(com.gh4a.BasePagerActivity) Intent(android.content.Intent) Response(retrofit2.Response) Single(io.reactivex.Single) UiUtils(com.gh4a.utils.UiUtils) ArrayList(java.util.ArrayList) User(com.meisolsson.githubsdk.model.User) AvatarHandler(com.gh4a.utils.AvatarHandler) Milestone(com.meisolsson.githubsdk.model.Milestone) Content(com.meisolsson.githubsdk.model.Content) R(com.gh4a.R) IssueRequest(com.meisolsson.githubsdk.model.request.issue.IssueRequest) IssueService(com.meisolsson.githubsdk.service.issues.IssueService) RepositoryCollaboratorService(com.meisolsson.githubsdk.service.repositories.RepositoryCollaboratorService) DialogInterface(android.content.DialogInterface) ApiHelpers(com.gh4a.utils.ApiHelpers) LayoutInflater(android.view.LayoutInflater) PagerAdapter(android.support.v4.view.PagerAdapter) IdRes(android.support.annotation.IdRes) AlertDialog(android.support.v7.app.AlertDialog) Gh4Application(com.gh4a.Gh4Application) ObjectsCompat(android.support.v4.util.ObjectsCompat) SingleFactory(com.gh4a.utils.SingleFactory) ServiceFactory(com.gh4a.ServiceFactory) EditText(android.widget.EditText) User(com.meisolsson.githubsdk.model.User) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 72 with User

use of com.meisolsson.githubsdk.model.User in project gh4a by slapperwan.

the class IssueEditActivity method updateOptionViews.

private void updateOptionViews() {
    if (mEditIssue.milestone() != null) {
        mSelectedMilestoneView.setText(mEditIssue.milestone().title());
    } else {
        mSelectedMilestoneView.setText(R.string.issue_clear_milestone);
    }
    List<User> assignees = mEditIssue.assignees();
    LayoutInflater inflater = getLayoutInflater();
    mSelectedAssigneeContainer.removeAllViews();
    if (assignees != null && !assignees.isEmpty()) {
        for (User assignee : assignees) {
            View row = inflater.inflate(R.layout.row_assignee, mSelectedAssigneeContainer, false);
            TextView tvAssignee = row.findViewById(R.id.tv_assignee);
            tvAssignee.setText(ApiHelpers.getUserLogin(this, assignee));
            ImageView ivAssignee = row.findViewById(R.id.iv_assignee);
            AvatarHandler.assignAvatar(ivAssignee, assignee);
            mSelectedAssigneeContainer.addView(row);
        }
    } else {
        View row = inflater.inflate(R.layout.row_assignee, mSelectedAssigneeContainer, false);
        TextView tvAssignee = row.findViewById(R.id.tv_assignee);
        tvAssignee.setText(R.string.issue_clear_assignee);
        row.findViewById(R.id.iv_assignee).setVisibility(View.GONE);
        mSelectedAssigneeContainer.addView(row);
    }
    List<Label> labels = mEditIssue.labels();
    if (labels == null || labels.isEmpty()) {
        mLabelsView.setText(R.string.issue_no_labels);
    } else {
        mLabelsView.setText(UiUtils.formatLabelList(this, labels));
    }
}
Also used : User(com.meisolsson.githubsdk.model.User) LayoutInflater(android.view.LayoutInflater) Label(com.meisolsson.githubsdk.model.Label) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) MarkdownPreviewWebView(com.gh4a.widget.MarkdownPreviewWebView) View(android.view.View) TextView(android.widget.TextView)

Example 73 with User

use of com.meisolsson.githubsdk.model.User in project gh4a by slapperwan.

the class EventViewHolder method onClick.

@Override
public void onClick(View v) {
    if (v.getId() == R.id.avatar_container) {
        User user = (User) v.getTag();
        Intent intent = UserActivity.makeIntent(mContext, user);
        if (intent != null) {
            mContext.startActivity(intent);
        }
    }
}
Also used : User(com.meisolsson.githubsdk.model.User) Intent(android.content.Intent)

Example 74 with User

use of com.meisolsson.githubsdk.model.User in project gh4a by slapperwan.

the class EventViewHolder method bind.

@Override
public void bind(TimelineItem.TimelineEvent item) {
    User user = item.event.assigner() != null ? item.event.assigner() : item.event.actor();
    AvatarHandler.assignAvatar(mAvatarView, user);
    mAvatarContainer.setTag(user);
    Integer eventIconAttr = EVENT_ICONS.get(item.event.event());
    if (eventIconAttr != null) {
        mEventIconView.setImageResource(UiUtils.resolveDrawable(mContext, eventIconAttr));
        mEventIconView.setVisibility(View.VISIBLE);
    } else {
        mEventIconView.setVisibility(View.GONE);
    }
    mMessageView.setText(formatEvent(item.event, user, mMessageView.getTypefaceValue(), mIsPullRequest));
}
Also used : User(com.meisolsson.githubsdk.model.User)

Example 75 with User

use of com.meisolsson.githubsdk.model.User in project gh4a by slapperwan.

the class UserAdapter method onClick.

@Override
public void onClick(View v) {
    if (v.getId() == R.id.iv_gravatar) {
        User user = (User) v.getTag();
        mContext.startActivity(UserActivity.makeIntent(mContext, user));
    } else {
        super.onClick(v);
    }
}
Also used : User(com.meisolsson.githubsdk.model.User)

Aggregations

User (com.meisolsson.githubsdk.model.User)97 Repository (com.meisolsson.githubsdk.model.Repository)15 View (android.view.View)14 Intent (android.content.Intent)13 TextView (android.widget.TextView)11 ImageView (android.widget.ImageView)10 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 Label (com.meisolsson.githubsdk.model.Label)9 Milestone (com.meisolsson.githubsdk.model.Milestone)8 Bundle (android.os.Bundle)7 ApiHelpers (com.gh4a.utils.ApiHelpers)7 GitHubEvent (com.meisolsson.githubsdk.model.GitHubEvent)7 UserService (com.meisolsson.githubsdk.service.users.UserService)7 SmallTest (androidx.test.filters.SmallTest)6 List (java.util.List)6 ViewGroup (android.view.ViewGroup)5 AvatarHandler (com.gh4a.utils.AvatarHandler)5 UiUtils (com.gh4a.utils.UiUtils)5 Issue (com.meisolsson.githubsdk.model.Issue)5