Skip to content

Commit

Permalink
Merge pull request rengwuxian#25 from hzsweers/master
Browse files Browse the repository at this point in the history
Use IntDef for float label modes to have lint and better IDE autocomplete support
  • Loading branch information
rengwuxian committed Nov 26, 2014
2 parents 4c18f94 + 46e404d commit 007c346
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Build;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Editable;
Expand All @@ -32,6 +33,9 @@
* <p/>
*/
public class MaterialAutoCompleteTextView extends AutoCompleteTextView {

@IntDef({FLOATING_LABEL_NONE, FLOATING_LABEL_NORMAL, FLOATING_LABEL_HIGHLIGHT})
public @interface FloatingLabelType {}
public static final int FLOATING_LABEL_NONE = 0;
public static final int FLOATING_LABEL_NORMAL = 1;
public static final int FLOATING_LABEL_HIGHLIGHT = 2;
Expand Down Expand Up @@ -421,7 +425,7 @@ private void setFloatingLabelInternal(int mode) {
}
}

public void setFloatingLabel(int mode) {
public void setFloatingLabel(@FloatingLabelType int mode) {
setFloatingLabelInternal(mode);
postInvalidate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.graphics.Paint;
import android.graphics.Typeface;
import android.os.Build;
import android.support.annotation.IntDef;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.Editable;
Expand All @@ -32,6 +33,9 @@
* <p/>
*/
public class MaterialEditText extends EditText {

@IntDef({FLOATING_LABEL_NONE, FLOATING_LABEL_NORMAL, FLOATING_LABEL_HIGHLIGHT})
public @interface FloatingLabelType {}
public static final int FLOATING_LABEL_NONE = 0;
public static final int FLOATING_LABEL_NORMAL = 1;
public static final int FLOATING_LABEL_HIGHLIGHT = 2;
Expand Down Expand Up @@ -420,7 +424,7 @@ private void setFloatingLabelInternal(int mode) {
}
}

public void setFloatingLabel(int mode) {
public void setFloatingLabel(@FloatingLabelType int mode) {
setFloatingLabelInternal(mode);
postInvalidate();
}
Expand Down

0 comments on commit 007c346

Please sign in to comment.