Commit d0326bf2 authored by Mehran Mahmoudi's avatar Mehran Mahmoudi Committed by Commit Bot

[Touchless] Fix problem with TouchlessDialogPresenter

This adds the capability to replace a dialog's ModelList while the
dialog is being displayed. More details can be found in the crbug.

Bug: 993528
Change-Id: I43f8934cd4e138f7a4b99e1ad923b7515dacb46b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1758547Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689174}
parent be3bb277
...@@ -89,16 +89,6 @@ public class TouchlessDialogPresenter extends Presenter { ...@@ -89,16 +89,6 @@ public class TouchlessDialogPresenter extends Presenter {
}); });
ViewGroup dialogView = (ViewGroup) LayoutInflater.from(mDialog.getContext()) ViewGroup dialogView = (ViewGroup) LayoutInflater.from(mDialog.getContext())
.inflate(R.layout.touchless_dialog_view, null); .inflate(R.layout.touchless_dialog_view, null);
if (model.get(TouchlessDialogProperties.LIST_MODELS) != null) {
ModelListAdapter adapter =
new ModelListAdapter(model.get(TouchlessDialogProperties.LIST_MODELS));
adapter.registerType(ListItemType.DEFAULT,
() -> LayoutInflater.from(mActivity).inflate(R.layout.dialog_list_item, null),
TouchlessDialogPresenter::bindListItem);
ListView dialogOptions = dialogView.findViewById(R.id.touchless_dialog_option_list);
dialogOptions.setAdapter(adapter);
dialogOptions.setItemsCanFocus(true);
}
mModelChangeProcessor = PropertyModelChangeProcessor.create( mModelChangeProcessor = PropertyModelChangeProcessor.create(
model, dialogView, TouchlessDialogPresenter::bind); model, dialogView, TouchlessDialogPresenter::bind);
mDialog.setContentView(dialogView); mDialog.setContentView(dialogView);
...@@ -166,6 +156,16 @@ public class TouchlessDialogPresenter extends Presenter { ...@@ -166,6 +156,16 @@ public class TouchlessDialogPresenter extends Presenter {
ViewGroup customGroup = view.findViewById(R.id.custom); ViewGroup customGroup = view.findViewById(R.id.custom);
customGroup.addView(model.get(ModalDialogProperties.CUSTOM_VIEW)); customGroup.addView(model.get(ModalDialogProperties.CUSTOM_VIEW));
customGroup.setVisibility(View.VISIBLE); customGroup.setVisibility(View.VISIBLE);
} else if (TouchlessDialogProperties.LIST_MODELS == propertyKey) {
ModelListAdapter adapter =
new ModelListAdapter(model.get(TouchlessDialogProperties.LIST_MODELS));
adapter.registerType(ListItemType.DEFAULT,
() -> LayoutInflater.from(view.getContext())
.inflate(R.layout.dialog_list_item, null),
TouchlessDialogPresenter::bindListItem);
ListView dialogOptions = view.findViewById(R.id.touchless_dialog_option_list);
dialogOptions.setAdapter(adapter);
dialogOptions.setItemsCanFocus(true);
} else if (TouchlessDialogProperties.FORCE_SINGLE_LINE_TITLE == propertyKey) { } else if (TouchlessDialogProperties.FORCE_SINGLE_LINE_TITLE == propertyKey) {
TextView textView = view.findViewById(R.id.touchless_dialog_title); TextView textView = view.findViewById(R.id.touchless_dialog_title);
textView.setMaxLines(model.get(TouchlessDialogProperties.FORCE_SINGLE_LINE_TITLE) textView.setMaxLines(model.get(TouchlessDialogProperties.FORCE_SINGLE_LINE_TITLE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment