PrintDocumentAdapter.java revision 6283608e0bd40548742839f5a8b02f7e5c9c5c7c
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;
21a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
22a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganovimport java.io.FileDescriptor;
23a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganovimport java.util.List;
24a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
25a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov/**
26a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Base class that provides the content of a document to be printed.
27a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov *
28a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <h3>Lifecycle</h3>
29a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <p>
30a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <ul>
31a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <li>
32a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Initially, you will receive a call to {@link #onStart()}. This callback
33a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * can be used to allocate resources.
34a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </li>
35a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <li>
36a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Next, you will get one or more calls to {@link #onLayout(PrintAttributes,
376283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * PrintAttributes, CancellationSignal, LayoutResultCallback, Bundle)} to
386283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * inform you that the print attributes (page size, density, etc) changed
396283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * giving you an opportunity to layout the content to match the new constraints.
40a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </li>
41a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <li>
42a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * After every call to {@link #onLayout(PrintAttributes, PrintAttributes,
436283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * CancellationSignal, LayoutResultCallback, Bundle)}, you may get a call to
446283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * {@link #onWrite(List, FileDescriptor, CancellationSignal, WriteResultCallback)}
45a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * asking you to write a PDF file with the content for specific pages.
46a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </li>
47a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * <li>
48a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * Finally, you will receive a call to {@link #onFinish()}. You can use this
49a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * callback to release resources allocated in {@link #onStart()}.
50a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </li>
51a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </ul>
52a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov * </p>
536283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * <h3>Implementation</h3>
546283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * <p>
556283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * The APIs defined in this class are designed to enable doing part or all
566283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * of the work on an arbitrary thread. For example, if the printed content
576283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * does not depend on the UI state, i.e. on what is shown on the screen, then
586283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * you can off load the entire work on a dedicated thread, thus making your
596283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * application interactive while the print work is being performed.
606283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * </p>
616283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * <p>
626283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * You can also do work on different threads, for example if you print UI
636283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * content, you can handle {@link #onStart()} and {@link #onLayout(PrintAttributes,
646283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * PrintAttributes, CancellationSignal, LayoutResultCallback, Bundle)} on
656283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * the UI thread (assuming onStart initializes resources needed for layout).
666283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * This will ensure that the UI does not change while you are laying out the
676283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * printed content. Then you can handle {@link #onWrite(List, FileDescriptor,
686283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * CancellationSignal, WriteResultCallback)} and {@link #onFinish()} on another
696283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * thread. This will ensure that the UI is frozen for the minimal amount of
706283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * time. Also this assumes that you will generate the printed content in
716283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * {@link #onLayout(PrintAttributes, PrintAttributes, CancellationSignal,
726283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * LayoutResultCallback, Bundle)} which is not mandatory. If you use multiple
736283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * threads, you are responsible for proper synchronization.
746283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav * </p>
75a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov */
76a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganovpublic abstract class PrintDocumentAdapter {
77a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
78a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
796283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * Meta-data key: mapped to a boolean value that is <code>true</code> if
806283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * the current layout is for a print preview, <code>false</code> otherwise.
816283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     */
826283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav    public static final String METADATA_KEY_PRINT_PREVIEW = "KEY_METADATA_PRINT_PREVIEW";
836283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav
846283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav    /**
85a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Called when printing starts. You can use this callback to allocate
86a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * resources. This method is invoked on the main thread.
87a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     */
88a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    public void onStart() {
89a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /* do nothing - stub */
90a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    }
91a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
92a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
93a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Called when the print attributes (page size, density, etc) changed
94a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * giving you a chance to layout the content such that it matches the
95a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * new constraints. This method is invoked on the main thread.
96a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * <p>
976283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * After you are done laying out, you <strong>must</strong> invoke: {@link
986283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * LayoutResultCallback#onLayoutFinished(PrintDocumentInfo, boolean)} with
996283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * the last argument <code>true</code> or <code>false</code> depending on
1006283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * whether the layout changed the content or not, respectively; and {@link
1016283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * LayoutResultCallback#onLayoutFailed(CharSequence)}, if an error occurred.
102a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * </p>
103a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * <p>
104a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * <strong>Note:</strong> If the content is large and a layout will be
105a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * performed, it is a good practice to schedule the work on a dedicated
106a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * thread and register an observer in the provided {@link
107a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * CancellationSignal} upon invocation of which you should stop the
108a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * layout. The cancellation callback will not be made on the main
109a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * thread.
110a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * </p>
111a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     *
112a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param oldAttributes The old print attributes.
113a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param newAttributes The new print attributes.
114a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param cancellationSignal Signal for observing cancel layout requests.
115a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param callback Callback to inform the system for the layout result.
1166283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * @param metadata Additional information about how layout the content.
117a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     *
118a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @see LayoutResultCallback
119a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @see CancellationSignal
1206283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * @see #METADATA_KEY_PRINT_PREVIEW
121a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     */
122a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    public abstract void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes,
1236283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav            CancellationSignal cancellationSignal, LayoutResultCallback callback,
1246283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav            Bundle metadata);
125a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
126a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
127a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Called when specific pages of the content should be written in the
128a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * from of a PDF file to the given file descriptor. This method is invoked
129a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * on the main thread.
130a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     *<p>
131a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * After you are done writing, you should <strong>not</strong> close the
132a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * file descriptor, rather you must invoke: {@link WriteResultCallback
1336283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * #onWriteFinished(List)}, if writing completed successfully; or {@link
134a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * WriteResultCallback#onWriteFailed(CharSequence)}, if an error occurred.
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     *
144a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * @param pages The pages whose content to print.
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     */
152a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    public abstract void onWrite(List<PageRange> pages, FileDescriptor 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
166a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * PrintDocumentAdapter#onWrite(List, FileDescriptor, 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         *
181a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @param pages The pages that were written.
182a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
183a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        public void onWriteFinished(List<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        }
195a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    }
196a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
197a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    /**
198a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * Base class for implementing a callback for the result of {@link
199a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     * PrintDocumentAdapter#onLayout(PrintAttributes, PrintAttributes,
2006283608e0bd40548742839f5a8b02f7e5c9c5c7cSvetoslav     * CancellationSignal, LayoutResultCallback, Bundle)}.
201a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov     */
202a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    public static abstract class LayoutResultCallback {
203a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
204a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /**
205a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @hide
206a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
207a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        public LayoutResultCallback() {
208a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            /* do nothing - hide constructor */
209a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        }
210a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
211a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /**
212a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * Notifies that the layout finished and whether the content changed.
213a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         *
214a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @param info An info object describing the document.
215a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @param changed Whether the layout changed.
216a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         *
217a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @see PrintDocumentInfo
218a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
219a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        public void onLayoutFinished(PrintDocumentInfo info, boolean changed) {
220a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            /* do nothing - stub */
221a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        }
222a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov
223a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        /**
224a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * Notifies that an error occurred while laying out the document.
225a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         *
226a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         * @param error Error message. May be null if error is unknown.
227a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov         */
228a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        public void onLayoutFailed(CharSequence error) {
229a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov            /* do nothing - stub */
230a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov        }
231a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov    }
232a00271533f639c8ed36429c663889ac9f654bc72Svetoslav Ganov}
233