|
18 | 18 |
|
19 | 19 | /** |
20 | 20 | * A base class for Cursors that store their data in {@link CursorWindow}s. |
21 | | - * <p> |
22 | | - * Subclasses are responsible for filling the cursor window with data during |
23 | | - * {@link #onMove(int, int)}, allocating a new cursor window if necessary. |
24 | | - * During {@link #requery()}, the existing cursor window should be cleared and |
25 | | - * filled with new data. |
26 | | - * </p><p> |
27 | | - * If the contents of the cursor change or become invalid, the old window must be closed |
28 | | - * (because it is owned by the cursor) and set to null. |
29 | | - * </p> |
30 | 21 | */ |
31 | 22 | public abstract class AbstractWindowedCursor extends AbstractCursor { |
32 | | - /** |
33 | | - * The cursor window owned by this cursor. |
34 | | - */ |
35 | | - protected CursorWindow mWindow; |
36 | | - |
37 | 23 | @Override |
38 | 24 | public byte[] getBlob(int columnIndex) { |
39 | 25 | checkPosition(); |
@@ -140,44 +126,25 @@ protected void checkPosition() { |
140 | 126 | public CursorWindow getWindow() { |
141 | 127 | return mWindow; |
142 | 128 | } |
143 | | - |
| 129 | + |
144 | 130 | /** |
145 | | - * Sets a new cursor window for the cursor to use. |
146 | | - * <p> |
147 | | - * The cursor takes ownership of the provided cursor window; the cursor window |
148 | | - * will be closed when the cursor is closed or when the cursor adopts a new |
149 | | - * cursor window. |
150 | | - * </p><p> |
151 | | - * If the cursor previously had a cursor window, then it is closed when the |
152 | | - * new cursor window is assigned. |
153 | | - * </p> |
154 | | - * |
155 | | - * @param window The new cursor window, typically a remote cursor window. |
| 131 | + * Set a new cursor window to cursor, usually set a remote cursor window |
| 132 | + * @param window cursor window |
156 | 133 | */ |
157 | 134 | public void setWindow(CursorWindow window) { |
158 | | - if (window != mWindow) { |
159 | | - closeWindow(); |
160 | | - mWindow = window; |
| 135 | + if (mWindow != null) { |
| 136 | + mWindow.close(); |
161 | 137 | } |
| 138 | + mWindow = window; |
162 | 139 | } |
163 | | - |
164 | | - /** |
165 | | - * Returns true if the cursor has an associated cursor window. |
166 | | - * |
167 | | - * @return True if the cursor has an associated cursor window. |
168 | | - */ |
| 140 | + |
169 | 141 | public boolean hasWindow() { |
170 | 142 | return mWindow != null; |
171 | 143 | } |
172 | 144 |
|
173 | 145 | /** |
174 | | - * Closes the cursor window and sets {@link #mWindow} to null. |
175 | | - * @hide |
| 146 | + * This needs be updated in {@link #onMove} by subclasses, and |
| 147 | + * needs to be set to NULL when the contents of the cursor change. |
176 | 148 | */ |
177 | | - protected void closeWindow() { |
178 | | - if (mWindow != null) { |
179 | | - mWindow.close(); |
180 | | - mWindow = null; |
181 | | - } |
182 | | - } |
| 149 | + protected CursorWindow mWindow; |
183 | 150 | } |
0 commit comments