|
@@ -27,14 +27,15 @@ import java.util.Locale;
|
|
|
* @author myLove
|
|
|
*/
|
|
|
public class SelectPeriod extends PopupWindow implements View.OnClickListener {
|
|
|
- private String tag = "SelectPeriod";
|
|
|
- private Context mContext;
|
|
|
- private SelectType selectType;
|
|
|
- private boolean boo;
|
|
|
+ private final String tag = "SelectPeriod";
|
|
|
+ private final Context mContext;
|
|
|
+ private final SelectType selectType;
|
|
|
+ private boolean judgmentTime = true;
|
|
|
+ private boolean boo = true;
|
|
|
|
|
|
public static boolean isDebug = true;
|
|
|
|
|
|
- private View mView;
|
|
|
+ private final View mView;
|
|
|
|
|
|
/**
|
|
|
* 取消按钮
|
|
@@ -104,22 +105,14 @@ public class SelectPeriod extends PopupWindow implements View.OnClickListener {
|
|
|
private OnDateClickListener onDateClickListener;
|
|
|
|
|
|
public SelectPeriod(Context context) {
|
|
|
- this(context, SelectType.NONE, true);
|
|
|
- }
|
|
|
-
|
|
|
- public SelectPeriod(Context context, boolean judgmentTime) {
|
|
|
- this(context, SelectType.NONE, judgmentTime);
|
|
|
+ this(context, SelectType.NONE);
|
|
|
}
|
|
|
|
|
|
public SelectPeriod(Context context, SelectType selectType) {
|
|
|
- this(context, selectType, true);
|
|
|
- }
|
|
|
-
|
|
|
- public SelectPeriod(Context context, SelectType selectType, boolean judgmentTime) {
|
|
|
super(context);
|
|
|
this.mContext = context;
|
|
|
this.selectType = selectType;
|
|
|
- this.boo = judgmentTime;
|
|
|
+ this.judgmentTime = judgmentTime;
|
|
|
mView = View.inflate(context, R.layout.select_period_pop_layout, null);
|
|
|
init();
|
|
|
//设置SelectPicPopupWindow的View
|
|
@@ -665,17 +658,37 @@ public class SelectPeriod extends PopupWindow implements View.OnClickListener {
|
|
|
String endTimeStr = getEndTimeStr();
|
|
|
log(getStringDate());
|
|
|
if (boo) {
|
|
|
- if (timeComparison(startTimeStr, endTimeStr)) {
|
|
|
- log(startTimeStr + "\t" + endTimeStr);
|
|
|
- onDateClickListener.onDateClickListener(startTimeStr, endTimeStr);
|
|
|
- dismiss();
|
|
|
+ if (timeComparison(startTimeStr, getStringDate())) {
|
|
|
+ toast("开始时间需要大于当前时间");
|
|
|
} else {
|
|
|
- toast("结束时间需要大于开始时间");
|
|
|
+ if (judgmentTime) {
|
|
|
+ if (timeComparison(startTimeStr, endTimeStr)) {
|
|
|
+ log(startTimeStr + "\t" + endTimeStr);
|
|
|
+ onDateClickListener.onDateClickListener(startTimeStr, endTimeStr);
|
|
|
+ dismiss();
|
|
|
+ } else {
|
|
|
+ toast("结束时间需要大于开始时间");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ onDateClickListener.onDateClickListener(startTimeStr, endTimeStr);
|
|
|
+ dismiss();
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
- onDateClickListener.onDateClickListener(startTimeStr, endTimeStr);
|
|
|
- dismiss();
|
|
|
+ if (judgmentTime) {
|
|
|
+ if (timeComparison(startTimeStr, endTimeStr)) {
|
|
|
+ log(startTimeStr + "\t" + endTimeStr);
|
|
|
+ onDateClickListener.onDateClickListener(startTimeStr, endTimeStr);
|
|
|
+ dismiss();
|
|
|
+ } else {
|
|
|
+ toast("结束时间需要大于开始时间");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ onDateClickListener.onDateClickListener(startTimeStr, endTimeStr);
|
|
|
+ dismiss();
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
} else if (view == butCancel) {
|
|
|
log("cancel");
|
|
@@ -861,8 +874,25 @@ public class SelectPeriod extends PopupWindow implements View.OnClickListener {
|
|
|
Toast.makeText(mContext, msg.toString(), Toast.LENGTH_SHORT).show();
|
|
|
}
|
|
|
|
|
|
- public void setOnDateClickListener(OnDateClickListener onDateClickListener) {
|
|
|
+ /**
|
|
|
+ * 当前时间小于开始时间
|
|
|
+ *
|
|
|
+ * @param b
|
|
|
+ * @return 是否可以当前时间小于开始时间
|
|
|
+ */
|
|
|
+ public SelectPeriod currentTimeLessStartTime(boolean b) {
|
|
|
+ this.boo = b;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public SelectPeriod startTimeLessEndTime(boolean judgmentTime) {
|
|
|
+ this.judgmentTime = judgmentTime;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ public SelectPeriod setOnDateClickListener(OnDateClickListener onDateClickListener) {
|
|
|
this.onDateClickListener = onDateClickListener;
|
|
|
+ return this;
|
|
|
}
|
|
|
|
|
|
public interface OnDateClickListener {
|