Skip to content

Commit 95fce81

Browse files
author
huangshouguo
committed
fix bugs: setting invalidate
1 parent f202a80 commit 95fce81

20 files changed

+270
-624
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ android {
3535

3636
dependencies {
3737
implementation fileTree(dir: 'libs', include: ['*.jar'])
38-
// implementation project(':library')
39-
implementation "com.github.ihsg:PatternLocker:$rootProject.ext.versionName"
38+
implementation project(':library')
39+
// implementation "com.github.ihsg:PatternLocker:$rootProject.ext.versionName"
4040

4141
implementation "com.android.support:appcompat-v7:$rootProject.ext.supportLibraryVersion"
4242
implementation "com.android.support.constraint:constraint-layout:$rootProject.ext.constraintLayoutVersion"

app/src/main/java/com/github/ihsg/demo/ui/def/DefaultPatternSettingActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ import com.github.ihsg.demo.util.PatternHelper
1010
import com.github.ihsg.patternlocker.OnPatternChangeListener
1111
import com.github.ihsg.patternlocker.PatternLockerView
1212
import kotlinx.android.synthetic.main.activity_default_pattern_checking.*
13+
import java.util.*
1314

1415
class DefaultPatternSettingActivity : AppCompatActivity() {
1516
private var patternHelper: PatternHelper? = null
1617

1718
override fun onCreate(savedInstanceState: Bundle?) {
1819
super.onCreate(savedInstanceState)
1920
setContentView(R.layout.activity_default_pattern_setting)
21+
patternIndicatorView.updateState(Arrays.asList(1, 2), false)
2022

2123
patternLockerView.setOnPatternChangedListener(object : OnPatternChangeListener {
2224
override fun onStart(view: PatternLockerView) {}

app/src/main/java/com/github/ihsg/demo/ui/simple/SimplePatternCheckingActivity.kt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.util.TypedValue
99

1010
import com.github.ihsg.demo.R
1111
import com.github.ihsg.demo.util.PatternHelper
12+
import com.github.ihsg.patternlocker.DefaultLockerNormalCellView
1213
import com.github.ihsg.patternlocker.OnPatternChangeListener
1314
import com.github.ihsg.patternlocker.PatternLockerView
1415
import kotlinx.android.synthetic.main.activity_default_pattern_checking.*
@@ -21,21 +22,21 @@ class SimplePatternCheckingActivity : AppCompatActivity() {
2122
super.onCreate(savedInstanceState)
2223
setContentView(R.layout.activity_simple_pattern_checking)
2324

24-
this.patternIndicatorView!!.setFillColor(ContextCompat.getColor(this, R.color.color_blue))
25-
.setNormalColor(ContextCompat.getColor(this, R.color.colorWhite))
26-
.setHitColor(ContextCompat.getColor(this, R.color.colorPrimaryDark))
27-
.setErrorColor(ContextCompat.getColor(this, R.color.color_red))
28-
.setLineWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2f,
29-
resources.displayMetrics))
30-
.buildWithDefaultStyle()
31-
32-
this.patternLockerView!!.setFillColor(ContextCompat.getColor(this, R.color.color_blue))
33-
.setNormalColor(ContextCompat.getColor(this, R.color.colorWhite))
34-
.setHitColor(ContextCompat.getColor(this, R.color.colorPrimaryDark))
35-
.setErrorColor(ContextCompat.getColor(this, R.color.color_red))
36-
.setLineWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5f,
37-
resources.displayMetrics))
38-
.buildWithDefaultStyle()
25+
val pivStyle = (this.patternIndicatorView.normalCellView as DefaultLockerNormalCellView).styleDecorator
26+
pivStyle.normalColor = ContextCompat.getColor(this, R.color.colorWhite)
27+
pivStyle.fillColor = ContextCompat.getColor(this, R.color.color_blue)
28+
pivStyle.hitColor = ContextCompat.getColor(this, R.color.colorPrimaryDark)
29+
pivStyle.errorColor = ContextCompat.getColor(this, R.color.color_red)
30+
pivStyle.lineWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2f,
31+
resources.displayMetrics)
32+
33+
val plvStyle = (this.patternLockerView.normalCellView as DefaultLockerNormalCellView).styleDecorator
34+
plvStyle.normalColor = ContextCompat.getColor(this, R.color.colorWhite)
35+
plvStyle.fillColor = ContextCompat.getColor(this, R.color.color_blue)
36+
plvStyle.hitColor = ContextCompat.getColor(this, R.color.colorPrimaryDark)
37+
plvStyle.errorColor = ContextCompat.getColor(this, R.color.color_red)
38+
plvStyle.lineWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5f,
39+
resources.displayMetrics)
3940

4041
this.patternLockerView!!.setOnPatternChangedListener(object : OnPatternChangeListener {
4142
override fun onStart(view: PatternLockerView) {}

app/src/main/java/com/github/ihsg/demo/ui/whole/WholePatternCheckingActivity.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import android.support.v4.content.ContextCompat
77
import android.support.v7.app.AppCompatActivity
88
import com.github.ihsg.demo.R
99
import com.github.ihsg.demo.util.PatternHelper
10+
import com.github.ihsg.patternlocker.DefaultLockerNormalCellView
1011
import com.github.ihsg.patternlocker.OnPatternChangeListener
1112
import com.github.ihsg.patternlocker.PatternLockerView
1213
import kotlinx.android.synthetic.main.activity_simple_pattern_checking.*
@@ -19,12 +20,11 @@ class WholePatternCheckingActivity : AppCompatActivity() {
1920
super.onCreate(savedInstanceState)
2021
setContentView(R.layout.activity_whole_pattern_checking)
2122

22-
val hitCellView = RippleLockerHitCellView()
23-
.setHitColor(this.patternLockerView.getHitColor())
24-
.setErrorColor(this.patternLockerView.getErrorColor())
23+
val decorator = (this.patternLockerView.normalCellView as DefaultLockerNormalCellView).styleDecorator
2524

26-
this.patternLockerView.setHitCellView(hitCellView)
27-
.build()
25+
this.patternLockerView.hitCellView = RippleLockerHitCellView()
26+
.setHitColor(decorator.hitColor)
27+
.setErrorColor(decorator.errorColor)
2828

2929
this.patternLockerView.setOnPatternChangedListener(object : OnPatternChangeListener {
3030
override fun onStart(view: PatternLockerView) {}

app/src/main/java/com/github/ihsg/demo/ui/whole/WholePatternSettingActivity.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import android.support.v7.app.AppCompatActivity
88
import android.view.View
99
import com.github.ihsg.demo.R
1010
import com.github.ihsg.demo.util.PatternHelper
11+
import com.github.ihsg.patternlocker.DefaultLockerNormalCellView
1112
import com.github.ihsg.patternlocker.OnPatternChangeListener
1213
import com.github.ihsg.patternlocker.PatternLockerView
1314
import kotlinx.android.synthetic.main.activity_simple_pattern_checking.*
@@ -20,13 +21,12 @@ class WholePatternSettingActivity : AppCompatActivity() {
2021
super.onCreate(savedInstanceState)
2122
setContentView(R.layout.activity_whole_pattern_setting)
2223

23-
val hitCellView = RippleLockerHitCellView()
24-
.setHitColor(this.patternLockerView!!.getHitColor())
25-
.setErrorColor(this.patternLockerView!!.getErrorColor())
26-
27-
this.patternLockerView!!.setHitCellView(hitCellView)
28-
.build()
24+
val decorator = (this.patternLockerView.normalCellView as DefaultLockerNormalCellView).styleDecorator
2925

26+
this.patternLockerView.hitCellView = RippleLockerHitCellView()
27+
.setHitColor(decorator.hitColor)
28+
.setErrorColor(decorator.errorColor)
29+
3030
this.patternLockerView!!.setOnPatternChangedListener(object : OnPatternChangeListener {
3131
override fun onStart(view: PatternLockerView) {}
3232

app/src/main/res/layout/activity_whole_pattern_setting.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
android:layout_marginLeft="50dp"
4141
android:layout_marginTop="20dp"
4242
android:layout_marginRight="50dp"
43-
app:plv_canSkip="true"
43+
app:plv_enableSkip="true"
4444
app:plv_enableHapticFeedback="true"
4545
app:plv_color="@color/color_gray"
4646
app:plv_enableAutoClean="false"

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
// versions
66
ext {
77
versionCode = 14
8-
versionName = '2.4.5'
8+
versionName = '2.5.0'
99

1010
minSdkVersion = 15
1111
targetSdkVersion = 28
@@ -23,7 +23,7 @@ buildscript {
2323
}
2424

2525
dependencies {
26-
classpath 'com.android.tools.build:gradle:3.3.2'
26+
classpath 'com.android.tools.build:gradle:3.4.0'
2727
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
2828
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
2929

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Thu Nov 01 10:15:42 CST 2018
1+
#Fri Apr 19 11:09:52 CST 2019
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

library/src/main/java/com/github/ihsg/patternlocker/CellBean.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@ package com.github.ihsg.patternlocker
22

33
/**
44
* Created by hsg on 20/09/2017.
5+
*
6+
* @param id each cell id order like this:
7+
*
8+
* 0 1 2
9+
* 3 4 5
10+
* 6 7 8
11+
*
12+
* @param x
13+
* @param y
14+
* @param radius
15+
* @param isHit
516
*/
6-
717
class CellBean(val id: Int, val x: Float, val y: Float, val radius: Float) {
818
var isHit: Boolean = false
919

@@ -24,5 +34,4 @@ class CellBean(val id: Int, val x: Float, val y: Float, val radius: Float) {
2434
override fun toString(): String {
2535
return "CellBean(id=$id, x=$x, y=$y, radius=$radius, isHit=$isHit)"
2636
}
27-
2837
}

library/src/main/java/com/github/ihsg/patternlocker/Config.kt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,20 @@ internal object Config {
1919
const val defaultFreezeDuration = 1000//ms
2020
const val defaultEnableAutoClean = true
2121
const val defaultEnableHapticFeedback = false
22-
const val defaultCanSkip = false
22+
const val defaultEnableSkip = false
2323
const val defaultEnableLogger = false
2424

25-
val defaultNormalColor: Int
26-
@ColorInt
27-
get() = Color.parseColor(DEFAULT_NORMAL_COLOR)
25+
@ColorInt
26+
val defaultNormalColor: Int = Color.parseColor(DEFAULT_NORMAL_COLOR)
2827

29-
val defaultHitColor: Int
30-
@ColorInt
31-
get() = Color.parseColor(DEFAULT_HIT_COLOR)
28+
@ColorInt
29+
val defaultHitColor: Int = Color.parseColor(DEFAULT_HIT_COLOR)
3230

33-
val defaultErrorColor: Int
34-
@ColorInt
35-
get() = Color.parseColor(DEFAULT_ERROR_COLOR)
31+
@ColorInt
32+
val defaultErrorColor: Int = Color.parseColor(DEFAULT_ERROR_COLOR)
3633

37-
val defaultFillColor: Int
38-
@ColorInt
39-
get() = Color.parseColor(DEFAULT_FILL_COLOR)
34+
@ColorInt
35+
val defaultFillColor: Int = Color.parseColor(DEFAULT_FILL_COLOR)
4036

4137
fun getDefaultLineWidth(resources: Resources): Float {
4238
return convertDpToPx(DEFAULT_LINE_WIDTH.toFloat(), resources)

0 commit comments

Comments
 (0)