mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
add some commits and clear code
This commit is contained in:
parent
5b69daa5d6
commit
97ab63e19a
2 changed files with 21 additions and 22 deletions
|
|
@ -101,8 +101,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setRetainInstance(true);
|
setRetainInstance(true);
|
||||||
Log.d("deneme1","onCreate");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
@ -111,7 +109,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
View view = inflater.inflate(R.layout.fragment_nearby, container, false);
|
View view = inflater.inflate(R.layout.fragment_nearby, container, false);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
this.view = view;
|
this.view = view;
|
||||||
Log.d("deneme1","onCreateView");
|
Timber.d("OnViewCreated");
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,9 +125,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
* it is attached.
|
* it is attached.
|
||||||
*/
|
*/
|
||||||
public void childMapFragmentAttached() {
|
public void childMapFragmentAttached() {
|
||||||
Log.d("deneme1","childMapFragmentAttached");
|
|
||||||
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter
|
nearbyParentFragmentPresenter = new NearbyParentFragmentPresenter
|
||||||
(this, nearbyMapFragment, locationManager);
|
(this, nearbyMapFragment, locationManager);
|
||||||
|
Timber.d("Child fragment attached");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -173,7 +171,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
* Resume fragments if they exists
|
* Resume fragments if they exists
|
||||||
*/
|
*/
|
||||||
private void resumeFragment() {
|
private void resumeFragment() {
|
||||||
Log.d("deneme1","resumeFragment");
|
Timber.d("Resume existing fragments if there is any");
|
||||||
// Find the retained fragment on activity restarts
|
// Find the retained fragment on activity restarts
|
||||||
nearbyMapFragment = getMapFragment();
|
nearbyMapFragment = getMapFragment();
|
||||||
nearbyListFragment = getListFragment();
|
nearbyListFragment = getListFragment();
|
||||||
|
|
@ -244,7 +242,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void registerLocationUpdates(LocationServiceManager locationServiceManager) {
|
public void registerLocationUpdates(LocationServiceManager locationServiceManager) {
|
||||||
Log.d("deneme1","registerLocationUpdates");
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (locationServiceManager.isLocationPermissionGranted(requireContext())) {
|
if (locationServiceManager.isLocationPermissionGranted(requireContext())) {
|
||||||
locationServiceManager.registerLocationManager(getActivity());
|
locationServiceManager.registerLocationManager(getActivity());
|
||||||
|
|
@ -314,7 +311,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkGps(LocationServiceManager locationServiceManager) {
|
public void checkGps(LocationServiceManager locationServiceManager) {
|
||||||
Log.d("deneme1","checkGPS");
|
|
||||||
Timber.d("checking GPS");
|
Timber.d("checking GPS");
|
||||||
if (!locationServiceManager.isProviderEnabled()) {
|
if (!locationServiceManager.isProviderEnabled()) {
|
||||||
Timber.d("GPS is not enabled");
|
Timber.d("GPS is not enabled");
|
||||||
|
|
@ -348,7 +344,6 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkLocationPermission(LocationServiceManager locationServiceManager) {
|
public void checkLocationPermission(LocationServiceManager locationServiceManager) {
|
||||||
Log.d("deneme1","checkLocationPermission");
|
|
||||||
Timber.d("Checking location permission");
|
Timber.d("Checking location permission");
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
if (locationServiceManager.isLocationPermissionGranted(requireContext())) {
|
if (locationServiceManager.isLocationPermissionGranted(requireContext())) {
|
||||||
|
|
|
||||||
|
|
@ -41,23 +41,27 @@ public class NearbyParentFragmentPresenter
|
||||||
LocationServiceManager locationServiceManager) {
|
LocationServiceManager locationServiceManager) {
|
||||||
this.nearbyParentFragmentView = nearbyParentFragmentView;
|
this.nearbyParentFragmentView = nearbyParentFragmentView;
|
||||||
this.nearbyMapFragmentView = nearbyMapFragmentView;
|
this.nearbyMapFragmentView = nearbyMapFragmentView;
|
||||||
nearbyMapFragmentView.viewsAreSet(this);
|
this.nearbyMapFragmentView.viewsAreSet(this);
|
||||||
this.locationServiceManager = locationServiceManager;
|
this.locationServiceManager = locationServiceManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will be called on list button click to expand list fragment at 9/16 rate
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void displayListFragmentExpanded() {
|
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
|
* Initializes nearby operations if nearby views are ready
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelected() {
|
public void onTabSelected() {
|
||||||
Log.d("deneme1","onTabSelected");
|
Timber.d("Nearby tab selected");
|
||||||
onTabSelected = true;
|
onTabSelected = true;
|
||||||
|
// The condition for initialize operations is both having views ready and tab is selected
|
||||||
if (nearbyViewsAreReady) {
|
if (nearbyViewsAreReady) {
|
||||||
initializeNearbyOperations();
|
initializeNearbyOperations();
|
||||||
}
|
}
|
||||||
|
|
@ -69,8 +73,9 @@ public class NearbyParentFragmentPresenter
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void nearbyFragmentAndMapViewReady() {
|
public void nearbyFragmentAndMapViewReady() {
|
||||||
Log.d("deneme1","nearbyFragmentAndMapViewReady");
|
Timber.d("Nearby map view ready");
|
||||||
nearbyViewsAreReady = true;
|
nearbyViewsAreReady = true;
|
||||||
|
// The condition for initialize operations is both having views ready and tab is selected
|
||||||
if (onTabSelected) {
|
if (onTabSelected) {
|
||||||
initializeNearbyOperations();
|
initializeNearbyOperations();
|
||||||
}
|
}
|
||||||
|
|
@ -79,19 +84,20 @@ public class NearbyParentFragmentPresenter
|
||||||
/**
|
/**
|
||||||
* Initializes nearby operations by following these steps:
|
* Initializes nearby operations by following these steps:
|
||||||
* - Add this location listener to location manager
|
* - 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
|
@Override
|
||||||
public void initializeNearbyOperations() {
|
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);
|
locationServiceManager.addLocationListener(this);
|
||||||
nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
||||||
Log.d("deneme1","initializeNearbyOperations2");
|
// Nearby buttons should be active, they should be inactive only during update
|
||||||
|
|
||||||
// Nearby buttons should be active, they should be deactive only during update
|
|
||||||
lockNearby(false);
|
lockNearby(false);
|
||||||
//This will start a consequence to check GPS depending on different API
|
// This will start a consequence to check GPS depending on different API
|
||||||
nearbyParentFragmentView.checkGps(locationServiceManager);
|
nearbyParentFragmentView.checkGps(locationServiceManager);
|
||||||
//We will know when we went offline and online again
|
// We will know when we went offline and online again
|
||||||
nearbyParentFragmentView.addNetworkBroadcastReceiver();
|
nearbyParentFragmentView.addNetworkBroadcastReceiver();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -106,9 +112,11 @@ public class NearbyParentFragmentPresenter
|
||||||
if (isNearbyLocked) {
|
if (isNearbyLocked) {
|
||||||
locationServiceManager.unregisterLocationManager();
|
locationServiceManager.unregisterLocationManager();
|
||||||
locationServiceManager.removeLocationListener(this);
|
locationServiceManager.removeLocationListener(this);
|
||||||
|
Timber.d("Nearby locked");
|
||||||
} else {
|
} else {
|
||||||
nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
||||||
locationServiceManager.addLocationListener(this);
|
locationServiceManager.addLocationListener(this);
|
||||||
|
Timber.d("Nearby unlocked");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +127,6 @@ public class NearbyParentFragmentPresenter
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType) {
|
public void updateMapAndList(LocationServiceManager.LocationChangeType locationChangeType) {
|
||||||
Log.d("deneme1","updateMapAndList");
|
|
||||||
if (isNearbyLocked) {
|
if (isNearbyLocked) {
|
||||||
Timber.d("Nearby is locked, so updateMapAndList returns");
|
Timber.d("Nearby is locked, so updateMapAndList returns");
|
||||||
return;
|
return;
|
||||||
|
|
@ -130,9 +137,7 @@ public class NearbyParentFragmentPresenter
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//nearbyParentFragmentView.registerLocationUpdates(locationServiceManager);
|
|
||||||
LatLng lastLocation = locationServiceManager.getLastLocation();
|
LatLng lastLocation = locationServiceManager.getLastLocation();
|
||||||
Log.d("deneme1","locationServiceManager.getLastLocation():"+locationServiceManager.getLastLocation().toString());
|
|
||||||
|
|
||||||
if (curLatLng != null) {
|
if (curLatLng != null) {
|
||||||
// TODO figure out what is happening here about orientation change
|
// 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.
|
* @param nearbyPlacesInfo This variable has place list information and distances.
|
||||||
*/
|
*/
|
||||||
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
public void updateMapMarkers(NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
|
||||||
Log.d("deneme","updateMapMarkers npfp");
|
|
||||||
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList);
|
nearbyMapFragmentView.updateMapMarkers(nearbyPlacesInfo.curLatLng, nearbyPlacesInfo.placeList);
|
||||||
nearbyMapFragmentView.updateMapToTrackPosition(nearbyPlacesInfo.curLatLng);
|
nearbyMapFragmentView.updateMapToTrackPosition(nearbyPlacesInfo.curLatLng);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue