Skip to content

Commit

Permalink
增加onCancel回调
Browse files Browse the repository at this point in the history
  • Loading branch information
junixapp committed Jul 29, 2022
1 parent 286e7ae commit d2d9613
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 6 deletions.
1 change: 0 additions & 1 deletion .idea/gradle.xml

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

19 changes: 17 additions & 2 deletions app/src/main/java/com/lxj/xpopupextdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public void onTimeConfirm(Date date, View view) {
//点击确认时间
Toast.makeText(MainActivity.this, "选择的时间:"+date.toLocaleString(), Toast.LENGTH_SHORT).show();
}

@Override
public void onCancel() {

}
});

new XPopup.Builder(MainActivity.this)
Expand All @@ -72,6 +77,11 @@ public void onCityChange(String province, String city, String area) {
Log.e("tag", province +" - " +city+" - " +area);
Toast.makeText(MainActivity.this, province +" - " +city+" - " +area, Toast.LENGTH_SHORT).show();
}

@Override
public void onCancel() {

}
});
new XPopup.Builder(MainActivity.this)
.borderRadius(30)
Expand All @@ -96,10 +106,15 @@ public void onClick(View v) {
public void onItemSelected(int index, String data) {
Toast.makeText(MainActivity.this, "选中的是 "+ data, Toast.LENGTH_SHORT).show();
}

@Override
public void onCancel() {

}
});
new XPopup.Builder(MainActivity.this)
.borderRadius(30)
.isDarkTheme(true)
// .borderRadius(30)
// .isDarkTheme(true)
.asCustom(popup)
.show();
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:3.5.3"
classpath "com.android.tools.build:gradle:4.2.0"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public interface CityPickerListener {

void onCityConfirm(String province, String city, String area, View v);
void onCityChange(String province, String city, String area);
void onCancel();

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

public interface CommonPickerListener {
void onItemSelected(int index, String data);
void onCancel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ public interface TimePickerListener {

void onTimeChanged(Date date);
void onTimeConfirm(Date date, View view);
void onCancel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected void onCreate() {
btnCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (cityPickerListener != null) cityPickerListener.onCancel();
dismiss();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected void onCreate() {
btnCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(commonPickerListener!=null) commonPickerListener.onCancel();
dismiss();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ protected void onCreate() {
btnCancel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (timePickerListener != null) timePickerListener.onCancel();
dismiss();
}
});
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Jun 16 22:36:20 CST 2020
#Wed Dec 18 19:13:30 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

0 comments on commit d2d9613

Please sign in to comment.