use of com.meisolsson.githubsdk.model.User in project PocketHub by pockethub.
the class GistFilesViewActivity method configurePager.
private void configurePager() {
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
User author = gist.owner();
if (author != null) {
actionBar.setSubtitle(author.login());
avatars.bind(actionBar, author);
} else {
actionBar.setSubtitle(R.string.anonymous);
}
loadingBar.setVisibility(View.GONE);
pager.setVisibility(View.VISIBLE);
tabs.setVisibility(View.VISIBLE);
adapter = new GistFilesPagerAdapter(this, gist);
pager.setAdapter(adapter);
tabs.setupWithViewPager(pager);
if (initialPosition < adapter.getCount()) {
pager.scheduleSetItem(initialPosition);
onPageSelected(initialPosition);
}
}
use of com.meisolsson.githubsdk.model.User in project PocketHub by pockethub.
the class IssuesViewActivity method createIntent.
/**
* Create an intent to show issues with an initial selected issue
*
* @param issues
* @param position
* @return intent
*/
public static Intent createIntent(Collection<? extends Issue> issues, int position) {
final int count = issues.size();
int[] numbers = new int[count];
boolean[] pullRequests = new boolean[count];
ArrayList<Repository> repos = new ArrayList<>(count);
int index = 0;
for (Issue issue : issues) {
numbers[index] = issue.number();
pullRequests[index] = IssueUtils.isPullRequest(issue);
index++;
Repository repoId = null;
Repository issueRepo = issue.repository();
if (issueRepo != null) {
User owner = issueRepo.owner();
if (owner != null) {
repoId = InfoUtils.createRepoFromData(owner.login(), issueRepo.name());
}
}
if (repoId == null) {
repoId = InfoUtils.createRepoFromUrl(issue.htmlUrl());
}
repos.add(repoId);
}
Builder builder = new Builder("issues.VIEW");
builder.add(EXTRA_ISSUE_NUMBERS, numbers);
builder.add(EXTRA_REPOSITORIES, repos);
builder.add(EXTRA_POSITION, position);
builder.add(EXTRA_PULL_REQUESTS, pullRequests);
return builder.toIntent();
}
use of com.meisolsson.githubsdk.model.User in project PocketHub by pockethub.
the class RepositoryListFragment method onItemLongClick.
@Override
public boolean onItemLongClick(@NonNull Item item, @NonNull View view) {
if (!isAdded()) {
return false;
}
if (item instanceof RepositoryItem) {
Repository repo = ((RepositoryItem) item).getRepo();
if (repo == null) {
return false;
}
MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()).title(InfoUtils.createRepoId(repo));
final MaterialDialog[] dialogHolder = new MaterialDialog[1];
View dialogView = getActivity().getLayoutInflater().inflate(R.layout.repo_dialog, null);
final User owner = repo.owner();
avatars.bind((ImageView) dialogView.findViewById(R.id.iv_owner_avatar), owner);
((TextView) dialogView.findViewById(R.id.tv_owner_name)).setText(getString(R.string.navigate_to_user, owner.login()));
dialogView.findViewById(R.id.ll_owner_area).setOnClickListener(v1 -> {
dialogHolder[0].dismiss();
viewUser(owner);
});
if ((recentRepos != null) && (recentRepos.contains(repo))) {
dialogView.findViewById(R.id.divider).setVisibility(View.VISIBLE);
View recentRepoArea = dialogView.findViewById(R.id.ll_recent_repo_area);
recentRepoArea.setVisibility(View.VISIBLE);
recentRepoArea.setOnClickListener(v1 -> {
dialogHolder[0].dismiss();
recentRepos.remove(repo);
refresh();
});
}
builder.customView(dialogView, false);
MaterialDialog dialog = builder.build();
dialogHolder[0] = dialog;
dialog.setCanceledOnTouchOutside(true);
dialog.show();
return true;
}
return false;
}
use of com.meisolsson.githubsdk.model.User 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();
}
use of com.meisolsson.githubsdk.model.User in project PocketHub by pockethub.
the class Organizations method request.
@Override
public List<User> request() throws IOException {
User user = ServiceGenerator.createService(context, UserService.class).getUser().blockingGet().body();
List<User> all = getAllOrgs();
all.add(user);
return all;
}
Aggregations