Skip to content

Commit 347c3f3

Browse files
authored
Merge pull request #18 from swapnil1104/hint_support
fixing NPE in OtpEditText
2 parents 2fe52b8 + 3441d10 commit 347c3f3

File tree

3 files changed

+1
-6
lines changed

3 files changed

+1
-6
lines changed

app/src/main/java/com/broooapps/otpedittext/MainActivity.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,15 @@ protected void onCreate(Bundle savedInstanceState) {
2121
setContentView(R.layout.activity_main);
2222

2323
otpEditText = findViewById(R.id.oev_view);
24-
2524
textDisplay = findViewById(R.id.text_display);
2625

27-
2826
otpEditText.setOnCompleteListener(new OnCompleteListener() {
2927
@SuppressLint("SetTextI18n")
3028
@Override
3129
public void onComplete(String value) {
3230
textDisplay.setText("Entered Value: " + value);
3331
}
3432
});
35-
36-
3733
}
3834

3935
public void displayText(View view) {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
android:digits="0123456789"
2626
android:maxLength="6"
2727
android:padding="32dp"
28-
android:hint="126786786"
2928
android:textSize="30sp"
3029
app:layout_constraintTop_toBottomOf="@+id/textView"
3130
app:oev_box_style="@string/style_rounded_underline"

otpedittext2/src/main/java/com/broooapps/otpedittext2/OtpEditText.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ protected void onDraw(Canvas canvas) {
228228
textWidths = new float[textLength];
229229

230230

231-
if (text.length() == 0 && !mHintText.isEmpty()) {
231+
if (text.length() == 0 && mHintText != null && !mHintText.isEmpty()) {
232232
getPaint().getTextWidths("1", 0, 1, hintWidth);
233233
for (int i = 0; i < mNumChars && i < mHintText.length(); i++) {
234234
float middle = hintStartX + mCharSize / 2;

0 commit comments

Comments
 (0)