Search in sources :

Example 1 with FeedFragment

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

Example 2 with FeedFragment

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

the class MainActivity method onCreate.

@SuppressLint("ClickableViewAccessibility")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /* Check for dark theme */
    SharedPreferences sharedPref = getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
    Utils.isDarkTheme = sharedPref.getBoolean(Constants.DARK_THEME, false);
    if (Utils.isDarkTheme)
        this.setTheme(R.style.AppThemeDark);
    ServiceGenerator serviceGenerator = new ServiceGenerator(getApplicationContext());
    Utils.setRetrofitInterface(serviceGenerator.getRetrofitInterface());
    Utils.makeGson();
    Utils.makeMarkwon(getApplicationContext());
    /* Make notification channel on oreo */
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
        createNotificationChannel();
    }
    setContentView(R.layout.activity_main);
    session = new SessionManager(getApplicationContext());
    if (session.isLoggedIn()) {
        Utils.setSessionId(session.getSessionID());
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();
    feedFragment = new FeedFragment();
    updateFragment(feedFragment);
    Intent intent = getIntent();
    if (intent != null) {
        // Check for data passed by FCM
        if (intent.getExtras() != null && intent.getBundleExtra(Constants.MAIN_INTENT_EXTRAS) != null) {
            handleFCMIntent(intent.getBundleExtra(Constants.MAIN_INTENT_EXTRAS));
        } else {
            handleIntent(intent);
        }
    }
    checkLatestVersion();
}
Also used : SharedPreferences(android.content.SharedPreferences) ServiceGenerator(app.insti.api.ServiceGenerator) SessionManager(app.insti.SessionManager) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) Intent(android.content.Intent) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) FeedFragment(app.insti.fragment.FeedFragment) Toolbar(androidx.appcompat.widget.Toolbar) SuppressLint(android.annotation.SuppressLint)

Example 3 with FeedFragment

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

the class MainActivity method updateFragment.

/**
 * Change the active fragment to the supplied one
 */
public void updateFragment(Fragment fragment) {
    if (session.isLoggedIn() && currentUser == null) {
        currentUser = session.getCurrentUser();
    }
    Bundle bundle = fragment.getArguments();
    if (bundle == null) {
        bundle = new Bundle();
    }
    bundle.putString(Constants.SESSION_ID, session.pref.getString(Constants.SESSION_ID, ""));
    if (fragment instanceof MessMenuFragment)
        bundle.putString(Constants.USER_HOSTEL, session.isLoggedIn() && currentUser.getHostel() != null ? currentUser.getHostel() : "1");
    if (fragment instanceof SettingsFragment && session.isLoggedIn())
        bundle.putString(Constants.USER_ID, currentUser.getUserID());
    if (fragment instanceof ComplaintsFragment && session.isLoggedIn()) {
        bundle.putString(Constants.USER_ID, currentUser.getUserID());
        bundle.putString(Constants.CURRENT_USER_PROFILE_PICTURE, currentUser.getUserProfilePictureUrl());
    }
    fragment.setArguments(bundle);
    FragmentManager manager = getSupportFragmentManager();
    if (fragment instanceof FeedFragment)
        manager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
    FragmentTransaction transaction = manager.beginTransaction();
    /* Animate only for UserFragment */
    if (fragment instanceof UserFragment) {
        transaction.setCustomAnimations(R.anim.slide_in_up, R.anim.fade_out, R.anim.fade_in, R.anim.slide_out_down);
    }
    transaction.replace(R.id.framelayout_for_fragment, fragment, Utils.getTag(fragment));
    transaction.addToBackStack(Utils.getTag(fragment)).commit();
}
Also used : SettingsFragment(app.insti.fragment.SettingsFragment) FragmentManager(androidx.fragment.app.FragmentManager) ComplaintsFragment(app.insti.fragment.ComplaintsFragment) FragmentTransaction(androidx.fragment.app.FragmentTransaction) UserFragment(app.insti.fragment.UserFragment) Bundle(android.os.Bundle) MessMenuFragment(app.insti.fragment.MessMenuFragment) FeedFragment(app.insti.fragment.FeedFragment)

Aggregations

FeedFragment (app.insti.fragment.FeedFragment)3 SuppressLint (android.annotation.SuppressLint)2 Bundle (android.os.Bundle)2 DrawerLayout (androidx.drawerlayout.widget.DrawerLayout)2 ComplaintsFragment (app.insti.fragment.ComplaintsFragment)2 MessMenuFragment (app.insti.fragment.MessMenuFragment)2 SettingsFragment (app.insti.fragment.SettingsFragment)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 ActionBarDrawerToggle (androidx.appcompat.app.ActionBarDrawerToggle)1 Toolbar (androidx.appcompat.widget.Toolbar)1 FragmentManager (androidx.fragment.app.FragmentManager)1 FragmentTransaction (androidx.fragment.app.FragmentTransaction)1 SessionManager (app.insti.SessionManager)1 ServiceGenerator (app.insti.api.ServiceGenerator)1 CalendarFragment (app.insti.fragment.CalendarFragment)1 MapFragment (app.insti.fragment.MapFragment)1 NewsFragment (app.insti.fragment.NewsFragment)1 QuickLinksFragment (app.insti.fragment.QuickLinksFragment)1 UserFragment (app.insti.fragment.UserFragment)1