add some commits and clear code

This commit is contained in:
neslihanturan 2019-05-27 13:17:57 +03:00
parent 5b69daa5d6
commit 97ab63e19a
2 changed files with 21 additions and 22 deletions

View file

@ -101,8 +101,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
Log.d("deneme1","onCreate");
}
@Nullable
@ -111,7 +109,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("deneme1","onCreateView");
Timber.d("OnViewCreated");
return view;
}
@ -127,9 +125,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
* it is attached.
*/
public void childMapFragmentAttached() {
Log.d("deneme1","childMapFragmentAttached");
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter
(this, nearbyMapFragment, locationManager);
Timber.d("Child fragment attached");
}
@ -173,7 +171,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
* Resume fragments if they exists
*/
private void resumeFragment() {
Log.d("deneme1","resumeFragment");
Timber.d("Resume existing fragments if there is any");
// Find the retained fragment on activity restarts
nearbyMapFragment = getMapFragment();
nearbyListFragment = getListFragment();
@ -244,7 +242,6 @@ 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(getActivity());
@ -314,7 +311,6 @@ 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");
@ -348,7 +344,6 @@ 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())) {

View file

@ -41,23 +41,27 @@ public class NearbyParentFragmentPresenter
LocationServiceManager locationServiceManager) {
this.nearbyParentFragmentView = nearbyParentFragmentView;
this.nearbyMapFragmentView = nearbyMapFragmentView;
nearbyMapFragmentView.viewsAreSet(this);
this.nearbyMapFragmentView.viewsAreSet(this);
this.locationServiceManager = locationServiceManager;
}
/**
* Will be called on list button click to expand list fragment at 9/16 rate
*/
@Override
public void displayListFragmentExpanded() {
}
/**
* -To initialize nearby operations both views should be ready and tab is selected.
* Note: To initialize nearby operations both views should be ready and tab is selected.
* Initializes nearby operations if nearby views are ready
*/
@Override
public void onTabSelected() {
Log.d("deneme1","onTabSelected");
Timber.d("Nearby tab selected");
onTabSelected = true;
// The condition for initialize operations is both having views ready and tab is selected
if (nearbyViewsAreReady) {
initializeNearbyOperations();
}
@ -69,8 +73,9 @@ public class NearbyParentFragmentPresenter
*/
@Override
public void nearbyFragmentAndMapViewReady() {
Log.d("deneme1","nearbyFragmentAndMapViewReady");
Timber.d("Nearby map view ready");
nearbyViewsAreReady = true;
// The condition for initialize operations is both having views ready and tab is selected
if (onTabSelected) {
initializeNearbyOperations();
}
@ -79,15 +84,16 @@ public class NearbyParentFragmentPresenter
/**
* Initializes nearby operations by following these steps:
* - Add this location listener to location manager
* - Registers location updates with parent fragment, this methods also checks permissions
* Note: Highly context dependent methods are handled in view and triggered from presenter
*/
@Override
public void initializeNearbyOperations() {
Log.d("deneme1","initializeNearbyOperations");
Timber.d("initializing nearby operations started");
// Add location listener to be notified about location changes
locationServiceManager.addLocationListener(this);
nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
Log.d("deneme1","initializeNearbyOperations2");
// Nearby buttons should be active, they should be deactive only during update
// Nearby buttons should be active, they should be inactive only during update
lockNearby(false);
// This will start a consequence to check GPS depending on different API
nearbyParentFragmentView.checkGps(locationServiceManager);
@ -106,9 +112,11 @@ public class NearbyParentFragmentPresenter
if (isNearbyLocked) {
locationServiceManager.unregisterLocationManager();
locationServiceManager.removeLocationListener(this);
Timber.d("Nearby locked");
} else {
nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
locationServiceManager.addLocationListener(this);
Timber.d("Nearby unlocked");
}
}
@ -119,7 +127,6 @@ 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;
@ -130,9 +137,7 @@ public class NearbyParentFragmentPresenter
return;
}
//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
@ -165,7 +170,6 @@ public class NearbyParentFragmentPresenter
* @param nearbyPlacesInfo This variable has place list information and distances.
*/
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
Log.d("deneme","updateMapMarkers npfp");
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList);
nearbyMapFragmentView.updateMapToTrackPosition(nearbyPlacesInfo.curLatLng);
}