From d44682b77f015ec7af81e9a9c618935ac5f4620d Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Thu, 16 Apr 2015 20:20:13 -0500 Subject: [PATCH] Fix for #7 --- gradle.properties | 4 ++-- .../library/material/MaterialBetterSpinner.java | 16 ++++++++++++---- .../betterspinner/library/BetterSpinner.java | 15 +++++++++++---- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index a2886f4..dcf23b5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -VERSION_NAME=1.0.6 -VERSION_CODE=106 +VERSION_NAME=1.0.7 +VERSION_CODE=107 GROUP=com.weiwangcn.betterspinner POM_DESCRIPTION=Android Spinner in a Better Design diff --git a/library-material/src/main/java/com/weiwangcn/betterspinner/library/material/MaterialBetterSpinner.java b/library-material/src/main/java/com/weiwangcn/betterspinner/library/material/MaterialBetterSpinner.java index bb3f821..a40a2f4 100644 --- a/library-material/src/main/java/com/weiwangcn/betterspinner/library/material/MaterialBetterSpinner.java +++ b/library-material/src/main/java/com/weiwangcn/betterspinner/library/material/MaterialBetterSpinner.java @@ -4,16 +4,16 @@ import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; +import android.view.View; import android.view.inputmethod.InputMethodManager; +import android.widget.AdapterView; import com.rengwuxian.materialedittext.MaterialAutoCompleteTextView; import java.util.Calendar; -/** - * Created by Wei on 2015/3/23. - */ -public class MaterialBetterSpinner extends MaterialAutoCompleteTextView { + +public class MaterialBetterSpinner extends MaterialAutoCompleteTextView implements AdapterView.OnItemClickListener { private static final int MAX_CLICK_DURATION = 200; private long startClickTime; @@ -21,14 +21,17 @@ public class MaterialBetterSpinner extends MaterialAutoCompleteTextView { public MaterialBetterSpinner(Context context) { super(context); + setOnItemClickListener(this); } public MaterialBetterSpinner(Context arg0, AttributeSet arg1) { super(arg0, arg1); + setOnItemClickListener(this); } public MaterialBetterSpinner(Context arg0, AttributeSet arg1, int arg2) { super(arg0, arg1, arg2); + setOnItemClickListener(this); } @Override @@ -77,4 +80,9 @@ public boolean onTouchEvent(MotionEvent event) { return super.onTouchEvent(event); } + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + isPopup = false; + } + } diff --git a/library/src/main/java/com/weiwangcn/betterspinner/library/BetterSpinner.java b/library/src/main/java/com/weiwangcn/betterspinner/library/BetterSpinner.java index 5963c45..76290ed 100644 --- a/library/src/main/java/com/weiwangcn/betterspinner/library/BetterSpinner.java +++ b/library/src/main/java/com/weiwangcn/betterspinner/library/BetterSpinner.java @@ -4,15 +4,14 @@ import android.graphics.Rect; import android.util.AttributeSet; import android.view.MotionEvent; +import android.view.View; import android.view.inputmethod.InputMethodManager; +import android.widget.AdapterView; import android.widget.AutoCompleteTextView; import java.util.Calendar; -/** - * Created by Wei on 2015/3/23. - */ -public class BetterSpinner extends AutoCompleteTextView { +public class BetterSpinner extends AutoCompleteTextView implements AdapterView.OnItemClickListener { private static final int MAX_CLICK_DURATION = 200; private long startClickTime; @@ -20,14 +19,17 @@ public class BetterSpinner extends AutoCompleteTextView { public BetterSpinner(Context context) { super(context); + setOnItemClickListener(this); } public BetterSpinner(Context arg0, AttributeSet arg1) { super(arg0, arg1); + setOnItemClickListener(this); } public BetterSpinner(Context arg0, AttributeSet arg1, int arg2) { super(arg0, arg1, arg2); + setOnItemClickListener(this); } @Override @@ -76,4 +78,9 @@ public boolean onTouchEvent(MotionEvent event) { return super.onTouchEvent(event); } + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + isPopup = false; + } + }