Search in sources :

Example 1 with MapFragment

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

the class MainActivity method onRequestPermissionsResult.

public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    switch(requestCode) {
        case MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE:
            // If request is cancelled, the result arrays are empty.
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                startActivityForResult(i, RESULT_LOAD_IMAGE);
            }
            return;
        case MY_PERMISSIONS_REQUEST_LOCATION:
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                // Map
                MapFragment mapFragment = (MapFragment) getSupportFragmentManager().findFragmentByTag(MapFragment.TAG);
                if (mapFragment != null && mapFragment.isVisible()) {
                    mapFragment.setupGPS(true);
                }
                // File complaint
                FileComplaintFragment fileComplaintFragment = (FileComplaintFragment) getSupportFragmentManager().findFragmentByTag(FileComplaintFragment.TAG);
                if (fileComplaintFragment != null && fileComplaintFragment.isVisible()) {
                    fileComplaintFragment.getMapReady();
                }
            } else {
                Toast toast = Toast.makeText(MainActivity.this, "Need Permission", Toast.LENGTH_SHORT);
                toast.show();
            }
    }
}
Also used : FileComplaintFragment(app.insti.fragment.FileComplaintFragment) Toast(android.widget.Toast) MapFragment(app.insti.fragment.MapFragment) Intent(android.content.Intent)

Example 2 with MapFragment

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

MapFragment (app.insti.fragment.MapFragment)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Toast (android.widget.Toast)1 DrawerLayout (androidx.drawerlayout.widget.DrawerLayout)1 CalendarFragment (app.insti.fragment.CalendarFragment)1 ComplaintsFragment (app.insti.fragment.ComplaintsFragment)1 FeedFragment (app.insti.fragment.FeedFragment)1 FileComplaintFragment (app.insti.fragment.FileComplaintFragment)1 MessMenuFragment (app.insti.fragment.MessMenuFragment)1 NewsFragment (app.insti.fragment.NewsFragment)1 QuickLinksFragment (app.insti.fragment.QuickLinksFragment)1 SettingsFragment (app.insti.fragment.SettingsFragment)1 WebViewFragment (app.insti.fragment.WebViewFragment)1