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

Commit

Permalink
Add BarCanBeToggle attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
hadiidbouk committed Dec 6, 2017
1 parent 413b06b commit 3219a8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class ChartProgressBar extends FrameLayout {
private int mBarTitleSelectedColor;
private int mProgressDisableColor;
private OnBarClickedListener listener;
private boolean mBarCanBeToggle;

public ChartProgressBar(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
Expand Down Expand Up @@ -103,6 +104,7 @@ private void setAttrs(AttributeSet attrs, int defStyleAttr) {
mPinMarginStart = typedArray.getDimensionPixelSize(R.styleable.ChartProgressBar_hdPinMarginStart, 0);
mBarTitleMarginTop = typedArray.getDimensionPixelSize(R.styleable.ChartProgressBar_hdBarTitleMarginTop, 0);
mPinDrawable = typedArray.getResourceId(R.styleable.ChartProgressBar_hdPinDrawable, 0);
mBarCanBeToggle = typedArray.getBoolean(R.styleable.ChartProgressBar_hdBarCanBeToggle, false);
typedArray.recycle();
}

Expand Down Expand Up @@ -376,7 +378,8 @@ public void onClick(View view) {

FrameLayout frameLayout = (FrameLayout) view;

if (oldFrameLayout == frameLayout) {

if (oldFrameLayout == frameLayout && mBarCanBeToggle) {
if (isOldBarClicked)
clickBarOff(frameLayout);
else
Expand Down
1 change: 1 addition & 0 deletions charts/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
<attr name="hdPinMarginStart" format="dimension"/>
<attr name="hdPinDrawable" format="integer"/>
<attr name="hdBarTitleSelectedColor" format="color"/>
<attr name="hdBarCanBeToggle" format="boolean"/>
</declare-styleable>
</resources>
3 changes: 2 additions & 1 deletion sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
app:hdBarTitleMarginTop="9dp"
app:hdPinDrawable="@drawable/ic_pin"
app:hdProgressDisableColor="@color/progress_disable"
app:hdBarTitleSelectedColor="@color/bar_title_selected_color"/>
app:hdBarTitleSelectedColor="@color/bar_title_selected_color"
app:hdBarCanBeToggle="true"/>

<LinearLayout
android:layout_width="match_parent"
Expand Down

0 comments on commit 3219a8f

Please sign in to comment.