|
@@ -12,54 +12,62 @@ import java.util.ArrayList;
|
|
* @createTime: 2022/8/8 15:08
|
|
* @createTime: 2022/8/8 15:08
|
|
*/
|
|
*/
|
|
public class DialogListBuilder {
|
|
public class DialogListBuilder {
|
|
-
|
|
|
|
|
|
+
|
|
ArrayList<BaseDialog> dialogs;
|
|
ArrayList<BaseDialog> dialogs;
|
|
-
|
|
|
|
|
|
+
|
|
public static DialogListBuilder create(BaseDialog... dialogs) {
|
|
public static DialogListBuilder create(BaseDialog... dialogs) {
|
|
DialogListBuilder builder = new DialogListBuilder();
|
|
DialogListBuilder builder = new DialogListBuilder();
|
|
for (BaseDialog d : dialogs) {
|
|
for (BaseDialog d : dialogs) {
|
|
- builder.add(d);
|
|
|
|
|
|
+ if (d != null) builder.add(d);
|
|
}
|
|
}
|
|
return builder;
|
|
return builder;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public DialogListBuilder add(BaseDialog dialog) {
|
|
public DialogListBuilder add(BaseDialog dialog) {
|
|
if (dialogs == null) {
|
|
if (dialogs == null) {
|
|
dialogs = new ArrayList<>();
|
|
dialogs = new ArrayList<>();
|
|
}
|
|
}
|
|
- if (dialog.isShow() || dialog.isPreShow()) {
|
|
|
|
|
|
+ if (dialog == null || dialog.isShow() || dialog.isPreShow()) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
dialog.setDialogListBuilder(this);
|
|
dialog.setDialogListBuilder(this);
|
|
dialogs.add(dialog);
|
|
dialogs.add(dialog);
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public DialogListBuilder show() {
|
|
public DialogListBuilder show() {
|
|
if (dialogs == null || dialogs.isEmpty()) {
|
|
if (dialogs == null || dialogs.isEmpty()) {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
+ while (!dialogs.isEmpty() && dialogs.get(0) == null) {
|
|
|
|
+ dialogs.remove(0);
|
|
|
|
+ }
|
|
dialogs.get(0).show();
|
|
dialogs.get(0).show();
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void showNext() {
|
|
public void showNext() {
|
|
if (dialogs == null || dialogs.isEmpty()) {
|
|
if (dialogs == null || dialogs.isEmpty()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- dialogs.remove(dialogs.get(0));
|
|
|
|
- if (!dialogs.isEmpty()) {
|
|
|
|
|
|
+ while (!dialogs.isEmpty() && dialogs.get(0) == null) {
|
|
|
|
+ dialogs.remove(0);
|
|
|
|
+ }
|
|
|
|
+ if (!dialogs.isEmpty() && dialogs.get(0) != null) {
|
|
dialogs.get(0).show();
|
|
dialogs.get(0).show();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public boolean isEmpty() {
|
|
public boolean isEmpty() {
|
|
if (dialogs == null) {
|
|
if (dialogs == null) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
+ while (!dialogs.isEmpty() && dialogs.get(0) == null) {
|
|
|
|
+ dialogs.remove(0);
|
|
|
|
+ }
|
|
return dialogs.isEmpty();
|
|
return dialogs.isEmpty();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public void clear() {
|
|
public void clear() {
|
|
dialogs.clear();
|
|
dialogs.clear();
|
|
}
|
|
}
|