@@ -99,6 +99,7 @@ public class NearbyFragment extends CommonsDaggerSupportFragment
99
99
100
100
private boolean onOrientationChanged = false ;
101
101
private boolean populateForCurrentLocation = false ;
102
+ private boolean isNetworkErrorOccured = false ;
102
103
103
104
@ Override
104
105
public void onCreate (@ Nullable Bundle savedInstanceState ) {
@@ -126,7 +127,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
126
127
super .onViewCreated (view , savedInstanceState );
127
128
if (savedInstanceState != null ) {
128
129
onOrientationChanged = true ;
129
- refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
130
+ Log .d ("deneme" ,"onViewCreated" );
131
+ //refreshView(LOCATION_SIGNIFICANTLY_CHANGED);
130
132
}
131
133
}
132
134
@@ -218,17 +220,22 @@ public void prepareViewsForSheetPosition(int bottomSheetState) {
218
220
219
221
@ Override
220
222
public void onLocationChangedSignificantly (LatLng latLng ) {
223
+ Log .d ("deneme" ,"onLocationChangedSignificantly" );
221
224
refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
222
225
}
223
226
224
227
@ Override
225
228
public void onLocationChangedSlightly (LatLng latLng ) {
226
- refreshView (LOCATION_SLIGHTLY_CHANGED );
229
+ Log .d ("deneme" ,"onLocationChangedSlightly" );
230
+
231
+ refreshView (LOCATION_SLIGHTLY_CHANGED );
227
232
}
228
233
229
234
230
235
@ Override
231
236
public void onLocationChangedMedium (LatLng latLng ) {
237
+ Log .d ("deneme" ,"onLocationChangedMedium" );
238
+
232
239
// For nearby map actions, there are no differences between 500 meter location change (aka medium change) and slight change
233
240
refreshView (LOCATION_SLIGHTLY_CHANGED );
234
241
}
@@ -237,6 +244,7 @@ public void onLocationChangedMedium(LatLng latLng) {
237
244
public void onWikidataEditSuccessful () {
238
245
// Do not refresh nearby map if we are checking other areas with search this area button
239
246
if (!nearbyMapFragment .searchThisAreaModeOn ) {
247
+ Log .d ("deneme" ,"onWikidateEditSuccesful" );
240
248
refreshView (MAP_UPDATED );
241
249
}
242
250
}
@@ -247,6 +255,7 @@ public void onWikidataEditSuccessful() {
247
255
* @param locationChangeType defines if location shanged significantly or slightly
248
256
*/
249
257
public void refreshView (LocationServiceManager .LocationChangeType locationChangeType ) {
258
+ Log .d ("deneme" ,"refreshView" );
250
259
Timber .d ("Refreshing nearby places" );
251
260
if (lockNearbyView ) {
252
261
return ;
@@ -298,6 +307,7 @@ public void refreshView(LocationServiceManager.LocationChangeType locationChange
298
307
bundle .clear ();
299
308
bundle .putString ("CurLatLng" , gsonCurLatLng );
300
309
310
+ Log .d ("deneme" ,"popuate places is called from here" );
301
311
placesDisposable = Observable .fromCallable (() -> nearbyController
302
312
.loadAttractionsFromLocation (curLatLng , curLatLng , false , true ))
303
313
.subscribeOn (Schedulers .io ())
@@ -331,7 +341,7 @@ public void refreshView(LocationServiceManager.LocationChangeType locationChange
331
341
* @param customLatLng Custom area which we will search around
332
342
*/
333
343
public void refreshViewForCustomLocation (LatLng customLatLng , boolean refreshForCurrentLocation ) {
334
-
344
+ Log . d ( "deneme" , "refreshViewForCutomLocatiom" );
335
345
if (customLatLng == null ) {
336
346
// If null, return
337
347
return ;
@@ -360,6 +370,7 @@ public void refreshViewForCustomLocation(LatLng customLatLng, boolean refreshFor
360
370
* @param nearbyPlacesInfo This variable has place list information and distances.
361
371
*/
362
372
private void populatePlacesFromCustomLocation (NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
373
+ Log .d ("deneme" ,"populatePlacesFromCustomLocation" );
363
374
//NearbyMapFragment nearbyMapFragment = getMapFragment();
364
375
if (nearbyMapFragment != null ) {
365
376
nearbyMapFragment .searchThisAreaButtonProgressBar .setVisibility (View .GONE );
@@ -376,6 +387,8 @@ private void populatePlacesFromCustomLocation(NearbyController.NearbyPlacesInfo
376
387
}
377
388
378
389
private void populatePlaces (NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
390
+ Log .d ("deneme" ,"populatePlaces" );
391
+
379
392
Timber .d ("Populating nearby places" );
380
393
List <Place > placeList = nearbyPlacesInfo .placeList ;
381
394
LatLng [] boundaryCoordinates = nearbyPlacesInfo .boundaryCoordinates ;
@@ -428,6 +441,9 @@ private void lockNearbyView(boolean lock) {
428
441
}
429
442
430
443
private void updateMapFragment (boolean updateViaButton , boolean isSlightUpdate , @ Nullable LatLng customLatLng , @ Nullable NearbyController .NearbyPlacesInfo nearbyPlacesInfo ) {
444
+ Log .d ("deneme" ,"update Map fragment" +" updateViaButton:" +updateViaButton +", isSlightUpdate:" +isSlightUpdate );
445
+ Log .d ("deneme" ,"update Map fragment status" +" checking around:" +nearbyMapFragment .checkingAround +", searchThisAreaModeOn:" +nearbyMapFragment .searchThisAreaModeOn +", onOrientationChanged:" +onOrientationChanged );
446
+
431
447
if (nearbyMapFragment .checkingAround ) {
432
448
return ;
433
449
}
@@ -446,11 +462,15 @@ private void updateMapFragment(boolean updateViaButton, boolean isSlightUpdate,
446
462
* If we are close to nearby places boundaries, we need a significant update to
447
463
* get new nearby places. Check order is south, north, west, east
448
464
* */
449
- if (nearbyMapFragment .boundaryCoordinates != null && !nearbyMapFragment .searchThisAreaModeOn
450
- && (curLatLng .getLatitude () <= nearbyMapFragment .boundaryCoordinates [0 ].getLatitude ()
451
- || curLatLng .getLatitude () >= nearbyMapFragment .boundaryCoordinates [1 ].getLatitude ()
452
- || curLatLng .getLongitude () <= nearbyMapFragment .boundaryCoordinates [2 ].getLongitude ()
453
- || curLatLng .getLongitude () >= nearbyMapFragment .boundaryCoordinates [3 ].getLongitude ())) {
465
+ if (nearbyMapFragment .boundaryCoordinates != null
466
+ && !nearbyMapFragment .checkingAround
467
+ && !nearbyMapFragment .searchThisAreaModeOn
468
+ && !onOrientationChanged
469
+ && (curLatLng .getLatitude () < nearbyMapFragment .boundaryCoordinates [0 ].getLatitude ()
470
+ || curLatLng .getLatitude () > nearbyMapFragment .boundaryCoordinates [1 ].getLatitude ()
471
+ || curLatLng .getLongitude () < nearbyMapFragment .boundaryCoordinates [2 ].getLongitude ()
472
+ || curLatLng .getLongitude () > nearbyMapFragment .boundaryCoordinates [3 ].getLongitude ())) {
473
+ Log .d ("deneme" ,"boundary is working" );
454
474
// populate places
455
475
placesDisposable = Observable .fromCallable (() -> nearbyController
456
476
.loadAttractionsFromLocation (curLatLng , curLatLng , false , updateViaButton ))
@@ -637,6 +657,7 @@ private void checkLocationPermission() {
637
657
Timber .d ("Checking location permission" );
638
658
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .M ) {
639
659
if (locationManager .isLocationPermissionGranted ()) {
660
+ Log .d ("deneme" ,"Check location permission if" );
640
661
refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
641
662
} else {
642
663
// Should we show an explanation?
@@ -663,6 +684,7 @@ private void checkLocationPermission() {
663
684
}
664
685
}
665
686
} else {
687
+ Log .d ("deneme" ,"Check location permission else" );
666
688
refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
667
689
}
668
690
}
@@ -681,9 +703,16 @@ private void addNetworkBroadcastReceiver() {
681
703
public void onReceive (Context context , Intent intent ) {
682
704
if (snackbar != null ) {
683
705
if (NetworkUtils .isInternetConnectionEstablished (getActivity ())) {
684
- refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
706
+ Log .d ("deneme" ,"NetworkUtils.isInternetConnectionEstablished(getActivity())" );
707
+ if (isNetworkErrorOccured ) {
708
+ Log .d ("deneme" ,"NetworkUtils.isInternetConnectionEstablished(getActivity())" );
709
+ Log .d ("deneme" ,"isNetworkErrorOccured refreshed" );
710
+ refreshView (LOCATION_SIGNIFICANTLY_CHANGED );
711
+ isNetworkErrorOccured = false ;
712
+ }
685
713
snackbar .dismiss ();
686
714
} else {
715
+ isNetworkErrorOccured = true ;
687
716
snackbar .show ();
688
717
}
689
718
}
0 commit comments