Search in sources :

Example 66 with User

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

the class SearchFragment method onItemClick.

@Override
public void onItemClick(Object item) {
    if (item instanceof Repository) {
        Repository repository = (Repository) item;
        startActivity(RepositoryActivity.makeIntent(getActivity(), repository));
    } else if (item instanceof SearchCode) {
        openFileViewer((SearchCode) item, -1);
    } else {
        User user = (User) item;
        startActivity(UserActivity.makeIntent(getActivity(), user));
    }
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) User(com.meisolsson.githubsdk.model.User) SearchCode(com.meisolsson.githubsdk.model.SearchCode)

Example 67 with User

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

the class ApiHelpers method getAuthorName.

// RepositoryCommit
public static String getAuthorName(Context context, Commit commit) {
    User author = commit.author();
    if (author != null && !TextUtils.isEmpty(author.login())) {
        return author.login();
    }
    GitUser commitAuthor = commit.commit().author();
    if (commitAuthor != null && !TextUtils.isEmpty(commitAuthor.name())) {
        return commitAuthor.name();
    }
    return context.getString(R.string.unknown);
}
Also used : User(com.meisolsson.githubsdk.model.User) GitUser(com.meisolsson.githubsdk.model.git.GitUser) GitUser(com.meisolsson.githubsdk.model.git.GitUser)

Example 68 with User

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

the class IssueListActivity method showAssigneesDialog.

private void showAssigneesDialog() {
    final String[] assignees = new String[mAssignees.size() + 2];
    int selected = mSelectedAssignee != null && mSelectedAssignee.isEmpty() ? 1 : 0;
    assignees[0] = getResources().getString(R.string.issue_filter_by_any_assignee);
    assignees[1] = getResources().getString(R.string.issue_filter_by_no_assignee);
    for (int i = 0; i < mAssignees.size(); i++) {
        User u = mAssignees.get(i);
        assignees[i + 2] = u.login();
        if (u.login().equalsIgnoreCase(mSelectedAssignee)) {
            selected = i + 2;
        }
    }
    DialogInterface.OnClickListener selectCb = (dialog, which) -> {
        mSelectedAssignee = which == 0 ? null : which == 1 ? "" : mAssignees.get(which - 2).login();
        dialog.dismiss();
        onFilterUpdated();
    };
    new AlertDialog.Builder(this).setCancelable(true).setTitle(R.string.issue_filter_by_assignee).setSingleChoiceItems(assignees, selected, selectCb).setNegativeButton(R.string.cancel, null).show();
}
Also used : Context(android.content.Context) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Bundle(android.os.Bundle) SearchView(android.support.v7.widget.SearchView) IssueMilestoneService(com.meisolsson.githubsdk.service.issues.IssueMilestoneService) Intent(android.content.Intent) StringRes(android.support.annotation.StringRes) NonNull(android.support.annotation.NonNull) MenuItem(android.view.MenuItem) UiUtils(com.gh4a.utils.UiUtils) User(com.meisolsson.githubsdk.model.User) IssueListFragment(com.gh4a.fragment.IssueListFragment) IssueState(com.meisolsson.githubsdk.model.IssueState) Milestone(com.meisolsson.githubsdk.model.Milestone) Label(com.meisolsson.githubsdk.model.Label) Locale(java.util.Locale) Menu(android.view.Menu) R(com.gh4a.R) Issue(com.meisolsson.githubsdk.model.Issue) View(android.view.View) IssueAssigneeService(com.meisolsson.githubsdk.service.issues.IssueAssigneeService) DialogInterface(android.content.DialogInterface) FloatingActionButton(android.support.design.widget.FloatingActionButton) ApiHelpers(com.gh4a.utils.ApiHelpers) BaseFragmentPagerActivity(com.gh4a.BaseFragmentPagerActivity) Fragment(android.support.v4.app.Fragment) IssueLabelService(com.meisolsson.githubsdk.service.issues.IssueLabelService) TextUtils(android.text.TextUtils) LoadingListFragmentBase(com.gh4a.fragment.LoadingListFragmentBase) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) AlertDialog(android.support.v7.app.AlertDialog) RxUtils(com.gh4a.utils.RxUtils) Gh4Application(com.gh4a.Gh4Application) SingleFactory(com.gh4a.utils.SingleFactory) Nullable(android.support.annotation.Nullable) ServiceFactory(com.gh4a.ServiceFactory) Activity(android.app.Activity) AlertDialog(android.support.v7.app.AlertDialog) User(com.meisolsson.githubsdk.model.User) DialogInterface(android.content.DialogInterface)

Example 69 with User

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

the class IssueEditActivity method loadPotentialAssignees.

private void loadPotentialAssignees() {
    final RepositoryCollaboratorService service = ServiceFactory.get(RepositoryCollaboratorService.class, false);
    registerTemporarySubscription(ApiHelpers.PageIterator.toSingle(page -> service.getCollaborators(mRepoOwner, mRepoName, page)).compose(RxUtils::doInBackground).compose(RxUtils.wrapWithProgressDialog(this, R.string.loading_msg)).subscribe(result -> {
        mAllAssignee = result;
        User creator = mEditIssue.user();
        if (creator != null && !mAllAssignee.contains(creator)) {
            mAllAssignee.add(creator);
        }
        showAssigneesDialog();
    }, this::handleLoadFailure));
}
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) RepositoryCollaboratorService(com.meisolsson.githubsdk.service.repositories.RepositoryCollaboratorService) User(com.meisolsson.githubsdk.model.User)

Example 70 with User

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

the class IssueEditActivity method saveIssue.

private void saveIssue() {
    Milestone milestone = mEditIssue.milestone();
    IssueRequest.Builder builder = IssueRequest.builder();
    if (!ObjectsCompat.equals(mEditIssue.title(), mOriginalIssue.title())) {
        builder.title(mEditIssue.title());
    }
    if (!ObjectsCompat.equals(mEditIssue.body(), mOriginalIssue.body())) {
        builder.body(mEditIssue.body());
    }
    if (!ObjectsCompat.equals(mEditIssue.milestone(), mOriginalIssue.milestone())) {
        builder.milestone(milestone != null ? milestone.number() : null);
    }
    if (!ObjectsCompat.equals(mEditIssue.assignees(), mOriginalIssue.assignees())) {
        List<String> assignees = new ArrayList<>();
        for (User assignee : mEditIssue.assignees()) {
            assignees.add(assignee.login());
        }
        builder.assignees(assignees);
    }
    if (!ObjectsCompat.equals(mEditIssue.labels(), mOriginalIssue.labels())) {
        List<String> labels = new ArrayList<>();
        for (Label label : mEditIssue.labels()) {
            labels.add(label.name());
        }
        builder.labels(labels);
    }
    Integer issueNumber = mEditIssue.number();
    String errorMessage = issueNumber != null ? getString(R.string.issue_error_edit, issueNumber) : getString(R.string.issue_error_create);
    IssueService service = ServiceFactory.get(IssueService.class, false);
    Single<Response<Issue>> single = isInEditMode() ? service.editIssue(mRepoOwner, mRepoName, issueNumber, builder.build()) : service.createIssue(mRepoOwner, mRepoName, builder.build());
    single.map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, R.string.saving_msg, errorMessage)).subscribe(result -> {
        Intent data = new Intent();
        Bundle extras = new Bundle();
        extras.putParcelable("issue", result);
        data.putExtras(extras);
        setResult(RESULT_OK, data);
        finish();
    }, error -> handleActionFailure("Saving issue failed", error));
}
Also used : IssueService(com.meisolsson.githubsdk.service.issues.IssueService) User(com.meisolsson.githubsdk.model.User) Milestone(com.meisolsson.githubsdk.model.Milestone) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) Label(com.meisolsson.githubsdk.model.Label) Intent(android.content.Intent) Response(retrofit2.Response) IssueRequest(com.meisolsson.githubsdk.model.request.issue.IssueRequest) ApiHelpers(com.gh4a.utils.ApiHelpers)

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