13
13
import android .os .Bundle ;
14
14
import android .util .Log ;
15
15
import android .view .Gravity ;
16
- import android .view .LayoutInflater ;
17
16
import android .view .MotionEvent ;
18
17
import android .view .View ;
19
- import android .view .ViewGroup ;
20
- import android .widget .ProgressBar ;
21
18
import android .widget .Toast ;
22
19
import androidx .annotation .NonNull ;
23
20
import androidx .annotation .Nullable ;
24
- import butterknife .BindView ;
25
- import butterknife .ButterKnife ;
26
21
import com .google .android .material .bottomsheet .BottomSheetBehavior ;
27
- import com .google .android .material .floatingactionbutton .FloatingActionButton ;
28
22
import com .google .android .material .snackbar .Snackbar ;
29
23
import com .mapbox .mapboxsdk .annotations .Icon ;
30
24
import com .mapbox .mapboxsdk .annotations .IconFactory ;
36
30
import com .mapbox .mapboxsdk .camera .CameraUpdate ;
37
31
import com .mapbox .mapboxsdk .camera .CameraUpdateFactory ;
38
32
import com .mapbox .mapboxsdk .geometry .LatLngBounds ;
39
- import com .mapbox .mapboxsdk .maps .MapView ;
40
33
import com .mapbox .mapboxsdk .maps .MapboxMap ;
41
34
import com .mapbox .mapboxsdk .maps .Style ;
42
35
import com .mapbox .mapboxsdk .maps .UiSettings ;
43
36
import com .mapbox .pluginscalebar .ScaleBarOptions ;
44
37
import com .mapbox .pluginscalebar .ScaleBarPlugin ;
45
38
import fr .free .nrw .commons .MapController ;
46
- import fr .free .nrw .commons .Media ;
47
39
import fr .free .nrw .commons .R ;
48
- import fr .free .nrw .commons .Utils ;
49
40
import fr .free .nrw .commons .bookmarks .locations .BookmarkLocationsDao ;
50
41
import fr .free .nrw .commons .category .CategoryImagesCallback ;
51
- import fr .free .nrw .commons .contributions .MainActivity ;
52
- import fr .free .nrw .commons .contributions .MainActivity .ActiveFragment ;
53
- import fr .free .nrw .commons .di .CommonsApplicationModule ;
54
42
import fr .free .nrw .commons .explore .SearchActivity ;
55
43
import fr .free .nrw .commons .explore .paging .LiveDataConverter ;
56
- import fr .free .nrw .commons .explore .paging .PagingContract .Presenter ;
57
44
import fr .free .nrw .commons .kvstore .JsonKvStore ;
58
45
import fr .free .nrw .commons .location .LatLng ;
59
46
import fr .free .nrw .commons .location .LocationServiceManager ;
70
57
import fr .free .nrw .commons .utils .UiUtils ;
71
58
import fr .free .nrw .commons .utils .ViewUtil ;
72
59
import io .reactivex .Observable ;
73
- import io .reactivex .Scheduler ;
74
60
import io .reactivex .android .schedulers .AndroidSchedulers ;
75
61
import io .reactivex .schedulers .Schedulers ;
76
- import java .util .ArrayList ;
77
- import java .util .Date ;
78
62
import java .util .List ;
79
63
import javax .inject .Inject ;
80
64
import javax .inject .Named ;
@@ -105,12 +89,6 @@ public class ExploreMapFragment extends PageableMapFragment
105
89
private ExploreFragmentInstanceReadyCallback exploreFragmentInstanceReadyCallback ;
106
90
IntentFilter intentFilter = new IntentFilter (MapUtils .NETWORK_INTENT_ACTION );
107
91
108
- @ Inject
109
- ExploreMapMediaDataSource dataSourceFactory ;
110
- @ Inject
111
- ExploreMapMediaPresenter mediaPresenter ;
112
- // Help wanted: Hey Madhur, one help need is binding these two variable above
113
-
114
92
@ Inject
115
93
LiveDataConverter liveDataConverter ;
116
94
@ Inject
@@ -119,8 +97,6 @@ public class ExploreMapFragment extends PageableMapFragment
119
97
LocationServiceManager locationManager ;
120
98
@ Inject
121
99
ExploreMapController exploreMapController ;
122
- @ Inject
123
- ExploreWithQueryMapController exploreWithQueryMapController ;
124
100
@ Inject @ Named ("default_preferences" )
125
101
JsonKvStore applicationKvStore ;
126
102
@ Inject
@@ -129,20 +105,8 @@ public class ExploreMapFragment extends PageableMapFragment
129
105
SystemThemeUtils systemThemeUtils ;
130
106
131
107
private boolean isFromSearchActivity ;
132
-
133
- /*@BindView(R.id.map_view)
134
- MapView mapView;
135
- @BindView(R.id.bottom_sheet_details)
136
- View bottomSheetDetails;
137
- @BindView(R.id.map_progress_bar)
138
- ProgressBar progressBar;
139
- @BindView(R.id.fab_recenter)
140
- FloatingActionButton fabRecenter;*/
141
-
142
-
143
- //private View view;
144
108
private ExploreMapPresenter presenter ;
145
- private String customQuery ;
109
+ private String query = "" ;
146
110
147
111
148
112
@ NonNull
@@ -157,32 +121,15 @@ protected int getLayoutResource() {
157
121
return R .layout .fragment_search_map_paginated ;
158
122
}
159
123
160
- //@Override
161
- //public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container,
162
- //final Bundle savedInstanceState) {
163
- //super.onCreateView(inflater, container, savedInstanceState);
164
- //view = inflater.inflate(R.layout.fragment_explore_map, container, false);
165
- //ButterKnife.bind(this, getView());
166
-
167
-
168
- // Inflate the layout for this fragmentz
169
- //return getView();
170
- //}
171
-
172
-
173
124
@ Override
174
125
public void onCreate (@ Nullable final Bundle savedInstanceState ) {
175
126
super .onCreate (savedInstanceState );
176
- //dataSourceFactory = new ExploreMapMediaDataSource(liveDataConverter, mediaClient, isFromSearchActivity);
177
- //mediaPresenter = new ExploreMapMediaPresenterIml(scheduler, dataSourceFactory,isFromSearchActivity);
178
127
}
179
128
129
+
180
130
@ Override
181
131
public void onViewCreated (@ NonNull final View view , @ Nullable final Bundle savedInstanceState ) {
182
132
super .onViewCreated (view , savedInstanceState );
183
- /*if (savedInstanceState != null) {
184
- onQueryUpdated(savedInstanceState.getString("placeName") + "map query");
185
- }*/
186
133
187
134
if (getActivity () instanceof SearchActivity ) {
188
135
isFromSearchActivity = true ;
@@ -256,6 +203,11 @@ public void onResume() {
256
203
}
257
204
}
258
205
206
+ public void onQueryUpdated (String query ) {
207
+ this .query = query ;
208
+ performMapReadyActions ();
209
+ }
210
+
259
211
private void startTheMap () {
260
212
mapView .onStart ();
261
213
performMapReadyActions ();
@@ -270,7 +222,7 @@ private void startMapWithoutPermission() {
270
222
if (mapBox != null ) {
271
223
addOnCameraMoveListener ();
272
224
}
273
- presenter .onMapReady ();
225
+ presenter .onMapReady (isFromSearchActivity , exploreMapController , query );
274
226
// TODO nesli removeCurrentLocationMarker();
275
227
}
276
228
@@ -351,10 +303,8 @@ public boolean isNetworkConnectionEstablished() {
351
303
@ Override
352
304
public void populatePlaces (LatLng curlatLng ) {
353
305
if (curlatLng .equals (lastFocusLocation ) || lastFocusLocation == null || recenterToUserLocation ) { // Means we are checking around current location
354
- Log .d ("nesli2" ,"populate places populatePlacesForCurrentLocation called" );
355
306
populatePlacesForCurrentLocation (lastKnownLocation , curlatLng );
356
307
} else {
357
- Log .d ("nesli2" ,"populate places populatePlacesForAnotherLocation called" );
358
308
populatePlacesForAnotherLocation (lastKnownLocation , curlatLng );
359
309
}
360
310
if (recenterToUserLocation ) {
@@ -365,17 +315,7 @@ public void populatePlaces(LatLng curlatLng) {
365
315
private void populatePlacesForCurrentLocation (final fr .free .nrw .commons .location .LatLng curlatLng ,
366
316
final fr .free .nrw .commons .location .LatLng searchLatLng ){
367
317
final Observable <MapController .ExplorePlacesInfo > nearbyPlacesInfoObservable ;
368
- if (!isFromSearchActivity ) {
369
- nearbyPlacesInfoObservable = Observable
370
- .fromCallable (() -> exploreMapController
371
- .loadAttractionsFromLocation (curlatLng , searchLatLng ,true ));
372
-
373
- } else {
374
- //Log.d("nesli3","presenters data source is:"+getPagedListAdapter().getCurrentList().snapshot());
375
- nearbyPlacesInfoObservable = Observable
376
- .fromCallable (() -> exploreWithQueryMapController
377
- .loadAttractionsFromLocation (curlatLng , searchLatLng ,true ));
378
- }
318
+ nearbyPlacesInfoObservable = presenter .loadAttractionsFromLocation (curlatLng , searchLatLng , true , isFromSearchActivity , query );
379
319
380
320
compositeDisposable .add (nearbyPlacesInfoObservable
381
321
.subscribeOn (Schedulers .io ())
@@ -397,8 +337,8 @@ private void populatePlacesForAnotherLocation(final fr.free.nrw.commons.location
397
337
398
338
final Observable <MapController .ExplorePlacesInfo > nearbyPlacesInfoObservable = Observable
399
339
.fromCallable (() -> exploreMapController
400
- .loadAttractionsFromLocation (curlatLng , searchLatLng ,false ));
401
- // TODO: check loadAttractionsromLocation with query parameter
340
+ .loadAttractionsFromLocation (curlatLng , searchLatLng ,false , isFromSearchActivity , query ));
341
+ // TODO: nesli do this over the presenter
402
342
403
343
compositeDisposable .add (nearbyPlacesInfoObservable
404
344
.subscribeOn (Schedulers .io ())
@@ -421,7 +361,6 @@ private void populatePlacesForAnotherLocation(final fr.free.nrw.commons.location
421
361
* @param explorePlacesInfo This variable has place list information and distances.
422
362
*/
423
363
private void updateMapMarkers (final MapController .ExplorePlacesInfo explorePlacesInfo , final boolean shouldUpdateSelectedMarker ) {
424
- Log .d ("nesli2" ,"updateMapMarkers1" );
425
364
presenter .updateMapMarkers (explorePlacesInfo , selectedMarker ,shouldUpdateSelectedMarker );
426
365
}
427
366
@@ -464,7 +403,7 @@ else if(locationManager.isGPSProviderEnabled()||locationManager.isNetworkProvide
464
403
else {
465
404
Toast .makeText (getContext (), getString (R .string .nearby_location_not_available ), Toast .LENGTH_LONG ).show ();
466
405
}
467
- presenter .onMapReady ();
406
+ presenter .onMapReady (isFromSearchActivity , exploreMapController , query );
468
407
registerUnregisterLocationListener (false );
469
408
addOnCameraMoveListener ();
470
409
}
@@ -655,16 +594,14 @@ public void enableFABRecenter() {
655
594
656
595
@ Override
657
596
public void setCustomQuery (String customQuery ) {
658
- this .customQuery = customQuery ;
597
+ this .query = query ;
659
598
}
660
599
661
600
@ Override
662
601
public void addNearbyMarkersToMapBoxMap (List <NearbyBaseMarker > nearbyBaseMarkers ,
663
602
Marker selectedMarker ) {
664
603
if (isMapBoxReady && mapBox != null ) {
665
- //allMarkers = new ArrayList<>(nearbyBaseMarkers);
666
604
mapBox .addMarkers (nearbyBaseMarkers );
667
- //setMapMarkerActions(selectedMarker);
668
605
presenter .updateMapMarkersToController (nearbyBaseMarkers );
669
606
}
670
607
}
@@ -674,12 +611,6 @@ public void setMapBoundaries(CameraUpdate cameaUpdate) {
674
611
mapBox .easeCamera (cameaUpdate );
675
612
}
676
613
677
- @ NonNull
678
- @ Override
679
- public Presenter <Media > getInjectedPresenter () {
680
- return mediaPresenter ;
681
- }
682
-
683
614
@ Override
684
615
public Integer getContributionStateAt (int position ) {
685
616
return null ;
0 commit comments