Search in sources :

Example 1 with MapFragment

use of in.ac.iitb.gymkhana.iitbapp.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_ACCESS_LOCATION:
            if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                MapFragment mapFragment = new MapFragment();
                updateFragment(mapFragment);
            } else {
                Toast toast = Toast.makeText(MainActivity.this, "Need Permission", Toast.LENGTH_SHORT);
                toast.show();
            }
    }
}
Also used : Toast(android.widget.Toast) MapFragment(in.ac.iitb.gymkhana.iitbapp.fragment.MapFragment) Intent(android.content.Intent)

Example 2 with MapFragment

use of in.ac.iitb.gymkhana.iitbapp.fragment.MapFragment in project IITB-App by wncc.

the class MainActivity method onNavigationItemSelected.

@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();
    switch(id) {
        case R.id.nav_feed:
            FeedFragment feedFragment = new FeedFragment();
            updateFragment(feedFragment);
            break;
        case R.id.nav_my_events:
            MyEventsFragment myeventsFragment = new MyEventsFragment();
            updateFragment(myeventsFragment);
            break;
        case R.id.nav_pt_cell:
            PTCellFragment ptcellFragment = new PTCellFragment();
            updateFragment(ptcellFragment);
            break;
        case R.id.nav_mess_menu:
            MessMenuFragment messmenuFragment = new MessMenuFragment();
            updateFragment(messmenuFragment);
            break;
        case R.id.nav_gc_rankings:
            GCRankingsFragment gcrankingsFragment = new GCRankingsFragment();
            updateFragment(gcrankingsFragment);
            break;
        case R.id.nav_calendar:
            CalendarFragment calendarFragment = new CalendarFragment();
            updateFragment(calendarFragment);
            break;
        case R.id.nav_cms:
            CMSFragment cmsFragment = new CMSFragment();
            updateFragment(cmsFragment);
            break;
        case R.id.nav_timetable:
            TimetableFragment timetableFragment = new TimetableFragment();
            updateFragment(timetableFragment);
            break;
        case R.id.nav_map:
            MapFragment mapFragment = new MapFragment();
            if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
                updateFragment(mapFragment);
            } else {
                ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, MY_PERMISSIONS_REQUEST_ACCESS_LOCATION);
            }
            break;
        case R.id.nav_contacts:
            ContactsFragment contactsFragment = new ContactsFragment();
            updateFragment(contactsFragment);
            break;
        case R.id.nav_about:
            AboutFragment aboutFragment = new AboutFragment();
            updateFragment(aboutFragment);
            break;
        case R.id.nav_people:
            PeopleFragment peopleFragment = new PeopleFragment();
            updateFragment(peopleFragment);
            break;
    }
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}
Also used : TimetableFragment(in.ac.iitb.gymkhana.iitbapp.fragment.TimetableFragment) AboutFragment(in.ac.iitb.gymkhana.iitbapp.fragment.AboutFragment) CalendarFragment(in.ac.iitb.gymkhana.iitbapp.fragment.CalendarFragment) CMSFragment(in.ac.iitb.gymkhana.iitbapp.fragment.CMSFragment) MapFragment(in.ac.iitb.gymkhana.iitbapp.fragment.MapFragment) GCRankingsFragment(in.ac.iitb.gymkhana.iitbapp.fragment.GCRankingsFragment) MyEventsFragment(in.ac.iitb.gymkhana.iitbapp.fragment.MyEventsFragment) PTCellFragment(in.ac.iitb.gymkhana.iitbapp.fragment.PTCellFragment) MessMenuFragment(in.ac.iitb.gymkhana.iitbapp.fragment.MessMenuFragment) FeedFragment(in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment) PeopleFragment(in.ac.iitb.gymkhana.iitbapp.fragment.PeopleFragment) DrawerLayout(android.support.v4.widget.DrawerLayout) ContactsFragment(in.ac.iitb.gymkhana.iitbapp.fragment.ContactsFragment)

Aggregations

MapFragment (in.ac.iitb.gymkhana.iitbapp.fragment.MapFragment)2 Intent (android.content.Intent)1 DrawerLayout (android.support.v4.widget.DrawerLayout)1 Toast (android.widget.Toast)1 AboutFragment (in.ac.iitb.gymkhana.iitbapp.fragment.AboutFragment)1 CMSFragment (in.ac.iitb.gymkhana.iitbapp.fragment.CMSFragment)1 CalendarFragment (in.ac.iitb.gymkhana.iitbapp.fragment.CalendarFragment)1 ContactsFragment (in.ac.iitb.gymkhana.iitbapp.fragment.ContactsFragment)1 FeedFragment (in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment)1 GCRankingsFragment (in.ac.iitb.gymkhana.iitbapp.fragment.GCRankingsFragment)1 MessMenuFragment (in.ac.iitb.gymkhana.iitbapp.fragment.MessMenuFragment)1 MyEventsFragment (in.ac.iitb.gymkhana.iitbapp.fragment.MyEventsFragment)1 PTCellFragment (in.ac.iitb.gymkhana.iitbapp.fragment.PTCellFragment)1 PeopleFragment (in.ac.iitb.gymkhana.iitbapp.fragment.PeopleFragment)1 TimetableFragment (in.ac.iitb.gymkhana.iitbapp.fragment.TimetableFragment)1