If you think the Android project AmbientAlarmClock listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package de.lukeslog.alarmclock.actions;
/*www.java2s.com*/import android.app.Fragment;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import de.lukeslog.alarmclock.R;
import de.lukeslog.alarmclock.ambientalarm.AmbientAlarm;
import de.lukeslog.alarmclock.support.AlarmClockConstants;
/**
* Created by lukas on 06.04.14.
*/publicclass CountdownActionConfigurationFragment extends Fragment
{
publicstaticfinal String PREFS_NAME = AlarmClockConstants.PREFS_NAME;
publicstatic String TAG = AlarmClockConstants.TAG;
AmbientAlarm alarm;
/** Called when the activity is first created. */public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View fragment = inflater.inflate(R.layout.action_countdown_configuration_activity, container, false);
//well... this is kinda evil.
ActionActivity parent = (ActionActivity) getActivity();
final CountdownAction action = (CountdownAction) parent.getAction();
alarm = parent.getAlarm();
int seconds =action.getCountDownDuration();
final EditText countdownTextEdit = (EditText) fragment.findViewById(R.id.countdownlengthtext);
countdownTextEdit.setText("" + (seconds / 60));
countdownTextEdit.addTextChangedListener(new TextWatcher()
{
publicvoid afterTextChanged(Editable s)
{
if(!countdownTextEdit.getEditableText().toString().equals(""))
{
try
{
int i = Integer.parseInt(countdownTextEdit.getEditableText().toString());
action.setDurationInSeconds(i*60);
}
catch(Exception e)
{
}
}
}
publicvoid beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
publicvoid onTextChanged(CharSequence s, int start, int before, int count)
{
}
});
final CheckBox awakeonend = (CheckBox) fragment.findViewById(R.id.awakeonend);
awakeonend.setChecked(action.offonend);
awakeonend.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
publicvoid onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
action.offonend=isChecked;
}
});
return fragment;
}
}