1a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov/*
2a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Copyright (C) 2013 The Android Open Source Project
3a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov *
4a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Licensed under the Apache License, Version 2.0 (the "License");
5a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * you may not use this file except in compliance with the License.
6a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * You may obtain a copy of the License at
7a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov *
8a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov *      http://www.apache.org/licenses/LICENSE-2.0
9a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov *
10a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Unless required by applicable law or agreed to in writing, software
11a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * distributed under the License is distributed on an "AS IS" BASIS,
12a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * See the License for the specific language governing permissions and
14a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * limitations under the License.
15a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov */
16a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
17a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganovpackage android.print;
18a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
196283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslavimport android.os.Bundle;
20a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganovimport android.os.CancellationSignal;
21d26d4898fcc9b78f4b66118895c375384098205eSvetoslav Ganovimport android.os.ParcelFileDescriptor;
22a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
23a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov/**
24a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Base class that provides the content of a document to be printed.
25a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov *
26a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <h3>Lifecycle</h3>
27a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <p>
28a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <ul>
29a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <li>
30a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Initially, you will receive a call to {@link #onStart()}. This callback
31a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * can be used to allocate resources.
32a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </li>
33a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <li>
34a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Next, you will get one or more calls to {@link #onLayout(PrintAttributes,
356283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * PrintAttributes, CancellationSignal, LayoutResultCallback, Bundle)} to
366283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * inform you that the print attributes (page size, density, etc) changed
376283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * giving you an opportunity to layout the content to match the new constraints.
38a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </li>
39a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <li>
40a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * After every call to {@link #onLayout(PrintAttributes, PrintAttributes,
416283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * CancellationSignal, LayoutResultCallback, Bundle)}, you may get a call to
42d26d4898fcc9b78f4b66118895c375384098205eSvetoslav Ganov * {@link #onWrite(PageRange[], ParcelFileDescriptor, CancellationSignal, WriteResultCallback)}
43a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * asking you to write a PDF file with the content for specific pages.
44a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </li>
45a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <li>
46a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Finally, you will receive a call to {@link #onFinish()}. You can use this
47a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * callback to release resources allocated in {@link #onStart()}.
48a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </li>
49a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </ul>
50a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </p>
516283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * <h3>Implementation</h3>
526283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * <p>
536283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * The APIs defined in this class are designed to enable doing part or all
546283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * of the work on an arbitrary thread. For example, if the printed content
556283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * does not depend on the UI state, i.e. on what is shown on the screen, then
5619fba5d34a444ce145ab0d3a12c578d9d5d3f38cSvetoslav Ganov * you can offload the entire work on a dedicated thread, thus making your
576283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * application interactive while the print work is being performed.
586283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * </p>
596283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * <p>
606283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * You can also do work on different threads, for example if you print UI
616283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * content, you can handle {@link #onStart()} and {@link #onLayout(PrintAttributes,
626283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * PrintAttributes, CancellationSignal, LayoutResultCallback, Bundle)} on
636283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * the UI thread (assuming onStart initializes resources needed for layout).
646283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * This will ensure that the UI does not change while you are laying out the
65d26d4898fcc9b78f4b66118895c375384098205eSvetoslav Ganov * printed content. Then you can handle {@link #onWrite(PageRange[], ParcelFileDescriptor,
666283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * CancellationSignal, WriteResultCallback)} and {@link #onFinish()} on another
676283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * thread. This will ensure that the UI is frozen for the minimal amount of
686283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * time. Also this assumes that you will generate the printed content in
696283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * {@link #onLayout(PrintAttributes, PrintAttributes, CancellationSignal,
706283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * LayoutResultCallback, Bundle)} which is not mandatory. If you use multiple
716283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * threads, you are responsible for proper synchronization.
726283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * </p>
73a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov */
74a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganovpublic abstract class PrintDocumentAdapter {
75a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
76a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
776811f4e92cbb64e72a0d13eb9b99b5894bd59c76Svetoslav     * Extra: mapped to a boolean value that is <code>true</code> if
786283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * the current layout is for a print preview, <code>false</code> otherwise.
796283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     */
806811f4e92cbb64e72a0d13eb9b99b5894bd59c76Svetoslav    public static final String EXTRA_PRINT_PREVIEW = "EXTRA_PRINT_PREVIEW";
816283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav
826283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav    /**
83a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Called when printing starts. You can use this callback to allocate
84a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * resources. This method is invoked on the main thread.
85a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     */
86a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    public void onStart() {
87a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /* do nothing - stub */
88a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    }
89a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
90a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
91a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Called when the print attributes (page size, density, etc) changed
92a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * giving you a chance to layout the content such that it matches the
93a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * new constraints. This method is invoked on the main thread.
94a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * <p>
956283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * After you are done laying out, you <strong>must</strong> invoke: {@link
966283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * LayoutResultCallback#onLayoutFinished(PrintDocumentInfo, boolean)} with
976283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * the last argument <code>true</code> or <code>false</code> depending on
986283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * whether the layout changed the content or not, respectively; and {@link
996283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * LayoutResultCallback#onLayoutFailed(CharSequence)}, if an error occurred.
10019fba5d34a444ce145ab0d3a12c578d9d5d3f38cSvetoslav Ganov     * Note that you must call one of the methods of the given callback.
101a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * </p>
102a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * <p>
103a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * <strong>Note:</strong> If the content is large and a layout will be
104a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * performed, it is a good practice to schedule the work on a dedicated
105a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * thread and register an observer in the provided {@link
106a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * CancellationSignal} upon invocation of which you should stop the
107a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * layout. The cancellation callback will not be made on the main
108a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * thread.
109a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * </p>
110a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     *
111a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param oldAttributes The old print attributes.
112a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param newAttributes The new print attributes.
113a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param cancellationSignal Signal for observing cancel layout requests.
114a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param callback Callback to inform the system for the layout result.
1156811f4e92cbb64e72a0d13eb9b99b5894bd59c76Svetoslav     * @param extras Additional information about how to layout the content.
116a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     *
117a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @see LayoutResultCallback
118a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @see CancellationSignal
1196811f4e92cbb64e72a0d13eb9b99b5894bd59c76Svetoslav     * @see #EXTRA_PRINT_PREVIEW
120a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     */
121a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    public abstract void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes,
1226283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav            CancellationSignal cancellationSignal, LayoutResultCallback callback,
1236811f4e92cbb64e72a0d13eb9b99b5894bd59c76Svetoslav            Bundle extras);
124a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
125a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
126a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Called when specific pages of the content should be written in the
12719fba5d34a444ce145ab0d3a12c578d9d5d3f38cSvetoslav Ganov     * form of a PDF file to the given file descriptor. This method is invoked
128a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * on the main thread.
129a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     *<p>
130d26d4898fcc9b78f4b66118895c375384098205eSvetoslav Ganov     * After you are done writing, you should close the file descriptor and
13119fba5d34a444ce145ab0d3a12c578d9d5d3f38cSvetoslav Ganov     * invoke {@link WriteResultCallback #onWriteFinished(PageRange[]), if writing
132d26d4898fcc9b78f4b66118895c375384098205eSvetoslav Ganov     * completed successfully; or {@link WriteResultCallback#onWriteFailed(
13319fba5d34a444ce145ab0d3a12c578d9d5d3f38cSvetoslav Ganov     * CharSequence)}, if an error occurred. Note that you must call one of
13419fba5d34a444ce145ab0d3a12c578d9d5d3f38cSvetoslav Ganov     * the methods of the given callback.
135a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * </p>
136a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * <p>
137a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * <strong>Note:</strong> If the printed content is large, it is a good
138a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * practice to schedule writing it on a dedicated thread and register an
139a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * observer in the provided {@link CancellationSignal} upon invocation of
140a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * which you should stop writing. The cancellation callback will not be
141a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * made on the main thread.
142a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * </p>
143a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     *
14485b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov     * @param pages The pages whose content to print - non-overlapping in ascending order.
145a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param destination The destination file descriptor to which to write.
146a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param cancellationSignal Signal for observing cancel writing requests.
147a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param callback Callback to inform the system for the write result.
148a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     *
149a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @see WriteResultCallback
150a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @see CancellationSignal
151a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     */
152d26d4898fcc9b78f4b66118895c375384098205eSvetoslav Ganov    public abstract void onWrite(PageRange[] pages, ParcelFileDescriptor destination,
153a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            CancellationSignal cancellationSignal, WriteResultCallback callback);
154a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
155a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
156a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Called when printing finishes. You can use this callback to release
157a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * resources acquired in {@link #onStart()}. This method is invoked on
158a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * the main thread.
159a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     */
160a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    public void onFinish() {
161a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /* do nothing - stub */
162a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    }
163a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
164a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
165a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Base class for implementing a callback for the result of {@link
166d26d4898fcc9b78f4b66118895c375384098205eSvetoslav Ganov     * PrintDocumentAdapter#onWrite(PageRange[], ParcelFileDescriptor, CancellationSignal,
167a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * WriteResultCallback)}.
168a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     */
169a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    public static abstract class WriteResultCallback {
170a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
171a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /**
172a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @hide
173a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
174a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        public WriteResultCallback() {
175a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            /* do nothing - hide constructor */
176a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        }
177a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
178a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /**
179a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * Notifies that all the data was written.
180a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         *
18185b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov         * @param pages The pages that were written. Cannot be null or empty.
182a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
18385b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov        public void onWriteFinished(PageRange[] pages) {
184a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            /* do nothing - stub */
185a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        }
186a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
187a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /**
188a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * Notifies that an error occurred while writing the data.
189a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         *
190a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @param error Error message. May be null if error is unknown.
191a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
192a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        public void onWriteFailed(CharSequence error) {
193a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            /* do nothing - stub */
194a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        }
19585b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov
19685b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov        /**
19785b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov         * Notifies that write was cancelled as a result of a cancellation request.
19885b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov         */
19985b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov        public void onWriteCancelled() {
20085b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov            /* do nothing - stub */
20185b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov        }
202a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    }
203a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
204a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
205a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Base class for implementing a callback for the result of {@link
206a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * PrintDocumentAdapter#onLayout(PrintAttributes, PrintAttributes,
2076283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * CancellationSignal, LayoutResultCallback, Bundle)}.
208a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     */
209a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    public static abstract class LayoutResultCallback {
210a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
211a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /**
212a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @hide
213a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
214a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        public LayoutResultCallback() {
215a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            /* do nothing - hide constructor */
216a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        }
217a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
218a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /**
219a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * Notifies that the layout finished and whether the content changed.
220a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         *
22185b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov         * @param info An info object describing the document. Cannot be null.
222a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @param changed Whether the layout changed.
223a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         *
224a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @see PrintDocumentInfo
225a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
226a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        public void onLayoutFinished(PrintDocumentInfo info, boolean changed) {
227a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            /* do nothing - stub */
228a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        }
229a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
230a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /**
231a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * Notifies that an error occurred while laying out the document.
232a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         *
233a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @param error Error message. May be null if error is unknown.
234a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
235a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        public void onLayoutFailed(CharSequence error) {
236a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            /* do nothing - stub */
237a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        }
23885b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov
23985b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov        /**
24085b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov         * Notifies that layout was cancelled as a result of a cancellation request.
24185b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov         */
24285b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov        public void onLayoutCancelled() {
24385b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov            /* do nothing - stub */
24485b1f883056a1d74473fd9ce774948878f389ab6Svetoslav Ganov        }
245a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    }
246a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov}
247