This source file includes following definitions.
- onValueSet
- createPicker
- onClick
- tryNotifyDateSet
- onStop
- onMonthOrWeekChanged
- updateDate
package org.chromium.content.browser.input;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Build;
import org.chromium.content.R;
import org.chromium.content.browser.input.TwoFieldDatePicker.OnMonthOrWeekChangedListener;
public abstract class TwoFieldDatePickerDialog extends AlertDialog implements OnClickListener,
OnMonthOrWeekChangedListener {
private static final String YEAR = "year";
private static final String POSITION_IN_YEAR = "position_in_year";
protected final TwoFieldDatePicker mPicker;
protected final OnValueSetListener mCallBack;
public interface OnValueSetListener {
void onValueSet(int year, int positionInYear);
}
public TwoFieldDatePickerDialog(Context context,
OnValueSetListener callBack,
int year,
int positionInYear,
double minValue,
double maxValue) {
this(context, 0, callBack, year, positionInYear, minValue, maxValue);
}
public TwoFieldDatePickerDialog(Context context,
int theme,
OnValueSetListener callBack,
int year,
int positionInYear,
double minValue,
double maxValue) {
super(context, theme);
mCallBack = callBack;
setButton(BUTTON_POSITIVE, context.getText(
R.string.date_picker_dialog_set), this);
setButton(BUTTON_NEGATIVE, context.getText(android.R.string.cancel),
(OnClickListener) null);
setIcon(0);
mPicker = createPicker(context, minValue, maxValue);
setView(mPicker);
mPicker.init(year, positionInYear, this);
}
protected TwoFieldDatePicker createPicker(Context context, double minValue, double maxValue) {
return null;
}
@Override
public void onClick(DialogInterface dialog, int which) {
tryNotifyDateSet();
}
protected void tryNotifyDateSet() {
if (mCallBack != null) {
mPicker.clearFocus();
mCallBack.onValueSet(mPicker.getYear(), mPicker.getPositionInYear());
}
}
@Override
protected void onStop() {
if (Build.VERSION.SDK_INT >= 16) {
tryNotifyDateSet();
}
super.onStop();
}
@Override
public void onMonthOrWeekChanged(TwoFieldDatePicker view, int year, int positionInYear) {
mPicker.init(year, positionInYear, null);
}
public void updateDate(int year, int weekOfYear) {
mPicker.updateDate(year, weekOfYear);
}
}