Chromium Code Reviews| 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..a4eba4302d1d659b63ed709be2387ff4371066d3 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/EditorModel.java |
| @@ -0,0 +1,91 @@ |
| +// 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; |
| + |
| +/** |
| + * 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; |
| + private Runnable mDoneCallback; |
| + private Runnable mCancelCallback; |
| + |
| + /** |
| + * Constructs an editor model. |
| + * |
| + * @param title The title for the editor window. |
| + */ |
| + public EditorModel(String title) { |
| + mTitle = title; |
| + mFields = new ArrayList<>(); |
| + } |
| + |
| + /** |
| + * Returns the title of the editor window. |
| + * |
| + * @return The title of the editor window. |
|
gone
2016/06/21 06:04:39
For these simple accessors, you might want to just
please use gerrit instead
2016/06/22 02:12:30
Done.
|
| + */ |
| + public String getTitle() { |
| + return mTitle; |
| + } |
| + |
| + /** |
| + * Returns the input fields for the editor. |
| + * |
| + * @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; |
| + } |
| +} |