Remove getDisplayView from TaskEditControlSetBase

pull/281/head
Alex Baker 9 years ago
parent d16b4a95be
commit 5b5b7342ba

@ -447,7 +447,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
TaskEditControlSet curr = controlSetMap.get(item); TaskEditControlSet curr = controlSetMap.get(item);
if (curr != null) { if (curr != null) {
controlSet = curr.getDisplayView(); controlSet = curr.getView();
} }
if (controlSet != null) { if (controlSet != null) {
@ -455,7 +455,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
} }
if (curr != null && curr.getClass().equals(openControl) && curr instanceof PopupControlSet) { if (curr != null && curr.getClass().equals(openControl) && curr instanceof PopupControlSet) {
curr.getDisplayView().performClick(); curr.getView().performClick();
} }
} }
} }
@ -588,7 +588,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
synchronized (controls) { synchronized (controls) {
if (!taskAttachmentDao.taskHasAttachments(model.getUuid())) { if (!taskAttachmentDao.taskHasAttachments(model.getUuid())) {
filesControlSet.getDisplayView().setVisibility(View.GONE); filesControlSet.getView().setVisibility(View.GONE);
} }
for (TaskEditControlSet controlSet : controls) { for (TaskEditControlSet controlSet : controls) {
controlSet.readFromTask(model); controlSet.readFromTask(model);
@ -842,7 +842,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
TaskAttachment attachment = TaskAttachment.createNewAttachment(model.getUuid(), path, fileName, fileType); TaskAttachment attachment = TaskAttachment.createNewAttachment(model.getUuid(), path, fileName, fileType);
taskAttachmentDao.createNew(attachment); taskAttachmentDao.createNew(attachment);
filesControlSet.refreshMetadata(); filesControlSet.refreshMetadata();
filesControlSet.getDisplayView().setVisibility(View.VISIBLE); filesControlSet.getView().setVisibility(View.VISIBLE);
} }
@Override @Override

@ -493,7 +493,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
FilesControlSet filesControlSet = new FilesControlSet(preferences, taskAttachmentDao, FilesControlSet filesControlSet = new FilesControlSet(preferences, taskAttachmentDao,
fragment.getActivity()); fragment.getActivity());
filesControlSet.readFromTask(task); filesControlSet.readFromTask(task);
filesControlSet.getDisplayView().performClick(); filesControlSet.getView().performClick();
} }
/* ====================================================================== /* ======================================================================

@ -52,7 +52,7 @@ public class FilesControlSet extends PopupControlSet {
public FilesControlSet(ActivityPreferences preferences, TaskAttachmentDao taskAttachmentDao, Activity activity) { public FilesControlSet(ActivityPreferences preferences, TaskAttachmentDao taskAttachmentDao, Activity activity) {
super(preferences, activity, R.layout.control_set_files_dialog, R.layout.control_set_files, R.string.TEA_control_files); super(preferences, activity, R.layout.control_set_files_dialog, R.layout.control_set_files, R.string.TEA_control_files);
this.taskAttachmentDao = taskAttachmentDao; this.taskAttachmentDao = taskAttachmentDao;
fileDisplayList = (LinearLayout) getDisplayView().findViewById(R.id.files_list); fileDisplayList = (LinearLayout) getView().findViewById(R.id.files_list);
inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
} }
@ -118,7 +118,7 @@ public class FilesControlSet extends PopupControlSet {
@Override @Override
protected void afterInflate() { protected void afterInflate() {
LinearLayout fileList = (LinearLayout) getView().findViewById(R.id.files_list); LinearLayout fileList = (LinearLayout) getDialogView().findViewById(R.id.files_list);
final LinearLayout finalList = fileList; final LinearLayout finalList = fileList;
fileList.removeAllViews(); fileList.removeAllViews();
LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);

@ -58,14 +58,14 @@ public class GCalControlSet extends PopupControlSet {
super(preferences, activity, R.layout.control_set_gcal, R.layout.control_set_gcal_display, title); super(preferences, activity, R.layout.control_set_gcal, R.layout.control_set_gcal_display, title);
this.gcal = gcal; this.gcal = gcal;
this.calendars = gcal.getCalendars(); this.calendars = gcal.getCalendars();
getView(); // Hack to force initialized getDialogView(); // Hack to force initialized
} }
@Override @Override
protected void afterInflate() { protected void afterInflate() {
((LinearLayout) getDisplayView()).addView(getView()); //hack for spinner ((LinearLayout) getView()).addView(getDialogView()); //hack for spinner
this.calendarSelector = (Spinner) getView().findViewById(R.id.calendars); this.calendarSelector = (Spinner) getDialogView().findViewById(R.id.calendars);
ArrayList<String> items = new ArrayList<>(); ArrayList<String> items = new ArrayList<>();
Collections.addAll(items, calendars.calendars); Collections.addAll(items, calendars.calendars);
items.add(0, activity.getString(R.string.gcal_TEA_nocal)); items.add(0, activity.getString(R.string.gcal_TEA_nocal));
@ -219,7 +219,7 @@ public class GCalControlSet extends PopupControlSet {
@Override @Override
protected void refreshDisplayView() { protected void refreshDisplayView() {
TextView calendar = (TextView) getDisplayView().findViewById(R.id.calendar_display_which); TextView calendar = (TextView) getView().findViewById(R.id.calendar_display_which);
calendar.setTextColor(themeColor); calendar.setTextColor(themeColor);
if (initialized) { if (initialized) {
if (hasEvent) { if (hasEvent) {
@ -249,7 +249,7 @@ public class GCalControlSet extends PopupControlSet {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (calendarSelector == null) { if (calendarSelector == null) {
getView(); // Force load getDialogView(); // Force load
} }
if (!hasEvent) { if (!hasEvent) {
calendarSelector.performClick(); calendarSelector.performClick();

@ -7,8 +7,6 @@ import com.todoroo.astrid.data.Task;
public interface TaskEditControlSet { public interface TaskEditControlSet {
View getView(); View getView();
View getDisplayView();
void readFromTask(Task task); void readFromTask(Task task);
void writeToModel(Task task); void writeToModel(Task task);

@ -62,11 +62,6 @@ public abstract class TaskEditControlSetBase implements TaskEditControlSet {
return view; return view;
} }
@Override
public View getDisplayView() {
return getView();
}
/** /**
* Read data from model to update the control set * Read data from model to update the control set
*/ */

@ -245,17 +245,17 @@ public class RepeatControlSet extends PopupControlSet {
@Override @Override
protected void afterInflate() { protected void afterInflate() {
value = (Button) getView().findViewById(R.id.repeatValue); value = (Button) getDialogView().findViewById(R.id.repeatValue);
interval = (Spinner) getView().findViewById(R.id.repeatInterval); interval = (Spinner) getDialogView().findViewById(R.id.repeatInterval);
interval.setAdapter(new ArrayAdapter<String>(activity, R.layout.simple_spinner_item, activity.getResources().getStringArray(R.array.repeat_interval)) {{ interval.setAdapter(new ArrayAdapter<String>(activity, R.layout.simple_spinner_item, activity.getResources().getStringArray(R.array.repeat_interval)) {{
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}}); }});
type = (Spinner) getView().findViewById(R.id.repeatType); type = (Spinner) getDialogView().findViewById(R.id.repeatType);
type.setAdapter(new ArrayAdapter<String>(activity, R.layout.simple_spinner_item, activity.getResources().getStringArray(R.array.repeat_type)) {{ type.setAdapter(new ArrayAdapter<String>(activity, R.layout.simple_spinner_item, activity.getResources().getStringArray(R.array.repeat_type)) {{
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}}); }});
daysOfWeekContainer = (LinearLayout) getView().findViewById(R.id.repeatDayOfWeekContainer); daysOfWeekContainer = (LinearLayout) getDialogView().findViewById(R.id.repeatDayOfWeekContainer);
repeatUntil = (Button) getView().findViewById(R.id.repeatUntil); repeatUntil = (Button) getDialogView().findViewById(R.id.repeatUntil);
setRepeatValue(1); setRepeatValue(1);
setRepeatUntilValue(0); setRepeatUntilValue(0);
@ -374,7 +374,7 @@ public class RepeatControlSet extends PopupControlSet {
@Override @Override
protected void refreshDisplayView() { protected void refreshDisplayView() {
TextView repeatDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit); TextView repeatDisplay = (TextView) getView().findViewById(R.id.display_row_edit);
if (doRepeat) { if (doRepeat) {
repeatDisplay.setText(getRepeatString()); repeatDisplay.setText(getRepeatString());
repeatDisplay.setTextColor(themeColor); repeatDisplay.setTextColor(themeColor);
@ -425,7 +425,7 @@ public class RepeatControlSet extends PopupControlSet {
} }
} }
}; };
getView().findViewById(R.id.edit_dont_repeat).setOnClickListener(dontRepeatButton); getDialogView().findViewById(R.id.edit_dont_repeat).setOnClickListener(dontRepeatButton);
return d; return d;
} }

@ -76,7 +76,7 @@ public final class TagsControlSet extends PopupControlSet {
this.metadataDao = metadataDao; this.metadataDao = metadataDao;
this.tagDataDao = tagDataDao; this.tagDataDao = tagDataDao;
this.tagService = tagService; this.tagService = tagService;
tagsDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit); tagsDisplay = (TextView) getView().findViewById(R.id.display_row_edit);
} }
private TagData[] getTagArray() { private TagData[] getTagArray() {
@ -286,12 +286,12 @@ public final class TagsControlSet extends PopupControlSet {
allTagNames = getTagNames(allTags); allTagNames = getTagNames(allTags);
tagIndices = buildTagIndices(allTagNames); tagIndices = buildTagIndices(allTagNames);
selectedTags = (ListView) getView().findViewById(R.id.existingTags); selectedTags = (ListView) getDialogView().findViewById(R.id.existingTags);
selectedTags.setAdapter(new ArrayAdapter<>(activity, selectedTags.setAdapter(new ArrayAdapter<>(activity,
R.layout.simple_list_item_multiple_choice_themed, allTagNames)); R.layout.simple_list_item_multiple_choice_themed, allTagNames));
selectedTags.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); selectedTags.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
this.newTags = (LinearLayout) getView().findViewById(R.id.newTags); this.newTags = (LinearLayout) getDialogView().findViewById(R.id.newTags);
} }
@Override @Override

@ -35,12 +35,12 @@ public class TimerControlSet extends PopupControlSet implements TimerActionListe
public TimerControlSet(ActivityPreferences preferences, final Activity activity, int viewLayout, int displayViewLayout, int title) { public TimerControlSet(ActivityPreferences preferences, final Activity activity, int viewLayout, int displayViewLayout, int title) {
super(preferences, activity, viewLayout, displayViewLayout, title); super(preferences, activity, viewLayout, displayViewLayout, title);
displayEdit = (TextView) getDisplayView().findViewById(R.id.display_row_edit); displayEdit = (TextView) getView().findViewById(R.id.display_row_edit);
displayEdit.setText(R.string.TEA_timer_controls); displayEdit.setText(R.string.TEA_timer_controls);
displayEdit.setTextColor(unsetColor); displayEdit.setTextColor(unsetColor);
estimated = new TimeDurationTaskEditControlSet(activity, getView(), Task.ESTIMATED_SECONDS,R.id.estimatedDuration); estimated = new TimeDurationTaskEditControlSet(activity, getDialogView(), Task.ESTIMATED_SECONDS,R.id.estimatedDuration);
elapsed = new TimeDurationTaskEditControlSet(activity, getView(), Task.ELAPSED_SECONDS, R.id.elapsedDuration); elapsed = new TimeDurationTaskEditControlSet(activity, getDialogView(), Task.ELAPSED_SECONDS, R.id.elapsedDuration);
} }
@Override @Override

@ -44,7 +44,7 @@ public class DeadlineControlSet extends PopupControlSet {
displayString.append(DateAndTimePicker.getDisplayString(activity, model.getDueDate(), false, false)); displayString.append(DateAndTimePicker.getDisplayString(activity, model.getDueDate(), false, false));
} }
TextView dateDisplay = (TextView) getDisplayView().findViewById(R.id.display_row_edit); TextView dateDisplay = (TextView) getView().findViewById(R.id.display_row_edit);
if (TextUtils.isEmpty(displayString)) { if (TextUtils.isEmpty(displayString)) {
dateDisplay.setText(R.string.TEA_deadline_hint); dateDisplay.setText(R.string.TEA_deadline_hint);
dateDisplay.setTextColor(unsetColor); dateDisplay.setTextColor(unsetColor);
@ -60,8 +60,8 @@ public class DeadlineControlSet extends PopupControlSet {
@Override @Override
protected void afterInflate() { protected void afterInflate() {
dateAndTimePicker = (DateAndTimePicker) getView().findViewById(R.id.date_and_time); dateAndTimePicker = (DateAndTimePicker) getDialogView().findViewById(R.id.date_and_time);
LinearLayout body = (LinearLayout) getView().findViewById(R.id.datetime_body); LinearLayout body = (LinearLayout) getDialogView().findViewById(R.id.datetime_body);
body.setGravity(Gravity.CENTER_HORIZONTAL); body.setGravity(Gravity.CENTER_HORIZONTAL);
Button okButton = (Button) LayoutInflater.from(activity).inflate(R.layout.control_dialog_ok, null); Button okButton = (Button) LayoutInflater.from(activity).inflate(R.layout.control_dialog_ok, null);
DisplayMetrics metrics = activity.getResources().getDisplayMetrics(); DisplayMetrics metrics = activity.getResources().getDisplayMetrics();

@ -148,9 +148,4 @@ public class EditTitleControlSet implements TaskEditControlSet, ImportanceChange
public View getView() { public View getView() {
throw new RuntimeException(); throw new RuntimeException();
} }
@Override
public View getDisplayView() {
throw new RuntimeException();
}
} }

@ -48,11 +48,11 @@ public abstract class PopupControlSet extends TaskEditControlSetBase {
} }
}; };
public PopupControlSet(ActivityPreferences preferences, Activity activity, int viewLayout, int displayViewLayout, final int title) { public PopupControlSet(ActivityPreferences preferences, Activity activity, int viewLayout, int taskEditViewLayout, final int title) {
super(activity, viewLayout); super(activity, viewLayout);
this.preferences = preferences; this.preferences = preferences;
if (displayViewLayout != -1) { if (taskEditViewLayout != -1) {
this.displayView = LayoutInflater.from(activity).inflate(displayViewLayout, null); this.displayView = LayoutInflater.from(activity).inflate(taskEditViewLayout, null);
} else { } else {
this.displayView = null; this.displayView = null;
} }
@ -64,10 +64,14 @@ public abstract class PopupControlSet extends TaskEditControlSetBase {
} }
} }
@Override @Override
public View getDisplayView() { public View getView() {
return displayView; return displayView;
} }
protected View getDialogView() {
return super.getView();
}
protected Dialog buildDialog(String title, final PopupDialogClickListener okClickListener, DialogInterface.OnCancelListener cancelClickListener) { protected Dialog buildDialog(String title, final PopupDialogClickListener okClickListener, DialogInterface.OnCancelListener cancelClickListener) {
dialog = new Dialog(activity, preferences.getEditDialogTheme()); dialog = new Dialog(activity, preferences.getEditDialogTheme());
if (title.length() == 0) { if (title.length() == 0) {
@ -76,7 +80,7 @@ public abstract class PopupControlSet extends TaskEditControlSetBase {
dialog.setTitle(title); dialog.setTitle(title);
} }
View v = getView(); View v = getDialogView();
dialog.setContentView(v, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); dialog.setContentView(v, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Button dismiss = (Button) v.findViewById(R.id.edit_dlg_ok); Button dismiss = (Button) v.findViewById(R.id.edit_dlg_ok);

@ -40,9 +40,9 @@ public class ReminderControlSet extends PopupControlSet {
public ReminderControlSet(ActivityPreferences preferences, AlarmService alarmService, TaskEditFragment taskEditFragment) { public ReminderControlSet(ActivityPreferences preferences, AlarmService alarmService, TaskEditFragment taskEditFragment) {
super(preferences, taskEditFragment.getActivity(), R.layout.control_set_reminders_dialog, R.layout.control_set_reminders, R.string.TEA_reminders_group_label); super(preferences, taskEditFragment.getActivity(), R.layout.control_set_reminders_dialog, R.layout.control_set_reminders, R.string.TEA_reminders_group_label);
label = (TextView) getDisplayView().findViewById(R.id.display_row_edit); label = (TextView) getView().findViewById(R.id.display_row_edit);
alarmControl = new AlarmControlSet(alarmService, taskEditFragment); alarmControl = new AlarmControlSet(alarmService, taskEditFragment);
LinearLayout reminderRow = (LinearLayout) getDisplayView().findViewById(R.id.reminder_row); LinearLayout reminderRow = (LinearLayout) getView().findViewById(R.id.reminder_row);
reminderRow.addView(alarmControl.getView()); reminderRow.addView(alarmControl.getView());
} }
@ -81,11 +81,11 @@ public class ReminderControlSet extends PopupControlSet {
@Override @Override
protected void afterInflate() { protected void afterInflate() {
during = (CheckBox) getView().findViewById(R.id.reminder_due); during = (CheckBox) getDialogView().findViewById(R.id.reminder_due);
after = (CheckBox) getView().findViewById(R.id.reminder_overdue); after = (CheckBox) getDialogView().findViewById(R.id.reminder_overdue);
modeDisplay = (TextView) getView().findViewById(R.id.reminder_alarm_display); modeDisplay = (TextView) getDialogView().findViewById(R.id.reminder_alarm_display);
mode = (Spinner) getView().findViewById(R.id.reminder_alarm); mode = (Spinner) getDialogView().findViewById(R.id.reminder_alarm);
View modeContainer = getView().findViewById(R.id.reminder_alarm_container); View modeContainer = getDialogView().findViewById(R.id.reminder_alarm_container);
modeContainer.setOnClickListener(new OnClickListener() { modeContainer.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -93,7 +93,7 @@ public class ReminderControlSet extends PopupControlSet {
} }
}); });
randomControlSet = new RandomReminderControlSet(activity, getView(), -1); randomControlSet = new RandomReminderControlSet(activity, getDialogView(), -1);
String[] list = new String[] { String[] list = new String[] {
activity.getString(R.string.TEA_reminder_mode_once), activity.getString(R.string.TEA_reminder_mode_once),

Loading…
Cancel
Save