use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class NewsFragment method onListItemClick.
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
GitHubEvent event = (GitHubEvent) l.getItemAtPosition(position);
if (DownloadEvent.equals(event.type())) {
openDownload(event);
return;
}
if (PushEvent.equals(event.type())) {
openPush(event);
return;
}
if (CommitCommentEvent.equals(event.type())) {
openCommitComment(event);
return;
}
Issue issue = issueMatcher.getIssue(event);
if (issue != null) {
Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
viewIssue(issue, repo);
return;
}
Gist gist = gistMatcher.getGist(event);
if (gist != null) {
startActivity(GistsViewActivity.createIntent(gist));
return;
}
Repository repo = repoMatcher.getRepository(event);
if (repo != null) {
viewRepository(repo);
}
UserPair users = userMatcher.getUsers(event);
if (users != null) {
viewUser(users);
}
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class EditIssuesFilterActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_issues_filter_edit);
if (savedInstanceState != null) {
filter = savedInstanceState.getParcelable(EXTRA_ISSUE_FILTER);
}
if (filter == null) {
filter = getIntent().getParcelableExtra(EXTRA_ISSUE_FILTER);
}
Repository repository = filter.getRepository();
ActionBar actionBar = getSupportActionBar();
actionBar.setTitle(R.string.filter_issues_title);
actionBar.setSubtitle(InfoUtils.createRepoId(repository));
avatars.bind(actionBar, repository.owner());
updateAssignee();
updateMilestone();
updateLabels();
RadioGroup status = findViewById(R.id.issue_filter_status);
RadioGroup sortOrder = findViewById(R.id.issue_sort_order);
RadioGroup sortType = findViewById(R.id.issue_sort_type);
status.setOnCheckedChangeListener(this::onStatusChanged);
sortOrder.setOnCheckedChangeListener(this::onSortOrderChanged);
sortType.setOnCheckedChangeListener(this::onSortTypeChanged);
if (filter.isOpen()) {
status.check(R.id.rb_open);
} else {
status.check(R.id.rb_closed);
}
if (filter.getDirection().equals(IssueFilter.DIRECTION_ASCENDING)) {
sortOrder.check(R.id.rb_asc);
} else {
sortOrder.check(R.id.rb_desc);
}
switch(filter.getSortType()) {
case IssueFilter.SORT_CREATED:
sortType.check(R.id.rb_created);
break;
case IssueFilter.SORT_UPDATED:
sortType.check(R.id.rb_updated);
break;
case IssueFilter.SORT_COMMENTS:
sortType.check(R.id.rb_comments);
break;
default:
break;
}
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class IssuesViewActivity method onPageSelected.
@Override
public void onPageSelected(final int position) {
super.onPageSelected(position);
if (repo != null) {
updateTitle(position);
return;
}
if (repoIds == null) {
return;
}
ActionBar actionBar = getSupportActionBar();
repo = repoIds.get(position);
if (repo != null) {
updateTitle(position);
actionBar.setSubtitle(InfoUtils.createRepoId(repo));
Issue issue = store.getIssue(repo, issueNumbers[position]);
if (issue != null) {
Repository fullRepo = issue.repository();
if (fullRepo != null && fullRepo.owner() != null) {
user = fullRepo.owner();
avatars.bind(actionBar, user);
} else {
actionBar.setLogo(null);
}
} else {
actionBar.setLogo(null);
}
} else {
actionBar.setSubtitle(null);
actionBar.setLogo(null);
}
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class NotificationListFragment method updateHeaders.
private void updateHeaders(final List<Item> notifications) {
if (notifications.isEmpty()) {
return;
}
Collections.sort(notifications, (i1, i2) -> {
Repository r1 = ((NotificationItem) i1).getNotificationThread().repository();
Repository r2 = ((NotificationItem) i2).getNotificationThread().repository();
return r1.fullName().compareToIgnoreCase(r2.fullName());
});
Repository repoFound = null;
for (int i = 0; i < notifications.size(); i++) {
NotificationItem item = (NotificationItem) notifications.get(i);
NotificationThread thread = item.getNotificationThread();
String fullName = thread.repository().fullName();
if (repoFound == null || !fullName.equals(repoFound.fullName())) {
notifications.add(i, new NotificationHeaderItem(thread.repository(), this));
}
repoFound = thread.repository();
}
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class RepositoryListFragment method updateHeaders.
private void updateHeaders(final List<Item> repos) {
if (repos.isEmpty()) {
return;
}
// Add recent header if at least one recent repository
Repository first = ((RepositoryItem) repos.get(0)).getRepo();
if (recentRepos.contains(first)) {
repos.add(0, new RepositoryHeaderItem(getString(R.string.recently_viewed)));
}
// Advance past all recent repositories
int index;
for (index = 0; index < repos.size(); index++) {
Item item = repos.get(index);
if (item instanceof RepositoryItem) {
Repository repository = ((RepositoryItem) item).getRepo();
if (!recentRepos.contains(repository.id())) {
break;
}
}
}
if (index >= repos.size()) {
return;
}
// Register header for first character
Repository current = ((RepositoryItem) repos.get(index)).getRepo();
char start = Character.toLowerCase(current.name().charAt(0));
repos.add(index, new RepositoryHeaderItem(Character.toString(start).toUpperCase(US)));
for (index = index + 1; index < repos.size(); index++) {
current = ((RepositoryItem) repos.get(index)).getRepo();
char repoStart = Character.toLowerCase(current.name().charAt(0));
if (repoStart <= start) {
continue;
}
repos.add(index, new RepositoryHeaderItem(Character.toString(repoStart).toUpperCase(US)));
start = repoStart;
}
}
Aggregations