use of com.meisolsson.githubsdk.model.GitHubEvent in project PocketHub by pockethub.
the class IconAndViewTextManagerTest method when_event_type_is_fork_then_icon_should_be_fork_and_its_text_should_be_formatted.
@Test
public void when_event_type_is_fork_then_icon_should_be_fork_and_its_text_should_be_formatted() throws Exception {
// Arrange
GitHubEvent event = GitHubEvent.builder().type(GitHubEventType.ForkEvent).build();
IconAndViewTextManager iconAndViewTextManager = new IconAndViewTextManager(null);
IconAndViewTextManager spyIconAndViewTextManager = spy(iconAndViewTextManager);
doNothing().when(spyIconAndViewTextManager).formatFork(event, new StyledText(), null);
// Act
String icon = spyIconAndViewTextManager.setIconAndFormatStyledText(event, new StyledText(), null);
// Assert
assertEquals(TypefaceUtils.ICON_FORK, icon);
verify(spyIconAndViewTextManager).formatFork(event, new StyledText(), null);
}
use of com.meisolsson.githubsdk.model.GitHubEvent in project PocketHub by pockethub.
the class IconAndViewTextManagerTest method when_event_type_is_pull_request_review_comment_then_icon_should_be_comment_and_its_text_should_be_formatted.
@Test
public void when_event_type_is_pull_request_review_comment_then_icon_should_be_comment_and_its_text_should_be_formatted() throws Exception {
// Arrange
GitHubEvent event = GitHubEvent.builder().type(GitHubEventType.PullRequestReviewCommentEvent).build();
IconAndViewTextManager iconAndViewTextManager = new IconAndViewTextManager(null);
IconAndViewTextManager spyIconAndViewTextManager = spy(iconAndViewTextManager);
doNothing().when(spyIconAndViewTextManager).formatReviewComment(event, null, null);
// Act
String icon = spyIconAndViewTextManager.setIconAndFormatStyledText(event, null, null);
// Assert
assertEquals(TypefaceUtils.ICON_COMMENT, icon);
verify(spyIconAndViewTextManager).formatReviewComment(event, null, null);
}
use of com.meisolsson.githubsdk.model.GitHubEvent in project PocketHub by pockethub.
the class IconAndViewTextManagerTest method when_event_type_is_pull_request_then_icon_should_be_pull_request_and_its_text_should_be_formatted.
@Test
public void when_event_type_is_pull_request_then_icon_should_be_pull_request_and_its_text_should_be_formatted() throws Exception {
// Arrange
GitHubEvent event = GitHubEvent.builder().type(GitHubEventType.PullRequestEvent).build();
IconAndViewTextManager iconAndViewTextManager = new IconAndViewTextManager(null);
IconAndViewTextManager spyIconAndViewTextManager = spy(iconAndViewTextManager);
doNothing().when(spyIconAndViewTextManager).formatPullRequest(event, null, null);
// Act
String icon = spyIconAndViewTextManager.setIconAndFormatStyledText(event, null, null);
// Assert
assertEquals(TypefaceUtils.ICON_PULL_REQUEST, icon);
verify(spyIconAndViewTextManager).formatPullRequest(event, null, null);
}
use of com.meisolsson.githubsdk.model.GitHubEvent 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.GitHubEvent 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