use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class NewsFragment method onListItemLongClick.
@Override
public boolean onListItemLongClick(ListView l, View v, int position, long itemId) {
if (!isUsable()) {
return false;
}
final GitHubEvent event = (GitHubEvent) l.getItemAtPosition(position);
final Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
final User user = event.actor();
if (repo != null && user != null) {
final MaterialDialog.Builder builder = new MaterialDialog.Builder(getActivity()).title(R.string.navigate_to);
// Hacky but necessary since material dialogs has a different API
final MaterialDialog[] dialogHolder = new MaterialDialog[1];
View view = getActivity().getLayoutInflater().inflate(R.layout.nav_dialog, null);
ViewFinder finder = new ViewFinder(view);
avatars.bind(finder.imageView(R.id.iv_user_avatar), user);
avatars.bind(finder.imageView(R.id.iv_repo_avatar), repo.owner());
finder.setText(R.id.tv_login, user.login());
finder.setText(R.id.tv_repo_name, InfoUtils.createRepoId(repo));
finder.onClick(R.id.ll_user_area, new OnClickListener() {
@Override
public void onClick(View v) {
dialogHolder[0].dismiss();
viewUser(user);
}
});
finder.onClick(R.id.ll_repo_area, new OnClickListener() {
@Override
public void onClick(View v) {
dialogHolder[0].dismiss();
viewRepository(repo);
}
});
builder.customView(view, false);
MaterialDialog dialog = builder.build();
dialogHolder[0] = dialog;
dialog.setCanceledOnTouchOutside(true);
dialog.show();
return true;
}
return false;
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class NewsFragment method openCommitComment.
private void openCommitComment(GitHubEvent event) {
Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
if (repo == null) {
return;
}
if (repo.name().contains("/")) {
String[] repoId = repo.name().split("/");
repo = InfoUtils.createRepoFromData(repoId[0], repoId[1]);
}
CommitCommentPayload payload = ((CommitCommentPayload) event.payload());
GitComment comment = payload.comment();
if (comment == null) {
return;
}
String sha = comment.commitId();
if (!TextUtils.isEmpty(sha)) {
startActivity(CommitViewActivity.createIntent(repo, sha));
}
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class RenderedCommentFragment method onCreateLoader.
@Override
public Loader<CharSequence> onCreateLoader(int loader, Bundle args) {
final CharSequence raw = args.getCharSequence(ARG_TEXT);
final Repository repo = args.getParcelable(ARG_REPO);
return new MarkdownLoader(getActivity(), repo, raw.toString(), imageGetter, true);
}
use of com.meisolsson.githubsdk.model.Repository 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.Repository in project PocketHub by pockethub.
the class IssuesViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pager);
issueNumbers = getIntArrayExtra(EXTRA_ISSUE_NUMBERS);
pullRequests = getBooleanArrayExtra(EXTRA_PULL_REQUESTS);
repoIds = getIntent().getParcelableArrayListExtra(EXTRA_REPOSITORIES);
repo = getParcelableExtra(EXTRA_REPOSITORY);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
if (repo != null) {
actionBar.setSubtitle(InfoUtils.createRepoId(repo));
user = repo.owner();
avatars.bind(actionBar, user);
}
// avatar URL
if (repo == null) {
Repository temp = repo != null ? repo : repoIds.get(0);
ServiceGenerator.createService(this, RepositoryService.class).getRepository(temp.owner().login(), temp.name()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).as(AutoDisposeUtils.bindToLifecycle(this)).subscribe(response -> repositoryLoaded(response.body()));
} else {
repositoryLoaded(repo);
}
}
Aggregations