Skip to content

Commit

Permalink
support minSdkVersion 7
Browse files Browse the repository at this point in the history
fixed #4
  • Loading branch information
Lesilva committed Apr 10, 2015
1 parent e92b786 commit f0f5416
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ android {

defaultConfig {
applicationId "com.weiwangcn.betterspinner.sample"
minSdkVersion 15
minSdkVersion 7
targetSdkVersion 22
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION_NAME=1.0.4
VERSION_CODE=104
VERSION_NAME=1.0.5
VERSION_CODE=105
GROUP=com.weiwangcn.betterspinner

POM_DESCRIPTION=Android Spinner in a Better Design
Expand Down
2 changes: 1 addition & 1 deletion library-material/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "22.0.0"

defaultConfig {
minSdkVersion 15
minSdkVersion 7
targetSdkVersion 22
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class MaterialBetterSpinner extends MaterialAutoCompleteTextView {

private static final int MAX_CLICK_DURATION = 200;
private long startClickTime;
private boolean isPopup;

public MaterialBetterSpinner(Context context) {
super(context);
Expand Down Expand Up @@ -59,8 +60,14 @@ public boolean onTouchEvent(MotionEvent event) {
case MotionEvent.ACTION_UP: {
long clickDuration = Calendar.getInstance().getTimeInMillis() - startClickTime;
if (clickDuration < MAX_CLICK_DURATION) {
requestFocus();
showDropDown();
if (isPopup) {
dismissDropDown();
isPopup = false;
} else {
requestFocus();
showDropDown();
isPopup = true;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ android {
buildToolsVersion "21.1.2"

defaultConfig {
minSdkVersion 15
minSdkVersion 7
targetSdkVersion 22
versionName project.VERSION_NAME
versionCode Integer.parseInt(project.VERSION_CODE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class BetterSpinner extends AutoCompleteTextView {

private static final int MAX_CLICK_DURATION = 200;
private long startClickTime;
private boolean isPopup;

public BetterSpinner(Context context) {
super(context);
Expand Down Expand Up @@ -58,8 +59,14 @@ public boolean onTouchEvent(MotionEvent event) {
case MotionEvent.ACTION_UP: {
long clickDuration = Calendar.getInstance().getTimeInMillis() - startClickTime;
if (clickDuration < MAX_CLICK_DURATION) {
requestFocus();
showDropDown();
if (isPopup) {
dismissDropDown();
isPopup = false;
} else {
requestFocus();
showDropDown();
isPopup = true;
}
}
}
}
Expand Down

0 comments on commit f0f5416

Please sign in to comment.