Skip to content

Commit

Permalink
Improved valuebar, added drawing for min and max.
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilJay committed Oct 24, 2014
1 parent e7e3888 commit 42f68cc
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 82 deletions.
Binary file added ValueBarExample/libs/valuebarlibrary-1-0-0.jar
Binary file not shown.
1 change: 0 additions & 1 deletion ValueBarExample/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@

# Project target.
target=android-20
android.library.reference.1=../ValueBarLib
24 changes: 20 additions & 4 deletions ValueBarExample/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,56 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="40dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="40dp"
tools:context="com.philjay.valuebar.MainActivity" >

<com.philjay.valuebar.ValueBar
android:id="@+id/valueBar1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1" />

<com.philjay.valuebar.ValueBar
android:id="@+id/valueBar2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1" />

<com.philjay.valuebar.ValueBar
android:id="@+id/valueBar3"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1" />

<com.philjay.valuebar.ValueBar
android:id="@+id/valueBar4"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1" />

<com.philjay.valuebar.ValueBar
android:id="@+id/valueBar5"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="5dp"
android:layout_weight="1" />

</LinearLayout>
8 changes: 8 additions & 0 deletions ValueBarExample/res/menu/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@
android:id="@+id/animDown"
android:orderInCategory="100"
android:title="Animate Down"/>
<item
android:id="@+id/toggleMinMaxLabel"
android:orderInCategory="100"
android:title="Toggle MinMax Label"/>
<item
android:id="@+id/toggleValueLabel"
android:orderInCategory="100"
android:title="Toggle Value Label"/>

</menu>
37 changes: 29 additions & 8 deletions ValueBarExample/src/com/philjay/valuebarexample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ private void setup() {
bar.setMinMax(0, 1000);
bar.animate(0, 900, 1500);
bar.setDrawBorder(false);
bar.setOffset(3);
bar.setValueBarSelectionListener(this);
bar.setColorFormatter(new RedToGreenFormatter());
// bar.setColor(Color.BLUE);
// bar.setColor(Color.BLUE);
}
}

Expand All @@ -48,23 +47,39 @@ private void animateUp() {
for (ValueBar bar : mValueBars)
bar.animateUp(800, 1500);
}

private void animateDown() {

for (ValueBar bar : mValueBars)
bar.animateDown(0, 1500);
}


private void toggleMinMaxLabel() {

for (ValueBar bar : mValueBars) {
bar.setDrawMinMaxText(bar.isDrawMinMaxTextEnabled() ? false : true);
bar.invalidate();
}
}

private void toggleValueLabel() {

for (ValueBar bar : mValueBars) {
bar.setDrawValueText(bar.isDrawValueTextEnabled() ? false : true);
bar.invalidate();
}
}

@Override
public void onSelectionUpdate(float val, float maxval, float minval, ValueBar bar) {
Log.i("ValueBar", "Value selection update: " + val);
}

@Override
public void onValueSelected(float val, float maxval, float minval, ValueBar bar) {
Log.i("ValueBar", "Value selected: " + val);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
Expand All @@ -73,14 +88,20 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {

switch (item.getItemId()) {
case R.id.animUp:
animateUp();
break;
case R.id.animDown:
animateDown();
break;
case R.id.toggleMinMaxLabel:
toggleMinMaxLabel();
break;
case R.id.toggleValueLabel:
toggleValueLabel();
break;
}

return super.onOptionsItemSelected(item);
Expand Down
Loading

0 comments on commit 42f68cc

Please sign in to comment.