Beispiel #1
0
        private void GiftAdapterOnItemClick(object sender, GiftAdapterClickEventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    return;
                }

                int position = e.Position;
                if (position > -1)
                {
                    var item = MAdapter.GetItem(position);
                    if (item != null)
                    {
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            () => RequestsAsync.Global.SendGiftAsync(UserId, item.Id)
                        });

                        Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_Done), ToastLength.Short).Show();
                        //Close Fragment
                        Dismiss();
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        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);
            }
        }
Beispiel #3
0
        private async void GiftAdapterOnItemClick(object sender, GiftAdapterClickEventArgs e)
        {
            try
            {
                int position = e.Position;
                if (position > -1)
                {
                    var item = GiftAdapter.GetItem(position);
                    if (item != null)
                    {
                        Toast.MakeText(Context, GetText(Resource.String.Lbl_Done), ToastLength.Short).Show();

                        (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
                                    {
                                        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);
            }
        }
Beispiel #4
0
        private void GiftAdapterOnItemClick(object sender, GiftAdapterClickEventArgs e)
        {
            try
            {
                int position = e.Position;
                if (position > -1)
                {
                    var item = GiftAdapter.GetItem(position);
                    if (item != null)
                    {
                        var    unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
                        string time2         = unixTimestamp.ToString(CultureInfo.InvariantCulture);
                        string timeNow       = DateTime.Now.ToString("hh:mm");

                        if (Methods.CheckConnectivity())
                        {
                            GetChatConversationsObject.Messages message = new GetChatConversationsObject.Messages
                            {
                                Id          = Convert.ToInt32(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     = item.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);
                            }

                            PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                () => MessageController.SendMessageTask(Activity, Convert.ToInt32(UserId), "", item.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.GiftButton.Tag = "Closed";
                                ChatWindow.ResetButtonTags();
                                ChatWindow.GiftButton.Drawable.SetTint(Color.ParseColor("#888888"));
                                ChatWindow.TopFragmentHolder.Animate().SetInterpolator(interpolator).TranslationY(1200).SetDuration(300);
                                ChatWindow.SupportFragmentManager.BeginTransaction().Remove(ChatWindow.ChatGiftFragment).Commit();
                            }
                        }
                        catch (Exception exception)
                        {
                            Console.WriteLine(exception);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
        private 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)
                    {
                        var    unixTimestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
                        string time2         = unixTimestamp.ToString(CultureInfo.InvariantCulture);
                        string timeNow       = DateTime.Now.ToString("hh:mm");

                        if (Methods.CheckConnectivity())
                        {
                            GetChatConversationsObject.Messages message = new GetChatConversationsObject.Messages
                            {
                                Id          = Convert.ToInt32(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     = item.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, Convert.ToInt32(UserId), "", item.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);
            }
        }