72 private boolean cameraListenerRegistered;
84 this(context,
null,
null,
null,
null,
null);
89 this(context, attrs,
null,
null,
null,
null);
103 this(context, attrs, viewConfig,
null,
null,
null);
115 super(context, attrs,
120 installFollowMeAndUserLocation();
124 private void installFollowMeAndUserLocation() {
126 this::followMePressed,
127 followMeButtonConfig);
128 FrameLayout.LayoutParams followLp =
new FrameLayout.LayoutParams(
129 ViewGroup.LayoutParams.WRAP_CONTENT,
130 ViewGroup.LayoutParams.WRAP_CONTENT
132 followLp.gravity = Gravity.END | Gravity.BOTTOM;
133 addView(followMeButton, followLp);
148 if (followMeButton !=
null && followMeButton.
isFollowing()) {
154 registerCameraListener();
157 private void registerCameraListener() {
158 if (cameraListenerRegistered || locationWindow ==
null || cameraListener ==
null) {
161 locationWindow.addCameraListener(cameraListener);
162 cameraListenerRegistered =
true;
165 private void unregisterCameraListener() {
166 if (!cameraListenerRegistered || locationWindow ==
null || cameraListener ==
null) {
169 locationWindow.removeCameraListener(cameraListener);
170 cameraListenerRegistered =
false;
175 super.applyConfigVisibility();
176 if (followMeButton !=
null) {
177 followMeButton.setVisibility(
185 super.applyWidgetLayoutParams();
186 if (followMeButton !=
null) {
187 FrameLayout.LayoutParams followLp = (FrameLayout.LayoutParams) followMeButton.getLayoutParams();
188 if (followLp ==
null) {
189 followLp =
new FrameLayout.LayoutParams(
190 ViewGroup.LayoutParams.WRAP_CONTENT,
191 ViewGroup.LayoutParams.WRAP_CONTENT);
193 followLp.gravity = Gravity.END | Gravity.BOTTOM;
197 : dpToPx((
int) com.navigine.view.widgets.WidgetStyles.STANDARD_RIGHT_PADDING);
200 : dpToPx((
int) com.navigine.view.widgets.WidgetStyles.FOLLOW_ME_BOTTOM_PADDING);
201 followLp.setMargins(0, 0, rightPad, bottomPad);
202 followMeButton.setLayoutParams(followLp);
210 private void followMePressed(
boolean isFollowing) {
212 updateFollowMeAnchor();
218 private void updateFollowMeAnchor() {
219 if (userLocationLayer ==
null) {
224 PointF anchorPoint =
new PointF(getWidth() / 2f, getHeight() / 2f);
225 userLocationLayer.setAnchor(anchorPoint);
232 super.setViewConfig(newViewConfig);
250 if (newFollowMeConfig !=
null) followMeButtonConfig = newFollowMeConfig;
251 super.setConfig(newViewConfig, newZoomConfig, newFloorConfig);
252 if (followMeButton !=
null) followMeButton.applyConfig(followMeButtonConfig);
270 super.onAttachedToWindow();
271 registerCameraListener();
276 unregisterCameraListener();
277 super.onDetachedFromWindow();
282 super.onSizeChanged(w, h, oldw, oldh);
284 if (followMeButton !=
null && followMeButton.isFollowing()) {
285 updateFollowMeAnchor();