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(); }
@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"); } }
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(); }