-
Notifications
You must be signed in to change notification settings - Fork 7
/
ViewSwazzledHooks.java
65 lines (55 loc) · 2.23 KB
/
ViewSwazzledHooks.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package io.embrace.android.embracesdk;
import android.util.Pair;
import io.embrace.android.embracesdk.annotation.InternalApi;
import io.embrace.android.embracesdk.payload.TapBreadcrumb.TapBreadcrumbType;
import io.embrace.android.embracesdk.logging.InternalStaticEmbraceLogger;
@InternalApi
public final class ViewSwazzledHooks {
private static final String UNKNOWN_ELEMENT_NAME = "Unknown element";
private ViewSwazzledHooks() {
}
static void logOnClickEvent(android.view.View view, TapBreadcrumbType breadcrumbType) {
try {
String viewName = "";
try {
viewName = view.getResources().getResourceName(view.getId());
} catch (Exception e) {
viewName = UNKNOWN_ELEMENT_NAME;
}
Pair point = null;
try {
point = new Pair<>(view.getX(), view.getY());
} catch (Exception e) {
point = new Pair<>(0.0F, 0.0F);
}
Embrace.getImpl().logTap(point, viewName, breadcrumbType);
} catch (NoSuchMethodError exception) {
// The customer may be overwriting View with their own implementation, and some of the
// methods we use are missing.
InternalStaticEmbraceLogger.logError("Could not log onClickEvent. Some methods are missing. ",
exception);
} catch (Exception exception) {
InternalStaticEmbraceLogger.logError("Could not log onClickEvent.", exception);
}
}
@InternalApi
public static final class OnClickListener {
private OnClickListener() {
}
@SuppressWarnings("MethodNameCheck")
public static void _preOnClick(android.view.View.OnClickListener thiz, android.view.View view) {
logOnClickEvent(view, TapBreadcrumbType.TAP);
}
}
@InternalApi
public static final class OnLongClickListener {
private OnLongClickListener() {
}
@SuppressWarnings("MethodNameCheck")
public static void _preOnLongClick(android.view.View.OnLongClickListener thiz, android.view.View view) {
if (thiz != null) {
logOnClickEvent(view, TapBreadcrumbType.LONG_PRESS);
}
}
}
}