use of com.meisolsson.githubsdk.model.NotificationSubject in project gh4a by slapperwan.
the class NotificationAdapter method onBindViewHolder.
@Override
protected void onBindViewHolder(ViewHolder holder, NotificationHolder item) {
holder.ivAction.setTag(item);
float alpha = item.isRead() ? 0.5f : 1f;
holder.tvTitle.setAlpha(alpha);
if (item.notification == null) {
holder.ivAction.setVisibility(item.isRead() ? View.GONE : View.VISIBLE);
Repository repository = item.repository;
holder.tvTitle.setText(repository.owner().login() + "/" + repository.name());
User owner = item.repository.owner();
AvatarHandler.assignAvatar(holder.ivAvatar, owner);
holder.ivAvatar.setTag(owner);
holder.ivAvatar.setAlpha(alpha);
return;
}
holder.ivIcon.setAlpha(alpha);
holder.tvTimestamp.setAlpha(alpha);
holder.mPopupMenu.getMenu().findItem(R.id.mark_as_read).setVisible(!item.isRead());
NotificationSubject subject = item.notification.subject();
int iconResId = getIconResId(subject.type());
if (iconResId > 0) {
holder.ivIcon.setImageResource(iconResId);
holder.ivIcon.setVisibility(View.VISIBLE);
} else {
holder.ivIcon.setVisibility(View.INVISIBLE);
}
holder.tvTitle.setText(subject.title());
holder.tvTimestamp.setText(StringUtils.formatRelativeTime(mContext, item.notification.updatedAt(), true));
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) holder.vNotificationContent.getLayoutParams();
int bottomMargin = item.isLastRepositoryNotification() ? mBottomMargin : 0;
layoutParams.setMargins(0, 0, 0, bottomMargin);
holder.vNotificationContent.setLayoutParams(layoutParams);
holder.vBottomShadow.setVisibility(item.isLastRepositoryNotification() ? View.VISIBLE : View.GONE);
}
use of com.meisolsson.githubsdk.model.NotificationSubject in project gh4a by slapperwan.
the class NotificationListFragment method onItemClick.
@Override
public void onItemClick(NotificationHolder item) {
final Intent intent;
if (item.notification == null) {
intent = RepositoryActivity.makeIntent(getActivity(), item.repository);
} else {
markAsRead(null, item.notification);
NotificationSubject subject = item.notification.subject();
String url = subject.url();
if (url != null) {
Uri uri = ApiHelpers.normalizeUri(Uri.parse(url));
intent = BrowseFilter.makeRedirectionIntent(getActivity(), uri, new IntentUtils.InitialCommentMarker(item.notification.lastReadAt()));
} else {
intent = null;
}
}
if (intent != null) {
startActivity(intent);
}
}
Aggregations