mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Move code into startLookingForNearby()
This commit is contained in:
parent
a704f5a740
commit
93acd40926
1 changed files with 14 additions and 11 deletions
|
|
@ -61,11 +61,6 @@ public class NearbyActivity extends NavigationBaseActivity {
|
||||||
|
|
||||||
checkLocationPermission();
|
checkLocationPermission();
|
||||||
bundle = new Bundle();
|
bundle = new Bundle();
|
||||||
locationManager = new LocationServiceManager(this);
|
|
||||||
locationManager.registerLocationManager();
|
|
||||||
curLatLang = locationManager.getLatestLocation();
|
|
||||||
nearbyAsyncTask = new NearbyAsyncTask(this);
|
|
||||||
nearbyAsyncTask.execute();
|
|
||||||
initDrawer();
|
initDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,11 +91,23 @@ public class NearbyActivity extends NavigationBaseActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void startLookingForNearby() {
|
||||||
|
locationManager = new LocationServiceManager(this);
|
||||||
|
locationManager.registerLocationManager();
|
||||||
|
curLatLang = locationManager.getLatestLocation();
|
||||||
|
nearbyAsyncTask = new NearbyAsyncTask(this);
|
||||||
|
nearbyAsyncTask.execute();
|
||||||
|
}
|
||||||
|
|
||||||
private void checkLocationPermission() {
|
private void checkLocationPermission() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
startLookingForNearby();
|
||||||
|
} else {
|
||||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_REQUEST);
|
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_REQUEST);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
startLookingForNearby();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -109,11 +116,7 @@ public class NearbyActivity extends NavigationBaseActivity {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case LOCATION_REQUEST: {
|
case LOCATION_REQUEST: {
|
||||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
locationManager = new LocationServiceManager(this);
|
startLookingForNearby();
|
||||||
locationManager.registerLocationManager();
|
|
||||||
curLatLang = locationManager.getLatestLocation();
|
|
||||||
nearbyAsyncTask = new NearbyAsyncTask(this);
|
|
||||||
nearbyAsyncTask.execute();
|
|
||||||
} else {
|
} else {
|
||||||
//If permission not granted, display notification that Nearby Places cannot be displayed
|
//If permission not granted, display notification that Nearby Places cannot be displayed
|
||||||
int duration = Toast.LENGTH_LONG;
|
int duration = Toast.LENGTH_LONG;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue