Esempio n. 1
0
        public static T MainThreadCall <T>(this AndroidJavaObject ajo, string methodName, params object[] args)
        {
            T    result = default(T);
            bool wasSet = false;

            JniUtils.RunOnUiThread(() =>
            {
                try
                {
                    result = ajo.Call <T>(methodName, args);
                }
                catch
                {
                    // Ignored
                }
                finally
                {
                    wasSet = true;
                }
            });
            while (!wasSet)
            {
                // Hack for IL2CPP to not optimize the loop
                hackyDummy++;
            }

            return(result);
        }
Esempio n. 2
0
        public static void MainThreadCall(this AndroidJavaObject ajo, string methodName, params object[] args)
        {
            bool finished = false;

            JniUtils.RunOnUiThread(() =>
            {
                try
                {
                    ajo.Call(methodName, args);
                }
                catch
                {
                    // Ignored
                }
                finally
                {
                    finished = true;
                }
            });
            while (!finished)
            {
                // Hack for IL2CPP to not optimize the loop
                hackyDummy++;
            }
        }
Esempio n. 3
0
 public void Init(string clientId, string clientSecret, bool isS2S, string userId)
 {
     JniUtils.RunOnUiThread(() =>
     {
         InBrainInst?.Call(Constants.SetInBrainJavaMethod,
                           JniUtils.Activity, clientId, clientSecret, isS2S, userId);
     });
 }
Esempio n. 4
0
 public void GetRewards(Action <List <InBrainReward> > onRewardsReceived, Action onFailedToReceiveRewards, bool confirmRewardsAutomatically = false)
 {
     JniUtils.RunOnUiThread(() =>
     {
         InBrainInst?.Call(Constants.GetRewardsJavaMethod,
                           new InBrainGetRewardsCallbackProxy(onRewardsReceived, onFailedToReceiveRewards, confirmRewardsAutomatically));
     });
 }
Esempio n. 5
0
        public void SetStatusBarConfig(InBrainStatusBarConfig config)
        {
            var javaConfig = new AndroidJavaObject(Constants.StatusBarConfigJavaClass)
                             .CallAJO("setStatusBarIconsLight", config.LightStatusBarIcons)
                             .CallAJO("setStatusBarColor", config.StatusBarColor.ToJavaColor());

            JniUtils.RunOnUiThread(() => { InBrainInst?.Call(Constants.SetStatusBarConfigJavaMethod, javaConfig); });
        }
Esempio n. 6
0
        public void SetToolbarConfig(InBrainToolbarConfig config)
        {
            var javaConfig = new AndroidJavaObject(Constants.ToolbarConfigJavaClass)
                             .CallAJO("setElevationEnabled", config.ElevationEnabled)
                             .CallAJO("setToolbarColor", config.ToolbarColor.ToJavaColor())
                             .CallAJO("setBackButtonColor", config.BackButtonColor.ToJavaColor())
                             .CallAJO("setTitleColor", config.TitleColor.ToJavaColor())
                             .CallAJO("setTitle", config.Title);

            JniUtils.RunOnUiThread(() => { InBrainInst?.Call(Constants.SetToolbarConfigJavaMethod, javaConfig); });
        }
Esempio n. 7
0
 public static void MainThreadCallNonBlocking(this AndroidJavaObject ajo, string methodName, params object[] args)
 {
     JniUtils.RunOnUiThread(() => ajo.Call(methodName, args));
 }
Esempio n. 8
0
 public void SetLanguage(string language)
 {
     JniUtils.RunOnUiThread(() => { InBrainInst?.Call(Constants.SetLanguageJavaMethod, language); });
 }
Esempio n. 9
0
 public void ConfirmRewards(List <InBrainReward> rewards)
 {
     JniUtils.RunOnUiThread(() => { InBrainInst?.Call(Constants.ConfirmRewardsJavaMethod, rewards.ToJavaList(reward => reward.ToAJO())); });
 }
Esempio n. 10
0
 public void GetRewards()
 {
     JniUtils.RunOnUiThread(() => { InBrainInst?.Call(Constants.GetRewardsJavaMethod); });
 }
Esempio n. 11
0
 public void ShowSurvey(string surveyId)
 {
     JniUtils.RunOnUiThread(() => { InBrainInst?.Call(Constants.ShowSurveyJavaMethod, JniUtils.Activity, surveyId, new InBrainStartSurveysCallbackProxy()); });
 }
Esempio n. 12
0
        public void AddCallback(Action <List <InBrainReward> > onRewardsReceived, Action onRewardsViewDismissed, bool confirmRewardsAutomatically = false)
        {
            _callback = new InBrainCallbackProxy(onRewardsViewDismissed, onRewardsReceived, confirmRewardsAutomatically);

            JniUtils.RunOnUiThread(() => { InBrainInst?.Call(Constants.AddCallbackJavaMethod, _callback); });
        }
Esempio n. 13
0
 public void GetSurveys(Action <List <InBrainSurvey> > onSurveysReceived)
 {
     JniUtils.RunOnUiThread(() => { InBrainInst?.Call(Constants.GetSurveysJavaMethod, new InBrainGetSurveysCallbackProxy(onSurveysReceived)); });
 }