53
53
import androidx .appcompat .app .AlertDialog ;
54
54
import androidx .coordinatorlayout .widget .CoordinatorLayout ;
55
55
import androidx .vectordrawable .graphics .drawable .VectorDrawableCompat ;
56
+ import butterknife .BindView ;
57
+ import butterknife .ButterKnife ;
56
58
import dagger .android .support .DaggerFragment ;
57
59
import fr .free .nrw .commons .CommonsApplication ;
58
60
import fr .free .nrw .commons .R ;
@@ -77,31 +79,77 @@ public class NearbyMapFragment extends DaggerFragment {
77
79
public fr .free .nrw .commons .location .LatLng [] boundaryCoordinates ;
78
80
private List <Place > bookmarkedplaces ;
79
81
80
- private View bottomSheetList ;
81
- private View bottomSheetDetails ;
82
+ @ BindView (R .id .bottom_sheet )
83
+ View bottomSheetList ;
84
+
85
+ @ BindView (R .id .bottom_sheet_details )
86
+ View bottomSheetDetails ;
87
+
88
+ @ BindView (R .id .wikipediaButton )
89
+ LinearLayout wikipediaButton ;
90
+
91
+ @ BindView (R .id .wikidataButton )
92
+ LinearLayout wikidataButton ;
93
+
94
+ @ BindView (R .id .directionsButton )
95
+ LinearLayout directionsButton ;
96
+
97
+ @ BindView (R .id .commonsButton )
98
+ LinearLayout commonsButton ;
99
+
100
+ @ BindView (R .id .bookmarkButton )
101
+ LinearLayout bookmarkButton ;
102
+
103
+ @ BindView (R .id .fab_plus )
104
+ FloatingActionButton fabPlus ;
105
+
106
+ @ BindView (R .id .fab_camera )
107
+ FloatingActionButton fabCamera ;
108
+
109
+ @ BindView (R .id .fab_gallery )
110
+ FloatingActionButton fabGallery ;
111
+
112
+ @ BindView (R .id .fab_recenter )
113
+ FloatingActionButton fabRecenter ;
114
+
115
+ @ BindView (R .id .transparentView )
116
+ View transparentView ;
117
+
118
+ @ BindView (R .id .description )
119
+ TextView description ;
120
+
121
+ @ BindView (R .id .title )
122
+ TextView title ;
123
+
124
+ @ BindView (R .id .category )
125
+ TextView distance ;
126
+
127
+ @ BindView (R .id .icon )
128
+ ImageView icon ;
129
+
130
+ @ BindView (R .id .bookmarkButtonImage )
131
+ ImageView bookmarkButtonImage ;
132
+
133
+ @ BindView (R .id .wikidataButtonText )
134
+ TextView wikidataButtonText ;
135
+
136
+ @ BindView (R .id .wikipediaButtonText )
137
+ TextView wikipediaButtonText ;
138
+
139
+ @ BindView (R .id .commonsButtonText )
140
+ TextView commonsButtonText ;
141
+
142
+ @ BindView (R .id .directionsButtonText )
143
+ TextView directionsButtonText ;
144
+
145
+ @ BindView (R .id .search_this_area_button )
146
+ Button searchThisAreaButton ;
147
+
148
+ @ BindView (R .id .search_this_area_button_progress_bar )
149
+ ProgressBar searchThisAreaButtonProgressBar ;
82
150
83
151
private BottomSheetBehavior bottomSheetListBehavior ;
84
152
private BottomSheetBehavior bottomSheetDetailsBehavior ;
85
- private LinearLayout wikipediaButton ;
86
- private LinearLayout wikidataButton ;
87
- private LinearLayout directionsButton ;
88
- private LinearLayout commonsButton ;
89
- private LinearLayout bookmarkButton ;
90
- private FloatingActionButton fabPlus ;
91
- private FloatingActionButton fabCamera ;
92
- private FloatingActionButton fabGallery ;
93
- private FloatingActionButton fabRecenter ;
94
- private View transparentView ;
95
- private TextView description ;
96
- private TextView title ;
97
- private TextView distance ;
98
- private ImageView icon ;
99
- private ImageView bookmarkButtonImage ;
100
-
101
- private TextView wikipediaButtonText ;
102
- private TextView wikidataButtonText ;
103
- private TextView commonsButtonText ;
104
- private TextView directionsButtonText ;
105
153
106
154
private boolean isFabOpen = false ;
107
155
private Animation rotate_backward ;
@@ -115,8 +163,6 @@ public class NearbyMapFragment extends DaggerFragment {
115
163
public MapboxMap mapboxMap ;
116
164
private PolygonOptions currentLocationPolygonOptions ;
117
165
118
- public Button searchThisAreaButton ;
119
- public ProgressBar searchThisAreaButtonProgressBar ;
120
166
121
167
private boolean isBottomListSheetExpanded ;
122
168
private final double CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT = 0.06 ;
@@ -256,6 +302,28 @@ public void updateMapSignificantlyForCurrentLocation() {
256
302
}
257
303
}
258
304
305
+ /**
306
+ * Initialize all views.
307
+ * TODO: View elements that are part of NearbyFragment should ideally be not accessed directly in NearbyMapFragment.
308
+ */
309
+ private void initViews () {
310
+ Timber .d ("initViews called" );
311
+ View view = ((NearbyFragment )getParentFragment ()).view ;
312
+ ButterKnife .bind (this , view );
313
+
314
+ bottomSheetListBehavior = BottomSheetBehavior .from (bottomSheetList );
315
+ bottomSheetDetailsBehavior = BottomSheetBehavior .from (bottomSheetDetails );
316
+ bottomSheetDetailsBehavior .setState (BottomSheetBehavior .STATE_HIDDEN );
317
+ bottomSheetDetails .setVisibility (View .VISIBLE );
318
+
319
+ fab_open = AnimationUtils .loadAnimation (getParentFragment ().getActivity (), R .anim .fab_open );
320
+ fab_close = AnimationUtils .loadAnimation (getParentFragment ().getActivity (), R .anim .fab_close );
321
+ rotate_forward = AnimationUtils .loadAnimation (getParentFragment ().getActivity (), R .anim .rotate_forward );
322
+ rotate_backward = AnimationUtils .loadAnimation (getParentFragment ().getActivity (), R .anim .rotate_backward );
323
+
324
+
325
+ }
326
+
259
327
/**
260
328
* Will be used for map vew updates for custom locations (ie. with search this area method).
261
329
* Clears the map, adds current location marker, adds nearby markers around custom location,
@@ -277,8 +345,8 @@ public void updateMapSignificantlyForCustomLocation(fr.free.nrw.commons.location
277
345
mapboxMap .getUiSettings ().setAllGesturesEnabled (true );
278
346
searchThisAreaButtonProgressBar .setVisibility (View .GONE );
279
347
}
280
-
281
348
// Only update current position marker and camera view
349
+
282
350
private void updateMapToTrackPosition () {
283
351
284
352
if (currentLocationMarker != null ) {
@@ -333,53 +401,6 @@ private void updateMapToTrackPosition() {
333
401
}
334
402
}
335
403
336
- /**
337
- * Initialize all views. TODO: Use bind view instead.
338
- */
339
- private void initViews () {
340
- Timber .d ("initViews called" );
341
- bottomSheetList = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .bottom_sheet );
342
- bottomSheetListBehavior = BottomSheetBehavior .from (bottomSheetList );
343
- bottomSheetDetails = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .bottom_sheet_details );
344
- bottomSheetDetailsBehavior = BottomSheetBehavior .from (bottomSheetDetails );
345
- bottomSheetDetailsBehavior .setState (BottomSheetBehavior .STATE_HIDDEN );
346
- bottomSheetDetails .setVisibility (View .VISIBLE );
347
-
348
- fabPlus = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .fab_plus );
349
- fabCamera = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .fab_camera );
350
- fabGallery = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .fab_gallery );
351
- fabRecenter = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .fab_recenter );
352
-
353
- fab_open = AnimationUtils .loadAnimation (getParentFragment ().getActivity (), R .anim .fab_open );
354
- fab_close = AnimationUtils .loadAnimation (getParentFragment ().getActivity (), R .anim .fab_close );
355
- rotate_forward = AnimationUtils .loadAnimation (getParentFragment ().getActivity (), R .anim .rotate_forward );
356
- rotate_backward = AnimationUtils .loadAnimation (getParentFragment ().getActivity (), R .anim .rotate_backward );
357
-
358
- transparentView = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .transparentView );
359
-
360
- description = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .description );
361
- title = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .title );
362
- distance = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .category );
363
- icon = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .icon );
364
-
365
- wikidataButton = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .wikidataButton );
366
- wikipediaButton = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .wikipediaButton );
367
- directionsButton = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .directionsButton );
368
- commonsButton = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .commonsButton );
369
-
370
- wikidataButtonText = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .wikidataButtonText );
371
- wikipediaButtonText = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .wikipediaButtonText );
372
- directionsButtonText = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .directionsButtonText );
373
- commonsButtonText = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .commonsButtonText );
374
-
375
- bookmarkButton = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .bookmarkButton );
376
- bookmarkButtonImage = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .bookmarkButtonImage );
377
-
378
- searchThisAreaButton = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .search_this_area_button );
379
- searchThisAreaButtonProgressBar = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .search_this_area_button_progress_bar );
380
-
381
- }
382
-
383
404
/**
384
405
* Sets click listeners of FABs, and 2 bottom sheets
385
406
*/
0 commit comments