use of app.insti.api.model.PlacementBlogPost 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.PlacementBlogPost in project IITB-App by wncc.
the class PlacementBlogAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder recyclerHolder, int position) {
if (recyclerHolder instanceof ViewHolder) {
ViewHolder holder = (ViewHolder) recyclerHolder;
PlacementBlogPost post = getPosts().get(position);
Utils.getMarkwon(false).setMarkdown(holder.postTitle, post.getTitle());
Date publishedDate = post.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.postPublished.setText(displayFormat.format(publishedDate));
Utils.getMarkwon(false).setMarkdown(holder.postContent, post.getContent());
} else {
((ProgressViewHolder) recyclerHolder).progressBar.setIndeterminate(true);
}
}
Aggregations