use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class SearchRepositoryListFragment method openRepositoryMatch.
/**
* Check if the search query is an exact repository name/owner match and
* open the repository activity and finish the current activity when it is
*
* @param query
* @return true if query opened as repository, false otherwise
*/
private boolean openRepositoryMatch(final String query) {
if (TextUtils.isEmpty(query)) {
return false;
}
Repository repoId = InfoUtils.createRepoFromUrl(query.trim());
if (repoId == null) {
return false;
}
ServiceGenerator.createService(getContext(), RepositoryService.class).getRepository(repoId.owner().login(), repoId.name()).subscribe(response -> {
if (response.isSuccessful()) {
startActivity(RepositoryViewActivity.createIntent(response.body()));
final Activity activity = getActivity();
if (activity != null) {
activity.finish();
}
}
});
return true;
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class NewsEventTextTest method testTeamAdd.
/**
* Verify text of push event
*/
@UiThreadTest
public void testTeamAdd() {
Team team = Team.builder().name("t1").build();
Repository repo = Repository.builder().name("r2").build();
TeamAddPayload payload = TeamAddPayload.builder().repository(repo).team(team).build();
GitHubEvent event = createEvent(GitHubEventType.TeamAddEvent, payload);
updateView(event);
verify("user added r2 to team t1");
}
use of com.meisolsson.githubsdk.model.Repository 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);
}
use of com.meisolsson.githubsdk.model.Repository in project gh4a by slapperwan.
the class UserFragment method onClick.
@Override
public void onClick(View view) {
int id = view.getId();
Intent intent = null;
if (id == R.id.cell_followers) {
if (mUser.type() == UserType.Organization) {
intent = OrganizationMemberListActivity.makeIntent(getActivity(), mUser.login());
} else {
intent = FollowerFollowingListActivity.makeIntent(getActivity(), mUser.login(), true);
}
} else if (id == R.id.cell_following) {
intent = FollowerFollowingListActivity.makeIntent(getActivity(), mUser.login(), false);
} else if (id == R.id.cell_repos || id == R.id.btn_repos) {
intent = RepositoryListActivity.makeIntent(getActivity(), mUser.login(), mUser.type() == UserType.Organization);
} else if (id == R.id.cell_gists) {
intent = GistListActivity.makeIntent(getActivity(), mUser.login());
} else if (id == R.id.cell_org_members) {
intent = OrganizationMemberListActivity.makeIntent(getActivity(), mUser.login());
} else if (view.getTag() instanceof Repository) {
intent = RepositoryActivity.makeIntent(getActivity(), (Repository) view.getTag());
} else if (view.getTag() instanceof User) {
intent = UserActivity.makeIntent(getActivity(), (User) view.getTag());
}
if (intent != null) {
startActivity(intent);
}
}
use of com.meisolsson.githubsdk.model.Repository in project gh4a by slapperwan.
the class UserFragment method loadTopRepositories.
private void loadTopRepositories(boolean force) {
RepositoryService service = ServiceFactory.get(RepositoryService.class, force, null, null, 5);
final Single<Response<Page<Repository>>> observable;
Map<String, String> filterData = new HashMap<>();
filterData.put("sort", "pushed");
filterData.put("affiliation", "owner,collaborator");
if (mIsSelf) {
observable = service.getUserRepositories(filterData, 1);
} else if (mUser.type() == UserType.Organization) {
observable = service.getOrganizationRepositories(mUser.login(), filterData, 1);
} else {
observable = service.getUserRepositories(mUser.login(), filterData, 1);
}
observable.map(ApiHelpers::throwOnFailure).map(Page::items).compose(makeLoaderSingle(ID_LOADER_REPO_LIST, force)).doOnSubscribe(disposable -> {
mContentView.findViewById(R.id.pb_top_repos).setVisibility(View.VISIBLE);
mContentView.findViewById(R.id.ll_top_repos).setVisibility(View.GONE);
}).subscribe(this::fillTopRepos, this::handleLoadFailure);
}
Aggregations