public void updateTaskAction() { taskDummy = new TaskObject( getId(), getTaskTitle(), getDescription(), getLocation(), getProximity(), TimeFromPickers, getIntervalIndexFromSpinner(), getIsDone(), getImportant()); myDataBase.open(); myDataBase.updateTask(taskDummy); TaskList.getTasksList().set(positionOftaskToEdit, taskDummy); if (taskDummy.getIfTaskHasProximity() != 0) { Log.i( getClass().getSimpleName(), "Got Task To set proximity at position" + positionOftaskToEdit + " with id: " + taskDummy.getTaskId()); myGPSManager.setProximityAlert( positionOftaskToEdit, getLocationLatitude(), getLocationLongitude()); } myDataBase.close(); }
public boolean editATaskAction() { setId(taskBeforeEdit.getTaskId()); setTitle(titleInputext.getText().toString().trim()); setDescription(descriptionInputText.getText().toString().trim()); setIsDone(taskBeforeEdit.getTaskDoneIndicator()); setImportant(taskBeforeEdit.getTaskImportantIndicator()); if (getTaskTitle() != null && getTaskTitle().length() > 0) { if (notifySwitch.isChecked() == true) { setIntervalFromSpinner(); TimeFromPickers = myalarmmanager.getTimeFromPickers(datepicker, timepicker); updateTaskAction(); setDifferenceInMillis(myalarmmanager.compareBetweenDates(TimeFromPickers)); boolean isLater = getDifferenceInMillis() != MyConstants.INVALID_TIME; if (isLater == true) { myalarmmanager.setAlarm(taskDummy, getDifferenceInMillis(), getRepeatAlarmInterval()); Log.i(getClass().getSimpleName(), "notify for: " + getId() + " changed"); return true; } else { toastWithGravity("Invalid Time" + "\n" + "Turn Off Switch or Pick A different Time"); TimeFromPickers = null; drawer.showMenu(true); return false; } } else { updateTaskAction(); if (taskBeforeEdit.getTaskNotificationDate() != null) { myalarmmanager.CancelAlarm(taskDummy); return true; } // if the notification switch is off and there where no notification before the editing // of the task, user want a task without any alarm else { return true; } } } else { toastWithGravity("First Fill in Task Title"); return false; } }
public void addANewTask() { myDataBase.open(); taskDummy = new TaskObject( getId(), getTaskTitle(), getDescription(), getLocation(), getProximity(), TimeFromPickers, getIntervalIndexFromSpinner(), MyConstants.NOTDONE, MyConstants.NOTIMPORTANT); taskDummy.setTaskId((myDataBase.insertTask(taskDummy))); Log.i(getClass().getSimpleName(), "Task Created: id: " + taskDummy.getTaskId()); TaskList.addToList(taskDummy); if (taskDummy.getIfTaskHasProximity() == MyConstants.HASPROXIMITY) { myGPSManager.setProximityAlert( MyConstants.INDEXOFFIRSTTASK, getLocationLatitude(), getLocationLongitude()); } Handler handle = new Handler(); handle.post( new Runnable() { public void run() { final MediaPlayer mediaplayer; // delete from database and tasklist mediaplayer = MediaPlayer.create(CreateTaskActivity.this, R.raw.plustask); mediaplayer.setVolume(1, 1); mediaplayer.start(); } }); myDataBase.close(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.create_layout); // ActionBar gets initiated actionBar = getSupportActionBar(); actionBar = getSupportActionBar(); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle("Compose"); myDataBase = new TaskDataBaseSQL(this); drawer = new SlidingMenu(this); drawer.setMode(SlidingMenu.LEFT); drawer.setShadowDrawable(R.drawable.shadow); drawer.setShadowWidthRes(R.dimen.shadow_width); drawer.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); drawer.setFadeDegree(0.35f); drawer.setBehindOffsetRes(R.dimen.slidingmenu_offset); drawer.attachToActivity(this, SlidingMenu.SLIDING_CONTENT); drawer.offsetTopAndBottom(25); drawer.setMenu(R.layout.alarmslidingmenu); drawer.setSlidingEnabled(false); positionOftaskToEdit = -1; initilizeViewVariables(); coder = new Geocoder(this); myGPSManager = new TaskGPSManager(this); myalarmmanager = new MyAlarmManager(this); timepicker.setCurrentHour(myalarmmanager.getHourOfDay()); if (getIntent().hasExtra("ob")) { positionOftaskToEdit = getIntent().getIntExtra("ob", 0); taskBeforeEdit = TaskList.getTasksList().get(positionOftaskToEdit); initilizeViewForExistingTask(); actionBar.setTitle("Edit"); Log.d(getClass().getSimpleName(), "Editing A Task" + "id: " + taskBeforeEdit.getTaskId()); } else { initilizeForNewTask(); Log.d(getClass().getSimpleName(), "Creating New Task"); } }