Search in sources :

Example 1 with TrainingBlogFragment

use of app.insti.fragment.TrainingBlogFragment 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);
    }
}
Also used : NewsArticle(app.insti.api.model.NewsArticle) PlacementBlogPost(app.insti.api.model.PlacementBlogPost) PlacementBlogFragment(app.insti.fragment.PlacementBlogFragment) Gson(com.google.gson.Gson) Event(app.insti.api.model.Event) NewsFragment(app.insti.fragment.NewsFragment) NotificationsFragment(app.insti.fragment.NotificationsFragment) NewsFragment(app.insti.fragment.NewsFragment) TrainingBlogFragment(app.insti.fragment.TrainingBlogFragment) Fragment(androidx.fragment.app.Fragment) PlacementBlogFragment(app.insti.fragment.PlacementBlogFragment) TrainingBlogFragment(app.insti.fragment.TrainingBlogFragment) RetrofitInterface(app.insti.api.RetrofitInterface)

Example 2 with TrainingBlogFragment

use of app.insti.fragment.TrainingBlogFragment in project IITB-App by wncc.

the class MainActivity method openTrainingBlog.

private void openTrainingBlog(String id) {
    if (session.isLoggedIn()) {
        TrainingBlogFragment trainingBlogFragment = new TrainingBlogFragment();
        if (id != null)
            trainingBlogFragment.withId(id);
        updateFragment(trainingBlogFragment);
    } else {
        Toast.makeText(this, Constants.LOGIN_MESSAGE, Toast.LENGTH_LONG).show();
    }
}
Also used : TrainingBlogFragment(app.insti.fragment.TrainingBlogFragment)

Aggregations

TrainingBlogFragment (app.insti.fragment.TrainingBlogFragment)2 Fragment (androidx.fragment.app.Fragment)1 RetrofitInterface (app.insti.api.RetrofitInterface)1 Event (app.insti.api.model.Event)1 NewsArticle (app.insti.api.model.NewsArticle)1 PlacementBlogPost (app.insti.api.model.PlacementBlogPost)1 NewsFragment (app.insti.fragment.NewsFragment)1 NotificationsFragment (app.insti.fragment.NotificationsFragment)1 PlacementBlogFragment (app.insti.fragment.PlacementBlogFragment)1 Gson (com.google.gson.Gson)1