| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorModel.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorModel.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorModel.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ca423c18660526e4b9d61391c158e2c009b85088
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorModel.java
|
| @@ -0,0 +1,85 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.chrome.browser.payments.ui;
|
| +
|
| +import java.util.ArrayList;
|
| +import java.util.List;
|
| +
|
| +import javax.annotation.Nullable;
|
| +
|
| +/**
|
| + * Representation of an editor layout. Can be used, for example, to edit contact information.
|
| + */
|
| +public class EditorModel {
|
| + private final String mTitle;
|
| + private final List<EditorFieldModel> mFields;
|
| + @Nullable private Runnable mDoneCallback;
|
| + @Nullable private Runnable mCancelCallback;
|
| +
|
| + /**
|
| + * Constructs an editor model.
|
| + *
|
| + * @param title The title for the editor window.
|
| + */
|
| + public EditorModel(String title) {
|
| + mTitle = title;
|
| + mFields = new ArrayList<>();
|
| + }
|
| +
|
| + /** @return The title of the editor window. */
|
| + public String getTitle() {
|
| + return mTitle;
|
| + }
|
| +
|
| + /** @return The input fields for the editor. */
|
| + public List<EditorFieldModel> getFields() {
|
| + return mFields;
|
| + }
|
| +
|
| + /**
|
| + * Adds an input field to the editor.
|
| + *
|
| + * @param field The input field to add.
|
| + */
|
| + public void addField(EditorFieldModel field) {
|
| + mFields.add(field);
|
| + }
|
| +
|
| + /**
|
| + * Specifies the callback to invoke when the user clicks "Done."
|
| + *
|
| + * @param callback The callback to invoke when the user clicks "Done."
|
| + */
|
| + public void setDoneCallback(Runnable callback) {
|
| + mDoneCallback = callback;
|
| + }
|
| +
|
| + /**
|
| + * Specifies the callback to invoke when the user clicks "Cancel."
|
| + *
|
| + * @param callback The callback to invoke when the user clicks "Cancel."
|
| + */
|
| + public void setCancelCallback(Runnable callback) {
|
| + mCancelCallback = callback;
|
| + }
|
| +
|
| + /**
|
| + * Called when the user clicks "Done."
|
| + */
|
| + public void done() {
|
| + if (mDoneCallback != null) mDoneCallback.run();
|
| + mDoneCallback = null;
|
| + mCancelCallback = null;
|
| + }
|
| +
|
| + /**
|
| + * Called when the user clicks "Cancel."
|
| + */
|
| + public void cancel() {
|
| + if (mCancelCallback != null) mCancelCallback.run();
|
| + mDoneCallback = null;
|
| + mCancelCallback = null;
|
| + }
|
| +}
|
|
|