mirror of
https://github.com/wismna/DoNext.git
synced 2025-10-03 15:40:14 -04:00
New task dialog works with list auto set to current tab
This commit is contained in:
@@ -85,6 +85,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
public void openNewTaskDialog(MenuItem menuItem) {
|
public void openNewTaskDialog(MenuItem menuItem) {
|
||||||
android.app.FragmentManager manager = getFragmentManager();
|
android.app.FragmentManager manager = getFragmentManager();
|
||||||
NewTaskFragment newTaskFragment = new NewTaskFragment();
|
NewTaskFragment newTaskFragment = new NewTaskFragment();
|
||||||
|
|
||||||
|
// Set current tab value to new task dialog
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putInt("list", mViewPager.getCurrentItem());
|
||||||
|
newTaskFragment.setArguments(args);
|
||||||
|
|
||||||
newTaskFragment.show(manager, "Create new task");
|
newTaskFragment.show(manager, "Create new task");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,6 +147,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
|
||||||
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
|
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
|
||||||
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
|
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
|
||||||
|
|
||||||
|
// TODO: implement task list
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,6 +170,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
return PlaceholderFragment.newInstance(position + 1);
|
return PlaceholderFragment.newInstance(position + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*@Override
|
||||||
|
public Object instantiateItem(ViewGroup container, int position) {
|
||||||
|
return super.instantiateItem(container, position);
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
if (taskLists != null) {
|
if (taskLists != null) {
|
||||||
|
@@ -26,6 +26,6 @@ public class TaskList {
|
|||||||
// 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() {
|
||||||
return String.valueOf(id);
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -26,10 +26,11 @@ public class NewTaskFragment extends DialogFragment {
|
|||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
// Get the layout inflater
|
// Get the layout inflater
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
|
View view = inflater.inflate(R.layout.new_task, null);
|
||||||
|
|
||||||
// Inflate and set the layout for the dialog
|
// Inflate and set the layout for the dialog
|
||||||
// Pass null as the parent view because its going in the dialog layout
|
// Pass null as the parent view because its going in the dialog layout
|
||||||
builder.setView(inflater.inflate(R.layout.new_task, null))
|
builder.setView(view)
|
||||||
// Add action buttons
|
// Add action buttons
|
||||||
.setPositiveButton(R.string.new_task_save, new DialogInterface.OnClickListener() {
|
.setPositiveButton(R.string.new_task_save, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -42,12 +43,6 @@ public class NewTaskFragment extends DialogFragment {
|
|||||||
NewTaskFragment.this.getDialog().cancel();
|
NewTaskFragment.this.getDialog().cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return builder.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
|
||||||
super.onViewCreated(view, savedInstanceState);
|
|
||||||
|
|
||||||
// Access database to retrieve task lists
|
// Access database to retrieve task lists
|
||||||
TasksDataAccess dataAccess = new TasksDataAccess(getActivity());
|
TasksDataAccess dataAccess = new TasksDataAccess(getActivity());
|
||||||
@@ -62,5 +57,12 @@ public class NewTaskFragment extends DialogFragment {
|
|||||||
// Specify the layout to use when the list of choices appears
|
// Specify the layout to use when the list of choices appears
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
spinner.setAdapter(adapter);
|
spinner.setAdapter(adapter);
|
||||||
|
|
||||||
|
// Auto set list value to current tab
|
||||||
|
Bundle args = getArguments();
|
||||||
|
int id = args.getInt("list");
|
||||||
|
spinner.setSelection(id);
|
||||||
|
|
||||||
|
return builder.create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user