Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
alguojian committed Jul 13, 2020
1 parent b5fe011 commit 2ba9d04
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion .idea/misc.xml

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

2 changes: 1 addition & 1 deletion app/src/main/java/com/alguojian/example/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MainActivity : AppCompatActivity() {
seekBar.progress = 50
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
heightColorImageView.setProgress(progress / 100.toFloat())
heightColorImageView.setProgress(progress / 100.toDouble())
}

override fun onStartTrackingTouch(seekBar: SeekBar?) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
android:layout_height="300dp"
android:layout_marginTop="30dp"
android:src="@mipmap/aaa"
percentage="@{0.8f}"/>
percentage="@{0.83}"/>

<com.alguojian.view.HeightColorImageView
android:layout_width="200dp"
Expand Down
4 changes: 2 additions & 2 deletions round-imageview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionCode 122
versionName "1.2.2"
versionCode 123
versionName "1.2.3"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HeightColorImageView @JvmOverloads constructor(context: Context, attrs: At
private lateinit var mBitmapPaint: Paint
private var mContext: Context? = null
private lateinit var mMatrix: Matrix
private var percentage = 0.5f
private var percentage = 0.00

private lateinit var paint: Paint

Expand Down Expand Up @@ -57,7 +57,7 @@ class HeightColorImageView @JvmOverloads constructor(context: Context, attrs: At

if (bb != 0) {
val createBitmap2 = Bitmap.createBitmap(bmp, 0, aa, bmp.width, bb, mMatrix, false)
canvas.drawBitmap(createBitmap2, 0f, height * (1.0f - percentage), paint)
canvas.drawBitmap(createBitmap2, 0f, height * (1.00 - percentage).toFloat(), paint)
createBitmap2.recycle()
}
createBitmap.recycle()
Expand Down Expand Up @@ -87,7 +87,7 @@ class HeightColorImageView @JvmOverloads constructor(context: Context, attrs: At
/**
* 设置高度灰色的占比,百分比
*/
fun setProgress(percentage: Float) {
fun setProgress(percentage: Double) {
this.percentage = percentage
invalidate()
}
Expand All @@ -101,7 +101,7 @@ class HeightColorImageView @JvmOverloads constructor(context: Context, attrs: At

@JvmStatic
@BindingAdapter(value = ["percentage"])
fun HeightColorImageView.setFloat(float: Float = 0.0f) {
fun HeightColorImageView.setFloat(float: Double = 0.00) {
this.percentage = float
}
}
Expand Down

0 comments on commit 2ba9d04

Please sign in to comment.