diff --git a/facebook-core/src/main/java/com/facebook/appevents/suggestedevents/ViewObserver.java b/facebook-core/src/main/java/com/facebook/appevents/suggestedevents/ViewObserver.java index 5556db6001..2093fadae4 100644 --- a/facebook-core/src/main/java/com/facebook/appevents/suggestedevents/ViewObserver.java +++ b/facebook-core/src/main/java/com/facebook/appevents/suggestedevents/ViewObserver.java @@ -130,7 +130,7 @@ public void run() { .getTextOfViewRecursively(view); if (!text.isEmpty() && text.length() <= MAX_TEXT_LENGTH) { ViewOnClickListener.attachListener(view, rootView, - activity.getLocalClassName(), text); + activity.getLocalClassName()); } } } catch (Exception e) { diff --git a/facebook-core/src/main/java/com/facebook/appevents/suggestedevents/ViewOnClickListener.java b/facebook-core/src/main/java/com/facebook/appevents/suggestedevents/ViewOnClickListener.java index 8dceae67be..0ee9560048 100644 --- a/facebook-core/src/main/java/com/facebook/appevents/suggestedevents/ViewOnClickListener.java +++ b/facebook-core/src/main/java/com/facebook/appevents/suggestedevents/ViewOnClickListener.java @@ -57,23 +57,21 @@ public final class ViewOnClickListener implements View.OnClickListener { private WeakReference rootViewWeakReference; private WeakReference hostViewWeakReference; private String activityName; - private String buttonText; - static void attachListener(View hostView, View rootView, String activityName, String buttonText) { + static void attachListener(View hostView, View rootView, String activityName) { int key = hostView.hashCode(); if (!viewsAttachedListener.contains(key)) { ViewHierarchy.setOnClickListener(hostView, - new ViewOnClickListener(hostView, rootView, activityName, buttonText)); + new ViewOnClickListener(hostView, rootView, activityName)); viewsAttachedListener.add(key); } } - private ViewOnClickListener(View hostView, View rootView, String activityName, String buttonText) { + private ViewOnClickListener(View hostView, View rootView, String activityName) { baseListener = ViewHierarchy.getExistingOnClickListener(hostView); hostViewWeakReference = new WeakReference<>(hostView); rootViewWeakReference = new WeakReference<>(rootView); this.activityName = activityName.toLowerCase().replace("activity", ""); - this.buttonText = buttonText; } @Override @@ -92,6 +90,7 @@ private void process() { } try { + String buttonText = SuggestedEventViewHierarchy.getTextOfViewRecursively(hostView); // query history @Nullable String pathID = PredictionHistoryManager.getPathID(hostView, buttonText); if (pathID == null) { @@ -105,7 +104,7 @@ private void process() { final JSONObject data = new JSONObject(); data.put(VIEW_KEY, SuggestedEventViewHierarchy.getDictionaryOfView(rootView, hostView)); data.put(SCREEN_NAME_KEY, activityName); - predictAndProcess(pathID, data); + predictAndProcess(pathID, buttonText, data); } catch (Exception e) { /*no op*/ } @@ -131,7 +130,7 @@ public void run() { return true; } - private void predictAndProcess(final String pathID, final JSONObject viewData) { + private void predictAndProcess(final String pathID, final String buttonText, final JSONObject viewData) { Utility.runOnNonUiThread(new Runnable() { @Override public void run() {