Merge pull request #256 from misaochan/fix-nearby-bugs

Fix bugs with Nearby NPE and switch statements falling through
This commit is contained in:
Nicolas Raoul 2016-09-05 15:11:43 +09:00 committed by GitHub
commit 8a6314490c
2 changed files with 11 additions and 3 deletions

View file

@ -117,7 +117,7 @@ public class ContributionsListFragment extends Fragment {
if (ContextCompat.checkSelfPermission(this.getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
//See http://stackoverflow.com/questions/33169455/onrequestpermissionsresult-not-being-called-in-dialog-fragment
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
return false;
return true;
} else {
controller.startGalleryPick();
return true;
@ -155,15 +155,17 @@ public class ContributionsListFragment extends Fragment {
if (ContextCompat.checkSelfPermission(this.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
//See http://stackoverflow.com/questions/33169455/onrequestpermissionsresult-not-being-called-in-dialog-fragment
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 2);
return false;
return true;
} else {
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
startActivity(nearbyIntent);
return true;
}
}
else {
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
startActivity(nearbyIntent);
return true;
}
case R.id.menu_refresh:
((SourceRefresher)getActivity()).refreshSource();
@ -183,6 +185,7 @@ public class ContributionsListFragment extends Fragment {
controller.startGalleryPick();
}
}
break;
// 2 = Location allowed when 'nearby places' selected
case 2: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
@ -191,6 +194,7 @@ public class ContributionsListFragment extends Fragment {
startActivity(nearbyIntent);
}
}
break;
}
}

View file

@ -165,7 +165,11 @@ public class NearbyListFragment extends ListFragment {
}
private void unlockScreenOrientation() {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
try {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
} catch (NullPointerException e){
Log.e(TAG, "NPE: ", e);
}
}
private class NearbyAdapter extends ArrayAdapter<Place> {