mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +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) {
|
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
|
//See http://stackoverflow.com/questions/33169455/onrequestpermissionsresult-not-being-called-in-dialog-fragment
|
||||||
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
|
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
|
||||||
return false;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
controller.startGalleryPick();
|
controller.startGalleryPick();
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -155,15 +155,17 @@ public class ContributionsListFragment extends Fragment {
|
||||||
if (ContextCompat.checkSelfPermission(this.getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
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
|
//See http://stackoverflow.com/questions/33169455/onrequestpermissionsresult-not-being-called-in-dialog-fragment
|
||||||
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 2);
|
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 2);
|
||||||
return false;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
||||||
startActivity(nearbyIntent);
|
startActivity(nearbyIntent);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
Intent nearbyIntent = new Intent(getActivity(), NearbyActivity.class);
|
||||||
startActivity(nearbyIntent);
|
startActivity(nearbyIntent);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
case R.id.menu_refresh:
|
case R.id.menu_refresh:
|
||||||
((SourceRefresher)getActivity()).refreshSource();
|
((SourceRefresher)getActivity()).refreshSource();
|
||||||
|
|
@ -183,6 +185,7 @@ public class ContributionsListFragment extends Fragment {
|
||||||
controller.startGalleryPick();
|
controller.startGalleryPick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
// 2 = Location allowed when 'nearby places' selected
|
// 2 = Location allowed when 'nearby places' selected
|
||||||
case 2: {
|
case 2: {
|
||||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
@ -191,6 +194,7 @@ public class ContributionsListFragment extends Fragment {
|
||||||
startActivity(nearbyIntent);
|
startActivity(nearbyIntent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,11 @@ public class NearbyListFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unlockScreenOrientation() {
|
private void unlockScreenOrientation() {
|
||||||
|
try {
|
||||||
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||||
|
} catch (NullPointerException e){
|
||||||
|
Log.e(TAG, "NPE: ", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class NearbyAdapter extends ArrayAdapter<Place> {
|
private class NearbyAdapter extends ArrayAdapter<Place> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue