Skip to content

Commit

Permalink
Release v1.5.0:
Browse files Browse the repository at this point in the history
- Improve on return type
- Added new method to hide dropdown item with specific position
  • Loading branch information
Chivorns committed Apr 16, 2021
1 parent 3579f27 commit 401fe52
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ The best Android spinner library for your android application with more customiz

```gradle
dependencies {
implementation 'com.github.chivorns:smartmaterialspinner:1.4.0'
implementation 'com.github.chivorns:smartmaterialspinner:1.5.0'
}
```

Expand Down
4 changes: 2 additions & 2 deletions smartmaterialspinner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ext {
LIBRARY_NAME = 'SmartMaterialSpinner'
PUBLISH_GROUP_ID = 'com.github.chivorns'
PUBLISH_ARTIFACT_ID = LIBRARY_NAME.toLowerCase()
PUBLISH_VERSION = '1.4.0'
PUBLISH_VERSION = '1.5.0'

// Bintray
BINTRAY_REPO = 'maven'
Expand All @@ -32,7 +32,7 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 29
versionCode 24
versionCode 25
versionName "$PUBLISH_VERSION"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public class SmartMaterialSpinner<T> extends AppCompatSpinner implements Adapter
private boolean isReSelectable = false;
private boolean isOnItemSelectedListenerOverride;
private boolean dropdownHeightUpdated = false;
private int hiddenItemPosition = -1;

/*
* **********************************************************************************
Expand Down Expand Up @@ -1007,6 +1008,11 @@ public void clearSelection() {
setSelection(-1);
}

public void setHiddenItemPosition(int hiddenItemPosition) {
this.hiddenItemPosition = hiddenItemPosition;
invalidate();
}

@Override
public void setSelected(boolean selected) {
isSelected = selected;
Expand Down Expand Up @@ -2092,9 +2098,7 @@ private void updateSpinnerItemStyle(ViewGroup parent, TextView textView, boolean
textView.setBackgroundColor(itemListHintBackground);
textView.setPadding(textView.getPaddingLeft(), dpToPx(12), textView.getPaddingRight(), dpToPx(12));
} else {
textView.setHeight(0);
textView.setMinHeight(0);
textView.setMinimumHeight(0);
hideTextView(textView);
}
} else {
if (isOutlined) {
Expand All @@ -2113,6 +2117,9 @@ private void updateSpinnerItemStyle(ViewGroup parent, TextView textView, boolean
if (position >= 0 && position == getSelectedItemPosition()) {
textView.setTextColor(selectedItemListColor);
}
if (hiddenItemPosition != -1 && position == hiddenItemPosition) {
hideTextView(textView);
}
} else {
int outlinedPaddingStart = 0;
if (isOutlined) {
Expand All @@ -2125,6 +2132,12 @@ private void updateSpinnerItemStyle(ViewGroup parent, TextView textView, boolean
}
}
}

private void hideTextView(TextView textView) {
textView.setHeight(0);
textView.setMinHeight(0);
textView.setMinimumHeight(0);
}
}

/**
Expand Down

0 comments on commit 401fe52

Please sign in to comment.