use of app.insti.api.model.NewsArticle in project IITB-App by wncc.
the class NotificationsAdapter method onClick.
@Override
public void onClick(Notification notification, FragmentActivity fragmentActivity) {
/* Mark notification read */
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
String sessId = Utils.getSessionIDHeader();
retrofitInterface.markNotificationRead(sessId, notification.getNotificationId().toString()).enqueue(new EmptyCallback<Void>());
ShortcutBadger.applyCount(fragmentActivity.getApplicationContext(), NotificationId.decrementAndGetCurrentCount());
/* Close the bottom sheet */
notificationsFragment.dismiss();
Gson gson = Utils.gson;
/* Open event */
if (notification.isEvent()) {
Event event = gson.fromJson(gson.toJson(notification.getNotificationActor()), Event.class);
Utils.openEventFragment(event, fragmentActivity);
} else if (notification.isNews()) {
NewsFragment newsFragment = new NewsFragment();
NewsArticle newsArticle = gson.fromJson(gson.toJson(notification.getNotificationActor()), NewsArticle.class);
newsFragment.withId(newsArticle.getId());
Utils.updateFragment(newsFragment, fragmentActivity);
} else if (notification.isBlogPost()) {
PlacementBlogPost post = gson.fromJson(gson.toJson(notification.getNotificationActor()), PlacementBlogPost.class);
Fragment fragment;
if (post.getLink().contains("training")) {
fragment = (new TrainingBlogFragment()).withId(post.getId());
} else {
fragment = (new PlacementBlogFragment()).withId(post.getId());
}
Utils.updateFragment(fragment, fragmentActivity);
}
}
use of app.insti.api.model.NewsArticle in project IITB-App by wncc.
the class NewsAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder recyclerHolder, int position) {
if (recyclerHolder instanceof ViewHolder) {
ViewHolder holder = (ViewHolder) recyclerHolder;
NewsArticle article = getPosts().get(position);
Utils.getMarkwon().setMarkdown(holder.articleTitle, article.getTitle());
holder.articleBody.setText(article.getBody().getBodyName());
Date publishedDate = article.getPublished();
Calendar calendar = Calendar.getInstance();
calendar.setTime(publishedDate);
DateFormat displayFormat;
if (calendar.get(Calendar.YEAR) == Calendar.getInstance().get(Calendar.YEAR)) {
displayFormat = new SimpleDateFormat("EEE, MMM d, HH:mm", Locale.US);
} else {
displayFormat = new SimpleDateFormat("EEE, MMM d, ''yy, HH:mm", Locale.US);
}
holder.articlePublished.setText(displayFormat.format(publishedDate));
Utils.getMarkwon().setMarkdown(holder.articleContent, article.getContent());
} else {
((ProgressViewHolder) recyclerHolder).progressBar.setIndeterminate(true);
}
}
Aggregations