private async void GiftAdapterOnItemClick(object sender, GiftAdapterClickEventArgs e)
        {
            try
            {
                var dataUser = ListUtils.MyUserInfo.FirstOrDefault();
                if (!AppSettings.EnableAppFree && (dataUser?.Balance == "0.00" || dataUser?.Balance == "0.0" || dataUser?.Balance == "0"))
                {
                    Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_ErrorNotHaveCredit), ToastLength.Short).Show();
                    var window = new PopupController(Activity);
                    window.DisplayCreditWindow("credits");
                    return;
                }

                int position = e.Position;
                if (position > -1)
                {
                    var item = GiftAdapter.GetItem(position);
                    if (item != null)
                    {
                        (int apiStatus, var respond) = await RequestsAsync.Users.SendGiftAsync(UserId, item.Id.ToString()).ConfigureAwait(false);

                        if (apiStatus == 200)
                        {
                            if (respond is AmountObject result)
                            {
                                Activity.RunOnUiThread(() =>
                                {
                                    try
                                    {
                                        Toast.MakeText(Context, GetText(Resource.String.Lbl_Done), ToastLength.Short).Show();


                                        if (HomeActivity.GetInstance().ProfileFragment?.WalletNumber != null)
                                        {
                                            HomeActivity.GetInstance().ProfileFragment.WalletNumber.Text = result.CreditAmount.ToString();
                                        }
                                    }
                                    catch (Exception exception)
                                    {
                                        Console.WriteLine(exception);
                                    }
                                });

                                //Close Fragment
                                Dismiss();
                            }
                        }
                        else
                        {
                            Methods.DisplayReportResult(Activity, respond);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
예제 #2
0
 private void BtnBuyCreditsOnClick(object sender, EventArgs e)
 {
     try
     {
         var window = new PopupController(Activity);
         window.DisplayCreditWindow("credits");
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
        private void StickerAdapterOnItemClick(object sender, StickerAdapterClickEventArgs e)
        {
            try
            {
                var dataUser = ListUtils.MyUserInfo.FirstOrDefault();
                if (!AppSettings.EnableAppFree && (dataUser?.Balance == "0.00" || dataUser?.Balance == "0.0" || dataUser?.Balance == "0"))
                {
                    Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_ErrorNotHaveCredit), ToastLength.Short).Show();
                    var window = new PopupController(Activity);
                    window.DisplayCreditWindow("credits");
                    return;
                }

                var stickerUrl = StickerAdapter.GetItem(e.Position);

                int    unixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
                var    time2         = unixTimestamp.ToString();
                string timeNow       = DateTime.Now.ToString("hh:mm");

                if (Methods.CheckConnectivity())
                {
                    GetChatConversationsObject.Messages message = new GetChatConversationsObject.Messages
                    {
                        Id          = unixTimestamp,
                        FromName    = UserDetails.FullName,
                        FromAvater  = UserDetails.Avatar,
                        ToName      = ChatWindow?.UserInfoData?.Fullname ?? "",
                        ToAvater    = ChatWindow?.UserInfoData?.Avater ?? "",
                        From        = UserDetails.UserId,
                        To          = Convert.ToInt32(UserId),
                        Text        = "",
                        Media       = "",
                        FromDelete  = 0,
                        ToDelete    = 0,
                        Sticker     = stickerUrl?.File,
                        CreatedAt   = timeNow,
                        Seen        = 0,
                        Type        = "Sent",
                        MessageType = "sticker"
                    };

                    int index = MessagesBoxActivity.MAdapter.MessageList.IndexOf(MessagesBoxActivity.MAdapter.MessageList.Last());
                    if (index > -1)
                    {
                        MessagesBoxActivity.MAdapter.MessageList.Add(message);
                        MessagesBoxActivity.MAdapter.NotifyItemInserted(index);

                        //Scroll Down >>
                        ChatWindow?.ChatBoxRecyclerView.ScrollToPosition(index);
                    }

                    Task.Factory.StartNew(() =>
                    {
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            () => MessageController.SendMessageTask(Activity, MessagesBoxActivity.Userid, "", stickerUrl?.Id.ToString(), "", time2, ChatWindow?.UserInfoData)
                        });
                    });
                }
                else
                {
                    Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short);
                }

                try
                {
                    if (ChatWindow != null)
                    {
                        var interpolator = new FastOutSlowInInterpolator();
                        ChatWindow.TopFragmentHolder.Animate().SetInterpolator(interpolator).TranslationY(1200).SetDuration(300);
                        ChatWindow.UpdateChatBoxAttachmentWindowState(ChatBoxButtonWindowState.AllClosed);
                    }
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        //Visits
        private async void BtnVisitsOnClick(object sender, EventArgs e)
        {
            try
            {
                if (!AppSettings.EnableAppFree)
                {
                    var myBalance = ListUtils.MyUserInfo.FirstOrDefault()?.Balance ?? "0.00";
                    if (!string.IsNullOrEmpty(myBalance) && myBalance != "0.00")
                    {
                        //Show a progress
                        AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading));

                        //sent new api
                        (int apiStatus, var respond) = await RequestsAsync.Users.ManagePopularityAsync("visits").ConfigureAwait(false);

                        if (apiStatus == 200)
                        {
                            if (respond is AmountObject result)
                            {
                                RunOnUiThread(() =>
                                {
                                    try
                                    {
                                        myBalance = result.CreditAmount.ToString();

                                        if (GlobalContext?.ProfileFragment != null)
                                        {
                                            GlobalContext.ProfileFragment.WalletNumber.Text = result.CreditAmount.ToString();
                                        }

                                        BtnVisits.Text = GetText(Resource.String.Lbl_IncreaseStarted);
                                    }
                                    catch (Exception exception)
                                    {
                                        Console.WriteLine(exception);
                                    }
                                });
                            }
                        }
                        else
                        {
                            Methods.DisplayReportResult(this, respond);
                        }

                        AndHUD.Shared.Dismiss(this);
                    }
                    else
                    {
                        var window = new PopupController(this);
                        window.DisplayCreditWindow("credits");
                    }
                }
                else
                {
                    //Show a progress
                    AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading));

                    //sent new api
                    (int apiStatus, var respond) = await RequestsAsync.Users.ManagePopularityAsync("visits").ConfigureAwait(false);

                    if (apiStatus == 200)
                    {
                        if (respond is AmountObject result)
                        {
                            RunOnUiThread(() =>
                            {
                                try
                                {
                                    //myBalance = result.CreditAmount.ToString();

                                    if (GlobalContext?.ProfileFragment != null)
                                    {
                                        GlobalContext.ProfileFragment.WalletNumber.Text = result.CreditAmount.ToString();
                                    }

                                    BtnVisits.Text = GetText(Resource.String.Lbl_IncreaseStarted);
                                }
                                catch (Exception exception)
                                {
                                    Console.WriteLine(exception);
                                }
                            });
                        }
                    }
                    else
                    {
                        Methods.DisplayReportResult(this, respond);
                    }

                    AndHUD.Shared.Dismiss(this);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                AndHUD.Shared.Dismiss(this);
            }
        }
예제 #5
0
        //Boost me
        private async void BoostButtonOnClick(object sender, EventArgs e)
        {
            try
            {
                var dataUser = ListUtils.MyUserInfo.FirstOrDefault();
                if (dataUser != null)
                {
                    if (BoostButton.Tag.ToString() == "Off")
                    {
                        BoostButton.Tag = "Run";

                        if (!AppSettings.EnableAppFree)
                        {
                            string myBalance = dataUser.Balance ?? "0.00";
                            if (!string.IsNullOrEmpty(myBalance) && myBalance != "0.00")
                            {
                                //sent new api
                                (int apiStatus, var respond) = await RequestsAsync.Users.ManagePopularityAsync("boost").ConfigureAwait(false);

                                if (apiStatus == 200)
                                {
                                    if (respond is AmountObject result)
                                    {
                                        Activity.RunOnUiThread(() =>
                                        {
                                            try
                                            {
                                                myBalance         = result.CreditAmount.ToString();
                                                WalletNumber.Text = result.CreditAmount.ToString();

                                                var timeBoost             = ListUtils.SettingsSiteList.FirstOrDefault()?.BoostExpireTime ?? "4";
                                                var timeBoostMilliseconds = Methods.Time.ConvertMinutesToMilliseconds(Convert.ToDouble(timeBoost));
                                                dataUser.BoostedTime      = timeBoostMilliseconds.ToString(CultureInfo.InvariantCulture);
                                                dataUser.IsBoosted        = "1";

                                                GetMyInfoData();
                                            }
                                            catch (Exception exception)
                                            {
                                                Console.WriteLine(exception);
                                            }
                                        });
                                    }
                                }
                                else
                                {
                                    Methods.DisplayReportResult(Activity, respond);
                                }
                            }
                            else
                            {
                                var window = new PopupController(Activity);
                                window.DisplayCreditWindow("credits");
                            }
                        }
                        else
                        {
                            //sent new api
                            (int apiStatus, var respond) = await RequestsAsync.Users.ManagePopularityAsync("boost").ConfigureAwait(false);

                            if (apiStatus == 200)
                            {
                                if (respond is AmountObject result)
                                {
                                    Activity.RunOnUiThread(() =>
                                    {
                                        try
                                        {
                                            //myBalance = result.CreditAmount.ToString();
                                            WalletNumber.Text = result.CreditAmount.ToString();

                                            var timeBoost             = ListUtils.SettingsSiteList.FirstOrDefault()?.BoostExpireTime ?? "4";
                                            var timeBoostMilliseconds = Methods.Time.ConvertMinutesToMilliseconds(Convert.ToDouble(timeBoost));
                                            dataUser.BoostedTime      = timeBoostMilliseconds.ToString(CultureInfo.InvariantCulture);
                                            dataUser.IsBoosted        = "1";

                                            GetMyInfoData();
                                        }
                                        catch (Exception exception)
                                        {
                                            Console.WriteLine(exception);
                                        }
                                    });
                                }
                            }
                            else
                            {
                                Methods.DisplayReportResult(Activity, respond);
                            }
                        }
                    }
                    else
                    {
                        Toast.MakeText(Context, GetText(Resource.String.Lbl_YourBoostExpireInMinutes), ToastLength.Long).Show();
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }