Search in sources :

Example 1 with FileComplaintFragment

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

Aggregations

Intent (android.content.Intent)1 Toast (android.widget.Toast)1 FileComplaintFragment (app.insti.fragment.FileComplaintFragment)1 MapFragment (app.insti.fragment.MapFragment)1