Skip to content

Commit

Permalink
add AlertNumberPickerDialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
shaoshuai904 committed Dec 6, 2018
1 parent f98bb01 commit 11c5f2d
Show file tree
Hide file tree
Showing 23 changed files with 495 additions and 181 deletions.
36 changes: 0 additions & 36 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

8 changes: 6 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion '28.0.2'
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "com.maple.iosdialog"
minSdkVersion 19
targetSdkVersion 26
versionCode 10
versionName "1.2.1"
targetSdkVersion 28
versionCode 11
versionName "1.2.2"
}
buildTypes {
release {
Expand Down
28 changes: 28 additions & 0 deletions app/src/main/java/com/maple/iosdialog/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.NumberPicker;
import android.widget.Toast;

import com.maple.msdialog.ActionSheetDialog;
import com.maple.msdialog.AlertDialog;
import com.maple.msdialog.AlertEditDialog;
import com.maple.msdialog.AlertNumberPickerDialog;

/**
* Custom Dialog Demo
Expand Down Expand Up @@ -226,6 +228,32 @@ public void callBack(String str) {
.show();
}

// --------------------------------- Number Picker Dialog -----------------------------------------
String[] city = {"北京", "上海", "天津", "杭州", "苏州", "深圳"};
String curSelect = city[0];

public void npOne(View view) {
new AlertNumberPickerDialog(mContext)
.setScaleWidth(0.8)
.setCancelable(false)
.setTitle("选择城市")
.setNumberValues(city, 2, new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
curSelect = city[newVal];
}
})
.setNumberValueSuffix("市")
.setLeftButton("Cancel", null)
.setRightButton("OK", new View.OnClickListener() {
@Override
public void onClick(View v) {
showToast(curSelect);
}
})
.show();

}
// ----------------------------------- other methods -------------------------------------------

private void showToast(String msg) {
Expand Down
42 changes: 28 additions & 14 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,72 +1,86 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:text="Action Sheet Dialog"
android:textSize="18sp"/>
android:textSize="18sp" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="asMessage"
android:text="消息"/>
android:text="消息" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="asImage"
android:text="图片"/>
android:text="图片" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="asList"
android:text="列表"/>
android:text="列表" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:text="Alert Dialog"
android:textSize="18sp"/>
android:textSize="18sp" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="adOne"
android:text="常规"/>
android:text="常规" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="adTwo"
android:text="极简"/>
android:text="极简" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:text="Alert Edit Dialog"
android:textSize="18sp"/>
android:textSize="18sp" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="aeOne"
android:text="文本输入"/>
android:text="文本输入" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="aeTwo"
android:text="极简"/>
android:text="极简" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center"
android:text="Number Picker Dialog"
android:textSize="18sp" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="npOne"
android:text="数字选择" />
</LinearLayout>
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.2.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
12 changes: 6 additions & 6 deletions msdialog/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 26
buildToolsVersion '28.0.2'
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 5
versionName "1.2.1"
targetSdkVersion 28
versionCode 6
versionName "1.2.2"
}
buildTypes {
release {
Expand All @@ -20,5 +20,5 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
}
10 changes: 1 addition & 9 deletions msdialog/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<manifest package="com.maple.msdialog"
xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">

</application>
<manifest package="com.maple.msdialog">

</manifest>
8 changes: 4 additions & 4 deletions msdialog/src/main/java/com/maple/msdialog/AlertDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public AlertDialog setRightButton(String text, final OnClickListener listener) {
public AlertDialog setRightButton(String text, int color, int size, boolean isBold, final OnClickListener listener) {
showRightBtn = true;
if (TextUtils.isEmpty(text)) {
rightButton.setText("OK");
rightButton.setText(R.string.ok);
} else {
rightButton.setText(text);
}
Expand Down Expand Up @@ -145,7 +145,7 @@ public AlertDialog setLeftButton(String text, final OnClickListener listener) {
public AlertDialog setLeftButton(String text, int color, int size, boolean isBold, final OnClickListener listener) {
showLeftBtn = true;
if (TextUtils.isEmpty(text)) {
leftButton.setText("Cancel");
leftButton.setText(R.string.cancel);
} else {
leftButton.setText(text);
}
Expand All @@ -172,7 +172,7 @@ public void onClick(View v) {

private void setLayout() {
if (!showTitle && !showMsg) {
txt_title.setText("Alert");
txt_title.setText(R.string.alert);
txt_title.setVisibility(View.VISIBLE);
}
if (showTitle) {
Expand All @@ -183,7 +183,7 @@ private void setLayout() {
}
// one button
if (!showRightBtn && !showLeftBtn) {
rightButton.setText("OK");
rightButton.setText(R.string.ok);
rightButton.setVisibility(View.VISIBLE);
rightButton.setBackgroundResource(R.drawable.alertdialog_single_selector);
rightButton.setOnClickListener(new OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public interface EditTextCallListener {

private void setLayout() {
if (!showTitle && !showMsg) {
txt_title.setText("Alert");
txt_title.setText(R.string.alert);
txt_title.setVisibility(View.VISIBLE);
}

Expand All @@ -183,7 +183,7 @@ private void setLayout() {
}

if (!showRightBtn && !showLeftBtn) {
rightBtn.setText("OK");
rightBtn.setText(R.string.ok);
rightBtn.setVisibility(View.VISIBLE);
rightBtn.setBackgroundResource(R.drawable.alertdialog_single_selector);
rightBtn.setOnClickListener(new OnClickListener() {
Expand Down
Loading

0 comments on commit 11c5f2d

Please sign in to comment.