Search in sources :

Example 1 with NewsFragment

use of app.insti.fragment.NewsFragment 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 NewsFragment

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

the class MainActivity method onNavigationItemSelected.

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();
    switch(id) {
        case R.id.nav_feed:
            feedFragment = new FeedFragment();
            updateFragment(feedFragment);
            break;
        case R.id.nav_explore:
            updateFragment(ExploreFragment.newInstance());
            break;
        case R.id.nav_news:
            updateFragment(new NewsFragment());
            break;
        case R.id.nav_placement_blog:
            openPlacementBlog();
            break;
        case R.id.nav_training_blog:
            openTrainingBlog();
            break;
        case R.id.nav_mess_menu:
            MessMenuFragment messMenuFragment = new MessMenuFragment();
            updateFragment(messMenuFragment);
            break;
        case R.id.nav_calendar:
            CalendarFragment calendarFragment = new CalendarFragment();
            updateFragment(calendarFragment);
            break;
        case R.id.nav_qlinks:
            QuickLinksFragment quickLinksFragment = new QuickLinksFragment();
            updateFragment(quickLinksFragment);
            break;
        case R.id.nav_map:
            MapFragment mapFragment = new MapFragment();
            updateFragment(mapFragment);
            break;
        case R.id.nav_achievements:
            WebViewFragment webViewFragment = new WebViewFragment();
            Bundle bundle = new Bundle();
            bundle.putString(Constants.WV_TYPE, Constants.WV_TYPE_ACHIEVEMENTS);
            webViewFragment.setArguments(bundle);
            updateFragment(webViewFragment);
            break;
        case R.id.nav_complaint:
            if (session.isLoggedIn()) {
                ComplaintsFragment complaintsFragment = new ComplaintsFragment();
                updateFragment(complaintsFragment);
            } else {
                Toast.makeText(this, Constants.LOGIN_MESSAGE, Toast.LENGTH_LONG).show();
            }
            break;
        case R.id.nav_settings:
            SettingsFragment settingsFragment = new SettingsFragment();
            updateFragment(settingsFragment);
            break;
        default:
            break;
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
Also used : SettingsFragment(app.insti.fragment.SettingsFragment) ComplaintsFragment(app.insti.fragment.ComplaintsFragment) WebViewFragment(app.insti.fragment.WebViewFragment) CalendarFragment(app.insti.fragment.CalendarFragment) Bundle(android.os.Bundle) MapFragment(app.insti.fragment.MapFragment) NewsFragment(app.insti.fragment.NewsFragment) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) MessMenuFragment(app.insti.fragment.MessMenuFragment) QuickLinksFragment(app.insti.fragment.QuickLinksFragment) SuppressLint(android.annotation.SuppressLint) FeedFragment(app.insti.fragment.FeedFragment)

Aggregations

NewsFragment (app.insti.fragment.NewsFragment)2 SuppressLint (android.annotation.SuppressLint)1 Bundle (android.os.Bundle)1 DrawerLayout (androidx.drawerlayout.widget.DrawerLayout)1 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 CalendarFragment (app.insti.fragment.CalendarFragment)1 ComplaintsFragment (app.insti.fragment.ComplaintsFragment)1 FeedFragment (app.insti.fragment.FeedFragment)1 MapFragment (app.insti.fragment.MapFragment)1 MessMenuFragment (app.insti.fragment.MessMenuFragment)1 NotificationsFragment (app.insti.fragment.NotificationsFragment)1 PlacementBlogFragment (app.insti.fragment.PlacementBlogFragment)1 QuickLinksFragment (app.insti.fragment.QuickLinksFragment)1 SettingsFragment (app.insti.fragment.SettingsFragment)1 TrainingBlogFragment (app.insti.fragment.TrainingBlogFragment)1 WebViewFragment (app.insti.fragment.WebViewFragment)1