Skip to content

Commit

Permalink
Release v1.1.4 : Fix onItemSelected call twice when call setSelection…
Browse files Browse the repository at this point in the history
… inside of thread
  • Loading branch information
Chivorns committed Jul 12, 2019
1 parent 0259bc5 commit 6a20fad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ The best Android spinner library for your android application with more customiz

```gradle
dependencies {
implementation 'com.github.chivorns:smartmaterialspinner:1.1.3'
implementation 'com.github.chivorns:smartmaterialspinner:1.1.4'
}
```

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.1.3'
PUBLISH_VERSION = '1.1.4'

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

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,24 +794,17 @@ public void setSelection(int position) {
if (isShowing && !isSearchable && hint != null) {
position -= 1;
}
final int finalPosition = position;
this.post(new Runnable() {
@Override
public void run() {
SmartMaterialSpinner.super.setSelection(hint != null ? finalPosition + 1 : finalPosition);
checkReSelectable(finalPosition);
}
});
SmartMaterialSpinner.super.setSelection(hint != null ? position + 1 : position);
checkReSelectable(position);
}

@Override
public void setSelection(int position, boolean animate) {
if (isShowing && !isSearchable && hint != null) {
position -= 1;
}
final int finalPosition = position;
super.setSelection(hint != null ? finalPosition + 1 : finalPosition, animate);
checkReSelectable(finalPosition);
super.setSelection(hint != null ? position + 1 : position, animate);
checkReSelectable(position);
}

public void clearSelection() {
Expand Down

0 comments on commit 6a20fad

Please sign in to comment.