use of com.github.pockethub.android.ui.item.news.NewsItem in project PocketHub by pockethub.
the class NewsFragment method onItemClick.
@Override
public void onItemClick(@NonNull Item item, @NonNull View view) {
if (!(item instanceof NewsItem)) {
return;
}
GitHubEvent event = ((NewsItem) item).getGitHubEvent();
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 = IssueEventMatcher.getIssue(event);
if (issue != null) {
Repository repo = ConvertUtils.eventRepoToRepo(event.repo());
viewIssue(issue, repo);
return;
}
Gist gist = GistEventMatcher.getGist(event);
if (gist != null) {
startActivity(GistsViewActivity.createIntent(gist));
return;
}
Repository repo = RepositoryEventMatcher.getRepository(event);
if (repo != null) {
viewRepository(repo);
}
UserPair users = UserEventMatcher.getUsers(event);
if (users != null) {
viewUser(users);
}
}
use of com.github.pockethub.android.ui.item.news.NewsItem in project PocketHub by pockethub.
the class NewsEventTextTest method updateView.
private void updateView(GitHubEvent event) {
NewsItem item = NewsItem.createNewsItem(avatarLoader, event);
View itemView = layoutInflater.inflate(item.getLayout(), null);
ViewHolder viewHolder = item.createViewHolder(itemView);
item.bind((com.xwray.groupie.kotlinandroidextensions.ViewHolder) viewHolder, 0);
text = viewHolder.itemView.findViewById(R.id.tv_event);
assertNotNull(text);
}
use of com.github.pockethub.android.ui.item.news.NewsItem 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