Search in sources :

Example 1 with Permissions

use of com.meisolsson.githubsdk.model.Permissions in project PocketHub by pockethub.

the class OrganizationRepositories method loadFrom.

@Override
public Repository loadFrom(Cursor cursor) {
    User owner = User.builder().login(cursor.getString(3)).id(cursor.getLong(2)).avatarUrl(cursor.getString(4)).build();
    Permissions permissions = Permissions.builder().admin(cursor.getInt(13) == 1).push(cursor.getInt(14) == 1).pull(cursor.getInt(15) == 1).build();
    return Repository.builder().owner(owner).name(cursor.getString(1)).id(cursor.getLong(0)).isPrivate(cursor.getInt(5) == 1).isFork(cursor.getInt(6) == 1).description(cursor.getString(7)).forksCount(cursor.getInt(8)).watchersCount(cursor.getInt(9)).language(cursor.getString(10)).hasIssues(cursor.getInt(11) == 1).mirrorUrl(cursor.getString(12)).permissions(permissions).build();
}
Also used : User(com.meisolsson.githubsdk.model.User) Permissions(com.meisolsson.githubsdk.model.Permissions)

Example 2 with Permissions

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

the class RepositoryFragment method fillData.

private void fillData() {
    TextView tvRepoName = mContentView.findViewById(R.id.tv_repo_name);
    IntentSpan repoSpan = new IntentSpan(tvRepoName.getContext(), context -> UserActivity.makeIntent(context, mRepository.owner()));
    SpannableStringBuilder repoName = new SpannableStringBuilder();
    repoName.append(mRepository.owner().login());
    repoName.append("/");
    repoName.append(mRepository.name());
    repoName.setSpan(repoSpan, 0, mRepository.owner().login().length(), 0);
    tvRepoName.setText(repoName);
    tvRepoName.setMovementMethod(UiUtils.CHECKING_LINK_METHOD);
    TextView tvParentRepo = mContentView.findViewById(R.id.tv_parent);
    if (mRepository.isFork() && mRepository.parent() != null) {
        Repository parent = mRepository.parent();
        tvParentRepo.setVisibility(View.VISIBLE);
        tvParentRepo.setText(getString(R.string.forked_from, parent.owner().login() + "/" + parent.name()));
        tvParentRepo.setOnClickListener(this);
        tvParentRepo.setTag(parent);
    } else {
        tvParentRepo.setVisibility(View.GONE);
    }
    fillTextView(R.id.tv_desc, 0, mRepository.description());
    fillTextView(R.id.tv_language, R.string.repo_language, mRepository.language());
    fillTextView(R.id.tv_url, 0, !StringUtils.isBlank(mRepository.homepage()) ? mRepository.homepage() : mRepository.htmlUrl());
    mContentView.findViewById(R.id.cell_stargazers).setOnClickListener(this);
    mContentView.findViewById(R.id.cell_forks).setOnClickListener(this);
    mContentView.findViewById(R.id.cell_pull_requests).setOnClickListener(this);
    mContentView.findViewById(R.id.tv_contributors_label).setOnClickListener(this);
    mContentView.findViewById(R.id.other_info).setOnClickListener(this);
    mContentView.findViewById(R.id.tv_releases_label).setOnClickListener(this);
    mReadmeTitleView.setOnClickListener(this);
    Permissions permissions = mRepository.permissions();
    updateClickableLabel(R.id.tv_collaborators_label, permissions != null && permissions.push());
    updateClickableLabel(R.id.tv_wiki_label, mRepository.hasWiki());
    TextView tvStargazersCount = mContentView.findViewById(R.id.tv_stargazers_count);
    tvStargazersCount.setText(String.valueOf(mRepository.watchersCount()));
    TextView tvForksCount = mContentView.findViewById(R.id.tv_forks_count);
    tvForksCount.setText(String.valueOf(mRepository.forksCount()));
    LinearLayout llIssues = mContentView.findViewById(R.id.cell_issues);
    if (mRepository.hasIssues()) {
        llIssues.setVisibility(View.VISIBLE);
        llIssues.setOnClickListener(this);
    // value will be filled when PR count arrives
    } else {
        llIssues.setVisibility(View.GONE);
    }
    mContentView.findViewById(R.id.tv_private).setVisibility(mRepository.isPrivate() ? View.VISIBLE : View.GONE);
}
Also used : Repository(com.meisolsson.githubsdk.model.Repository) IntentSpan(com.gh4a.widget.IntentSpan) Permissions(com.meisolsson.githubsdk.model.Permissions) TextView(android.widget.TextView) SpannableStringBuilder(android.text.SpannableStringBuilder) LinearLayout(android.widget.LinearLayout)

Aggregations

Permissions (com.meisolsson.githubsdk.model.Permissions)2 SpannableStringBuilder (android.text.SpannableStringBuilder)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1 IntentSpan (com.gh4a.widget.IntentSpan)1 Repository (com.meisolsson.githubsdk.model.Repository)1 User (com.meisolsson.githubsdk.model.User)1