mirror of
https://github.com/wismna/DoNext.git
synced 2025-10-03 15:40:14 -04:00
Lots of code cleanup
Confirm dialog cancel now also works on touch outside and click back button New task dialog is now also an Edit Task dialog: - data is loaded when clicked on an existing Task - a delete button is added on Edit mode - Undo in snackbar is working - Saving inserts or updates in DB depending on mode
This commit is contained in:
1
DoNExt/.idea/dictionaries/geoffroy.xml
generated
1
DoNExt/.idea/dictionaries/geoffroy.xml
generated
@@ -1,6 +1,7 @@
|
|||||||
<component name="ProjectDictionaryState">
|
<component name="ProjectDictionaryState">
|
||||||
<dictionary name="geoffroy">
|
<dictionary name="geoffroy">
|
||||||
<words>
|
<words>
|
||||||
|
<w>geoffroy</w>
|
||||||
<w>wismna</w>
|
<w>wismna</w>
|
||||||
</words>
|
</words>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
|
@@ -34,14 +34,6 @@
|
|||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value=".activities.MainActivity" />
|
android:value=".activities.MainActivity" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name=".activities.TaskDetailsActivity"
|
|
||||||
android:label="@string/task_details_activity_title"
|
|
||||||
android:parentActivityName=".activities.MainActivity">
|
|
||||||
<meta-data
|
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
|
||||||
android:value=".activities.MainActivity" />
|
|
||||||
</activity>
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@@ -17,6 +17,7 @@ import com.wismna.geoffroy.donext.fragments.ConfirmDialogFragment;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-12-04.
|
* Created by geoffroy on 15-12-04.
|
||||||
|
* Helper class that handles all swipe events on a Task
|
||||||
*/
|
*/
|
||||||
public class TaskTouchHelper extends ItemTouchHelper.SimpleCallback {
|
public class TaskTouchHelper extends ItemTouchHelper.SimpleCallback {
|
||||||
private TaskAdapter taskAdapter;
|
private TaskAdapter taskAdapter;
|
||||||
|
@@ -16,7 +16,6 @@ import android.support.v7.app.AppCompatActivity;
|
|||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -33,13 +32,13 @@ import com.wismna.geoffroy.donext.dao.TaskList;
|
|||||||
import com.wismna.geoffroy.donext.database.TaskDataAccess;
|
import com.wismna.geoffroy.donext.database.TaskDataAccess;
|
||||||
import com.wismna.geoffroy.donext.database.TaskListDataAccess;
|
import com.wismna.geoffroy.donext.database.TaskListDataAccess;
|
||||||
import com.wismna.geoffroy.donext.fragments.ConfirmDialogFragment;
|
import com.wismna.geoffroy.donext.fragments.ConfirmDialogFragment;
|
||||||
import com.wismna.geoffroy.donext.fragments.NewTaskFragment;
|
import com.wismna.geoffroy.donext.fragments.TaskDialogFragment;
|
||||||
import com.wismna.geoffroy.donext.fragments.TasksFragment;
|
import com.wismna.geoffroy.donext.fragments.TasksFragment;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements
|
public class MainActivity extends AppCompatActivity implements
|
||||||
NewTaskFragment.NewTaskListener,
|
TaskDialogFragment.NewTaskListener,
|
||||||
TasksFragment.OnListFragmentInteractionListener,
|
TasksFragment.OnListFragmentInteractionListener,
|
||||||
ConfirmDialogFragment.ConfirmDialogListener
|
ConfirmDialogFragment.ConfirmDialogListener
|
||||||
{
|
{
|
||||||
@@ -53,13 +52,11 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
* may be best to switch to a
|
* may be best to switch to a
|
||||||
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
|
* {@link android.support.v4.app.FragmentStatePagerAdapter}.
|
||||||
*/
|
*/
|
||||||
private SectionsPagerAdapter mSectionsPagerAdapter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link ViewPager} that will host the section contents.
|
* The {@link ViewPager} that will host the section contents.
|
||||||
*/
|
*/
|
||||||
private ViewPager mViewPager;
|
private ViewPager mViewPager;
|
||||||
|
|
||||||
private List<TaskList> taskLists;
|
private List<TaskList> taskLists;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,7 +69,7 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
|
|
||||||
// Create the adapter that will return a fragment for each of the three
|
// Create the adapter that will return a fragment for each of the three
|
||||||
// primary sections of the activity.
|
// primary sections of the activity.
|
||||||
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
|
|
||||||
// Access database to retrieve tasks
|
// Access database to retrieve tasks
|
||||||
taskDataAccess = new TaskDataAccess(this);
|
taskDataAccess = new TaskDataAccess(this);
|
||||||
@@ -148,6 +145,8 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
public void onNewTaskDialogPositiveClick(DialogFragment dialog) {
|
public void onNewTaskDialogPositiveClick(DialogFragment dialog) {
|
||||||
// Get the dialog fragment
|
// Get the dialog fragment
|
||||||
Dialog dialogView = dialog.getDialog();
|
Dialog dialogView = dialog.getDialog();
|
||||||
|
Bundle args = dialog.getArguments();
|
||||||
|
long id = args.getLong("id");
|
||||||
// Get the controls
|
// Get the controls
|
||||||
Spinner listSpinner = (Spinner) dialogView.findViewById(R.id.new_task_list);
|
Spinner listSpinner = (Spinner) dialogView.findViewById(R.id.new_task_list);
|
||||||
EditText nameText = (EditText) dialogView.findViewById(R.id.new_task_name);
|
EditText nameText = (EditText) dialogView.findViewById(R.id.new_task_name);
|
||||||
@@ -156,17 +155,64 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
RadioButton priorityRadio = (RadioButton) dialogView.findViewById(priorityGroup.getCheckedRadioButtonId());
|
RadioButton priorityRadio = (RadioButton) dialogView.findViewById(priorityGroup.getCheckedRadioButtonId());
|
||||||
TaskList taskList = (TaskList) listSpinner.getSelectedItem();
|
TaskList taskList = (TaskList) listSpinner.getSelectedItem();
|
||||||
// Add the task to the database
|
// Add the task to the database
|
||||||
Task task = taskDataAccess.createOrUpdateTask(
|
taskDataAccess.open();
|
||||||
|
Task task = taskDataAccess.createOrUpdateTask(id,
|
||||||
nameText.getText().toString(),
|
nameText.getText().toString(),
|
||||||
descText.getText().toString(),
|
descText.getText().toString(),
|
||||||
priorityRadio.getText().toString(),
|
priorityRadio.getText().toString(),
|
||||||
taskList.getId());
|
taskList.getId());
|
||||||
|
taskDataAccess.close();
|
||||||
// Update the corresponding tab adapter
|
// Update the corresponding tab adapter
|
||||||
TasksFragment taskFragment = (TasksFragment) mSectionsPagerAdapter.getRegisteredFragment(listSpinner.getSelectedItemPosition());
|
//TasksFragment taskFragment = (TasksFragment) mSectionsPagerAdapter.getRegisteredFragment(listSpinner.getSelectedItemPosition());
|
||||||
TaskAdapter taskAdapter = ((TaskAdapter)((RecyclerView)taskFragment.getView().findViewById(R.id.task_list_view)).getAdapter());
|
//TaskAdapter taskAdapter = ((TaskAdapter)((RecyclerView)taskFragment.getView().findViewById(R.id.task_list_view)).getAdapter());
|
||||||
taskAdapter.add(task, taskAdapter.getItemCount());
|
TaskAdapter taskAdapter = ((TaskDialogFragment)dialog).getTaskAdapter();
|
||||||
|
// Add the task
|
||||||
|
if (id == 0)
|
||||||
|
taskAdapter.add(task, taskAdapter.getItemCount());
|
||||||
|
// Update the task
|
||||||
|
else
|
||||||
|
taskAdapter.update(task, args.getInt("position"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNewTaskDialogNeutralClick(DialogFragment dialog) {
|
||||||
|
// TODO: add confirm dialog
|
||||||
|
TaskDialogFragment taskDialogFragment = (TaskDialogFragment) dialog;
|
||||||
|
Bundle args = dialog.getArguments();
|
||||||
|
final long id = args.getLong("id");
|
||||||
|
|
||||||
|
// Delete task from Adapter
|
||||||
|
final int position = args.getInt("position");
|
||||||
|
final TaskAdapter taskAdapter = taskDialogFragment.getTaskAdapter();
|
||||||
|
final Task task = taskAdapter.getItem(position);
|
||||||
|
taskAdapter.remove(position);
|
||||||
|
|
||||||
|
// Setup the snack bar
|
||||||
|
final View view = taskDialogFragment.getRecyclerView();
|
||||||
|
Snackbar.make(view, "Task deleted", Snackbar.LENGTH_LONG)
|
||||||
|
.setAction("Undo", new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
// Undo adapter changes
|
||||||
|
taskAdapter.add(task, position);
|
||||||
|
((RecyclerView)view).scrollToPosition(position);
|
||||||
|
}
|
||||||
|
}).setCallback(new Snackbar.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onDismissed(Snackbar snackbar, int event) {
|
||||||
|
super.onDismissed(snackbar, event);
|
||||||
|
|
||||||
|
// When clicked on undo, do not write to DB
|
||||||
|
if (event == DISMISS_EVENT_ACTION) return;
|
||||||
|
|
||||||
|
// Commit the changes to DB
|
||||||
|
taskDataAccess.open();
|
||||||
|
taskDataAccess.deleteTask(id);
|
||||||
|
taskDataAccess.close();
|
||||||
|
}
|
||||||
|
}).show();
|
||||||
|
}
|
||||||
|
|
||||||
/** Called when user clicks on the New Task floating button */
|
/** Called when user clicks on the New Task floating button */
|
||||||
public void onNewTaskClick(View view) {
|
public void onNewTaskClick(View view) {
|
||||||
OpenNewTaskDialog();
|
OpenNewTaskDialog();
|
||||||
@@ -182,17 +228,6 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when the user clicks the New Task button */
|
|
||||||
public void openNewTaskDialog(MenuItem menuItem) {
|
|
||||||
OpenNewTaskDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Will be called when the delete Task button is clicked */
|
|
||||||
public void onDeleteTask(View view) {
|
|
||||||
RecyclerView recyclerView = (RecyclerView) view;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListFragmentInteraction(Task item) {
|
public void onListFragmentInteraction(Task item) {
|
||||||
|
|
||||||
@@ -209,7 +244,7 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirmDialogNeutralClick(android.support.v4.app.DialogFragment dialog) {
|
public void onConfirmDialogNeutralClick(DialogFragment dialog) {
|
||||||
Bundle args = dialog.getArguments();
|
Bundle args = dialog.getArguments();
|
||||||
int itemPosition = args.getInt("ItemPosition");
|
int itemPosition = args.getInt("ItemPosition");
|
||||||
int direction = args.getInt("Direction");
|
int direction = args.getInt("Direction");
|
||||||
@@ -234,31 +269,16 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
PerformSwipeAction(taskDataAccess, taskAdapter, itemPosition, direction, ((ConfirmDialogFragment) dialog).getRecyclerView());
|
PerformSwipeAction(taskDataAccess, taskAdapter, itemPosition, direction, ((ConfirmDialogFragment) dialog).getRecyclerView());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfirmDialogNegativeClick(android.support.v4.app.DialogFragment dialog) {
|
|
||||||
Bundle args = dialog.getArguments();
|
|
||||||
int itemPosition = args.getInt("ItemPosition");
|
|
||||||
|
|
||||||
TaskAdapter taskAdapter = ((ConfirmDialogFragment)dialog).getTaskAdapter();
|
|
||||||
taskAdapter.notifyItemChanged(itemPosition);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onConfirmDialogKeyListener(android.support.v4.app.DialogFragment dialog, int keyCode, KeyEvent event) {
|
|
||||||
onConfirmDialogNegativeClick(dialog);
|
|
||||||
return keyCode != KeyEvent.KEYCODE_BACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OpenNewTaskDialog() {
|
private void OpenNewTaskDialog() {
|
||||||
FragmentManager manager = getSupportFragmentManager();
|
FragmentManager manager = getSupportFragmentManager();
|
||||||
NewTaskFragment newTaskFragment = new NewTaskFragment();
|
TaskDialogFragment taskDialogFragment = new TaskDialogFragment();
|
||||||
|
|
||||||
// Set current tab value to new task dialog
|
// Set current tab value to new task dialog
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putInt("list", mViewPager.getCurrentItem());
|
args.putInt("list", mViewPager.getCurrentItem());
|
||||||
newTaskFragment.setArguments(args);
|
taskDialogFragment.setArguments(args);
|
||||||
|
|
||||||
newTaskFragment.show(manager, "Create new task");
|
taskDialogFragment.show(manager, "Create new task");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PerformSwipeAction(final TaskDataAccess taskDataAccess,
|
public static void PerformSwipeAction(final TaskDataAccess taskDataAccess,
|
||||||
|
@@ -1,15 +0,0 @@
|
|||||||
package com.wismna.geoffroy.donext.activities;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import com.wismna.geoffroy.donext.R;
|
|
||||||
|
|
||||||
public class TaskDetailsActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_task_details);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -2,6 +2,9 @@ package com.wismna.geoffroy.donext.adapters;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-28.
|
* Created by geoffroy on 15-11-28.
|
||||||
|
* Extension of FragmentStatePagerAdapter which intelligently caches
|
||||||
|
* all active fragments and manages the fragment lifecycles.
|
||||||
|
* Usage involves extending from SmartFragmentStatePagerAdapter as you would any other PagerAdapter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
@@ -10,11 +13,6 @@ import android.support.v4.app.FragmentStatePagerAdapter;
|
|||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
/**
|
|
||||||
Extension of FragmentStatePagerAdapter which intelligently caches
|
|
||||||
all active fragments and manages the fragment lifecycles.
|
|
||||||
Usage involves extending from SmartFragmentStatePagerAdapter as you would any other PagerAdapter.
|
|
||||||
*/
|
|
||||||
public abstract class SmartFragmentStatePagerAdapter extends FragmentStatePagerAdapter {
|
public abstract class SmartFragmentStatePagerAdapter extends FragmentStatePagerAdapter {
|
||||||
// Sparse array to keep track of registered fragments in memory
|
// Sparse array to keep track of registered fragments in memory
|
||||||
private SparseArray<Fragment> registeredFragments = new SparseArray<>();
|
private SparseArray<Fragment> registeredFragments = new SparseArray<>();
|
||||||
|
@@ -33,8 +33,7 @@ public class TaskAdapter extends RecyclerView.Adapter<TaskAdapter.ViewHolder> {
|
|||||||
View view = LayoutInflater.from(parent.getContext())
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.fragment_task, parent, false);
|
.inflate(R.layout.fragment_task, parent, false);
|
||||||
|
|
||||||
ViewHolder holder = new ViewHolder(view);
|
return new ViewHolder(view);
|
||||||
return holder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,7 +83,6 @@ public class TaskAdapter extends RecyclerView.Adapter<TaskAdapter.ViewHolder> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void remove(int position) {
|
public void remove(int position) {
|
||||||
//int position = mValues.indexOf(item);
|
|
||||||
mValues.remove(position);
|
mValues.remove(position);
|
||||||
notifyItemRemoved(position);
|
notifyItemRemoved(position);
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@ import com.wismna.geoffroy.donext.database.DatabaseHelper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-25.
|
* Created by geoffroy on 15-11-25.
|
||||||
|
* DEPRECATED
|
||||||
*/
|
*/
|
||||||
public class TaskListCursorAdapter extends ResourceCursorAdapter {
|
public class TaskListCursorAdapter extends ResourceCursorAdapter {
|
||||||
public TaskListCursorAdapter(Context context, int layout, Cursor cursor, int flags) {
|
public TaskListCursorAdapter(Context context, int layout, Cursor cursor, int flags) {
|
||||||
|
@@ -2,6 +2,7 @@ package com.wismna.geoffroy.donext.dao;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-25.
|
* Created by geoffroy on 15-11-25.
|
||||||
|
* Data access object class that represents a Task
|
||||||
*/
|
*/
|
||||||
public class Task {
|
public class Task {
|
||||||
private long id;
|
private long id;
|
||||||
@@ -14,18 +15,6 @@ public class Task {
|
|||||||
private long taskList;
|
private long taskList;
|
||||||
private String taskListName;
|
private String taskListName;
|
||||||
|
|
||||||
public enum TaskPriority {
|
|
||||||
LOW(0),
|
|
||||||
NORMAL(1),
|
|
||||||
HIGH(2);
|
|
||||||
|
|
||||||
private int value;
|
|
||||||
|
|
||||||
private TaskPriority(int value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ package com.wismna.geoffroy.donext.dao;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-25.
|
* Created by geoffroy on 15-11-25.
|
||||||
|
* Data access object class that represents a Task List
|
||||||
*/
|
*/
|
||||||
public class TaskList {
|
public class TaskList {
|
||||||
private long id;
|
private long id;
|
||||||
@@ -24,14 +25,6 @@ public class TaskList {
|
|||||||
this.name = comment;
|
this.name = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTaskCount() {
|
|
||||||
return taskCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTaskCount(long taskCount) {
|
|
||||||
this.taskCount = taskCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Will be used by the ArrayAdapter in the ListView
|
// Will be used by the ArrayAdapter in the ListView
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@@ -6,6 +6,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-25.
|
* Created by geoffroy on 15-11-25.
|
||||||
|
* Database helper class that contains table and column names as well as handles database creation
|
||||||
*/
|
*/
|
||||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||||
private static final int DATABASE_VERSION = 1;
|
private static final int DATABASE_VERSION = 1;
|
||||||
|
@@ -14,6 +14,7 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-27.
|
* Created by geoffroy on 15-11-27.
|
||||||
|
* Data access class that handles Tasks
|
||||||
*/
|
*/
|
||||||
public class TaskDataAccess {
|
public class TaskDataAccess {
|
||||||
private SQLiteDatabase database;
|
private SQLiteDatabase database;
|
||||||
@@ -41,15 +42,20 @@ public class TaskDataAccess {
|
|||||||
dbHelper.close();
|
dbHelper.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: add taskID
|
/** Adds or update a task in the database */
|
||||||
public Task createOrUpdateTask(String name, String description, String priority, long taskList) {
|
public Task createOrUpdateTask(long id, String name, String description, String priority, long taskList) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(DatabaseHelper.TASKS_COLUMN_NAME, name);
|
values.put(DatabaseHelper.TASKS_COLUMN_NAME, name);
|
||||||
values.put(DatabaseHelper.TASKS_COLUMN_DESC, description);
|
values.put(DatabaseHelper.TASKS_COLUMN_DESC, description);
|
||||||
values.put(DatabaseHelper.TASKS_COLUMN_PRIORITY, priorities.indexOf(priority));
|
values.put(DatabaseHelper.TASKS_COLUMN_PRIORITY, priorities.indexOf(priority));
|
||||||
values.put(DatabaseHelper.TASKS_COLUMN_LIST, taskList);
|
values.put(DatabaseHelper.TASKS_COLUMN_LIST, taskList);
|
||||||
long insertId = database.insert(DatabaseHelper.TASKS_TABLE_NAME, null, values);
|
long insertId;
|
||||||
|
if (id == 0)
|
||||||
|
insertId = database.insert(DatabaseHelper.TASKS_TABLE_NAME, null, values);
|
||||||
|
else {
|
||||||
|
database.update(DatabaseHelper.TASKS_TABLE_NAME, values, DatabaseHelper.COLUMN_ID + " == " + id, null);
|
||||||
|
insertId = id;
|
||||||
|
}
|
||||||
Cursor cursor = database.query(DatabaseHelper.TASKS_TABLE_NAME,
|
Cursor cursor = database.query(DatabaseHelper.TASKS_TABLE_NAME,
|
||||||
taskColumns, DatabaseHelper.COLUMN_ID + " = " + insertId, null,
|
taskColumns, DatabaseHelper.COLUMN_ID + " = " + insertId, null,
|
||||||
null, null, null);
|
null, null, null);
|
||||||
@@ -60,7 +66,8 @@ public class TaskDataAccess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deleteTask(long taskId) {
|
public void deleteTask(long taskId) {
|
||||||
|
database.delete(DatabaseHelper.TASKS_TABLE_NAME,
|
||||||
|
DatabaseHelper.COLUMN_ID + " = " + taskId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public Cursor deleteTask(Cursor taskCursor) {
|
/*public Cursor deleteTask(Cursor taskCursor) {
|
||||||
|
@@ -13,12 +13,13 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-25.
|
* Created by geoffroy on 15-11-25.
|
||||||
|
* Data access class that handles Task Lists
|
||||||
*/
|
*/
|
||||||
public class TaskListDataAccess {
|
public class TaskListDataAccess {
|
||||||
// Database fields
|
// Database fields
|
||||||
private SQLiteDatabase database;
|
private SQLiteDatabase database;
|
||||||
private DatabaseHelper dbHelper;
|
private DatabaseHelper dbHelper;
|
||||||
private String[] taskListColumns = {DatabaseHelper.COLUMN_ID, DatabaseHelper.TASKLIST_COLUMN_NAME};
|
//private String[] taskListColumns = {DatabaseHelper.COLUMN_ID, DatabaseHelper.TASKLIST_COLUMN_NAME};
|
||||||
|
|
||||||
public TaskListDataAccess(Context context) {
|
public TaskListDataAccess(Context context) {
|
||||||
dbHelper = new DatabaseHelper(context);
|
dbHelper = new DatabaseHelper(context);
|
||||||
|
@@ -4,6 +4,7 @@ import android.app.Activity;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
@@ -16,8 +17,6 @@ public class ConfirmDialogFragment extends DialogFragment {
|
|||||||
public interface ConfirmDialogListener {
|
public interface ConfirmDialogListener {
|
||||||
void onConfirmDialogPositiveClick(DialogFragment dialog);
|
void onConfirmDialogPositiveClick(DialogFragment dialog);
|
||||||
void onConfirmDialogNeutralClick(DialogFragment dialog);
|
void onConfirmDialogNeutralClick(DialogFragment dialog);
|
||||||
void onConfirmDialogNegativeClick(DialogFragment dialog);
|
|
||||||
boolean onConfirmDialogKeyListener(DialogFragment dialog, int keyCode, KeyEvent event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ConfirmDialogListener confirmDialogListener;
|
private ConfirmDialogListener confirmDialogListener;
|
||||||
@@ -38,6 +37,15 @@ public class ConfirmDialogFragment extends DialogFragment {
|
|||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Allows refreshing the first item of the adapter */
|
||||||
|
private void RefreshAdapter()
|
||||||
|
{
|
||||||
|
Bundle args = getArguments();
|
||||||
|
int itemPosition = args.getInt("ItemPosition");
|
||||||
|
|
||||||
|
getTaskAdapter().notifyItemChanged(itemPosition);
|
||||||
|
}
|
||||||
|
|
||||||
public TaskAdapter getTaskAdapter() {
|
public TaskAdapter getTaskAdapter() {
|
||||||
return taskAdapter;
|
return taskAdapter;
|
||||||
}
|
}
|
||||||
@@ -49,6 +57,7 @@ public class ConfirmDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
super.onCancel(dialog);
|
super.onCancel(dialog);
|
||||||
|
RefreshAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,9 +75,9 @@ public class ConfirmDialogFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NonNull
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
// TODO: Handle on dismiss or similar
|
|
||||||
builder.setMessage(getResources().getString(R.string.settings_confirm_message) + " " + message + "?")
|
builder.setMessage(getResources().getString(R.string.settings_confirm_message) + " " + message + "?")
|
||||||
.setPositiveButton(R.string.task_swipe_confirmation_yes, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.task_swipe_confirmation_yes, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
@@ -78,7 +87,7 @@ public class ConfirmDialogFragment extends DialogFragment {
|
|||||||
.setNegativeButton(R.string.task_swipe_confirmation_no, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.task_swipe_confirmation_no, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
// User cancelled the dialog
|
// User cancelled the dialog
|
||||||
confirmDialogListener.onConfirmDialogNegativeClick(ConfirmDialogFragment.this);
|
RefreshAdapter();
|
||||||
}
|
}
|
||||||
}).setNeutralButton(R.string.task_swipe_confirmation_never, new DialogInterface.OnClickListener() {
|
}).setNeutralButton(R.string.task_swipe_confirmation_never, new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
@@ -89,7 +98,7 @@ public class ConfirmDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||||
//return false;
|
//return false;
|
||||||
return confirmDialogListener.onConfirmDialogKeyListener(ConfirmDialogFragment.this, keyCode, event);
|
return keyCode != KeyEvent.KEYCODE_BACK;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// Create the AlertDialog object and return it
|
// Create the AlertDialog object and return it
|
||||||
|
@@ -1,109 +0,0 @@
|
|||||||
package com.wismna.geoffroy.donext.fragments;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import com.wismna.geoffroy.donext.R;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple {@link Fragment} subclass.
|
|
||||||
* Activities that contain this fragment must implement the
|
|
||||||
* {@link TaskDetailsFragment.OnFragmentInteractionListener} interface
|
|
||||||
* to handle interaction events.
|
|
||||||
* Use the {@link TaskDetailsFragment#newInstance} factory method to
|
|
||||||
* create an instance of this fragment.
|
|
||||||
*/
|
|
||||||
public class TaskDetailsFragment extends Fragment {
|
|
||||||
// TODO: Rename parameter arguments, choose names that match
|
|
||||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
|
||||||
private static final String ARG_PARAM1 = "param1";
|
|
||||||
private static final String ARG_PARAM2 = "param2";
|
|
||||||
|
|
||||||
// TODO: Rename and change types of parameters
|
|
||||||
private String mParam1;
|
|
||||||
private String mParam2;
|
|
||||||
|
|
||||||
private OnFragmentInteractionListener mListener;
|
|
||||||
|
|
||||||
public TaskDetailsFragment() {
|
|
||||||
// Required empty public constructor
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use this factory method to create a new instance of
|
|
||||||
* this fragment using the provided parameters.
|
|
||||||
*
|
|
||||||
* @param param1 Parameter 1.
|
|
||||||
* @param param2 Parameter 2.
|
|
||||||
* @return A new instance of fragment TaskDetailsFragment.
|
|
||||||
*/
|
|
||||||
// TODO: Rename and change types and number of parameters
|
|
||||||
public static TaskDetailsFragment newInstance(String param1, String param2) {
|
|
||||||
TaskDetailsFragment fragment = new TaskDetailsFragment();
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(ARG_PARAM1, param1);
|
|
||||||
args.putString(ARG_PARAM2, param2);
|
|
||||||
fragment.setArguments(args);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
if (getArguments() != null) {
|
|
||||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
|
||||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
// Inflate the layout for this fragment
|
|
||||||
return inflater.inflate(R.layout.fragment_task_details, container, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Rename method, update argument and hook method into UI event
|
|
||||||
public void onButtonPressed(Uri uri) {
|
|
||||||
if (mListener != null) {
|
|
||||||
mListener.onFragmentInteraction(uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Context context) {
|
|
||||||
super.onAttach(context);
|
|
||||||
if (context instanceof OnFragmentInteractionListener) {
|
|
||||||
mListener = (OnFragmentInteractionListener) context;
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException(context.toString()
|
|
||||||
+ " must implement OnFragmentInteractionListener");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDetach() {
|
|
||||||
super.onDetach();
|
|
||||||
mListener = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface must be implemented by activities that contain this
|
|
||||||
* fragment to allow an interaction in this fragment to be communicated
|
|
||||||
* to the activity and potentially other fragments contained in that
|
|
||||||
* activity.
|
|
||||||
* <p/>
|
|
||||||
* See the Android Training lesson <a href=
|
|
||||||
* "http://developer.android.com/training/basics/fragments/communicating.html"
|
|
||||||
* >Communicating with Other Fragments</a> for more information.
|
|
||||||
*/
|
|
||||||
public interface OnFragmentInteractionListener {
|
|
||||||
// TODO: Update argument type and name
|
|
||||||
void onFragmentInteraction(Uri uri);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -5,7 +5,9 @@ import android.app.AlertDialog;
|
|||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
@@ -14,6 +16,7 @@ import android.widget.RadioGroup;
|
|||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
import com.wismna.geoffroy.donext.R;
|
import com.wismna.geoffroy.donext.R;
|
||||||
|
import com.wismna.geoffroy.donext.adapters.TaskAdapter;
|
||||||
import com.wismna.geoffroy.donext.dao.TaskList;
|
import com.wismna.geoffroy.donext.dao.TaskList;
|
||||||
import com.wismna.geoffroy.donext.database.TaskListDataAccess;
|
import com.wismna.geoffroy.donext.database.TaskListDataAccess;
|
||||||
|
|
||||||
@@ -21,21 +24,51 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-11-26.
|
* Created by geoffroy on 15-11-26.
|
||||||
|
* Represents a New or Edit Task dialog
|
||||||
*/
|
*/
|
||||||
public class NewTaskFragment extends DialogFragment {
|
public class TaskDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
public TaskAdapter getTaskAdapter() {
|
||||||
|
return taskAdapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTaskAdapter(TaskAdapter taskAdapter) {
|
||||||
|
this.taskAdapter = taskAdapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecyclerView getRecyclerView() {
|
||||||
|
return recyclerView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRecyclerView(RecyclerView recyclerView) {
|
||||||
|
this.recyclerView = recyclerView;
|
||||||
|
}
|
||||||
|
|
||||||
/** The activity that creates an instance of this dialog fragment must
|
/** The activity that creates an instance of this dialog fragment must
|
||||||
* implement this interface in order to receive event callbacks.
|
* implement this interface in order to receive event callbacks.
|
||||||
* Each method passes the DialogFragment in case the host needs to query it. */
|
* Each method passes the DialogFragment in case the host needs to query it. */
|
||||||
public interface NewTaskListener {
|
public interface NewTaskListener {
|
||||||
void onNewTaskDialogPositiveClick(DialogFragment dialog);
|
void onNewTaskDialogPositiveClick(DialogFragment dialog);
|
||||||
|
void onNewTaskDialogNeutralClick(DialogFragment dialog);
|
||||||
//void onDialogNegativeClick(DialogFragment dialog);
|
//void onDialogNegativeClick(DialogFragment dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
//private TaskDataAccess taskDataAccess;
|
private TaskAdapter taskAdapter;
|
||||||
|
private RecyclerView recyclerView;
|
||||||
// Use this instance of the interface to deliver action events
|
// Use this instance of the interface to deliver action events
|
||||||
private NewTaskListener mListener;
|
private NewTaskListener mListener;
|
||||||
|
|
||||||
|
public static TaskDialogFragment newInstance(TaskAdapter taskAdapter, RecyclerView recyclerView) {
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
|
||||||
|
TaskDialogFragment fragment = new TaskDialogFragment();
|
||||||
|
fragment.setTaskAdapter(taskAdapter);
|
||||||
|
fragment.setRecyclerView(recyclerView);
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
/** Override the Fragment.onAttach() method to instantiate the NoticeDialogListener */
|
/** Override the Fragment.onAttach() method to instantiate the NoticeDialogListener */
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
@@ -52,6 +85,7 @@ public class NewTaskFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@NonNull
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
// Get the layout inflater
|
// Get the layout inflater
|
||||||
@@ -66,7 +100,7 @@ public class NewTaskFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
// Send the positive button event back to the host activity
|
// Send the positive button event back to the host activity
|
||||||
mListener.onNewTaskDialogPositiveClick(NewTaskFragment.this);
|
mListener.onNewTaskDialogPositiveClick(TaskDialogFragment.this);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.new_task_cancel, new DialogInterface.OnClickListener() {
|
.setNegativeButton(R.string.new_task_cancel, new DialogInterface.OnClickListener() {
|
||||||
@@ -74,7 +108,7 @@ public class NewTaskFragment extends DialogFragment {
|
|||||||
// Send the negative button event back to the host activity
|
// Send the negative button event back to the host activity
|
||||||
//mListener.onDialogNegativeClick(NoticeDialogFragment.this);
|
//mListener.onDialogNegativeClick(NoticeDialogFragment.this);
|
||||||
// Canceled creation, nothing to do
|
// Canceled creation, nothing to do
|
||||||
NewTaskFragment.this.getDialog().cancel();
|
TaskDialogFragment.this.getDialog().cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -98,7 +132,7 @@ public class NewTaskFragment extends DialogFragment {
|
|||||||
int id = args.getInt("list");
|
int id = args.getInt("list");
|
||||||
spinner.setSelection(id);
|
spinner.setSelection(id);
|
||||||
|
|
||||||
// Set other properties
|
// Set other properties if they exist
|
||||||
EditText titleText = (EditText) view.findViewById(R.id.new_task_name);
|
EditText titleText = (EditText) view.findViewById(R.id.new_task_name);
|
||||||
titleText.setText(args.getString("title"));
|
titleText.setText(args.getString("title"));
|
||||||
EditText descText = (EditText) view.findViewById(R.id.new_task_description);
|
EditText descText = (EditText) view.findViewById(R.id.new_task_description);
|
||||||
@@ -117,7 +151,14 @@ public class NewTaskFragment extends DialogFragment {
|
|||||||
priorityGroup.check(R.id.new_task_priority_high);
|
priorityGroup.check(R.id.new_task_priority_high);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Add a Delete button in Edit mode
|
||||||
|
if (args.getLong("id") != 0)
|
||||||
|
builder.setNeutralButton(R.string.new_task_delete, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
mListener.onNewTaskDialogNeutralClick(TaskDialogFragment.this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
@@ -45,7 +45,6 @@ public class TasksFragment extends Fragment {
|
|||||||
public TasksFragment() {
|
public TasksFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public static TasksFragment newInstance(long taskListId) {
|
public static TasksFragment newInstance(long taskListId) {
|
||||||
TasksFragment fragment = new TasksFragment();
|
TasksFragment fragment = new TasksFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
@@ -70,7 +69,7 @@ public class TasksFragment extends Fragment {
|
|||||||
final Context context = view.getContext();
|
final Context context = view.getContext();
|
||||||
|
|
||||||
// Set the Recycler view
|
// Set the Recycler view
|
||||||
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.task_list_view);
|
final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.task_list_view);
|
||||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||||
|
|
||||||
TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext());
|
TaskDataAccess taskDataAccess = new TaskDataAccess(view.getContext());
|
||||||
@@ -85,7 +84,7 @@ public class TasksFragment extends Fragment {
|
|||||||
totalTasksView.setText(String.valueOf(taskDataAccess.getTaskCount(taskListId)));
|
totalTasksView.setText(String.valueOf(taskDataAccess.getTaskCount(taskListId)));
|
||||||
|
|
||||||
// Set RecyclerView Adapter
|
// Set RecyclerView Adapter
|
||||||
TaskAdapter taskAdapter = new TaskAdapter(taskDataAccess.getAllTasks(taskListId), mListener);
|
final TaskAdapter taskAdapter = new TaskAdapter(taskDataAccess.getAllTasks(taskListId), mListener);
|
||||||
recyclerView.setAdapter(taskAdapter);
|
recyclerView.setAdapter(taskAdapter);
|
||||||
|
|
||||||
taskDataAccess.close();
|
taskDataAccess.close();
|
||||||
@@ -106,14 +105,16 @@ public class TasksFragment extends Fragment {
|
|||||||
public void onItemClick(View view, int position) {
|
public void onItemClick(View view, int position) {
|
||||||
//tasksFragmentListener.onItemClick(view, position);
|
//tasksFragmentListener.onItemClick(view, position);
|
||||||
|
|
||||||
/*TextView idTextView = (TextView) view.findViewById(R.id.task_id);
|
TextView idTextView = (TextView) view.findViewById(R.id.task_id);
|
||||||
mToast.setText("Item " + idTextView.getText() + " clicked!");
|
/*mToast.setText("Item " + idTextView.getText() + " clicked!");
|
||||||
mToast.show();*/
|
mToast.show();*/
|
||||||
|
|
||||||
FragmentManager manager = getFragmentManager();
|
FragmentManager manager = getFragmentManager();
|
||||||
NewTaskFragment newTaskFragment = new NewTaskFragment();
|
TaskDialogFragment taskDialogFragment = TaskDialogFragment.newInstance(taskAdapter, recyclerView);
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
args.putLong("id", Long.valueOf(idTextView.getText().toString()));
|
||||||
|
args.putInt("position", position);
|
||||||
|
|
||||||
// Set current tab value to new task dialog
|
// Set current tab value to new task dialog
|
||||||
ViewPager viewPager =(ViewPager) getActivity().findViewById(R.id.container);
|
ViewPager viewPager =(ViewPager) getActivity().findViewById(R.id.container);
|
||||||
@@ -131,8 +132,8 @@ public class TasksFragment extends Fragment {
|
|||||||
if (titleTextView.getTypeface().isBold()) priority = 2;
|
if (titleTextView.getTypeface().isBold()) priority = 2;
|
||||||
args.putInt("priority", priority);
|
args.putInt("priority", priority);
|
||||||
|
|
||||||
newTaskFragment.setArguments(args);
|
taskDialogFragment.setArguments(args);
|
||||||
newTaskFragment.show(manager, "Edit task");
|
taskDialogFragment.show(manager, "Edit task");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@@ -8,6 +8,8 @@ import android.view.View;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geoffroy on 15-12-02.
|
* Created by geoffroy on 15-12-02.
|
||||||
|
* Listener class on RecyclerView to intercept touch events
|
||||||
|
* This allows disabling swipe on any other element than the first one
|
||||||
*/
|
*/
|
||||||
public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
|
public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
|
||||||
private OnItemClickListener mListener;
|
private OnItemClickListener mListener;
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
|
||||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:paddingTop="@dimen/activity_vertical_margin"
|
|
||||||
tools:context="com.wismna.geoffroy.donext.activities.TaskDetailsActivity">
|
|
||||||
<fragment
|
|
||||||
android:name="com.wismna.geoffroy.donext.fragments.TaskDetailsFragment"
|
|
||||||
android:id="@+id/task_details_fragment"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent" />
|
|
||||||
</RelativeLayout>
|
|
@@ -30,7 +30,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:textColor="@color/colorPrimary"
|
android:textColor="@color/colorPrimary"
|
||||||
android:textSize="14dp"
|
android:textSize="14sp"
|
||||||
android:textAppearance="?attr/textAppearanceListItemSmall" />
|
android:textAppearance="?attr/textAppearanceListItemSmall" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context="com.wismna.geoffroy.donext.fragments.TaskDetailsFragment">
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/task_details_name"
|
|
||||||
android:layout_width="300dp"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:text="@string/hello_blank_fragment" />
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/task_details_description"
|
|
||||||
android:layout_width="300dp"
|
|
||||||
android:layout_height="50dp"
|
|
||||||
android:layout_below="@id/task_details_name"
|
|
||||||
android:text="@string/hello_blank_fragment" />
|
|
||||||
</RelativeLayout>
|
|
@@ -25,6 +25,7 @@
|
|||||||
<string name="new_task_priority_high">High</string>
|
<string name="new_task_priority_high">High</string>
|
||||||
<string name="new_task_save">Save</string>
|
<string name="new_task_save">Save</string>
|
||||||
<string name="new_task_cancel">Cancel</string>
|
<string name="new_task_cancel">Cancel</string>
|
||||||
|
<string name="new_task_delete">Delete</string>
|
||||||
|
|
||||||
<!-- String related to task details activity -->
|
<!-- String related to task details activity -->
|
||||||
<string name="task_details_activity_title">Details</string>
|
<string name="task_details_activity_title">Details</string>
|
||||||
@@ -39,8 +40,8 @@
|
|||||||
|
|
||||||
<!-- Strings related to Settings -->
|
<!-- Strings related to Settings -->
|
||||||
<string name="settings_confirm_message">Mark task as</string>
|
<string name="settings_confirm_message">Mark task as</string>
|
||||||
<string name="settings_confirm_donext">Confirm on DoNext?</string>
|
<string name="settings_confirm_donext">Confirm on next?</string>
|
||||||
<string name="settings_confirm_markdone">Confirm on mark Done?</string>
|
<string name="settings_confirm_markdone">Confirm on done?</string>
|
||||||
<string name="settings_confirm_delete">Confirm on delete?</string>
|
<string name="settings_confirm_delete">Confirm on delete?</string>
|
||||||
<string name="settings_max_lists_label">Maximum number of lists:</string>
|
<string name="settings_max_lists_label">Maximum number of lists:</string>
|
||||||
<string-array name="settings_max_lists_number">
|
<string-array name="settings_max_lists_number">
|
||||||
@@ -53,7 +54,4 @@
|
|||||||
<item>7</item>
|
<item>7</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string name="title_activity_task_list">TaskListActivity</string>
|
<string name="title_activity_task_list">TaskListActivity</string>
|
||||||
|
|
||||||
<!-- TODO: Remove or change this placeholder text -->
|
|
||||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Reference in New Issue
Block a user