Back to project page AmbientAlarmClock.
The source code is released under:
<p align="center"><a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"> <img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-nc-sa/4.0...
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.
package de.lukeslog.alarmclock.ui; // w ww. j a va 2s.c om import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.ListView; import de.lukeslog.alarmclock.actions.ActionManager; import de.lukeslog.alarmclock.actions.AmbientAction; import de.lukeslog.alarmclock.ambientalarm.AmbientAlarm; import de.lukeslog.alarmclock.ambientalarm.AmbientAlarmManager; import de.lukeslog.alarmclock.R; import de.lukeslog.alarmclock.actions.ActionActivity; import de.lukeslog.alarmclock.support.AlarmClockConstants; import de.lukeslog.alarmclock.support.Logger; /** * Created by lukas on 15.04.14. */ public class NewAmbientAction extends Activity { public static String TAG = AlarmClockConstants.TAG; Context ctx; ActionListAdapter adapter; AmbientAlarm alarm; /** * Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.action_list); String alarmID = getIntent().getStringExtra("ambientAlarmID"); alarm = AmbientAlarmManager.getAlarmById(alarmID); ctx = this; fillListOfAmbientActions(); } private void fillListOfAmbientActions() { ListView listOfActionTypes = (ListView) findViewById(R.id.actionListView); adapter = new ActionListAdapter(ctx); listOfActionTypes.setAdapter(adapter); adapter.notifyDataSetChanged(); listOfActionTypes.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { createNewActionView(position); } }); } private void createNewActionView(int clickPosition) { String actionTypeName = adapter.getActionTypeNameOnItemClicked(clickPosition); //TODO create a new ambient action of this type with default values and add it to the database and the registrar Logger.d(TAG, "actionTypeName = " + actionTypeName); AmbientAction ambientAction = ActionManager.createNewDefaultAction(actionTypeName); Logger.d(TAG, "ambientAction!=null =>"+(ambientAction!=null)); Intent startActionConfigurationActivity = new Intent(ctx, ActionActivity.class); startActionConfigurationActivity.putExtra("ambientAlarmID", alarm.getAlarmID()); startActionConfigurationActivity.putExtra("ambientActionID", ambientAction.getActionID()); alarm.registerAction("0", ambientAction); AmbientAlarmManager.updateDataBaseEntry(alarm); startActivity(startActionConfigurationActivity); NewAmbientAction.this.finish(); } }