14
14
import android .support .design .widget .Snackbar ;
15
15
import android .support .v4 .app .FragmentTransaction ;
16
16
import android .support .v7 .app .AlertDialog ;
17
- import android .util .Log ;
18
17
import android .view .LayoutInflater ;
19
18
import android .view .View ;
20
19
import android .view .ViewGroup ;
@@ -211,6 +210,10 @@ public void onSlide(View bottomSheet, float slideOffset) {
211
210
bottomSheetBehaviorForDetails .setState (BottomSheetBehavior .STATE_HIDDEN );
212
211
}
213
212
213
+ /**
214
+ * Sets camera position, zoom level according to sheet positions
215
+ * @param bottomSheetState expanded, collapsed or hidden
216
+ */
214
217
public void prepareViewsForSheetPosition (int bottomSheetState ) {
215
218
// TODO
216
219
}
@@ -243,7 +246,7 @@ public void onWikidataEditSuccessful() {
243
246
/**
244
247
* This method should be the single point to load/refresh nearby places
245
248
*
246
- * @param locationChangeType defines if location shanged significantly or slightly
249
+ * @param locationChangeType defines if location changed significantly or slightly
247
250
*/
248
251
public void refreshView (LocationServiceManager .LocationChangeType locationChangeType ) {
249
252
Timber .d ("Refreshing nearby places" );
@@ -359,7 +362,6 @@ public void refreshViewForCustomLocation(LatLng customLatLng, boolean refreshFor
359
362
* @param nearbyPlacesInfo This variable has place list information and distances.
360
363
*/
361
364
private void populatePlacesFromCustomLocation (NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
362
- //NearbyMapFragment nearbyMapFragment = getMapFragment();
363
365
if (nearbyMapFragment != null ) {
364
366
nearbyMapFragment .searchThisAreaButtonProgressBar .setVisibility (View .GONE );
365
367
}
@@ -374,6 +376,11 @@ private void populatePlacesFromCustomLocation(NearbyController.NearbyPlacesInfo
374
376
}
375
377
}
376
378
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
+ */
377
384
private void populatePlaces (NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
378
385
Timber .d ("Populating nearby places" );
379
386
List <Place > placeList = nearbyPlacesInfo .placeList ;
@@ -390,7 +397,6 @@ private void populatePlaces(NearbyController.NearbyPlacesInfo nearbyPlacesInfo)
390
397
}
391
398
392
399
bundle .putString ("PlaceList" , gsonPlaceList );
393
- //bundle.putString("CurLatLng", gsonCurLatLng);
394
400
bundle .putString ("BoundaryCoord" , gsonBoundaryCoordinates );
395
401
396
402
// First time to init fragments
@@ -412,7 +418,7 @@ private void populatePlaces(NearbyController.NearbyPlacesInfo nearbyPlacesInfo)
412
418
/**
413
419
* Lock nearby view updates while updating map or list. Because we don't want new update calls
414
420
* when we already updating for old location update.
415
- * @param lock
421
+ * @param lock true if we should lock nearby map
416
422
*/
417
423
private void lockNearbyView (boolean lock ) {
418
424
if (lock ) {
@@ -426,6 +432,18 @@ private void lockNearbyView(boolean lock) {
426
432
}
427
433
}
428
434
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
+ */
429
447
private void updateMapFragment (boolean updateViaButton , boolean isSlightUpdate , @ Nullable LatLng customLatLng , @ Nullable NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
430
448
431
449
if (nearbyMapFragment .searchThisAreaModeOn ) {
@@ -499,6 +517,10 @@ private void updateMapFragment(boolean updateViaButton, boolean isSlightUpdate,
499
517
}
500
518
}
501
519
520
+ /**
521
+ * Updates already existing list fragment with bundle includes nearby places and boundary
522
+ * coordinates
523
+ */
502
524
private void updateListFragment () {
503
525
nearbyListFragment .setBundleForUpdates (bundle );
504
526
nearbyListFragment .updateNearbyListSignificantly ();
@@ -537,6 +559,9 @@ private void setListFragment() {
537
559
fragmentTransaction .commitAllowingStateLoss ();
538
560
}
539
561
562
+ /**
563
+ * Hides progress bar
564
+ */
540
565
private void hideProgressBar () {
541
566
if (progressBar != null ) {
542
567
progressBar .setVisibility (View .GONE );
@@ -576,12 +601,18 @@ private void registerLocationUpdates() {
576
601
}
577
602
}
578
603
604
+ /**
605
+ * Requests location permission if activity is not null
606
+ */
579
607
private void requestLocationPermissions () {
580
608
if (!getActivity ().isFinishing ()) {
581
609
locationManager .requestPermissions (getActivity ());
582
610
}
583
611
}
584
612
613
+ /**
614
+ * Will warn user if location is denied
615
+ */
585
616
private void showLocationPermissionDeniedErrorDialog () {
586
617
new AlertDialog .Builder (getActivity ())
587
618
.setMessage (R .string .nearby_needs_permissions )
@@ -671,6 +702,9 @@ private void showErrorMessage(String message) {
671
702
ViewUtil .showLongToast (getActivity (), message );
672
703
}
673
704
705
+ /**
706
+ * Adds network broadcast receiver to recognize connection established
707
+ */
674
708
private void addNetworkBroadcastReceiver () {
675
709
if (!FragmentUtils .isFragmentUIActive (this )) {
676
710
return ;
@@ -708,6 +742,10 @@ public void onResume() {
708
742
resumeFragment ();
709
743
}
710
744
745
+ /**
746
+ * Perform nearby operations on nearby tab selected
747
+ * @param onOrientationChanged pass orientation changed info to fragment
748
+ */
711
749
public void onTabSelected (boolean onOrientationChanged ) {
712
750
Timber .d ("On nearby tab selected" );
713
751
this .onOrientationChanged = onOrientationChanged ;
0 commit comments