1package com.android.deskclock;
2
3import android.text.format.DateFormat;
4
5import com.android.datetimepicker.time.RadialPickerLayout;
6import com.android.datetimepicker.time.TimePickerDialog;
7import com.android.deskclock.provider.Alarm;
8
9/**
10 * AlarmClockFragment for pre-L devices
11 */
12public class AlarmClockFragmentPreL extends AlarmClockFragment implements
13        TimePickerDialog.OnTimeSetListener {
14
15    @Override
16    public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) {
17        processTimeSet(hourOfDay, minute);
18    }
19
20    @Override
21    protected void setTimePickerListener() {
22        // Make sure to use the child FragmentManager. We have to use that one for the
23        // case where an intent comes in telling the activity to load the timepicker,
24        // which means we have to use that one everywhere so that the fragment can get
25        // correctly picked up here if it's open.
26        final TimePickerDialog tpd = (TimePickerDialog) getChildFragmentManager()
27                .findFragmentByTag(AlarmUtils.FRAG_TAG_TIME_PICKER);
28        if (tpd != null) {
29            // The dialog is already open so we need to set the listener again.
30            tpd.setOnTimeSetListener(this);
31        }
32    }
33
34    @Override
35    protected void startCreatingAlarm() {
36        // Set the "selected" alarm as null, and we'll create the new one when the timepicker
37        // comes back.
38        mSelectedAlarm = null;
39        AlarmUtils.showTimeEditDialog(getChildFragmentManager(),
40                null, AlarmClockFragmentPreL.this, DateFormat.is24HourFormat(getActivity()));
41    }
42
43    @Override
44    public void showTimeEditDialog(Alarm alarm) {
45        AlarmUtils.showTimeEditDialog(getChildFragmentManager(),
46            alarm, AlarmClockFragmentPreL.this, DateFormat.is24HourFormat(getActivity()));
47    }
48}
49