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);
if (curr != null) {
controlSet = curr.getDisplayView();
controlSet = curr.getView();
}
if (controlSet != null) {
@ -455,7 +455,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
}
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) {
if (!taskAttachmentDao.taskHasAttachments(model.getUuid())) {
filesControlSet.getDisplayView().setVisibility(View.GONE);
filesControlSet.getView().setVisibility(View.GONE);
}
for (TaskEditControlSet controlSet : controls) {
controlSet.readFromTask(model);
@ -842,7 +842,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
TaskAttachment attachment = TaskAttachment.createNewAttachment(model.getUuid(), path, fileName, fileType);
taskAttachmentDao.createNew(attachment);
filesControlSet.refreshMetadata();
filesControlSet.getDisplayView().setVisibility(View.VISIBLE);
filesControlSet.getView().setVisibility(View.VISIBLE);
}
@Override

@ -493,7 +493,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
FilesControlSet filesControlSet = new FilesControlSet(preferences, taskAttachmentDao,
fragment.getActivity());
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) {
super(preferences, activity, R.layout.control_set_files_dialog, R.layout.control_set_files, R.string.TEA_control_files);
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);
}
@ -118,7 +118,7 @@ public class FilesControlSet extends PopupControlSet {
@Override
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;
fileList.removeAllViews();
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);
this.gcal = gcal;
this.calendars = gcal.getCalendars();
getView(); // Hack to force initialized
getDialogView(); // Hack to force initialized
}
@Override
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<>();
Collections.addAll(items, calendars.calendars);
items.add(0, activity.getString(R.string.gcal_TEA_nocal));
@ -219,7 +219,7 @@ public class GCalControlSet extends PopupControlSet {
@Override
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);
if (initialized) {
if (hasEvent) {
@ -249,7 +249,7 @@ public class GCalControlSet extends PopupControlSet {
@Override
public void onClick(View v) {
if (calendarSelector == null) {
getView(); // Force load
getDialogView(); // Force load
}
if (!hasEvent) {
calendarSelector.performClick();

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

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

@ -245,17 +245,17 @@ public class RepeatControlSet extends PopupControlSet {
@Override
protected void afterInflate() {
value = (Button) getView().findViewById(R.id.repeatValue);
interval = (Spinner) getView().findViewById(R.id.repeatInterval);
value = (Button) getDialogView().findViewById(R.id.repeatValue);
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)) {{
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)) {{
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
}});
daysOfWeekContainer = (LinearLayout) getView().findViewById(R.id.repeatDayOfWeekContainer);
repeatUntil = (Button) getView().findViewById(R.id.repeatUntil);
daysOfWeekContainer = (LinearLayout) getDialogView().findViewById(R.id.repeatDayOfWeekContainer);
repeatUntil = (Button) getDialogView().findViewById(R.id.repeatUntil);
setRepeatValue(1);
setRepeatUntilValue(0);
@ -374,7 +374,7 @@ public class RepeatControlSet extends PopupControlSet {
@Override
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) {
repeatDisplay.setText(getRepeatString());
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;
}

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

@ -44,7 +44,7 @@ public class DeadlineControlSet extends PopupControlSet {
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)) {
dateDisplay.setText(R.string.TEA_deadline_hint);
dateDisplay.setTextColor(unsetColor);
@ -60,8 +60,8 @@ public class DeadlineControlSet extends PopupControlSet {
@Override
protected void afterInflate() {
dateAndTimePicker = (DateAndTimePicker) getView().findViewById(R.id.date_and_time);
LinearLayout body = (LinearLayout) getView().findViewById(R.id.datetime_body);
dateAndTimePicker = (DateAndTimePicker) getDialogView().findViewById(R.id.date_and_time);
LinearLayout body = (LinearLayout) getDialogView().findViewById(R.id.datetime_body);
body.setGravity(Gravity.CENTER_HORIZONTAL);
Button okButton = (Button) LayoutInflater.from(activity).inflate(R.layout.control_dialog_ok, null);
DisplayMetrics metrics = activity.getResources().getDisplayMetrics();

@ -148,9 +148,4 @@ public class EditTitleControlSet implements TaskEditControlSet, ImportanceChange
public View getView() {
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);
this.preferences = preferences;
if (displayViewLayout != -1) {
this.displayView = LayoutInflater.from(activity).inflate(displayViewLayout, null);
if (taskEditViewLayout != -1) {
this.displayView = LayoutInflater.from(activity).inflate(taskEditViewLayout, null);
} else {
this.displayView = null;
}
@ -64,10 +64,14 @@ public abstract class PopupControlSet extends TaskEditControlSetBase {
}
}
@Override
public View getDisplayView() {
public View getView() {
return displayView;
}
protected View getDialogView() {
return super.getView();
}
protected Dialog buildDialog(String title, final PopupDialogClickListener okClickListener, DialogInterface.OnCancelListener cancelClickListener) {
dialog = new Dialog(activity, preferences.getEditDialogTheme());
if (title.length() == 0) {
@ -76,7 +80,7 @@ public abstract class PopupControlSet extends TaskEditControlSetBase {
dialog.setTitle(title);
}
View v = getView();
View v = getDialogView();
dialog.setContentView(v, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
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) {
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);
LinearLayout reminderRow = (LinearLayout) getDisplayView().findViewById(R.id.reminder_row);
LinearLayout reminderRow = (LinearLayout) getView().findViewById(R.id.reminder_row);
reminderRow.addView(alarmControl.getView());
}
@ -81,11 +81,11 @@ public class ReminderControlSet extends PopupControlSet {
@Override
protected void afterInflate() {
during = (CheckBox) getView().findViewById(R.id.reminder_due);
after = (CheckBox) getView().findViewById(R.id.reminder_overdue);
modeDisplay = (TextView) getView().findViewById(R.id.reminder_alarm_display);
mode = (Spinner) getView().findViewById(R.id.reminder_alarm);
View modeContainer = getView().findViewById(R.id.reminder_alarm_container);
during = (CheckBox) getDialogView().findViewById(R.id.reminder_due);
after = (CheckBox) getDialogView().findViewById(R.id.reminder_overdue);
modeDisplay = (TextView) getDialogView().findViewById(R.id.reminder_alarm_display);
mode = (Spinner) getDialogView().findViewById(R.id.reminder_alarm);
View modeContainer = getDialogView().findViewById(R.id.reminder_alarm_container);
modeContainer.setOnClickListener(new OnClickListener() {
@Override
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[] {
activity.getString(R.string.TEA_reminder_mode_once),

Loading…
Cancel
Save