mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Merge pull request #256 from misaochan/fix-nearby-bugs
Fix bugs with Nearby NPE and switch statements falling through
This commit is contained in:
commit
8a6314490c
2 changed files with 11 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,11 @@ public class NearbyListFragment extends ListFragment {
|
|||
}
|
||||
|
||||
private void unlockScreenOrientation() {
|
||||
try {
|
||||
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||
} catch (NullPointerException e){
|
||||
Log.e(TAG, "NPE: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
private class NearbyAdapter extends ArrayAdapter<Place> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue