1414import android .support .design .widget .Snackbar ;
1515import android .support .v4 .app .FragmentTransaction ;
1616import android .support .v7 .app .AlertDialog ;
17- import android .util .Log ;
1817import android .view .LayoutInflater ;
1918import android .view .View ;
2019import android .view .ViewGroup ;
@@ -211,6 +210,10 @@ public void onSlide(View bottomSheet, float slideOffset) {
211210 bottomSheetBehaviorForDetails .setState (BottomSheetBehavior .STATE_HIDDEN );
212211 }
213212
213+ /**
214+ * Sets camera position, zoom level according to sheet positions
215+ * @param bottomSheetState expanded, collapsed or hidden
216+ */
214217 public void prepareViewsForSheetPosition (int bottomSheetState ) {
215218 // TODO
216219 }
@@ -243,7 +246,7 @@ public void onWikidataEditSuccessful() {
243246 /**
244247 * This method should be the single point to load/refresh nearby places
245248 *
246- * @param locationChangeType defines if location shanged significantly or slightly
249+ * @param locationChangeType defines if location changed significantly or slightly
247250 */
248251 public void refreshView (LocationServiceManager .LocationChangeType locationChangeType ) {
249252 Timber .d ("Refreshing nearby places" );
@@ -359,7 +362,6 @@ public void refreshViewForCustomLocation(LatLng customLatLng, boolean refreshFor
359362 * @param nearbyPlacesInfo This variable has place list information and distances.
360363 */
361364 private void populatePlacesFromCustomLocation (NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
362- //NearbyMapFragment nearbyMapFragment = getMapFragment();
363365 if (nearbyMapFragment != null ) {
364366 nearbyMapFragment .searchThisAreaButtonProgressBar .setVisibility (View .GONE );
365367 }
@@ -374,6 +376,11 @@ private void populatePlacesFromCustomLocation(NearbyController.NearbyPlacesInfo
374376 }
375377 }
376378
379+ /**
380+ * Turns nearby place lists and boundary coordinates into gson and update map and list fragments
381+ * accordingly
382+ * @param nearbyPlacesInfo a variable holds both nearby place list and boundary coordinates
383+ */
377384 private void populatePlaces (NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
378385 Timber .d ("Populating nearby places" );
379386 List <Place > placeList = nearbyPlacesInfo .placeList ;
@@ -390,7 +397,6 @@ private void populatePlaces(NearbyController.NearbyPlacesInfo nearbyPlacesInfo)
390397 }
391398
392399 bundle .putString ("PlaceList" , gsonPlaceList );
393- //bundle.putString("CurLatLng", gsonCurLatLng);
394400 bundle .putString ("BoundaryCoord" , gsonBoundaryCoordinates );
395401
396402 // First time to init fragments
@@ -412,7 +418,7 @@ private void populatePlaces(NearbyController.NearbyPlacesInfo nearbyPlacesInfo)
412418 /**
413419 * Lock nearby view updates while updating map or list. Because we don't want new update calls
414420 * when we already updating for old location update.
415- * @param lock
421+ * @param lock true if we should lock nearby map
416422 */
417423 private void lockNearbyView (boolean lock ) {
418424 if (lock ) {
@@ -426,6 +432,18 @@ private void lockNearbyView(boolean lock) {
426432 }
427433 }
428434
435+ /**
436+ * Updates map fragment,
437+ * For slight update: camera follows users location
438+ * For significant update: nearby markers are removed and new markers added again
439+ * Slight updates stop if user is checking another area of map
440+ *
441+ * @param updateViaButton search this area button is clicked
442+ * @param isSlightUpdate Means no need to update markers, just follow user location with camera
443+ * @param customLatLng Will be used for updates for other locations than users current location.
444+ * Ie. when we use search this area feature
445+ * @param nearbyPlacesInfo Includes nearby places list and boundary coordinates
446+ */
429447 private void updateMapFragment (boolean updateViaButton , boolean isSlightUpdate , @ Nullable LatLng customLatLng , @ Nullable NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
430448
431449 if (nearbyMapFragment .searchThisAreaModeOn ) {
@@ -499,6 +517,10 @@ private void updateMapFragment(boolean updateViaButton, boolean isSlightUpdate,
499517 }
500518 }
501519
520+ /**
521+ * Updates already existing list fragment with bundle includes nearby places and boundary
522+ * coordinates
523+ */
502524 private void updateListFragment () {
503525 nearbyListFragment .setBundleForUpdates (bundle );
504526 nearbyListFragment .updateNearbyListSignificantly ();
@@ -537,6 +559,9 @@ private void setListFragment() {
537559 fragmentTransaction .commitAllowingStateLoss ();
538560 }
539561
562+ /**
563+ * Hides progress bar
564+ */
540565 private void hideProgressBar () {
541566 if (progressBar != null ) {
542567 progressBar .setVisibility (View .GONE );
@@ -576,12 +601,18 @@ private void registerLocationUpdates() {
576601 }
577602 }
578603
604+ /**
605+ * Requests location permission if activity is not null
606+ */
579607 private void requestLocationPermissions () {
580608 if (!getActivity ().isFinishing ()) {
581609 locationManager .requestPermissions (getActivity ());
582610 }
583611 }
584612
613+ /**
614+ * Will warn user if location is denied
615+ */
585616 private void showLocationPermissionDeniedErrorDialog () {
586617 new AlertDialog .Builder (getActivity ())
587618 .setMessage (R .string .nearby_needs_permissions )
@@ -671,6 +702,9 @@ private void showErrorMessage(String message) {
671702 ViewUtil .showLongToast (getActivity (), message );
672703 }
673704
705+ /**
706+ * Adds network broadcast receiver to recognize connection established
707+ */
674708 private void addNetworkBroadcastReceiver () {
675709 if (!FragmentUtils .isFragmentUIActive (this )) {
676710 return ;
@@ -708,6 +742,10 @@ public void onResume() {
708742 resumeFragment ();
709743 }
710744
745+ /**
746+ * Perform nearby operations on nearby tab selected
747+ * @param onOrientationChanged pass orientation changed info to fragment
748+ */
711749 public void onTabSelected (boolean onOrientationChanged ) {
712750 Timber .d ("On nearby tab selected" );
713751 this .onOrientationChanged = onOrientationChanged ;
0 commit comments