Skip to content

Commit

Permalink
Fix ScCopier not closing arc
Browse files Browse the repository at this point in the history
  • Loading branch information
paroca72 committed Jun 20, 2019
1 parent 5b0c2de commit f52ceb2
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 39 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Add the dependency
```java
dependencies {
...
compile 'com.github.paroca72:sc-gauges:3.2.0'
compile 'com.github.paroca72:sc-gauges:3.2.1'
}
```
<br />
Expand Down
2 changes: 2 additions & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/apk_list" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundle_manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check_manifest_result" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/compatible_screen_manifest" />
Expand Down Expand Up @@ -120,6 +121,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/signing_config" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/split-apk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/validate_signing_config" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
Expand Down
31 changes: 1 addition & 30 deletions app/src/main/java/com/sccomponents/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,10 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

// Find the components
final ScArcGauge gauge = (ScArcGauge) this.findViewById(R.id.gauge);
final ScArcGauge gauge = this.findViewById(R.id.gauge);
assert gauge != null;

ScCopier base = gauge.getBase();
base.setColors(Color.parseColor("#ff0000"));
base.setWidths(100);

ScCopier progress = gauge.getProgress();
progress.setWidths(100);
progress.setColors(Color.parseColor("#00ff00"));

ScNotches notches = gauge.getNotches();
notches.setRepetitions(11);
notches.setWidths(10);
notches.setHeights(10);
notches.setColors(Color.parseColor("#000000"));
notches.setPosition(ScFeature.Positions.MIDDLE);
gauge.bringOnTop(notches);

ScLabeler labeler = gauge.getLabeler();
labeler.setVisible(true);
labeler.setBending(true);
labeler.setLetterSpacing(0.3f);
//labeler.setBackground(Color.parseColor("#ffff00"));
labeler.getPainter().setTextSize(60);
labeler.getPainter().setTextAlign(Paint.Align.RIGHT);
labeler.setPosition(ScFeature.Positions.MIDDLE);
labeler.setFormat("0");

gauge.setAngleStart(0);
gauge.setAngleSweep(270);
gauge.setHighValue(10);
//gauge.setPadding(30, 30, 30, 30);
}

}
21 changes: 16 additions & 5 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,31 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:sc="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:gravity="center_vertical|center_horizontal">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent"
android:background="#000000">

<com.sccomponents.gauges.library.ScArcGauge
android:id="@+id/gauge"
xmlns:sc="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="50dp" />
android:layout_marginTop="50dp"
android:padding="10dp"
app:scPathTouchable="true"
app:sccAngleStart="270"
app:sccNotchesHeight="10dp"
app:sccNotchesWidth="10dp"
app:sccProgressColor="#3DB8B7"
app:sccProgressRoundedCap="true"
app:sccProgressWidth="8dp"
app:sccSnapToNotches="true"
app:sccStrokeColor="#f5f5f5"
app:sccStrokeWidth="20dp"
/>

</FrameLayout>

Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 550
versionName '3.2.0'
versionCode 551
versionName '3.2.1'
}
buildTypes {
release {
Expand Down
1 change: 1 addition & 0 deletions library/library.iml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/runtime_library_classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shader_assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,16 @@ private void cloneSourcePath(Path path, float startFrom, float endTo) {
}

// Clone the source path adjusting the y position
for (float distance = fixedStart; distance < fixedEnd; distance++) {
float distance = fixedStart;
boolean running = true;

while (running) {
// Check for exit
if (distance > fixedEnd) {
distance = fixedEnd;
running = false;
}

// Fix the distance as the return way check is different and
// calculate the right point position on the path.
float fixedDistance = isReturn ? startFrom - distance : distance;
Expand All @@ -172,6 +181,9 @@ private void cloneSourcePath(Path path, float startFrom, float endTo) {
else
// Draw a line
path.lineTo(this.mFirstPoint[0], this.mFirstPoint[1]);

// Next step
distance ++;
}

// Conjunction with arc
Expand Down

0 comments on commit f52ceb2

Please sign in to comment.