Ejemplo n.º 1
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            try
            {
                var            view = convertView;
                UserInfoObject item = UsersDateList[position];
                if (item == null)
                {
                    return(view);
                }
                CardAdapterViewHolder holder = null;

                if (view != null)
                {
                    holder = view.Tag as CardAdapterViewHolder;
                }

                if (holder == null)
                {
                    var inflater = ActivityContext.GetSystemService(Context.LayoutInflaterService).JavaCast <LayoutInflater>();
                    view = inflater.Inflate(Resource.Layout.Style_DatingCardview, parent, false);

                    string name = QuickDateTools.GetNameFinal(item);

                    string city = !string.IsNullOrEmpty(item.City) ? item.City : ActivityContext.GetText(Resource.String.Lbl_Unknown);

                    holder = new CardAdapterViewHolder(view)
                    {
                        Name = { Text = name },
                        City = { Text = city }
                    };

                    Glide.With(ActivityContext).Load(item.Avater).Apply(new RequestOptions()).Into(holder.Image);

                    //GlideImageLoader.LoadImage(ActivityContext, item.Avater, holder.Image, ImageStyle.CenterCrop, ImagePlaceholders.Drawable,false);

                    FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.Status, IonIconsFonts.Record);
                    holder.Status.SetTextColor(Color.Green);

                    holder.Status.Visibility = QuickDateTools.GetStatusOnline(item.Lastseen, item.Online) ? ViewStates.Visible : ViewStates.Gone;

                    if (!holder.MainWhiteBox.HasOnClickListeners)
                    {
                        holder.MainWhiteBox.Click += delegate
                        {
                            QuickDateTools.OpenProfile(ActivityContext, "LikeAndMoveCardMach", item, holder.Image);
                        };
                    }

                    view.Tag = holder;
                }

                return(view);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
        //Open user profile
        private void MAdapterOnItemClick(object sender, NotificationsAdapterClickEventArgs e)
        {
            try
            {
                if (e.Position > -1)
                {
                    var item = MAdapter.GetItem(e.Position);
                    if (item != null)
                    {
                        string eventPage;
                        if (item.Type == "got_new_match")
                        {
                            eventPage = "HideButton";
                        }
                        else if (item.Type == "like")
                        {
                            eventPage = "likeAndClose";
                        }
                        else
                        {
                            eventPage = "Close";
                        }

                        QuickDateTools.OpenProfile(Activity, eventPage, item.Notifier, e.Image);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Ejemplo n.º 3
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is SuggestionsAdapterViewHolder holder)
                {
                    var item = NearByList[position];
                    if (item != null)
                    {
                        holder.Name.Text = Methods.FunString.SubStringCutOf(QuickDateTools.GetNameFinal(item), 10);

                        GlideImageLoader.LoadImage(ActivityContext, item.Avater, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                        holder.ImageOnline.Visibility = QuickDateTools.GetStatusOnline(item.Lastseen, item.Online) ? ViewStates.Visible : ViewStates.Gone;

                        holder.Verified.Visibility = item.VerifiedFinal != null && item.VerifiedFinal.Value ? ViewStates.Visible : ViewStates.Gone;

                        if (position == 1)
                        {
                            var height = holder.MainLayout.LayoutParameters.Height;
                            if (height <= 450)
                            {
                                holder.MainLayout.LayoutParameters.Height = height + 150;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 4
0
 //Open profile user  >> Pro User
 private void ProUserAdapterOnItemClick(object sender, ProUserAdapterClickEventArgs e)
 {
     try
     {
         if (e.Position > -1)
         {
             var item = ProUserAdapter.GetItem(e.Position);
             if (item != null)
             {
                 if (item.Type == "Your")
                 {
                     var window = new PopupController(Activity);
                     window.DisplayPremiumWindow();
                 }
                 else
                 {
                     QuickDateTools.OpenProfile(Activity, "Close", item, e.Image);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 5
0
        private void GetMyInfoData()
        {
            try
            {
                if (ListUtils.MyUserInfo.Count == 0)
                {
                    var sqlEntity = new SqLiteDatabase();
                    sqlEntity.GetDataMyInfo();
                    sqlEntity.Dispose();
                }

                var dataUser = ListUtils.MyUserInfo.FirstOrDefault();
                if (dataUser != null)
                {
                    EdtFirstName.Text = dataUser.FirstName;
                    EdtLastName.Text  = dataUser.LastName;

                    EdtGender.Text = ListUtils.SettingsSiteList.FirstOrDefault()?.Gender?.FirstOrDefault(a => a.ContainsKey(dataUser.Gender))?.Values.FirstOrDefault() ?? dataUser.GenderTxt;
                    IdGender       = Convert.ToInt32(dataUser.Gender);

                    EdtBirthday.Text = dataUser.Birthday;

                    if (Methods.FunString.StringNullRemover(dataUser.Location) != "-----")
                    {
                        EdtLocation.Text = dataUser.Location;
                    }

                    if (Methods.FunString.StringNullRemover(dataUser.Language) != "-----")
                    {
                        EdtLanguage.Text = dataUser.Language;
                    }

                    string relationship = QuickDateTools.GetRelationship(dataUser.Relationship);
                    if (Methods.FunString.StringNullRemover(relationship) != "-----")
                    {
                        EdtRelationship.Text = relationship;
                        IdRelationShip       = Convert.ToInt32(dataUser.Relationship);
                    }

                    string work = QuickDateTools.GetWorkStatus(dataUser.WorkStatus);
                    if (Methods.FunString.StringNullRemover(work) != "-----")
                    {
                        EdtWorkStatus.Text = work;
                        IdWorkStatus       = Convert.ToInt32(dataUser.WorkStatus);
                    }

                    string education = QuickDateTools.GetEducation(dataUser.Education);
                    if (Methods.FunString.StringNullRemover(education) != "-----")
                    {
                        EdtEducation.Text = education;
                        IdEducation       = Convert.ToInt32(dataUser.Education);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 6
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is CardAdapter2ViewHolder holder)
                {
                    var item = UsersDateList[position];
                    if (item != null)
                    {
                        GlideImageLoader.LoadImage(ActivityContext, item.Avater, holder.ImgUser, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);
                        //holder.CountImage.Text = item.Mediafiles.Count.ToString();

                        if (item.Age != null)
                        {
                            holder.TxtName.Text = Methods.FunString.SubStringCutOf(QuickDateTools.GetNameFinal(item), 20) + " , " + item.Age;
                        }
                        else if (!string.IsNullOrEmpty(item.Birthday) && item.Birthday != "0000-00-00" && item.Birthday != "0")
                        {
                            //1997-05-28
                            var units = item.Birthday.Split('-');

                            var year = Convert.ToInt32(units[0]);
                            if (units[1][0] == '0')
                            {
                                units[1] = units[1][1].ToString();
                            }

                            var month = Convert.ToInt32(units[1]);

                            if (units[2][0] == '0')
                            {
                                units[2] = units[2][1].ToString();
                            }

                            var day = Convert.ToInt32(units[2]);

                            DateTime now      = DateTime.Now;
                            DateTime birthday = new DateTime(year, month, day);
                            int      age      = now.Year - birthday.Year;
                            if (now < birthday.AddYears(age))
                            {
                                age--;
                            }

                            holder.TxtName.Text = Methods.FunString.SubStringCutOf(QuickDateTools.GetNameFinal(item), 20) + " , " + age;
                        }
                        else
                        {
                            holder.TxtName.Text = Methods.FunString.SubStringCutOf(QuickDateTools.GetNameFinal(item), 20);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 7
0
        private async Task LoadDataAsync(string offset = "")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                int countList = MAdapter.NotificationsList.Count;
                (int apiStatus, var respond) = await RequestsAsync.Common.GetNotificationsAsync("25", offset, UserDetails.DeviceId);

                if (apiStatus != 200 || !(respond is GetNotificationsObject result) || result.Data == null)
                {
                    Methods.DisplayReportResult(Activity, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        foreach (var item in result.Data)
                        {
                            item.Text = QuickDateTools.GetNotification(item);
                        }

                        Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                    }
                    else
                    {
                        if (MAdapter.NotificationsList.Count > 10 && !MRecycler.CanScrollVertically(1))
                        {
                            Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreUsers), ToastLength.Short).Show();
                        }
                    }
                }

                Activity.RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                MainScrollEvent.IsLoading = false;
            }
            MainScrollEvent.IsLoading = false;
        }
Ejemplo n.º 8
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is UsersAdapterViewHolder holder)
                {
                    var item = UserList[position];
                    if (item != null)
                    {
                        GlideImageLoader.LoadImage(ActivityContext, item.Avater, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                        holder.ImageOnline.Visibility = QuickDateTools.GetStatusOnline(item.Lastseen, item.Online) ? ViewStates.Visible: ViewStates.Gone;

                        holder.Name.Text = Methods.FunString.SubStringCutOf(QuickDateTools.GetNameFinal(item), 14);

                        switch (NameButton)
                        {
                        case "FavoriteUsers":
                            holder.Button.Text = ActivityContext.GetString(Resource.String.Lbl_UnFavorite);
                            break;

                        case "Friends":
                        {
                            if (item.IsFriend != null && item.IsFriend.Value)
                            {
                                holder.Button.Text = ActivityContext.GetString(Resource.String.Lbl_UnFriend);
                                holder.Button.Tag  = "true";
                            }
                            else if (item.IsFriend != null && !item.IsFriend.Value)
                            {
                                if (item.IsFriendRequest != null && !item.IsFriendRequest.Value)
                                {
                                    holder.Button.Text = ActivityContext.GetString(Resource.String.Lbl_AddFriend);
                                    holder.Button.Tag  = "false";
                                }
                                else
                                {
                                    holder.Button.Text = ActivityContext.GetString(Resource.String.Lbl_UnFriend);
                                    holder.Button.Tag  = "true";
                                }
                            }
                        }  break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 private void MAdapterOnItemClick(object sender, FavoriteUserAdapterClickEventArgs e)
 {
     try
     {
         var item = MAdapter.UserList[e.Position];
         if (item != null)
         {
             QuickDateTools.OpenProfile(Activity, "Close", item.UserData, e.Image);
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
        private void GetMyInfoData()
        {
            try
            {
                if (ListUtils.MyUserInfo.Count == 0)
                {
                    var sqlEntity = new SqLiteDatabase();
                    sqlEntity.GetDataMyInfo();
                    sqlEntity.Dispose();
                }

                var dataUser = ListUtils.MyUserInfo.FirstOrDefault();
                if (dataUser != null)
                {
                    string character = QuickDateTools.GetCharacter(dataUser.Character);
                    if (Methods.FunString.StringNullRemover(character) != "-----")
                    {
                        IdCharacter       = Convert.ToInt32(dataUser.Character);
                        EdtCharacter.Text = character;
                    }

                    string children = QuickDateTools.GetChildren(dataUser.Children);
                    if (Methods.FunString.StringNullRemover(children) != "-----")
                    {
                        IdChildren       = Convert.ToInt32(dataUser.Children);
                        EdtChildren.Text = children;
                    }

                    string friends = QuickDateTools.GetFriends(dataUser.Friends);
                    if (Methods.FunString.StringNullRemover(friends) != "-----")
                    {
                        IdFriends       = Convert.ToInt32(dataUser.Friends);
                        EdtFriends.Text = friends;
                    }

                    string pets = QuickDateTools.GetPets(dataUser.Pets);
                    if (Methods.FunString.StringNullRemover(pets) != "-----")
                    {
                        IdPets       = Convert.ToInt32(dataUser.Pets);
                        EdtPets.Text = pets;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 11
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is NotificationsAdapterViewHolder holder)
                {
                    var item = NotificationsList[position];
                    if (item != null)
                    {
                        holder.UserNameNoitfy.Text = QuickDateTools.GetNameFinal(item.Notifier);

                        GlideImageLoader.LoadImage(ActivityContext, item.Notifier.Avater, holder.ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                        if (item.Type == "got_new_match")
                        {
                            holder.CircleIcon.SetBackgroundResource(Resource.Drawable.Shape_Radius_Gradient_Btn3);
                            if (holder.IconNotify.Text != IonIconsFonts.IosHeart)
                            {
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.IconNotify, IonIconsFonts.IosHeart);
                            }
                        }
                        else if (item.Type == "like")
                        {
                            holder.CircleIcon.SetBackgroundResource(Resource.Drawable.Shape_Radius_Gradient_Btn2);
                            if (holder.IconNotify.Text != IonIconsFonts.HeartBroken)
                            {
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.IconNotify, IonIconsFonts.HeartBroken);
                            }
                        }
                        else if (item.Type == "visit")
                        {
                            holder.CircleIcon.SetBackgroundResource(Resource.Drawable.Shape_Radius_Gradient_Btn);
                            if (holder.IconNotify.Text != IonIconsFonts.IosEye)
                            {
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.IconNotify, IonIconsFonts.IosEye);
                            }
                        }

                        holder.Description.Text = QuickDateTools.GetNotificationsText(item.Type);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 12
0
        public void OpenDialogMatchFound(UserInfoObject dataUser)
        {
            try
            {
                DataUser = dataUser;

                AlertDialogMatchFound = new Dialog(Activity, AppSettings.SetTabDarkTheme ? Resource.Style.MyTheme_Dark_Base : Resource.Style.MyTheme_Base);
                AlertDialogMatchFound.SetContentView(Resource.Layout.DialogMatchFound);

                SetTransparentBackground(AlertDialogMatchFound.Window);
                AlertDialogMatchFound.Window.SetGravity(GravityFlags.Center);

                var image1 = AlertDialogMatchFound.FindViewById <ImageView>(Resource.Id.Iconimage);
                var image2 = AlertDialogMatchFound.FindViewById <ImageView>(Resource.Id.Iconimage2);

                GlideImageLoader.LoadImage(Activity, dataUser.Avater, image1, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                GlideImageLoader.LoadImage(Activity, UserDetails.Avatar, image2, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                var subTitle = AlertDialogMatchFound.FindViewById <TextView>(Resource.Id.secondarytextview);
                subTitle.Text = Activity.GetText(Resource.String.Lbl_YouAnd) + " " + QuickDateTools.GetNameFinal(dataUser) + " " + Activity.GetText(Resource.String.Lbl_SubTitle_Match);

                Button btnSkipMatch = AlertDialogMatchFound.FindViewById <Button>(Resource.Id.skippButton);
                Button btnNextMatch = AlertDialogMatchFound.FindViewById <Button>(Resource.Id.NextButton);

                btnSkipMatch.Click += BtnSkipMatchOnClick;
                btnNextMatch.Click += BtnNextMatchOnClick;

                AlertDialogMatchFound.Show();

                //got_new_match
                var data = ListUtils.MatchList.FirstOrDefault(a => a.Notifier.Id == dataUser.Id);
                if (data == null)
                {
                    ListUtils.MatchList.Add(new GetNotificationsObject.Datum()
                    {
                        Notifier = dataUser,
                        Type     = "got_new_match"
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 13
0
 //Open profile user >> Near By
 private void NearByAdapterOnItemClick(object sender, SuggestionsAdapterClickEventArgs e)
 {
     try
     {
         if (e.Position > -1)
         {
             var item = NearByAdapter.GetItem(e.Position);
             if (item != null)
             {
                 QuickDateTools.OpenProfile(Activity, "LikeAndMoveTrending", item, e.Image);
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 14
0
 //Open profile user  >> Hot Or NotL
 private void MAdapterOnImageItemClick(object sender, HotOrNotUserAdapterClickEventArgs e)
 {
     try
     {
         if (e.Position > -1)
         {
             var item = HotOrNotUserAdapter.GetItem(e.Position);
             if (item != null)
             {
                 QuickDateTools.OpenProfile(Activity, "Close", item, e.Image);
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 15
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is UsersAdapterViewHolder holder)
                {
                    var item = UserList[position];
                    if (item != null)
                    {
                        if (!item.Avater.Contains(Client.WebsiteUrl))
                        {
                            item.Avater = Client.WebsiteUrl + "/" + item.Avater;
                        }

                        GlideImageLoader.LoadImage(ActivityContext, item.Avater, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                        holder.ImageOnline.Visibility = QuickDateTools.GetStatusOnline(item.Lastseen, item.Online) ? ViewStates.Visible : ViewStates.Gone;

                        holder.Name.Text           = Methods.FunString.SubStringCutOf(QuickDateTools.GetNameFinal(item), 14);
                        holder.LastTimeOnline.Text = Methods.Time.TimeAgo(int.Parse(item.Lastseen), false);

                        switch (NameButton)
                        {
                        case "ILikedUsers":
                            holder.Button.SetImageResource(Resource.Drawable.ic_action_remove_heart);
                            break;

                        case "IDislikedUsers":
                            holder.Button.SetImageResource(Resource.Drawable.ic_action_remove_heart);
                            break;

                        case "Friends":
                            holder.Button.SetImageResource(Resource.Drawable.ic_action_person_add_disabled);
                            holder.Button.SetColor(Color.ParseColor(AppSettings.MainColor));
                            break;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 16
0
 // Replace the contents of a view (invoked by the layout manager)
 public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
 {
     try
     {
         if (viewHolder is HotOrNotUserAdapterViewHolder holder)
         {
             var item = UsersDateList[position];
             if (item != null)
             {
                 GlideImageLoader.LoadImage(ActivityContext, item.Avater, holder.Image, ImageStyle.FitCenter, ImagePlaceholders.Drawable);
                 holder.Name.Text = QuickDateTools.GetNameFinal(item);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        private void GetMyInfoData()
        {
            try
            {
                if (ListUtils.MyUserInfo.Count == 0)
                {
                    var sqlEntity = new SqLiteDatabase();
                    sqlEntity.GetDataMyInfo();
                    sqlEntity.Dispose();
                }

                var dataUser = ListUtils.MyUserInfo.FirstOrDefault();
                if (dataUser != null)
                {
                    string ethnicity = QuickDateTools.GetEthnicity(dataUser.Ethnicity);
                    if (Methods.FunString.StringNullRemover(ethnicity) != "-----")
                    {
                        EdtEthnicity.Text = ethnicity;
                        IdEthnicity       = Convert.ToInt32(dataUser.Ethnicity);
                    }

                    string body = QuickDateTools.GetBody(dataUser.Body);
                    if (Methods.FunString.StringNullRemover(body) != "-----")
                    {
                        EdtBody.Text = body;
                        IdBody       = Convert.ToInt32(dataUser.Body);
                    }

                    EdtHeight.Text = dataUser.Height + " " + GetText(Resource.String.Lbl_Cm);

                    string hairColor = QuickDateTools.GetHairColor(dataUser.HairColor);
                    if (Methods.FunString.StringNullRemover(hairColor) != "-----")
                    {
                        EdtHairColor.Text = hairColor;
                        IdHairColor       = Convert.ToInt32(dataUser.HairColor);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 18
0
 private void CardDateAdapter2_OnItemClick(object sender, CardAdapter2ClickEventArgs e)
 {
     try
     {
         if (e.Position <= -1)
         {
             return;
         }
         var item = CardDateAdapter2.GetItem(e.Position);
         if (item != null)
         {
             QuickDateTools.OpenProfile(Activity, "LikeAndMoveTrending", item, e.Image);
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 19
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is ProUserAdapterViewHolder holder)
                {
                    var item = ProUserList[position];
                    if (item != null)
                    {
                        //holder.Circleindicator.Status = InsLoadingView.Statuses.Loading;
                        //holder.Circleindicator.SetStartColor(Color.ParseColor(AppSettings.StartColor));
                        //holder.Circleindicator.SetEndColor(Color.ParseColor(AppSettings.EndColor));

                        GlideImageLoader.LoadImage(ActivityContext, item.Avater, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                        if (item.Type != "Your")
                        {
                            //holder.Circleindicator.Status = InsLoadingView.Statuses.Unclicked;
                            holder.IconCircle.Visibility = ViewStates.Gone;
                            holder.IconStory.Visibility  = ViewStates.Gone;

                            holder.Name.Text = Methods.FunString.SubStringCutOf(QuickDateTools.GetNameFinal(item), 20);
                        }
                        else
                        {
                            holder.Name.Text = ActivityContext.GetString(Resource.String.Lbl_AddMe);
                        }

                        if (!holder.Circleindicator.HasOnClickListeners)
                        {
                            holder.Circleindicator.Click += (sender, e) => Click(new ProUserAdapterClickEventArgs {
                                View = holder.MainView, Position = position, Image = holder.Circleindicator
                            });
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Ejemplo n.º 20
0
        //Open profile user >> Near By
        private void MAdapterOnUsersItemClick(object sender, NearByAdapterClickEventArgs e)
        {
            try
            {
                if (e.Position <= -1)
                {
                    return;
                }

                var item = MAdapter.GetItem(e.Position);
                if (item != null)
                {
                    QuickDateTools.OpenProfile(Activity, "LikeAndMoveTrending", item.UsersData, e.Image);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Ejemplo n.º 21
0
 // Replace the contents of a view (invoked by the layout manager)
 public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
 {
     try
     {
         if (viewHolder is FriendRequestsAdapterViewHolder holder)
         {
             var item = UserList[position];
             if (item != null)
             {
                 GlideImageLoader.LoadImage(ActivityContext, item.Avater, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                 holder.Name.Text  = Methods.FunString.SubStringCutOf(QuickDateTools.GetNameFinal(item), 35);
                 holder.About.Text = ActivityContext.GetString(Resource.String.Lbl_Last_seen) + " " + Methods.Time.TimeAgo(int.Parse(item.Lastseen), false);
             }
         }
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
Ejemplo n.º 22
0
 // Replace the contents of a view (invoked by the layout manager)
 public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
 {
     try
     {
         if (viewHolder is FavoriteUserAdapterViewHolder holder)
         {
             var item = UserList[position];
             if (item != null)
             {
                 GlideImageLoader.LoadImage(ActivityContext, item.UserData.Avater, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                 holder.ImageOnline.Visibility = QuickDateTools.GetStatusOnline(item.UserData.Lastseen, item.UserData.Online) ? ViewStates.Visible : ViewStates.Gone;
                 holder.Name.Text   = Methods.FunString.SubStringCutOf(QuickDateTools.GetNameFinal(item.UserData), 14);
                 holder.Button.Text = ActivityContext.GetString(Resource.String.Lbl_UnFavorite);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        private void GetMyInfoData()
        {
            try
            {
                if (ListUtils.MyUserInfo.Count == 0)
                {
                    var sqlEntity = new SqLiteDatabase();
                    sqlEntity.GetDataMyInfo();
                    sqlEntity.Dispose();
                }

                var dataUser = ListUtils.MyUserInfo.FirstOrDefault();
                if (dataUser != null)
                {
                    EdtUsername.Text    = dataUser.Username;
                    EdtEmail.Text       = dataUser.Email;
                    EdtPhoneNumber.Text = dataUser.PhoneNumber;
                    EdtCountry.Text     = QuickDateTools.GetCountry(dataUser.Country);

                    if (dataUser.PhoneVerified == "0" && dataUser.Verified == "0" && AppSettings.ValidationEnabled)
                    {
                        var window = new PopupController(this);
                        window.DisplayAddPhoneNumber();

                        if (GlobalContext.TracksCounter != null)
                        {
                            GlobalContext.TracksCounter.LastCounterEnum = TracksCounter.TracksCounterEnum.AddPhoneNumber;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 24
0
        private async Task LoadUsersAsync(string offset = "0")
        {
            if (MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                MainScrollEvent.IsLoading = true;
                if (UserDetails.Lat == "" && UserDetails.Lng == "")
                {
                    var locator = CrossGeolocator.Current;
                    locator.DesiredAccuracy = 50;
                    var position = await locator.GetPositionAsync(TimeSpan.FromMilliseconds(10000));

                    Console.WriteLine("Position Status: {0}", position.Timestamp);
                    Console.WriteLine("Position Latitude: {0}", position.Latitude);
                    Console.WriteLine("Position Longitude: {0}", position.Longitude);

                    UserDetails.Lat = position.Latitude.ToString(CultureInfo.InvariantCulture);
                    UserDetails.Lng = position.Longitude.ToString(CultureInfo.InvariantCulture);
                }

                UserDetails.Location = ListUtils.MyUserInfo.FirstOrDefault()?.Location;

                var dictionary = new Dictionary <string, string>
                {
                    { "limit", "35" },
                    { "offset", offset },
                    { "_gender", UserDetails.Gender },
                    { "_located", UserDetails.Located },
                    { "_location", UserDetails.Location },
                    { "_age_from", UserDetails.AgeMin.ToString() },
                    { "_age_to", UserDetails.AgeMax.ToString() },
                    { "_lat", UserDetails.Lat },
                    { "_lng", UserDetails.Lng },

                    { "_body", UserDetails.Body ?? "" },
                    { "_ethnicity", UserDetails.Ethnicity ?? "" },
                    { "_religion", UserDetails.Religion ?? "" },
                    { "_drink", UserDetails.Drink ?? "" },
                    { "_smoke", UserDetails.Smoke ?? "" },
                    { "_education", UserDetails.Education ?? "" },
                    { "_pets", UserDetails.Pets ?? "" },
                    { "_relationship", UserDetails.RelationShip ?? "" },
                    { "_language", UserDetails.Language ?? "english" },
                    { "_interest", UserDetails.Interest ?? "" },
                    { "_height_from", UserDetails.FromHeight ?? "139" },
                    { "_height_to", UserDetails.ToHeight ?? "220" },
                };

                int countList = AppSettings.ShowUsersAsCards ? CardDateAdapter2.UsersDateList.Count : NearByAdapter.NearByList.Count;
                var(apiStatus, respond) = await RequestsAsync.Users.SearchAsync(dictionary);

                if (apiStatus != 200 || !(respond is ListUsersObject result) || result.Data == null)
                {
                    Methods.DisplayReportResult(Activity, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        foreach (var item in from item in result.Data let check = AppSettings.ShowUsersAsCards ? CardDateAdapter2.UsersDateList.FirstOrDefault(a => a.Id == item.Id) : NearByAdapter.NearByList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                        {
                            if (UserDetails.SwitchState)
                            {
                                var online = QuickDateTools.GetStatusOnline(item.Lastseen, item.Online);
                                if (!online)
                                {
                                    continue;
                                }
                                if (AppSettings.ShowUsersAsCards)
                                {
                                    CardDateAdapter2.UsersDateList.Add(item);
                                }
                                else
                                {
                                    NearByAdapter.NearByList.Add(item);
                                }
                            }
                            else
                            {
                                if (AppSettings.ShowUsersAsCards)
                                {
                                    CardDateAdapter2.UsersDateList.Add(item);
                                }
                                else
                                {
                                    NearByAdapter.NearByList.Add(item);
                                }
                            }
                        }

                        if (AppSettings.ShowUsersAsCards)
                        {
                            if (countList > 0)
                            {
                                Activity.RunOnUiThread(() => CardDateAdapter2.NotifyItemRangeInserted(countList - 1, CardDateAdapter2.UsersDateList.Count - countList));
                            }
                            else
                            {
                                Activity.RunOnUiThread(() => CardDateAdapter2.NotifyDataSetChanged());
                            }
                        }
                        else
                        {
                            if (countList > 0)
                            {
                                Activity.RunOnUiThread(() => NearByAdapter.NotifyItemRangeInserted(countList - 1, NearByAdapter.NearByList.Count - countList));
                            }
                            else
                            {
                                Activity.RunOnUiThread(() => NearByAdapter.NotifyDataSetChanged());
                            }
                        }
                    }
                    else
                    {
                        if (AppSettings.ShowUsersAsCards)
                        {
                            if (CardDateAdapter2.UsersDateList.Count > 10 && !NearByRecyclerView.CanScrollVertically(1))
                            {
                                Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreUsers), ToastLength.Short).Show();
                            }
                        }
                        else
                        {
                            if (NearByAdapter.NearByList.Count > 10 && !NearByRecyclerView.CanScrollVertically(1))
                            {
                                Toast.MakeText(Context, Context.GetText(Resource.String.Lbl_NoMoreUsers), ToastLength.Short).Show();
                            }
                        }
                    }
                }

                Activity.RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                MainScrollEvent.IsLoading = false;
            }
            MainScrollEvent.IsLoading = false;
        }
Ejemplo n.º 25
0
        private void Initialize(LastChatAdapterViewHolder holder, GetConversationListObject.DataConversation item)
        {
            try
            {
                GlideImageLoader.LoadImage(ActivityContext, item.User.Avater, holder.ImageAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                string name = QuickDateTools.GetNameFinal(item.User);
                if (holder.TxtUsername.Text != name)
                {
                    holder.TxtUsername.Text = name;
                }

                //If message contains Media files
                switch (item.MessageType)
                {
                case "text":
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Gone;
                    holder.TxtLastMessages.Text        = item.Text.Contains("http")
                            ? Methods.FunString.SubStringCutOf(item.Text, 30)
                            : Methods.FunString.DecodeString(Methods.FunString.SubStringCutOf(item.Text, 30))
                                                         ?? ActivityContext.GetText(Resource.String.Lbl_SendMessage);
                    break;
                }

                case "media":
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.LastMessagesIcon, IonIconsFonts.Images);
                    holder.TxtLastMessages.Text = Application.Context.GetText(Resource.String.Lbl_SendImageFile);
                    break;
                }

                case "sticker" when item.Sticker.Contains(".gif"):
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, holder.LastMessagesIcon, FontAwesomeIcon.Gift);
                    holder.TxtLastMessages.Text = Application.Context.GetText(Resource.String.Lbl_SendGifFile);
                    break;
                }

                case "sticker":
                {
                    holder.LastMessagesIcon.Visibility = ViewStates.Visible;
                    FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.LastMessagesIcon, IonIconsFonts.Happy);
                    holder.TxtLastMessages.Text = Application.Context.GetText(Resource.String.Lbl_SendStickerFile);
                    break;
                }
                }

                //last seen time
                holder.TxtTimestamp.Text = Methods.Time.ReplaceTime(item.Time);

                //Check read message
                if (item.FromId != null && item.ToId != null && item.ToId != UserDetails.UserId && item.FromId == UserDetails.UserId)
                {
                    if (item.Seen == 0)
                    {
                        holder.ImageColor.Visibility = ViewStates.Invisible;
                        holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                    }
                    else
                    {
                        holder.ImageColor.Visibility = ViewStates.Invisible;
                        holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                    }
                }
                else if (item.FromId != null && item.ToId != null && item.ToId == UserDetails.UserId && item.FromId != UserDetails.UserId)
                {
                    if (item.Seen == 0)
                    {
                        holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Bold);
                        holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Bold);

                        if (item.NewMessages != 0)
                        {
                            var drawable = TextDrawable.InvokeBuilder().BeginConfig().FontSize(25).EndConfig().BuildRound(item.NewMessages.ToString(), Color.ParseColor(AppSettings.MainColor));
                            holder.ImageColor.SetImageDrawable(drawable);
                            holder.ImageColor.Visibility = ViewStates.Visible;
                        }
                        else
                        {
                            holder.ImageColor.Visibility = ViewStates.Invisible;
                        }
                    }
                    else
                    {
                        holder.ImageColor.Visibility = ViewStates.Invisible;
                        holder.TxtUsername.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                        holder.TxtLastMessages.SetTypeface(Typeface.Default, TypefaceStyle.Normal);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 26
0
        private async Task LoadUsersAsync(string offset = "0")
        {
            if (MainScrollEvent != null && MainScrollEvent.IsLoading)
            {
                return;
            }

            if (Methods.CheckConnectivity())
            {
                if (MainScrollEvent != null)
                {
                    MainScrollEvent.IsLoading = true;
                }

                if (UserDetails.Lat == "" && UserDetails.Lng == "")
                {
                    var locator = CrossGeolocator.Current;
                    locator.DesiredAccuracy = 50;
                    var position = await locator.GetPositionAsync(TimeSpan.FromMilliseconds(10000));

                    Console.WriteLine("Position Status: {0}", position.Timestamp);
                    Console.WriteLine("Position Latitude: {0}", position.Latitude);
                    Console.WriteLine("Position Longitude: {0}", position.Longitude);

                    UserDetails.Lat = position.Latitude.ToString(CultureInfo.InvariantCulture);
                    UserDetails.Lng = position.Longitude.ToString(CultureInfo.InvariantCulture);
                }

                UserDetails.Location = ListUtils.MyUserInfo.FirstOrDefault()?.Location;

                var dictionary = new Dictionary <string, string>
                {
                    { "limit", "25" },
                    { "offset", offset },
                    { "_gender", UserDetails.Gender },
                    { "_located", UserDetails.Located },
                    { "_location", UserDetails.Location },
                    { "_age_from", UserDetails.AgeMin.ToString() },
                    { "_age_to", UserDetails.AgeMax.ToString() },
                    { "_lat", UserDetails.Lat },
                    { "_lng", UserDetails.Lng },
                    { "_body", UserDetails.Body ?? "" },
                    { "_ethnicity", UserDetails.Ethnicity ?? "" },
                    { "_religion", UserDetails.Religion ?? "" },
                    { "_drink", UserDetails.Drink ?? "" },
                    { "_smoke", UserDetails.Smoke ?? "" },
                    { "_education", UserDetails.Education ?? "" },
                    { "_pets", UserDetails.Pets ?? "" },
                    { "_relationship", UserDetails.RelationShip ?? "" },
                    { "_language", UserDetails.Language ?? GlobalConstants.FilterOptionLanguage },
                    { "_interest", UserDetails.Interest ?? "" },
                    { "_height_from", UserDetails.FromHeight ?? GlobalConstants.FilterOptionFromHeight },
                    { "_height_to", UserDetails.ToHeight ?? GlobalConstants.FilterOptionToHeight },
                };

                var(apiStatus, respond) = await RequestsAsync.Users.SearchAsync(dictionary);

                if (apiStatus != 200 || !(respond is ListUsersObject result) || result.Data == null)
                {
                    if (MainScrollEvent != null)
                    {
                        MainScrollEvent.IsLoading = false;
                    }
                    Methods.DisplayReportResult(Activity, respond);
                }
                else
                {
                    var respondList = result.Data.Count;
                    if (respondList > 0)
                    {
                        foreach (var item in result.Data)
                        {
                            var check = MAdapter.TrendingList.FirstOrDefault(a => a.Id == item.Id);
                            if (check == null)
                            {
                                var users = new Classes.TrendingClass()
                                {
                                    Id        = item.Id,
                                    UsersData = item,
                                    Type      = ItemType.Users
                                };

                                if (UserDetails.SwitchState)
                                {
                                    var online = QuickDateTools.GetStatusOnline(item.Lastseen, item.Online);
                                    if (!online)
                                    {
                                        continue;
                                    }
                                    MAdapter.TrendingList.Add(users);
                                }
                                else
                                {
                                    MAdapter.TrendingList.Add(users);
                                }
                            }
                        }
                    }
                }

                Activity.RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                if (MainScrollEvent != null)
                {
                    MainScrollEvent.IsLoading = false;
                }
            }
            if (MainScrollEvent != null)
            {
                MainScrollEvent.IsLoading = false;
            }
        }
Ejemplo n.º 27
0
        //Open
        private void MAdapterOnItemClick(object sender, AllMediaAdapterClickEventArgs e)
        {
            try
            {
                var position = e.Position;
                if (position > -1)
                {
                    var item = MAdapter.GetItem(position);
                    if (item != null)
                    {
                        if (string.IsNullOrEmpty(item.UrlFile))
                        {
                            item.UrlFile = item.Full;
                        }

                        var type     = Methods.AttachmentFiles.Check_FileExtension(item.UrlFile);
                        var fileName = item.UrlFile.Split('/').Last();
                        if (type == "Video")
                        {
                            item.UrlFile = QuickDateTools.GetFile(UserDetails.UserId.ToString(), Methods.Path.FolderDiskVideo, fileName, item.UrlFile);
                            if (!string.IsNullOrEmpty(item.UrlFile) && (item.UrlFile.Contains("file://") || item.UrlFile.Contains("content://") || item.UrlFile.Contains("storage") || item.UrlFile.Contains("/data/user/0/")))
                            {
                                File file2    = new File(item.UrlFile);
                                var  mediaUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);

                                Intent intent = new Intent();
                                intent.SetAction(Intent.ActionView);
                                intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                                intent.SetDataAndType(mediaUri, "video/*");
                                StartActivity(intent);
                            }
                            else
                            {
                                Intent intent = new Intent(Intent.ActionView, Uri.Parse(item.UrlFile));
                                StartActivity(intent);
                            }
                        }
                        else
                        {
                            item.UrlFile = QuickDateTools.GetFile(UserDetails.UserId.ToString(), Methods.Path.FolderDiskImage, fileName, item.UrlFile);
                            if (!string.IsNullOrEmpty(item.UrlFile) && (item.UrlFile.Contains("file://") || item.UrlFile.Contains("content://") || item.UrlFile.Contains("storage") || item.UrlFile.Contains("/data/user/0/")))

                            {
                                File   file2    = new File(item.UrlFile);
                                var    photoUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);
                                Intent intent   = new Intent();
                                intent.SetAction(Intent.ActionView);
                                intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                                intent.SetDataAndType(photoUri, "image/*");
                                StartActivity(intent);
                            }
                            else
                            {
                                Intent intent = new Intent(Intent.ActionView, Uri.Parse(item.UrlFile));
                                StartActivity(intent);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Ejemplo n.º 28
0
        private void GetMyInfoData()
        {
            try
            {
                if (ListUtils.MyUserInfo.Count == 0)
                {
                    var sqlEntity = new SqLiteDatabase();
                    sqlEntity.GetDataMyInfo();
                    sqlEntity.Dispose();
                }

                var dataUser = ListUtils.MyUserInfo.FirstOrDefault();
                if (dataUser != null)
                {
                    string liveWith = QuickDateTools.GetLiveWith(Convert.ToInt32(dataUser.LiveWith));
                    if (Methods.FunString.StringNullRemover(liveWith) != "-----")
                    {
                        IdLiveWith       = Convert.ToInt32(dataUser.LiveWith);
                        EdtLiveWith.Text = liveWith;
                    }

                    string car = QuickDateTools.GetCar(Convert.ToInt32(dataUser.Car));
                    if (Methods.FunString.StringNullRemover(car) != "-----")
                    {
                        IdCar       = Convert.ToInt32(dataUser.Car);
                        EdtCar.Text = car;
                    }

                    string religion = QuickDateTools.GetReligion(Convert.ToInt32(dataUser.Religion));
                    if (Methods.FunString.StringNullRemover(religion) != "-----")
                    {
                        IdReligion       = Convert.ToInt32(dataUser.Religion);
                        EdtReligion.Text = religion;
                    }

                    string smoke = QuickDateTools.GetSmoke(Convert.ToInt32(dataUser.Smoke));
                    if (Methods.FunString.StringNullRemover(smoke) != "-----")
                    {
                        IdSmoke       = Convert.ToInt32(dataUser.Smoke);
                        EdtSmoke.Text = smoke;
                    }

                    string drink = QuickDateTools.GetDrink(Convert.ToInt32(dataUser.Drink));
                    if (Methods.FunString.StringNullRemover(drink) != "-----")
                    {
                        IdDrink       = Convert.ToInt32(dataUser.Drink);
                        EdtDrink.Text = drink;
                    }

                    string travel = QuickDateTools.GetTravel(Convert.ToInt32(dataUser.Travel));
                    if (Methods.FunString.StringNullRemover(travel) != "-----")
                    {
                        IdTravel       = Convert.ToInt32(dataUser.Travel);
                        EdtTravel.Text = travel;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 29
0
        public static async Task <ProfileObject> GetInfoData(Activity context, string userId)
        {
            if (Methods.CheckConnectivity())
            {
                int     apiStatus;
                dynamic respond;

                if (userId == UserDetails.UserId.ToString())
                {
                    (apiStatus, respond) = await RequestsAsync.Users.ProfileAsync(userId);
                }
                else
                {
                    (apiStatus, respond) = await RequestsAsync.Users.ProfileAsync(userId, "data,media");
                }
                if (apiStatus == 200)
                {
                    if (respond is ProfileObject result)
                    {
                        if (userId == UserDetails.UserId.ToString())
                        {
                            UserDetails.Avatar   = result.Data.Avater;
                            UserDetails.Username = result.Data.Username;
                            UserDetails.FullName = result.Data.Fullname;
                            UserDetails.IsPro    = result.Data.IsPro;
                            UserDetails.Url      = Client.WebsiteUrl + "@" + result.Data?.Username;

                            ListUtils.MyUserInfo.Clear();
                            ListUtils.MyUserInfo.Add(result.Data);

                            SqLiteDatabase dbDatabase = new SqLiteDatabase();
                            dbDatabase.InsertOrUpdate_DataMyInfo(result.Data);
                            dbDatabase.Dispose();

                            await Task.Factory.StartNew(() =>
                            {
                                try
                                {
                                    var respondList = result.Data.Mediafiles.Count;
                                    if (respondList > 0)
                                    {
                                        foreach (var item in result.Data.Mediafiles)
                                        {
                                            Glide.With(context).Load(item.Avater).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();

                                            var newPath = item.VideoFile;
                                            if (!string.IsNullOrEmpty(newPath) && !newPath.Contains(Client.WebsiteUrl))
                                            {
                                                newPath = Client.WebsiteUrl + item.VideoFile;
                                            }
                                            else
                                            {
                                                newPath = item.Full;
                                            }

                                            var type = Methods.AttachmentFiles.Check_FileExtension(newPath);
                                            if (type == "Video" || item.Avater.Contains("video_thumb"))
                                            {
                                                var fileName = newPath.Split('/').Last();
                                                item.UrlFile = QuickDateTools.GetFile(UserDetails.UserId.ToString(), Methods.Path.FolderDiskVideo, fileName, newPath);
                                            }
                                            else if (type == "Image")
                                            {
                                                var fileName = item.Full.Split('/').Last();
                                                item.UrlFile = QuickDateTools.GetFile(UserDetails.UserId.ToString(), Methods.Path.FolderDiskImage, fileName, item.Full);
                                            }
                                        }
                                    }
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e);
                                }
                            }).ConfigureAwait(false);

                            return(result);
                        }
                        else
                        {
                            return(result);
                        }
                    }
                }
                //else Methods.DisplayReportResult(context, respond);
            }

            return(null);
        }
Ejemplo n.º 30
0
        private async Task LoadMediaFilesAsync()
        {
            if (Methods.CheckConnectivity())
            {
                int countList = MAdapter.MediaList.Count;
                var(apiStatus, respond) = await RequestsAsync.Users.ProfileAsync(UserDetails.UserId.ToString(), "data,media");

                if (apiStatus != 200 || !(respond is ProfileObject result) || result.Data == null)
                {
                    Methods.DisplayReportResult(this, respond);
                }
                else
                {
                    var respondList = result.Data.Mediafiles.Count;
                    if (respondList > 0)
                    {
                        foreach (var item in from item in result.Data.Mediafiles let check = MAdapter.MediaList.FirstOrDefault(a => a.Id == item.Id) where check == null select item)
                        {
                            MAdapter.MediaList.Add(item);

                            await Task.Factory.StartNew(() =>
                            {
                                try
                                {
                                    var newPath = item.VideoFile;
                                    if (!string.IsNullOrEmpty(newPath) && !newPath.Contains(Client.WebsiteUrl))
                                    {
                                        newPath = Client.WebsiteUrl + item.VideoFile;
                                    }
                                    else
                                    {
                                        newPath = item.Full;
                                    }

                                    var type = Methods.AttachmentFiles.Check_FileExtension(newPath);
                                    if (type == "Video" || item.Avater.Contains("video_thumb"))
                                    {
                                        var fileName = newPath.Split('/').Last();
                                        item.UrlFile = QuickDateTools.GetFile(UserDetails.UserId.ToString(), Methods.Path.FolderDiskVideo, fileName, newPath);
                                    }
                                    else if (type == "Image")
                                    {
                                        var fileName = item.Full.Split('/').Last();
                                        item.UrlFile = QuickDateTools.GetFile(UserDetails.UserId.ToString(), Methods.Path.FolderDiskImage, fileName, item.Full);
                                    }
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e);
                                }
                            }).ConfigureAwait(false);
                        }

                        if (countList > 0)
                        {
                            RunOnUiThread(() => { MAdapter.NotifyItemRangeInserted(countList - 1, MAdapter.MediaList.Count - countList); });
                        }
                        else
                        {
                            RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                        }
                    }
                }

                RunOnUiThread(ShowEmptyPage);
            }
            else
            {
                Inflated = EmptyStateLayout.Inflate();
                EmptyStateInflater x = new EmptyStateInflater();
                x.InflateLayout(Inflated, EmptyStateInflater.Type.NoConnection);
                if (!x.EmptyStateButton.HasOnClickListeners)
                {
                    x.EmptyStateButton.Click += null;
                    x.EmptyStateButton.Click += EmptyStateButtonOnClick;
                }

                Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
        }