use of ve.com.abicelis.remindy.enums.ReminderType in project Remindy by abicelis.
the class RemindyDAO method getTaskFromCursor.
/* Cursor to Model */
private Task getTaskFromCursor(Cursor cursor) {
int id = cursor.getInt(cursor.getColumnIndex(RemindyContract.TaskTable._ID));
TaskStatus status = TaskStatus.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_STATUS.getName())));
String title = cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_TITLE.getName()));
String description = cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_DESCRIPTION.getName()));
TaskCategory category = TaskCategory.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_CATEGORY.getName())));
ReminderType reminderType;
try {
reminderType = ReminderType.valueOf(cursor.getString(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_REMINDER_TYPE.getName())));
} catch (IllegalArgumentException e) {
//Thrown if task has no reminder
reminderType = null;
}
Calendar doneDate = null;
if (status == TaskStatus.DONE) {
long doneDateLong = cursor.getLong(cursor.getColumnIndex(RemindyContract.TaskTable.COLUMN_NAME_DONE_DATE.getName()));
if (doneDateLong != -1) {
doneDate = Calendar.getInstance();
doneDate.setTimeInMillis(doneDateLong);
}
}
return new Task(id, status, title, description, category, reminderType, null, doneDate);
}
use of ve.com.abicelis.remindy.enums.ReminderType in project Remindy by abicelis.
the class HomeActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == NEW_TASK_REQUEST_CODE && resultCode == RESULT_OK) {
//Try to get NEW_TASK_RETURN_REMINDER_TYPE
ReminderType rt;
if (data.hasExtra(NEW_TASK_RETURN_REMINDER_TYPE)) {
rt = (ReminderType) data.getSerializableExtra(NEW_TASK_RETURN_REMINDER_TYPE);
try {
switch(rt) {
case NONE:
//Unprogrammed tasks will always be in tab #1
mHomeViewPagerAdapter.getRegisteredFragment(0).refreshRecyclerView();
break;
case LOCATION_BASED:
case ONE_TIME:
case REPEATING:
//Programmed tasks will always be in tab #1
mHomeViewPagerAdapter.getRegisteredFragment(1).refreshRecyclerView();
}
} catch (NullPointerException e) {
/* Do nothing, the recycler will be refreshed upon creation */
}
} else {
//Just refresh everything
setupViewPagerAndTabLayout();
}
}
if (requestCode == TaskDetailActivity.TASK_DETAIL_REQUEST_CODE && resultCode == RESULT_OK) {
//Try to get TASK_DETAIL_RETURN_TASK_POSITION and TASK_DETAIL_RETURN_ACTION_TYPE
if (data.hasExtra(TaskDetailActivity.TASK_DETAIL_RETURN_ACTION_TYPE) && data.hasExtra(TaskDetailActivity.TASK_DETAIL_RETURN_TASK_VIEWPAGER_INDEX)) {
int position = data.getIntExtra(TaskDetailActivity.TASK_DETAIL_RETURN_TASK_POSITION, -1);
int viewPagerIndex = data.getIntExtra(TaskDetailActivity.TASK_DETAIL_RETURN_TASK_VIEWPAGER_INDEX, -1);
if (position == -1) {
//If TaskDetailActivity was called from an android notification, impossible to tell position so refresh all.
//Just refresh everything
setupViewPagerAndTabLayout();
return;
}
switch(data.getIntExtra(TaskDetailActivity.TASK_DETAIL_RETURN_ACTION_TYPE, -1)) {
case TaskDetailActivity.TASK_DETAIL_RETURN_ACTION_DELETED:
try {
mHomeViewPagerAdapter.getRegisteredFragment(viewPagerIndex).removeViewHolderItem(position);
} catch (NullPointerException e) {
/* Do nothing, the recycler will be refreshed upon creation */
}
break;
case TaskDetailActivity.TASK_DETAIL_RETURN_ACTION_EDITED:
try {
mHomeViewPagerAdapter.getRegisteredFragment(viewPagerIndex).updateViewholderItem(position);
} catch (NullPointerException e) {
/* Do nothing, the recycler will be refreshed upon creation */
}
break;
case TaskDetailActivity.TASK_DETAIL_RETURN_ACTION_EDITED_REMINDER:
//Just refresh everything
setupViewPagerAndTabLayout();
break;
}
} else {
Log.d(TAG, "Error! TASK_DETAIL_RETURN_ACTION_TYPE or TASK_DETAIL_RETURN_TASK_VIEWPAGER_INDEX == null");
SnackbarUtil.showSnackbar(mViewpager, SnackbarUtil.SnackbarType.ERROR, R.string.error_unexpected, SnackbarUtil.SnackbarDuration.LONG, null);
}
}
if (requestCode == SettingsActivity.SETTINGS_ACTIVITY_REQUEST_CODE) {
if (resultCode == RESULT_OK)
setupViewPagerAndTabLayout();
}
}
Aggregations