Methods Summary |
---|
public void | add(android.view.MotionEvent ev)
synchronized (mGestures) {
if (mCurrentGesture == null || mCurrentGesture.isComplete()) {
mCurrentGesture = new Gesture();
mGestures.add(mCurrentGesture);
}
mCurrentGesture.add(ev);
}
saveLater();
|
public void | dump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String[] args)
save();
if (mLastSaveLen >= 0) {
pw.println(String.valueOf(mLastSaveLen) + " gestures written to " + mLogfile);
} else {
pw.println("error writing gestures");
}
|
public void | save()
synchronized (mGestures) {
try {
BufferedWriter w = new BufferedWriter(new FileWriter(mLogfile, /*append=*/ true));
w.append(toJsonLocked() + "\n");
w.close();
mGestures.clear();
// If we have a pending gesture, push it back
if (mCurrentGesture != null && !mCurrentGesture.isComplete()) {
mGestures.add(mCurrentGesture);
}
if (DEBUG) {
Log.v(TAG, String.format("Wrote %d complete gestures to %s", mLastSaveLen, mLogfile));
}
} catch (IOException e) {
Log.e(TAG, String.format("Couldn't write gestures to %s", mLogfile), e);
mLastSaveLen = -1;
}
}
|
public void | saveLater()
mHandler.removeMessages(SAVE_MESSAGE);
mHandler.sendEmptyMessageDelayed(SAVE_MESSAGE, SAVE_DELAY);
|
public void | tag(long when, java.lang.String tag, java.lang.String info)
synchronized (mGestures) {
if (mCurrentGesture == null) {
mCurrentGesture = new Gesture();
mGestures.add(mCurrentGesture);
}
mCurrentGesture.tag(when, tag, info);
}
saveLater();
|
public void | tag(long when, java.lang.String tag)
tag(when, tag, null);
|
public void | tag(java.lang.String tag)
tag(SystemClock.uptimeMillis(), tag, null);
|
public void | tag(java.lang.String tag, java.lang.String info)
tag(SystemClock.uptimeMillis(), tag, info);
|
public java.lang.String | toJson()
String s;
synchronized (mGestures) {
s = toJsonLocked();
}
return s;
|
public java.lang.String | toJsonLocked()Generates a JSON string capturing all completed gestures.
Not threadsafe; call with a lock.
StringBuilder sb = new StringBuilder();
boolean first = true;
sb.append("[");
int count = 0;
for (Gesture g : mGestures) {
if (!g.isComplete()) continue;
if (!first) sb.append("," );
first = false;
sb.append(g.toJson());
count++;
}
mLastSaveLen = count;
sb.append("]");
return sb.toString();
|