use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class RepositoryListFragment method onItemClick.
@Override
public void onItemClick(@NonNull Item item, @NonNull View view) {
if (item instanceof RepositoryItem) {
Repository repo = ((RepositoryItem) item).getRepo();
if (recentRepos != null) {
recentRepos.add(repo);
}
startActivityForResult(RepositoryViewActivity.createIntent(repo), REPOSITORY_VIEW);
}
}
use of com.meisolsson.githubsdk.model.Repository 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.Repository in project PocketHub by pockethub.
the class RepositoryViewActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.m_star:
starRepository();
return true;
case R.id.m_fork:
forkRepository();
return true;
case R.id.m_contributors:
startActivity(RepositoryContributorsActivity.createIntent(repository));
return true;
case R.id.m_share:
shareRepository();
return true;
case R.id.m_parent_repo:
if (repository.parent() == null) {
ServiceGenerator.createService(this, RepositoryService.class).getRepository(repository.owner().login(), repository.name()).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(response -> {
Repository parent = response.body().parent();
startActivity(RepositoryViewActivity.createIntent(parent));
});
} else {
startActivity(RepositoryViewActivity.createIntent(repository.parent()));
}
return true;
case R.id.m_delete:
deleteRepository();
return true;
case R.id.m_refresh:
checkStarredRepositoryStatus();
return super.onOptionsItemSelected(item);
case android.R.id.home:
finish();
Intent intent = UserViewActivity.createIntent(repository.owner());
intent.addFlags(FLAG_ACTIVITY_CLEAR_TOP | FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class NewsFragment method openPush.
private void openPush(GitHubEvent event) {
Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
if (repo == null) {
return;
}
PushPayload payload = ((PushPayload) event.payload());
List<GitCommit> commits = payload.commits();
if (commits.isEmpty()) {
return;
}
if (commits.size() > 1) {
String base = payload.before();
String head = payload.head();
if (!TextUtils.isEmpty(base) && !TextUtils.isEmpty(head)) {
startActivity(CommitCompareViewActivity.createIntent(repo, base, head));
}
} else {
GitCommit commit = commits.get(0);
String sha = commit != null ? commit.sha() : null;
if (!TextUtils.isEmpty(sha)) {
startActivity(CommitViewActivity.createIntent(repo, sha));
}
}
}
use of com.meisolsson.githubsdk.model.Repository in project PocketHub by pockethub.
the class NewsFragment method onItemLongClick.
@Override
public boolean onItemLongClick(@NonNull Item item, @NonNull View view) {
if (!isAdded()) {
return false;
}
if (!(item instanceof NewsItem)) {
return false;
}
final GitHubEvent event = ((NewsItem) item).getGitHubEvent();
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 dialogView = getActivity().getLayoutInflater().inflate(R.layout.nav_dialog, null);
avatars.bind((ImageView) dialogView.findViewById(R.id.iv_user_avatar), user);
avatars.bind((ImageView) dialogView.findViewById(R.id.iv_repo_avatar), repo.owner());
((TextView) dialogView.findViewById(R.id.tv_login)).setText(user.login());
((TextView) dialogView.findViewById(R.id.tv_repo_name)).setText(InfoUtils.createRepoId(repo));
dialogView.findViewById(R.id.ll_user_area).setOnClickListener(v1 -> {
dialogHolder[0].dismiss();
viewUser(user);
});
dialogView.findViewById(R.id.ll_repo_area).setOnClickListener(v1 -> {
dialogHolder[0].dismiss();
viewRepository(repo);
});
builder.customView(dialogView, false);
MaterialDialog dialog = builder.build();
dialogHolder[0] = dialog;
dialog.setCanceledOnTouchOutside(true);
dialog.show();
return true;
}
return false;
}
Aggregations