Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
Add selectBar and deselectBar methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hadiidbouk committed Dec 6, 2017
1 parent bdadc1d commit 54f13b8
Showing 1 changed file with 44 additions and 1 deletion.
45 changes: 44 additions & 1 deletion charts/src/main/java/com/hadiidbouk/charts/ChartProgressBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void build() {
Drawable d = getResources().getDrawable(mPinDrawable);
int h = d.getIntrinsicHeight();

if(mPinMarginBottom != 0)
if (mPinMarginBottom != 0)
h += mPinMarginBottom / 2;

linearLayout.setPadding(0, h, 0, 0);
Expand Down Expand Up @@ -681,4 +681,47 @@ public void enableBar(int index) {
}
}
}

public void selectBar(int index) {

final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

for (int i = 0; i < barsCount; i++) {

FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

int rootChildCount = rootFrame.getChildCount();

for (int j = 0; j < rootChildCount; j++) {

if ((int) rootFrame.getTag() != index)
continue;

if (oldFrameLayout != null)
clickBarOff(oldFrameLayout);

clickBarOn(rootFrame);
oldFrameLayout = rootFrame;
}
}
}

public void deselectBar(int index) {
final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

for (int i = 0; i < barsCount; i++) {

FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

int rootChildCount = rootFrame.getChildCount();

for (int j = 0; j < rootChildCount; j++) {

if ((int) rootFrame.getTag() != index)
continue;

clickBarOff(rootFrame);
}
}
}
}

0 comments on commit 54f13b8

Please sign in to comment.