Skip to content

Commit

Permalink
fixed #issue1
Browse files Browse the repository at this point in the history
  • Loading branch information
fairytale110 committed May 4, 2019
1 parent a925a83 commit 7942d8b
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 91 deletions.
29 changes: 0 additions & 29 deletions .idea/codeStyles/Project.xml

This file was deleted.

16 changes: 13 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId rootProject.ext.android.applicationId
minSdkVersion rootProject.ext.android.sampleMinSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode 3
versionName "1.0.1"
versionCode 4
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
51 changes: 34 additions & 17 deletions app/src/main/java/tech/nicesky/bezierseekbardemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatTextView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;

import tech.nicesky.bezierseekbar.BezierSeekBar;
Expand All @@ -13,6 +15,11 @@
public class MainActivity extends AppCompatActivity {
AppCompatTextView txtStatus, txtStatus2;
LinearLayout fram;
private Button btnSetSValue;

BezierSeekBar seekBarInView;
BezierSeekBar seekBarCreated;
int max,min;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -22,12 +29,22 @@ protected void onCreate(Bundle savedInstanceState) {
txtStatus = findViewById(R.id.txt_statue);
txtStatus2 = findViewById(R.id.txt_statue2);
fram = findViewById(R.id.fram);
seekBarInView = findViewById(R.id.bsBar_test);
findViewById(R.id.btn_setValueSelected).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int value2Show = (int)(Math.random()*(max-min+1)+min);
seekBarInView.setValueSelected(value2Show);
seekBarCreated.setValueSelected(value2Show);
}
});

BezierSeekBar seekBar = findViewById(R.id.bsBar_test);
max = 150;
min = 20;

checkWeight(seekBar.getValueSelected());
checkWeight(seekBarInView.getValueSelected());

seekBar.setSelectedListener(new OnSelectedListener() {
seekBarInView.setSelectedListener(new OnSelectedListener() {
@Override
public void onSelected(int value) {
checkWeight(value);
Expand Down Expand Up @@ -60,26 +77,26 @@ private void checkLength(int value) {
private void createBsbar() {
fram.setBackgroundColor(Color.WHITE);

BezierSeekBar seekBar = new BezierSeekBar(this);
seekBar.setColorBall(Color.BLACK);
seekBar.setColorLine(Color.BLACK);
seekBar.setColorValueSelected(Color.WHITE);
seekBar.setColorValue(Color.BLACK);
seekBar.setColorBgSelected(Color.BLACK);
seekBar.setValueMax(150);
seekBar.setValueMin(20);
seekBar.setValueSelected(60);
seekBar.setUnit("mm");
seekBar.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

seekBar.setSelectedListener(new OnSelectedListener() {
seekBarCreated = new BezierSeekBar(this);
seekBarCreated.setColorBall(Color.BLACK);
seekBarCreated.setColorLine(Color.BLACK);
seekBarCreated.setColorValueSelected(Color.WHITE);
seekBarCreated.setColorValue(Color.BLACK);
seekBarCreated.setColorBgSelected(Color.BLACK);
seekBarCreated.setValueMax(150);
seekBarCreated.setValueMin(20);
seekBarCreated.setValueSelected(60);
seekBarCreated.setUnit("mm");
seekBarCreated.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

seekBarCreated.setSelectedListener(new OnSelectedListener() {
@Override
public void onSelected(int value) {
checkLength(value);
}
});

fram.addView(seekBar);
fram.addView(seekBarCreated);

//checkLength(seekBar.getValueSelected());
}
Expand Down
67 changes: 37 additions & 30 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,82 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:gravity="center_horizontal"
android:layout_height="match_parent"
android:background="#ef5350"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context=".MainActivity">

<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:text="你的体重是多少?"
android:textSize="30sp"
android:padding="10dp"
android:layout_height="wrap_content"
android:gravity="left"
android:textStyle="bold"
android:padding="10dp"
android:text="你的体重是多少?"
android:textColor="@android:color/white"
android:layout_height="wrap_content" />
android:textSize="30sp"
android:textStyle="bold" />

<android.support.v7.widget.AppCompatTextView
android:id="@+id/txt_statue"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="left"
android:text="balance"
android:textColor="@android:color/white"
android:layout_marginTop="20dp"
android:textSize="25sp"
android:gravity="left"
android:textStyle="italic"
android:layout_height="wrap_content" />
android:textStyle="italic" />

<tech.nicesky.bezierseekbar.BezierSeekBar
android:id="@+id/bsBar_test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:bsBar_color_ball="@android:color/white"
app:bsBar_color_bg_selected="@android:color/white"
app:bsBar_color_line="@android:color/white"
app:bsBar_color_value="@android:color/white"
app:bsBar_color_value_selected="#ef5350"
app:bsBar_value_min="30"
app:bsBar_value_max="120"
app:bsBar_value_selected="65"
app:bsBar_unit="kg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
app:bsBar_value_max="150"
app:bsBar_value_min="20"
app:bsBar_value_selected="65" />

<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@android:color/white"
android:gravity="left"
android:padding="10dp"
android:text="你的尺寸?"
android:textSize="30sp"
android:padding="10dp"
android:gravity="left"
android:background="@android:color/white"
android:textStyle="bold"
android:layout_marginTop="20dp"
android:layout_height="wrap_content" />
android:textStyle="bold" />

<android.support.v7.widget.AppCompatTextView
android:id="@+id/txt_statue2"
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:gravity="left"
android:padding="10dp"
android:text="balance"
android:textSize="25sp"
android:gravity="left"
android:background="@android:color/white"
android:textStyle="italic"
android:layout_height="wrap_content" />
android:textStyle="italic" />

<LinearLayout
android:id="@+id/fram"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:layout_height="0dp">
android:gravity="center">

</LinearLayout>

<Button
android:id="@+id/btn_setValueSelected"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="45dp"
android:text="Value random" />
</LinearLayout>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.4.0'


// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
5 changes: 3 additions & 2 deletions libBezierSeekBar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
defaultConfig {
minSdkVersion rootProject.ext.android.sampleMinSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode 3
versionName "1.0.1"
versionCode 4
versionName "1.0.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -30,4 +30,5 @@ dependencies {
//implementation 'com.android.support.constraint:constraint-layout:1.1.3'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:support-annotations:28.0.0'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tech.nicesky.bezierseekbar;

import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
Expand All @@ -13,7 +14,6 @@
import android.graphics.Typeface;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
Expand Down Expand Up @@ -117,13 +117,13 @@ public BezierSeekBar(Context context, @Nullable AttributeSet attrs, int defStyle
init(context, attrs);
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public BezierSeekBar(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context, attrs);
}


private void init(Context context, AttributeSet attrs) {
this.context = context;

Expand Down Expand Up @@ -492,6 +492,9 @@ public void setColorBgSelected(int colorBgSelected) {

public void setValueSelected(int valueSelected) {
this.valueSelected = valueSelected;
this.fingerXDefault = width * (float) (this.valueSelected - valueMin) / (float) (this.valueMax - this.valueMin);
this.fingerX = this.fingerXDefault;
postInvalidate();
}

public void setColorBall(int colorBall) {
Expand Down
Binary file modified release/app-release.apk
Binary file not shown.

0 comments on commit 7942d8b

Please sign in to comment.