Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008-2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Romain Guy | db567c3 | 2009-05-21 16:23:21 -0700 | [diff] [blame] | 17 | package android.gesture; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 18 | |
| 19 | import android.graphics.Bitmap; |
| 20 | import android.graphics.Canvas; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 21 | import android.graphics.Paint; |
| 22 | import android.graphics.Path; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 23 | import android.graphics.RectF; |
| 24 | import android.os.Parcel; |
| 25 | import android.os.Parcelable; |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 26 | import android.util.Log; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 27 | |
| 28 | import java.io.IOException; |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 29 | import java.io.DataOutputStream; |
| 30 | import java.io.DataInputStream; |
| 31 | import java.io.ByteArrayOutputStream; |
| 32 | import java.io.ByteArrayInputStream; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 33 | import java.util.ArrayList; |
Romain Guy | ef0e9ae | 2009-07-10 14:11:26 -0700 | [diff] [blame] | 34 | import java.util.concurrent.atomic.AtomicInteger; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
Yang Li | 6fc1f15 | 2010-01-15 14:35:27 -0800 | [diff] [blame] | 37 | * A gesture is a hand-drawn shape on a touch screen. It can have one or multiple strokes. |
| 38 | * Each stroke is a sequence of timed points. A user-defined gesture can be recognized by |
Romain Guy | 02739a8 | 2011-05-16 11:43:18 -0700 | [diff] [blame] | 39 | * a GestureLibrary. |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 40 | */ |
| 41 | |
| 42 | public class Gesture implements Parcelable { |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 43 | private static final long GESTURE_ID_BASE = System.currentTimeMillis(); |
| 44 | |
| 45 | private static final int BITMAP_RENDERING_WIDTH = 2; |
| 46 | |
| 47 | private static final boolean BITMAP_RENDERING_ANTIALIAS = true; |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 48 | private static final boolean BITMAP_RENDERING_DITHER = true; |
| 49 | |
Romain Guy | ef0e9ae | 2009-07-10 14:11:26 -0700 | [diff] [blame] | 50 | private static final AtomicInteger sGestureCount = new AtomicInteger(0); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 51 | |
Romain Guy | 9ffe1ae | 2009-05-29 12:28:23 -0700 | [diff] [blame] | 52 | private final RectF mBoundingBox = new RectF(); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 53 | |
| 54 | // the same as its instance ID |
| 55 | private long mGestureID; |
| 56 | |
Romain Guy | c534727 | 2009-05-20 10:37:13 -0700 | [diff] [blame] | 57 | private final ArrayList<GestureStroke> mStrokes = new ArrayList<GestureStroke>(); |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 58 | |
| 59 | public Gesture() { |
Romain Guy | ef0e9ae | 2009-07-10 14:11:26 -0700 | [diff] [blame] | 60 | mGestureID = GESTURE_ID_BASE + sGestureCount.incrementAndGet(); |
Yang Li | f817341 | 2009-05-15 13:55:56 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Yang Li | 6fc1f15 | 2010-01-15 14:35:27 -0800 | [diff] [blame] | 63 | @Override |
| 64 | public Object clone() { |
| 65 | Gesture gesture = new Gesture(); |
| 66 | gesture.mBoundingBox.set(mBoundingBox.left, mBoundingBox.top, |
| 67 | mBoundingBox.right, mBoundingBox.bottom); |
| 68 | final int count = mStrokes.size(); |
| 69 | for (int i = 0; i < count; i++) { |
| 70 | GestureStroke stroke = mStrokes.get(i); |
| 71 | gesture.mStrokes.add((GestureStroke)stroke.clone()); |
| 72 | } |
| 73 | return gesture; |
| 74 | } |
| 75 | |
Yang Li | f817341 | 2009-05-15 13:55:56 -0700 | [diff] [blame] | 76 | /** |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 77 | * @return all the strokes of the gesture |
| 78 | */ |
| 79 | public ArrayList<GestureStroke> getStrokes() { |
| 80 | return mStrokes; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * @return the number of strokes included by this gesture |
| 85 | */ |
| 86 | public int getStrokesCount() { |
| 87 | return mStrokes.size(); |
| 88 | } |
| 89 | |
| 90 | /** |
Yang Li | 6fc1f15 | 2010-01-15 14:35:27 -0800 | [diff] [blame] | 91 | * Adds a stroke to the gesture. |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 92 | * |
| 93 | * @param stroke |
| 94 | */ |
| 95 | public void addStroke(GestureStroke stroke) { |
| 96 | mStrokes.add(stroke); |
Romain Guy | 9ffe1ae | 2009-05-29 12:28:23 -0700 | [diff] [blame] | 97 | mBoundingBox.union(stroke.boundingBox); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | /** |
Yang Li | 6fc1f15 | 2010-01-15 14:35:27 -0800 | [diff] [blame] | 101 | * Calculates the total length of the gesture. When there are multiple strokes in |
| 102 | * the gesture, this returns the sum of the lengths of all the strokes. |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 103 | * |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 104 | * @return the length of the gesture |
| 105 | */ |
| 106 | public float getLength() { |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 107 | int len = 0; |
Romain Guy | c534727 | 2009-05-20 10:37:13 -0700 | [diff] [blame] | 108 | final ArrayList<GestureStroke> strokes = mStrokes; |
| 109 | final int count = strokes.size(); |
| 110 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 111 | for (int i = 0; i < count; i++) { |
Romain Guy | c534727 | 2009-05-20 10:37:13 -0700 | [diff] [blame] | 112 | len += strokes.get(i).length; |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 113 | } |
Romain Guy | c534727 | 2009-05-20 10:37:13 -0700 | [diff] [blame] | 114 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 115 | return len; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 116 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * @return the bounding box of the gesture |
| 120 | */ |
| 121 | public RectF getBoundingBox() { |
| 122 | return mBoundingBox; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 123 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 124 | |
Romain Guy | 82f3495 | 2009-05-24 18:40:45 -0700 | [diff] [blame] | 125 | public Path toPath() { |
| 126 | return toPath(null); |
| 127 | } |
| 128 | |
| 129 | public Path toPath(Path path) { |
| 130 | if (path == null) path = new Path(); |
| 131 | |
| 132 | final ArrayList<GestureStroke> strokes = mStrokes; |
| 133 | final int count = strokes.size(); |
| 134 | |
| 135 | for (int i = 0; i < count; i++) { |
| 136 | path.addPath(strokes.get(i).getPath()); |
| 137 | } |
| 138 | |
| 139 | return path; |
| 140 | } |
| 141 | |
| 142 | public Path toPath(int width, int height, int edge, int numSample) { |
| 143 | return toPath(null, width, height, edge, numSample); |
| 144 | } |
| 145 | |
| 146 | public Path toPath(Path path, int width, int height, int edge, int numSample) { |
| 147 | if (path == null) path = new Path(); |
| 148 | |
| 149 | final ArrayList<GestureStroke> strokes = mStrokes; |
| 150 | final int count = strokes.size(); |
| 151 | |
| 152 | for (int i = 0; i < count; i++) { |
| 153 | path.addPath(strokes.get(i).toPath(width - 2 * edge, height - 2 * edge, numSample)); |
| 154 | } |
| 155 | |
| 156 | return path; |
| 157 | } |
| 158 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 159 | /** |
Yang Li | 6fc1f15 | 2010-01-15 14:35:27 -0800 | [diff] [blame] | 160 | * Sets the id of the gesture. |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 161 | * |
| 162 | * @param id |
| 163 | */ |
| 164 | void setID(long id) { |
| 165 | mGestureID = id; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 166 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 167 | |
| 168 | /** |
| 169 | * @return the id of the gesture |
| 170 | */ |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 171 | public long getID() { |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 172 | return mGestureID; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 173 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 174 | |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 175 | /** |
Yang Li | 6fc1f15 | 2010-01-15 14:35:27 -0800 | [diff] [blame] | 176 | * Creates a bitmap of the gesture with a transparent background. |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 177 | * |
| 178 | * @param width width of the target bitmap |
| 179 | * @param height height of the target bitmap |
| 180 | * @param edge the edge |
Yang Li | 935fd37 | 2009-05-15 16:51:46 -0700 | [diff] [blame] | 181 | * @param numSample |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 182 | * @param color |
| 183 | * @return the bitmap |
Yang Li | f817341 | 2009-05-15 13:55:56 -0700 | [diff] [blame] | 184 | */ |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 185 | public Bitmap toBitmap(int width, int height, int edge, int numSample, int color) { |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 186 | final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); |
| 187 | final Canvas canvas = new Canvas(bitmap); |
| 188 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 189 | canvas.translate(edge, edge); |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 190 | |
| 191 | final Paint paint = new Paint(); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 192 | paint.setAntiAlias(BITMAP_RENDERING_ANTIALIAS); |
| 193 | paint.setDither(BITMAP_RENDERING_DITHER); |
| 194 | paint.setColor(color); |
Yang Li | f817341 | 2009-05-15 13:55:56 -0700 | [diff] [blame] | 195 | paint.setStyle(Paint.Style.STROKE); |
| 196 | paint.setStrokeJoin(Paint.Join.ROUND); |
| 197 | paint.setStrokeCap(Paint.Cap.ROUND); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 198 | paint.setStrokeWidth(BITMAP_RENDERING_WIDTH); |
Romain Guy | c534727 | 2009-05-20 10:37:13 -0700 | [diff] [blame] | 199 | |
| 200 | final ArrayList<GestureStroke> strokes = mStrokes; |
| 201 | final int count = strokes.size(); |
| 202 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 203 | for (int i = 0; i < count; i++) { |
Romain Guy | c534727 | 2009-05-20 10:37:13 -0700 | [diff] [blame] | 204 | Path path = strokes.get(i).toPath(width - 2 * edge, height - 2 * edge, numSample); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 205 | canvas.drawPath(path, paint); |
| 206 | } |
| 207 | |
Yang Li | f817341 | 2009-05-15 13:55:56 -0700 | [diff] [blame] | 208 | return bitmap; |
| 209 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 210 | |
Yang Li | f817341 | 2009-05-15 13:55:56 -0700 | [diff] [blame] | 211 | /** |
Yang Li | 6fc1f15 | 2010-01-15 14:35:27 -0800 | [diff] [blame] | 212 | * Creates a bitmap of the gesture with a transparent background. |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 213 | * |
| 214 | * @param width |
| 215 | * @param height |
Romain Guy | cfbe8cf | 2009-06-10 01:21:20 -0700 | [diff] [blame] | 216 | * @param inset |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 217 | * @param color |
| 218 | * @return the bitmap |
| 219 | */ |
Romain Guy | cfbe8cf | 2009-06-10 01:21:20 -0700 | [diff] [blame] | 220 | public Bitmap toBitmap(int width, int height, int inset, int color) { |
| 221 | final Bitmap bitmap = Bitmap.createBitmap(width, height, |
| 222 | Bitmap.Config.ARGB_8888); |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 223 | final Canvas canvas = new Canvas(bitmap); |
| 224 | |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 225 | final Paint paint = new Paint(); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 226 | paint.setAntiAlias(BITMAP_RENDERING_ANTIALIAS); |
| 227 | paint.setDither(BITMAP_RENDERING_DITHER); |
| 228 | paint.setColor(color); |
| 229 | paint.setStyle(Paint.Style.STROKE); |
| 230 | paint.setStrokeJoin(Paint.Join.ROUND); |
| 231 | paint.setStrokeCap(Paint.Cap.ROUND); |
| 232 | paint.setStrokeWidth(BITMAP_RENDERING_WIDTH); |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 233 | |
Romain Guy | cfbe8cf | 2009-06-10 01:21:20 -0700 | [diff] [blame] | 234 | final Path path = toPath(); |
| 235 | final RectF bounds = new RectF(); |
| 236 | path.computeBounds(bounds, true); |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 237 | |
Romain Guy | cfbe8cf | 2009-06-10 01:21:20 -0700 | [diff] [blame] | 238 | final float sx = (width - 2 * inset) / bounds.width(); |
| 239 | final float sy = (height - 2 * inset) / bounds.height(); |
| 240 | final float scale = sx > sy ? sy : sx; |
| 241 | paint.setStrokeWidth(2.0f / scale); |
| 242 | |
| 243 | path.offset(-bounds.left + (width - bounds.width() * scale) / 2.0f, |
| 244 | -bounds.top + (height - bounds.height() * scale) / 2.0f); |
| 245 | |
| 246 | canvas.translate(inset, inset); |
| 247 | canvas.scale(scale, scale); |
| 248 | |
| 249 | canvas.drawPath(path, paint); |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 250 | |
| 251 | return bitmap; |
| 252 | } |
| 253 | |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 254 | void serialize(DataOutputStream out) throws IOException { |
| 255 | final ArrayList<GestureStroke> strokes = mStrokes; |
| 256 | final int count = strokes.size(); |
| 257 | |
| 258 | // Write gesture ID |
| 259 | out.writeLong(mGestureID); |
| 260 | // Write number of strokes |
| 261 | out.writeInt(count); |
| 262 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 263 | for (int i = 0; i < count; i++) { |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 264 | strokes.get(i).serialize(out); |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 265 | } |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 266 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 267 | |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 268 | static Gesture deserialize(DataInputStream in) throws IOException { |
| 269 | final Gesture gesture = new Gesture(); |
| 270 | |
| 271 | // Gesture ID |
| 272 | gesture.mGestureID = in.readLong(); |
| 273 | // Number of strokes |
| 274 | final int count = in.readInt(); |
| 275 | |
| 276 | for (int i = 0; i < count; i++) { |
| 277 | gesture.addStroke(GestureStroke.deserialize(in)); |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 278 | } |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 279 | |
| 280 | return gesture; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 281 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 282 | |
Jeff Sharkey | 9e8f83d | 2019-02-28 12:06:45 -0700 | [diff] [blame^] | 283 | public static final @android.annotation.NonNull Parcelable.Creator<Gesture> CREATOR = new Parcelable.Creator<Gesture>() { |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 284 | public Gesture createFromParcel(Parcel in) { |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 285 | Gesture gesture = null; |
| 286 | final long gestureID = in.readLong(); |
| 287 | |
| 288 | final DataInputStream inStream = new DataInputStream( |
| 289 | new ByteArrayInputStream(in.createByteArray())); |
| 290 | |
| 291 | try { |
| 292 | gesture = deserialize(inStream); |
| 293 | } catch (IOException e) { |
Romain Guy | db567c3 | 2009-05-21 16:23:21 -0700 | [diff] [blame] | 294 | Log.e(GestureConstants.LOG_TAG, "Error reading Gesture from parcel:", e); |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 295 | } finally { |
Romain Guy | 46c5312 | 2010-02-04 14:19:50 -0800 | [diff] [blame] | 296 | GestureUtils.closeStream(inStream); |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | if (gesture != null) { |
| 300 | gesture.mGestureID = gestureID; |
| 301 | } |
| 302 | |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 303 | return gesture; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 304 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 305 | |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 306 | public Gesture[] newArray(int size) { |
| 307 | return new Gesture[size]; |
| 308 | } |
| 309 | }; |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 310 | |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 311 | public void writeToParcel(Parcel out, int flags) { |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 312 | out.writeLong(mGestureID); |
| 313 | |
| 314 | boolean result = false; |
| 315 | final ByteArrayOutputStream byteStream = |
| 316 | new ByteArrayOutputStream(GestureConstants.IO_BUFFER_SIZE); |
| 317 | final DataOutputStream outStream = new DataOutputStream(byteStream); |
| 318 | |
| 319 | try { |
| 320 | serialize(outStream); |
| 321 | result = true; |
| 322 | } catch (IOException e) { |
Romain Guy | db567c3 | 2009-05-21 16:23:21 -0700 | [diff] [blame] | 323 | Log.e(GestureConstants.LOG_TAG, "Error writing Gesture to parcel:", e); |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 324 | } finally { |
Romain Guy | 46c5312 | 2010-02-04 14:19:50 -0800 | [diff] [blame] | 325 | GestureUtils.closeStream(outStream); |
| 326 | GestureUtils.closeStream(byteStream); |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | if (result) { |
| 330 | out.writeByteArray(byteStream.toByteArray()); |
| 331 | } |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 332 | } |
Yang Li | 35aa84b | 2009-05-18 18:29:05 -0700 | [diff] [blame] | 333 | |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 334 | public int describeContents() { |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 335 | return 0; |
Joe Onorato | 6e93a3d | 2009-04-17 14:18:46 -0700 | [diff] [blame] | 336 | } |
| 337 | } |
Romain Guy | b6d99b7 | 2009-05-21 15:05:50 -0700 | [diff] [blame] | 338 | |