Skip to content

Commit

Permalink
#17570: Fixed widget dots flickering
Browse files Browse the repository at this point in the history
  • Loading branch information
Corwin-Kh committed Jul 27, 2023
1 parent 65bc393 commit 66b82b9
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions OsmAnd/src/net/osmand/plus/views/controls/SideWidgetsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,27 @@ private void updateDots() {
int dotsBackgroundId = nightMode ? R.color.icon_color_secondary_dark : R.color.divider_color_light;
dots.setBackgroundResource(dotsBackgroundId);

dots.removeAllViews();

for (int i = 0; i < pagesCount; i++) {
ImageView dot = new ImageView(getContext());
int dp3 = AndroidUtils.dpToPx(getContext(), 3);
MarginLayoutParams dotParams = new ViewGroup.MarginLayoutParams(dp3, dp3);
AndroidUtils.setMargins(dotParams, dp3, 0, dp3, 0);
dot.setLayoutParams(dotParams);

boolean currentPage = i == viewPager.getCurrentItem();
int dotColor = getDotColorId(currentPage);
dot.setImageDrawable(getIconsCache().getIcon(R.drawable.ic_dot_position, dotColor));
dots.addView(dot);
if (dots.getChildCount() != pagesCount) {
dots.removeAllViews();
for (int i = 0; i < pagesCount; i++) {
ImageView dot = new ImageView(getContext());
int dp3 = AndroidUtils.dpToPx(getContext(), 3);
MarginLayoutParams dotParams = new ViewGroup.MarginLayoutParams(dp3, dp3);
AndroidUtils.setMargins(dotParams, dp3, 0, dp3, 0);
dot.setLayoutParams(dotParams);
int dotColor = getDotColorId(i == viewPager.getCurrentItem());
dot.setImageDrawable(getIconsCache().getIcon(R.drawable.ic_dot_position, dotColor));
dots.addView(dot);
}
} else {
for (int i = 0; i < dots.getChildCount(); i++) {
View childView = dots.getChildAt(i);
if (childView instanceof ImageView) {
ImageView dot = (ImageView) childView;
int dotColor = getDotColorId(i == viewPager.getCurrentItem());
dot.setImageDrawable(getIconsCache().getIcon(R.drawable.ic_dot_position, dotColor));
}
}
}
}

Expand Down

0 comments on commit 66b82b9

Please sign in to comment.