mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Make sure updateMAoAndList method is called when everything ready
This commit is contained in:
parent
771a9ecda3
commit
7080c3a943
7 changed files with 33 additions and 22 deletions
|
|
@ -359,7 +359,7 @@ public class ContributionsFragment
|
|||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
Timber.d("Location permission granted, refreshing view");
|
||||
// No need to display permission request button anymore
|
||||
locationManager.registerLocationManager();
|
||||
locationManager.registerLocationManager(getActivity());
|
||||
} else {
|
||||
if (store.getBoolean("displayLocationPermissionForCardView", true)) {
|
||||
// Still ask for permission
|
||||
|
|
@ -535,7 +535,7 @@ public class ContributionsFragment
|
|||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (locationManager.isLocationPermissionGranted(requireContext())) {
|
||||
nearbyNotificationCardView.permissionType = NearbyNotificationCardView.PermissionType.NO_PERMISSION_NEEDED;
|
||||
locationManager.registerLocationManager();
|
||||
locationManager.registerLocationManager(getActivity());
|
||||
} else {
|
||||
nearbyNotificationCardView.permissionType = NearbyNotificationCardView.PermissionType.ENABLE_LOCATION_PERMISSION;
|
||||
// If user didn't selected Don't ask again
|
||||
|
|
@ -553,7 +553,7 @@ public class ContributionsFragment
|
|||
} else {
|
||||
// If device is under Marshmallow, we already checked for GPS
|
||||
nearbyNotificationCardView.permissionType = NearbyNotificationCardView.PermissionType.NO_PERMISSION_NEEDED;
|
||||
locationManager.registerLocationManager();
|
||||
locationManager.registerLocationManager(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
|||
}
|
||||
|
||||
case 1:
|
||||
Log.d("deneme","case 1");
|
||||
Log.d("deneme1","case 1");
|
||||
NearbyParentFragment retainedNearbyFragment = getNearbyFragment(1);
|
||||
if (retainedNearbyFragment != null) {
|
||||
return retainedNearbyFragment;
|
||||
|
|
@ -480,7 +480,7 @@ public class MainActivity extends AuthenticatedActivity implements FragmentManag
|
|||
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
Timber.d("Location permission given");
|
||||
((ContributionsFragment)contributionsActivityPagerAdapter
|
||||
.getItem(0)).locationManager.registerLocationManager();
|
||||
.getItem(0)).locationManager.registerLocationManager(this);
|
||||
} else {
|
||||
// If nearby fragment is visible and location permission is not given, send user back to contrib fragment
|
||||
if (!isContributionsFragmentVisible) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.location.Location;
|
|||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
|
@ -126,7 +127,8 @@ public class LocationServiceManager implements LocationListener {
|
|||
/**
|
||||
* Registers a LocationManager to listen for current location.
|
||||
*/
|
||||
public void registerLocationManager() {
|
||||
public void registerLocationManager(Context context) {
|
||||
Log.d("deneme1","registerLocationManager2");
|
||||
if (!isLocationManagerRegistered) {
|
||||
isLocationManagerRegistered = requestLocationUpdatesFromProvider(LocationManager.NETWORK_PROVIDER)
|
||||
&& requestLocationUpdatesFromProvider(LocationManager.GPS_PROVIDER);
|
||||
|
|
|
|||
|
|
@ -570,7 +570,7 @@ public class NearbyFragment extends CommonsDaggerSupportFragment
|
|||
private void registerLocationUpdates() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (locationManager.isLocationPermissionGranted(requireContext())) {
|
||||
locationManager.registerLocationManager();
|
||||
locationManager.registerLocationManager(getActivity());
|
||||
} else {
|
||||
// Should we show an explanation?
|
||||
if (locationManager.isPermissionExplanationRequired(getActivity())) {
|
||||
|
|
@ -593,7 +593,7 @@ public class NearbyFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
} else {
|
||||
locationManager.registerLocationManager();
|
||||
locationManager.registerLocationManager(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment implements N
|
|||
|
||||
@Override
|
||||
public void setViewsAreReady(NearbyParentFragmentContract.ViewsAreReadyCallback viewsAreReadyCallback) {
|
||||
Log.d("deneme","setViewsAreReady");
|
||||
Log.d("deneme1","setViewsAreReady");
|
||||
this.viewsAreReadyCallback = viewsAreReadyCallback;
|
||||
this.viewsAreReadyCallback.nearbyFragmentAndMapViewReady();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setRetainInstance(true);
|
||||
Log.d("deneme","onCreate");
|
||||
Log.d("deneme1","onCreate");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
View view = inflater.inflate(R.layout.fragment_nearby, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
this.view = view;
|
||||
Log.d("deneme","onCreateView");
|
||||
Log.d("deneme1","onCreateView");
|
||||
return view;
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +124,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
* it is attached.
|
||||
*/
|
||||
public void childMapFragmentAttached() {
|
||||
Log.d("deneme","childMapFragmentAttached");
|
||||
Log.d("deneme1","childMapFragmentAttached");
|
||||
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter
|
||||
(this, nearbyMapFragment, locationManager);
|
||||
}
|
||||
|
|
@ -146,7 +146,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
* Resume fragments if they exists
|
||||
*/
|
||||
private void resumeFragment() {
|
||||
Log.d("deneme","resumeFragment");
|
||||
Log.d("deneme1","resumeFragment");
|
||||
// Find the retained fragment on activity restarts
|
||||
nearbyMapFragment = getMapFragment();
|
||||
nearbyListFragment = getListFragment();
|
||||
|
|
@ -181,17 +181,17 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
|
||||
@Override
|
||||
public void onLocationChangedSignificantly(LatLng latLng) {
|
||||
Log.d("deneme","location changed significantly");
|
||||
Log.d("deneme1","location changed significantly");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChangedSlightly(LatLng latLng) {
|
||||
Log.d("deneme","location changed significantly");
|
||||
Log.d("deneme1","location changed significantly");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChangedMedium(LatLng latLng) {
|
||||
Log.d("deneme","location changed significantly");
|
||||
Log.d("deneme1","location changed significantly");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -217,9 +217,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
*/
|
||||
@Override
|
||||
public void registerLocationUpdates(LocationServiceManager locationServiceManager) {
|
||||
Log.d("deneme1","registerLocationUpdates");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (locationServiceManager.isLocationPermissionGranted(requireContext())) {
|
||||
locationServiceManager.registerLocationManager();
|
||||
locationServiceManager.registerLocationManager(getActivity());
|
||||
} else {
|
||||
// Should we show an explanation?
|
||||
if (locationServiceManager.isPermissionExplanationRequired(getActivity())) {
|
||||
|
|
@ -242,7 +243,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
} else {
|
||||
locationServiceManager.registerLocationManager();
|
||||
locationServiceManager.registerLocationManager(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -286,6 +287,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
*/
|
||||
@Override
|
||||
public void checkGps(LocationServiceManager locationServiceManager) {
|
||||
Log.d("deneme1","checkGPS");
|
||||
Timber.d("checking GPS");
|
||||
if (!locationServiceManager.isProviderEnabled()) {
|
||||
Timber.d("GPS is not enabled");
|
||||
|
|
@ -319,6 +321,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
*/
|
||||
@Override
|
||||
public void checkLocationPermission(LocationServiceManager locationServiceManager) {
|
||||
Log.d("deneme1","checkLocationPermission");
|
||||
Timber.d("Checking location permission");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (locationServiceManager.isLocationPermissionGranted(requireContext())) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class NearbyParentFragmentPresenter
|
|||
*/
|
||||
@Override
|
||||
public void onTabSelected() {
|
||||
Log.d("deneme","onTabSelected");
|
||||
Log.d("deneme1","onTabSelected");
|
||||
onTabSelected = true;
|
||||
if (nearbyViewsAreReady) {
|
||||
initializeNearbyOperations();
|
||||
|
|
@ -63,7 +63,7 @@ public class NearbyParentFragmentPresenter
|
|||
*/
|
||||
@Override
|
||||
public void nearbyFragmentAndMapViewReady() {
|
||||
Log.d("deneme","nearbyFragmentAndMapViewReady");
|
||||
Log.d("deneme1","nearbyFragmentAndMapViewReady");
|
||||
nearbyViewsAreReady = true;
|
||||
if (onTabSelected) {
|
||||
initializeNearbyOperations();
|
||||
|
|
@ -76,9 +76,11 @@ public class NearbyParentFragmentPresenter
|
|||
*/
|
||||
@Override
|
||||
public void initializeNearbyOperations() {
|
||||
Log.d("deneme","initializeNearbyOperations");
|
||||
Log.d("deneme1","initializeNearbyOperations");
|
||||
locationServiceManager.addLocationListener(this);
|
||||
nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
||||
Log.d("deneme1","initializeNearbyOperations2");
|
||||
|
||||
// Nearby buttons should be active, they should be deactive only during update
|
||||
lockNearby(false);
|
||||
//This will start a consequence to check GPS depending on different API
|
||||
|
|
@ -111,6 +113,7 @@ public class NearbyParentFragmentPresenter
|
|||
*/
|
||||
@Override
|
||||
public void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType) {
|
||||
Log.d("deneme1","updateMapAndList");
|
||||
if (isNearbyLocked) {
|
||||
Timber.d("Nearby is locked, so updateMapAndList returns");
|
||||
return;
|
||||
|
|
@ -123,6 +126,7 @@ public class NearbyParentFragmentPresenter
|
|||
|
||||
//nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
||||
LatLng lastLocation = locationServiceManager.getLastLocation();
|
||||
Log.d("deneme1","locationServiceManager.getLastLocation():"+locationServiceManager.getLastLocation().toString());
|
||||
|
||||
if (curLatLng != null) {
|
||||
// TODO figure out what is happening here about orientation change
|
||||
|
|
@ -155,17 +159,19 @@ public class NearbyParentFragmentPresenter
|
|||
|
||||
@Override
|
||||
public void onLocationChangedSignificantly(LatLng latLng) {
|
||||
Log.d("deneme1","onLocationChangedSignificantly");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChangedSlightly(LatLng latLng) {
|
||||
Log.d("deneme1","onLocationChangedSlightly");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChangedMedium(LatLng latLng) {
|
||||
|
||||
Log.d("deneme1","onLocationChangedMedium");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue