Skip to content

Commit ba76e35

Browse files
committed
2 parents 887fc7a + 0875c0b commit ba76e35

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

.idea/modules.xml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/build.gradle

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ android {
2020
}
2121

2222
dependencies {
23-
compile fileTree(include: ['*.jar'], dir: 'libs')
24-
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
23+
implementation fileTree(include: ['*.jar'], dir: 'libs')
24+
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
2525
exclude group: 'com.android.support', module: 'support-annotations'
2626
})
27-
compile 'com.android.support:appcompat-v7:28.1.1'
28-
compile 'com.android.support.constraint:constraint-layout:1.1.3'
29-
compile 'com.android.support:design:28.1.1'
27+
implementation 'com.android.support:appcompat-v7:27.1.1'
28+
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
29+
implementation 'com.android.support:design:27.1.1'
3030
// compile 'com.github.HITGIF:TextFieldBoxes:1.4.1'
31-
compile project(':textfieldboxes')
32-
testCompile 'junit:junit:4.12'
31+
implementation project(':textfieldboxes')
32+
testImplementation 'junit:junit:4.12'
3333
}

textfieldboxes/src/main/java/studio/carbonylgroup/textfieldboxes/TextFieldBoxes.java

+13-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import android.support.annotation.Nullable;
1212
import android.support.v4.content.ContextCompat;
1313
import android.support.v4.view.ViewCompat;
14-
import android.support.v4.widget.Space;
1514
import android.support.v4.widget.TextViewCompat;
1615
import android.support.v7.widget.AppCompatImageButton;
1716
import android.support.v7.widget.AppCompatTextView;
@@ -26,6 +25,7 @@
2625
import android.widget.EditText;
2726
import android.widget.FrameLayout;
2827
import android.widget.RelativeLayout;
28+
import android.widget.Space;
2929
import android.widget.TextView;
3030

3131
import java.lang.reflect.Field;
@@ -443,6 +443,9 @@ public void onFocusChange(View view, boolean b) {
443443
});
444444

445445
this.editText.addTextChangedListener(new TextWatcher() {
446+
447+
private String lastValue = "";
448+
446449
@Override
447450
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
448451
//do nothing
@@ -462,9 +465,16 @@ public void afterTextChanged(Editable editable) {
462465
} else {
463466
validate(); //this will call updateCounterText(true);
464467
}
465-
if (textChangeListener != null) {
466-
textChangeListener.onTextChanged(editable.toString(), onError);
468+
469+
// Only trigger simple watcher when the String actually changed
470+
471+
if (!lastValue.equals(editable.toString())){
472+
lastValue = editable.toString();
473+
if (textChangeListener != null) {
474+
textChangeListener.onTextChanged(editable.toString(), onError);
475+
}
467476
}
477+
468478
}
469479
});
470480

textfieldboxes/src/main/res/layout/text_field_boxes_layout.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
android:textSize="@dimen/label_text_size"
6767
tools:text="Label" />
6868

69-
<android.support.v4.widget.Space
69+
<android.widget.Space
7070
android:id="@+id/text_field_boxes_label_space"
7171
android:layout_width="wrap_content"
7272
android:layout_height="@dimen/label_space_height"
@@ -122,7 +122,7 @@
122122

123123
</FrameLayout>
124124

125-
<android.support.v4.widget.Space
125+
<android.widget.Space
126126
android:id="@+id/text_field_boxes_label_space_below"
127127
android:layout_width="wrap_content"
128128
android:layout_height="@dimen/label_space_height"

0 commit comments

Comments
 (0)