check sdk ready

This commit is contained in:
Akinwale Ariwodola 2020-03-20 11:15:41 +01:00
parent e9c8f9432f
commit 4d1f142f9c
3 changed files with 14 additions and 3 deletions

View file

@ -106,9 +106,9 @@ public class MainActivity extends FragmentActivity implements DefaultHardwareBac
*/
private boolean serviceRunning;
private CheckSdkReadyTask checkSdkReadyTask;
private boolean lbrySdkReady;
private boolean receivedStopService;
private PermissionListener permissionListener;
public static boolean lbrySdkReady;
protected String getMainComponentName() {
return "LBRYApp";

View file

@ -77,8 +77,8 @@ public class FirebaseModule extends ReactContextBaseJavaModule {
@ReactMethod
public void logException(boolean fatal, String message, String error) {
Bundle bundle = new Bundle();
bundle.putString("message", message);
bundle.putString("error", error);
bundle.putString("exception_message", message);
bundle.putString("exception_error", error);
if (firebaseAnalytics != null) {
firebaseAnalytics.logEvent(fatal ? "reactjs_exception" : "reactjs_warning", bundle);
}

View file

@ -23,10 +23,12 @@ import android.view.WindowManager;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.squareup.picasso.Picasso;
import java.io.File;
@ -509,6 +511,15 @@ public class UtilityModule extends ReactContextBaseJavaModule {
promise.resolve(platform);
}
@ReactMethod
public void checkSdkReady() {
// check that the sdk ready when the service is already running so that we can send the ready event
ReactContext reactContext = (ReactContext) context;
if (MainActivity.lbrySdkReady && reactContext != null) {
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("onSdkReady", null);
}
}
@ReactMethod
public void log(String tag, String message) {
android.util.Log.d(tag, message);