From 660adb4a6fe6b388e1084ec5e055e9a6973c4f9b Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Sun, 25 Aug 2019 16:36:25 +0100 Subject: [PATCH] setCurrentScreen tweaks --- app | 2 +- .../lbry/browser/reactmodules/FirebaseModule.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app b/app index 430fc1a6..68d99ac6 160000 --- a/app +++ b/app @@ -1 +1 @@ -Subproject commit 430fc1a66106efc99513eeae8043910bc40c0b82 +Subproject commit 68d99ac639b908f6011325140c3a37428d039ad9 diff --git a/src/main/java/io/lbry/browser/reactmodules/FirebaseModule.java b/src/main/java/io/lbry/browser/reactmodules/FirebaseModule.java index a48bb996..38839a45 100644 --- a/src/main/java/io/lbry/browser/reactmodules/FirebaseModule.java +++ b/src/main/java/io/lbry/browser/reactmodules/FirebaseModule.java @@ -1,9 +1,11 @@ package io.lbry.browser.reactmodules; +import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.widget.Toast; +import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; @@ -37,10 +39,16 @@ public class FirebaseModule extends ReactContextBaseJavaModule { } @ReactMethod - public void setCurrentScreen(String name) { - if (firebaseAnalytics != null) { - firebaseAnalytics.setCurrentScreen(MainActivity.getActivity(), name, Utils.capitalizeAndStrip(name)); + public void setCurrentScreen(String name, final Promise promise) { + final Activity activity = getCurrentActivity(); + if (activity != null && firebaseAnalytics != null) { + activity.runOnUiThread(new Runnable() { + public void run() { + firebaseAnalytics.setCurrentScreen(activity, name, Utils.capitalizeAndStrip(name)); + } + }); } + promise.resolve(true); } @ReactMethod