Пример #1
0
        private void LoadAudioItem(CommentAdapterViewHolder soundViewHolder, CommentObjectExtra item)
        {
            try
            {
                soundViewHolder.VoiceLayout.Visibility = ViewStates.Visible;

                var fileName = item.Record.Split('/').Last();

                var mediaFile = WoWonderTools.GetFile(item.PostId, Methods.Path.FolderDcimSound, fileName, item.Record);

                if (string.IsNullOrEmpty(item.MediaDuration) || item.MediaDuration == "00:00")
                {
                    var duration = WoWonderTools.GetDuration(mediaFile);
                    soundViewHolder.DurationVoice.Text = Methods.AudioRecorderAndPlayer.GetTimeString(duration);
                }
                else
                {
                    soundViewHolder.DurationVoice.Text = item.MediaDuration;
                }

                soundViewHolder.PlayButton.Visibility = ViewStates.Visible;

                if (item.MediaIsPlaying)
                {
                    soundViewHolder.PlayButton.SetImageResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.ic_media_pause_light : Resource.Drawable.ic_media_pause_dark);
                }
                else
                {
                    soundViewHolder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private async Task LoadStory()
        {
            switch (AppSettings.ShowStory)
            {
            case false:
                return;
            }

            if (Methods.CheckConnectivity())
            {
                var checkSection = PostFeedAdapter?.ListDiffer?.FirstOrDefault(a => a.TypeView == PostModelType.Story);
                if (checkSection != null)
                {
                    checkSection.StoryList ??= new ObservableCollection <StoryDataObject>();

                    var(apiStatus, respond) = await RequestsAsync.Story.GetUserStoriesAsync();

                    switch (apiStatus)
                    {
                    case 200:
                    {
                        switch (respond)
                        {
                        case GetUserStoriesObject result:
                            await Task.Factory.StartNew(() =>
                                {
                                    try
                                    {
                                        foreach (var item in result.Stories)
                                        {
                                            var check = checkSection.StoryList.FirstOrDefault(a => a.UserId == item.UserId);
                                            if (check != null)
                                            {
                                                foreach (var item2 in item.Stories)
                                                {
                                                    item.DurationsList ??= new List <long>();

                                                    //image and video
                                                    var mediaFile = !item2.Thumbnail.Contains("avatar") && item2.Videos.Count == 0 ? item2.Thumbnail : item2.Videos[0].Filename;

                                                    var type = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                                    if (type != "Video")
                                                    {
                                                        Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                                        item.DurationsList.Add(10000L);
                                                    }
                                                    else
                                                    {
                                                        var fileName = mediaFile.Split('/').Last();
                                                        mediaFile    = WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                                        var duration = WoWonderTools.GetDuration(mediaFile);
                                                        item.DurationsList.Add(Long.ParseLong(duration));
                                                    }
                                                }

                                                check.Stories = item.Stories;
                                            }
                                            else
                                            {
                                                foreach (var item1 in item.Stories)
                                                {
                                                    item.DurationsList ??= new List <long>();

                                                    //image and video
                                                    var mediaFile = !item1.Thumbnail.Contains("avatar") && item1.Videos.Count == 0 ? item1.Thumbnail : item1.Videos[0].Filename;

                                                    var type1 = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                                    if (type1 != "Video")
                                                    {
                                                        Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                                        item.DurationsList.Add(10000L);
                                                    }
                                                    else
                                                    {
                                                        var fileName = mediaFile.Split('/').Last();
                                                        WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                                        var duration = WoWonderTools.GetDuration(mediaFile);
                                                        item.DurationsList.Add(Long.ParseLong(duration));
                                                    }
                                                }

                                                checkSection.StoryList.Add(item);
                                            }
                                        }
                                        Activity?.RunOnUiThread(() =>
                                        {
                                            try
                                            {
                                                PostFeedAdapter.HolderStory.AboutMore.Visibility = checkSection.StoryList.Count > 4 ? ViewStates.Visible : ViewStates.Invisible;
                                            }
                                            catch (Exception e)
                                            {
                                                Console.WriteLine(e);
                                            }
                                        });
                                    }
                                    catch (Exception e)
                                    {
                                        Methods.DisplayReportResultTrack(e);
                                    }
                                }).ConfigureAwait(false);

                            break;
                        }

                        break;
                    }

                    default:
                        Methods.DisplayReportResult(Activity, respond);
                        break;
                    }
                    var d = new Runnable(() => { PostFeedAdapter.NotifyItemChanged(PostFeedAdapter.ListDiffer.IndexOf(checkSection)); }); d.Run();
                }
            }
            else
            {
                Toast.MakeText(Context, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show();
            }
        }
Пример #3
0
        public void PlaySound(CommentReplyClickEventArgs args)
        {
            try
            {
                if (args.Holder.CommentAdapter.PositionSound != args.Position)
                {
                    var list = args.Holder.CommentAdapter.CommentList.Where(a => a.MediaPlayer != null).ToList();
                    if (list.Count > 0)
                    {
                        foreach (var item in list)
                        {
                            item.MediaIsPlaying = false;

                            if (item.MediaPlayer != null)
                            {
                                item.MediaPlayer.Stop();
                                item.MediaPlayer.Reset();
                            }
                            item.MediaPlayer = null !;
                            item.MediaTimer  = null !;

                            item.MediaPlayer?.Release();
                            item.MediaPlayer = null !;
                        }

                        args.Holder.CommentAdapter.NotifyItemChanged(args.Holder.CommentAdapter.PositionSound, "WithoutBlobAudio");
                    }
                }

                var fileName  = args.CommentObject.Record.Split('/').Last();
                var mediaFile = WoWonderTools.GetFile(args.CommentObject.PostId, Methods.Path.FolderDcimSound, fileName, args.CommentObject.Record);

                if (string.IsNullOrEmpty(args.CommentObject.MediaDuration) || args.CommentObject.MediaDuration == "00:00")
                {
                    var duration = WoWonderTools.GetDuration(mediaFile);
                    args.Holder.DurationVoice.Text = Methods.AudioRecorderAndPlayer.GetTimeString(duration);
                }
                else
                {
                    args.Holder.DurationVoice.Text = args.CommentObject.MediaDuration;
                }

                if (mediaFile.Contains("http"))
                {
                    mediaFile = WoWonderTools.GetFile(args.CommentObject.PostId, Methods.Path.FolderDcimSound, fileName, args.CommentObject.Record);
                }

                if (args.CommentObject.MediaPlayer == null)
                {
                    args.Holder.DurationVoice.Text           = "00:00";
                    args.Holder.CommentAdapter.PositionSound = args.Position;
                    args.CommentObject.MediaPlayer           = new MediaPlayer();
                    args.CommentObject.MediaPlayer.SetAudioAttributes(new AudioAttributes.Builder().SetUsage(AudioUsageKind.Media).SetContentType(AudioContentType.Music).Build());

                    args.CommentObject.MediaPlayer.Completion += (sender, e) =>
                    {
                        try
                        {
                            args.Holder.PlayButton.Tag = "Play";
                            args.Holder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);

                            args.CommentObject.MediaIsPlaying = false;

                            args.CommentObject.MediaPlayer.Stop();
                            args.CommentObject.MediaPlayer.Reset();
                            args.CommentObject.MediaPlayer = null !;

                            args.CommentObject.MediaTimer.Enabled = false;
                            args.CommentObject.MediaTimer.Stop();
                            args.CommentObject.MediaTimer = null !;
                        }
                        catch (Exception exception)
                        {
                            Methods.DisplayReportResultTrack(exception);
                        }
                    };

                    args.CommentObject.MediaPlayer.Prepared += (s, ee) =>
                    {
                        try
                        {
                            args.CommentObject.MediaIsPlaying = true;
                            args.Holder.PlayButton.Tag        = "Pause";
                            args.Holder.PlayButton.SetImageResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.ic_media_pause_light : Resource.Drawable.ic_media_pause_dark);

                            args.CommentObject.MediaTimer ??= new Timer {
                                Interval = 1000
                            };

                            args.CommentObject.MediaPlayer.Start();

                            //var durationOfSound = message.MediaPlayer.Duration;

                            args.CommentObject.MediaTimer.Elapsed += (sender, eventArgs) =>
                            {
                                args.Holder.CommentAdapter.ActivityContext.RunOnUiThread(() =>
                                {
                                    try
                                    {
                                        if (args.CommentObject.MediaTimer != null && args.CommentObject.MediaTimer.Enabled)
                                        {
                                            if (args.CommentObject.MediaPlayer.CurrentPosition <= args.CommentObject.MediaPlayer.Duration)
                                            {
                                                args.Holder.DurationVoice.Text = Methods.AudioRecorderAndPlayer.GetTimeString(args.CommentObject.MediaPlayer.CurrentPosition.ToString());
                                            }
                                            else
                                            {
                                                args.Holder.DurationVoice.Text = Methods.AudioRecorderAndPlayer.GetTimeString(args.CommentObject.MediaPlayer.Duration.ToString());

                                                args.Holder.PlayButton.Tag = "Play";
                                                args.Holder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);
                                            }
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        Methods.DisplayReportResultTrack(e);
                                        args.Holder.PlayButton.Tag = "Play";
                                    }
                                });
                            };
                            args.CommentObject.MediaTimer.Start();
                        }
                        catch (Exception e)
                        {
                            Methods.DisplayReportResultTrack(e);
                        }
                    };

                    if (mediaFile.Contains("http"))
                    {
                        args.CommentObject.MediaPlayer.SetDataSource(args.Holder.CommentAdapter.ActivityContext, Android.Net.Uri.Parse(mediaFile));
                        args.CommentObject.MediaPlayer.PrepareAsync();
                    }
                    else
                    {
                        Java.IO.File file2    = new Java.IO.File(mediaFile);
                        var          photoUri = FileProvider.GetUriForFile(args.Holder.CommentAdapter.ActivityContext, args.Holder.CommentAdapter.ActivityContext.PackageName + ".fileprovider", file2);

                        args.CommentObject.MediaPlayer.SetDataSource(args.Holder.CommentAdapter.ActivityContext, photoUri);
                        args.CommentObject.MediaPlayer.PrepareAsync();
                    }

                    //args.CommentObject.SoundViewHolder = soundViewHolder;
                }
                else
                {
                    if (args.Holder.PlayButton?.Tag?.ToString() == "Play")
                    {
                        args.Holder.PlayButton.Tag = "Pause";
                        args.Holder.PlayButton.SetImageResource(AppSettings.SetTabDarkTheme ? Resource.Drawable.ic_media_pause_light : Resource.Drawable.ic_media_pause_dark);

                        args.CommentObject.MediaIsPlaying = true;
                        args.CommentObject.MediaPlayer?.Start();

                        if (args.CommentObject.MediaTimer != null)
                        {
                            args.CommentObject.MediaTimer.Enabled = true;
                            args.CommentObject.MediaTimer.Start();
                        }
                    }
                    else if (args.Holder.PlayButton?.Tag?.ToString() == "Pause")
                    {
                        args.Holder.PlayButton.Tag = "Play";
                        args.Holder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);

                        args.CommentObject.MediaIsPlaying = false;
                        args.CommentObject.MediaPlayer?.Pause();

                        if (args.CommentObject.MediaTimer != null)
                        {
                            args.CommentObject.MediaTimer.Enabled = false;
                            args.CommentObject.MediaTimer.Stop();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private async void AddStory()
        {
            try
            {
                var modelStory = GlobalContextTabbed.LastStoriesTab.MAdapter;

                string time          = Methods.Time.TimeAgo(DateTime.Now, false);
                int    unixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
                string time2         = unixTimestamp.ToString();

                var userData = ListUtils.MyProfileList.FirstOrDefault();

                //just pass file_path and type video or image
                var(apiStatus, respond) = await RequestsAsync.Story.Create_Story(DataPost.StoryTitle, DataPost.StoryDescription, DataPost.StoryFilePath, DataPost.StoryFileType);

                if (apiStatus == 200)
                {
                    if (respond is CreateStoryObject result)
                    {
                        Toast.MakeText(GlobalContextTabbed, GlobalContextTabbed.GetText(Resource.String.Lbl_Story_Added), ToastLength.Short).Show();

                        var check = modelStory.StoryList?.FirstOrDefault(a => a.UserId == UserDetails.UserId);
                        if (check != null)
                        {
                            if (DataPost.StoryFileType == "image")
                            {
                                var item = new GetUserStoriesObject.StoryObject.Story()
                                {
                                    UserId      = UserDetails.UserId,
                                    Id          = result.StoryId,
                                    Description = DataPost.StoryDescription,
                                    Title       = DataPost.StoryTitle,
                                    TimeText    = time,
                                    IsOwner     = true,
                                    Expire      = "",
                                    Posted      = time2,
                                    Thumbnail   = DataPost.StoryFilePath,
                                    UserData    = userData,
                                    Images      = new List <GetUserStoriesObject.StoryObject.Image>(),
                                    Videos      = new List <GetUserStoriesObject.StoryObject.Video>()
                                };

                                if (check.DurationsList == null)
                                {
                                    check.DurationsList = new List <long>()
                                    {
                                        AppSettings.StoryDuration
                                    }
                                }
                                ;
                                else
                                {
                                    check.DurationsList.Add(AppSettings.StoryDuration);
                                }

                                check.Stories.Add(item);
                            }
                            else
                            {
                                var item = new GetUserStoriesObject.StoryObject.Story()
                                {
                                    UserId      = UserDetails.UserId,
                                    Id          = result.StoryId,
                                    Description = DataPost.StoryDescription,
                                    Title       = DataPost.StoryTitle,
                                    TimeText    = time,
                                    IsOwner     = true,
                                    Expire      = "",
                                    Posted      = time2,
                                    Thumbnail   = DataPost.StoryThumbnail,
                                    UserData    = userData,
                                    Images      = new List <GetUserStoriesObject.StoryObject.Image>(),
                                    Videos      = new List <GetUserStoriesObject.StoryObject.Video>()
                                    {
                                        new GetUserStoriesObject.StoryObject.Video()
                                        {
                                            StoryId  = result.StoryId,
                                            Filename = DataPost.StoryFilePath,
                                            Id       = time2,
                                            Expire   = time2,
                                            Type     = "video",
                                        }
                                    }
                                };

                                var duration = WoWonderTools.GetDuration(DataPost.StoryFilePath);

                                if (check.DurationsList == null)
                                {
                                    check.DurationsList = new List <long>()
                                    {
                                        Long.ParseLong(duration)
                                    }
                                }
                                ;
                                else
                                {
                                    check.DurationsList.Add(Long.ParseLong(duration));
                                }

                                check.Stories.Add(item);
                            }
                        }
                        else
                        {
                            if (DataPost.StoryFileType == "image")
                            {
                                var item = new GetUserStoriesObject.StoryObject
                                {
                                    Type    = "image",
                                    Stories = new List <GetUserStoriesObject.StoryObject.Story>
                                    {
                                        new GetUserStoriesObject.StoryObject.Story()
                                        {
                                            UserId      = UserDetails.UserId,
                                            Id          = result.StoryId,
                                            Description = DataPost.StoryDescription,
                                            Title       = DataPost.StoryTitle,
                                            TimeText    = time,
                                            IsOwner     = true,
                                            Expire      = "",
                                            Posted      = time2,
                                            Thumbnail   = DataPost.StoryFilePath,
                                            UserData    = userData,
                                            Images      = new List <GetUserStoriesObject.StoryObject.Image>(),
                                            Videos      = new List <GetUserStoriesObject.StoryObject.Video>(),
                                        }
                                    },
                                    UserId                = userData?.UserId,
                                    Username              = userData?.Username,
                                    Email                 = userData?.Email,
                                    FirstName             = userData?.FirstName,
                                    LastName              = userData?.LastName,
                                    Avatar                = userData?.Avatar,
                                    Cover                 = userData?.Cover,
                                    BackgroundImage       = userData?.BackgroundImage,
                                    RelationshipId        = userData?.RelationshipId,
                                    Address               = userData?.Address,
                                    Working               = userData?.Working,
                                    Gender                = userData?.Gender,
                                    Facebook              = userData?.Facebook,
                                    Google                = userData?.Google,
                                    Twitter               = userData?.Twitter,
                                    Linkedin              = userData?.Linkedin,
                                    Website               = userData?.Website,
                                    Instagram             = userData?.Instagram,
                                    WebDeviceId           = userData?.WebDeviceId,
                                    Language              = userData?.Language,
                                    IpAddress             = userData?.IpAddress,
                                    PhoneNumber           = userData?.PhoneNumber,
                                    Timezone              = userData?.Timezone,
                                    Lat                   = userData?.Lat,
                                    Lng                   = userData?.Lng,
                                    About                 = userData?.About,
                                    Birthday              = userData?.Birthday,
                                    Registered            = userData?.Registered,
                                    Lastseen              = userData?.Lastseen,
                                    LastLocationUpdate    = userData?.LastLocationUpdate,
                                    Balance               = userData?.Balance,
                                    Verified              = userData?.Verified,
                                    Status                = userData?.Status,
                                    Active                = userData?.Active,
                                    Admin                 = userData?.Admin,
                                    IsPro                 = userData?.IsPro,
                                    ProType               = userData?.ProType,
                                    School                = userData?.School,
                                    Name                  = userData?.Name,
                                    AndroidMDeviceId      = userData?.AndroidMDeviceId,
                                    ECommented            = userData?.ECommented,
                                    AndroidNDeviceId      = userData?.AndroidMDeviceId,
                                    AvatarFull            = userData?.AvatarFull,
                                    BirthPrivacy          = userData?.BirthPrivacy,
                                    CanFollow             = userData?.CanFollow,
                                    ConfirmFollowers      = userData?.ConfirmFollowers,
                                    CountryId             = userData?.CountryId,
                                    EAccepted             = userData?.EAccepted,
                                    EFollowed             = userData?.EFollowed,
                                    EJoinedGroup          = userData?.EJoinedGroup,
                                    ELastNotif            = userData?.ELastNotif,
                                    ELiked                = userData?.ELiked,
                                    ELikedPage            = userData?.ELikedPage,
                                    EMentioned            = userData?.EMentioned,
                                    EProfileWallPost      = userData?.EProfileWallPost,
                                    ESentmeMsg            = userData?.ESentmeMsg,
                                    EShared               = userData?.EShared,
                                    EVisited              = userData?.EVisited,
                                    EWondered             = userData?.EWondered,
                                    EmailNotification     = userData?.EmailNotification,
                                    FollowPrivacy         = userData?.FollowPrivacy,
                                    FriendPrivacy         = userData?.FriendPrivacy,
                                    GenderText            = userData?.GenderText,
                                    InfoFile              = userData?.InfoFile,
                                    IosMDeviceId          = userData?.IosMDeviceId,
                                    IosNDeviceId          = userData?.IosNDeviceId,
                                    IsFollowing           = userData?.IsFollowing,
                                    IsFollowingMe         = userData?.IsFollowingMe,
                                    LastAvatarMod         = userData?.LastAvatarMod,
                                    LastCoverMod          = userData?.LastCoverMod,
                                    LastDataUpdate        = userData?.LastDataUpdate,
                                    LastFollowId          = userData?.LastFollowId,
                                    LastLoginData         = userData?.LastLoginData,
                                    LastseenStatus        = userData?.LastseenStatus,
                                    LastseenTimeText      = userData?.LastseenTimeText,
                                    LastseenUnixTime      = userData?.LastseenUnixTime,
                                    MessagePrivacy        = userData?.MessagePrivacy,
                                    NewEmail              = userData?.NewEmail,
                                    NewPhone              = userData?.NewPhone,
                                    NotificationSettings  = userData?.NotificationSettings,
                                    NotificationsSound    = userData?.NotificationsSound,
                                    OrderPostsBy          = userData?.OrderPostsBy,
                                    PaypalEmail           = userData?.PaypalEmail,
                                    PostPrivacy           = userData?.PostPrivacy,
                                    Referrer              = userData?.Referrer,
                                    ShareMyData           = userData?.ShareMyData,
                                    ShareMyLocation       = userData?.ShareMyLocation,
                                    ShowActivitiesPrivacy = userData?.ShowActivitiesPrivacy,
                                    TwoFactor             = userData?.TwoFactor,
                                    TwoFactorVerified     = userData?.TwoFactorVerified,
                                    Url                   = userData?.Url,
                                    VisitPrivacy          = userData?.VisitPrivacy,
                                    Vk             = userData?.Vk,
                                    Wallet         = userData?.Wallet,
                                    WorkingLink    = userData?.WorkingLink,
                                    Youtube        = userData?.Youtube,
                                    City           = userData?.City,
                                    Points         = userData?.Points,
                                    DailyPoints    = userData?.DailyPoints,
                                    State          = userData?.State,
                                    Zip            = userData?.Zip,
                                    IsAdmin        = userData?.IsAdmin,
                                    IsBlocked      = userData?.IsBlocked,
                                    MemberId       = userData?.MemberId,
                                    PointDayExpire = userData?.PointDayExpire,
                                    UserPlatform   = userData?.UserPlatform,
                                    Details        = new DetailsUnion()
                                    {
                                        DetailsClass = new Details(),
                                    },
                                };

                                if (item.DurationsList == null)
                                {
                                    item.DurationsList = new List <long>()
                                    {
                                        AppSettings.StoryDuration
                                    }
                                }
                                ;
                                else
                                {
                                    item.DurationsList.Add(AppSettings.StoryDuration);
                                }

                                modelStory.StoryList?.Add(item);
                            }
                            else
                            {
                                var item = new GetUserStoriesObject.StoryObject()
                                {
                                    Type    = "video",
                                    Stories = new List <GetUserStoriesObject.StoryObject.Story>()
                                    {
                                        new GetUserStoriesObject.StoryObject.Story()
                                        {
                                            UserId      = UserDetails.UserId,
                                            Id          = result.StoryId,
                                            Description = DataPost.StoryDescription,
                                            Title       = DataPost.StoryTitle,
                                            TimeText    = time,
                                            IsOwner     = true,
                                            Expire      = "",
                                            Posted      = time2,
                                            Thumbnail   = DataPost.StoryThumbnail,
                                            UserData    = userData,
                                            Images      = new List <GetUserStoriesObject.StoryObject.Image>(),
                                            Videos      = new List <GetUserStoriesObject.StoryObject.Video>()
                                            {
                                                new GetUserStoriesObject.StoryObject.Video()
                                                {
                                                    StoryId  = result.StoryId,
                                                    Filename = DataPost.StoryFilePath,
                                                    Id       = time2,
                                                    Expire   = time2,
                                                    Type     = "video",
                                                }
                                            }
                                        },
                                    },
                                    UserId                = userData?.UserId,
                                    Username              = userData?.Username,
                                    Email                 = userData?.Email,
                                    FirstName             = userData?.FirstName,
                                    LastName              = userData?.LastName,
                                    Avatar                = userData?.Avatar,
                                    Cover                 = userData?.Cover,
                                    BackgroundImage       = userData?.BackgroundImage,
                                    RelationshipId        = userData?.RelationshipId,
                                    Address               = userData?.Address,
                                    Working               = userData?.Working,
                                    Gender                = userData?.Gender,
                                    Facebook              = userData?.Facebook,
                                    Google                = userData?.Google,
                                    Twitter               = userData?.Twitter,
                                    Linkedin              = userData?.Linkedin,
                                    Website               = userData?.Website,
                                    Instagram             = userData?.Instagram,
                                    WebDeviceId           = userData?.WebDeviceId,
                                    Language              = userData?.Language,
                                    IpAddress             = userData?.IpAddress,
                                    PhoneNumber           = userData?.PhoneNumber,
                                    Timezone              = userData?.Timezone,
                                    Lat                   = userData?.Lat,
                                    Lng                   = userData?.Lng,
                                    About                 = userData?.About,
                                    Birthday              = userData?.Birthday,
                                    Registered            = userData?.Registered,
                                    Lastseen              = userData?.Lastseen,
                                    LastLocationUpdate    = userData?.LastLocationUpdate,
                                    Balance               = userData?.Balance,
                                    Verified              = userData?.Verified,
                                    Status                = userData?.Status,
                                    Active                = userData?.Active,
                                    Admin                 = userData?.Admin,
                                    IsPro                 = userData?.IsPro,
                                    ProType               = userData?.ProType,
                                    School                = userData?.School,
                                    Name                  = userData?.Name,
                                    AndroidMDeviceId      = userData?.AndroidMDeviceId,
                                    ECommented            = userData?.ECommented,
                                    AndroidNDeviceId      = userData?.AndroidMDeviceId,
                                    AvatarFull            = userData?.AvatarFull,
                                    BirthPrivacy          = userData?.BirthPrivacy,
                                    CanFollow             = userData?.CanFollow,
                                    ConfirmFollowers      = userData?.ConfirmFollowers,
                                    CountryId             = userData?.CountryId,
                                    EAccepted             = userData?.EAccepted,
                                    EFollowed             = userData?.EFollowed,
                                    EJoinedGroup          = userData?.EJoinedGroup,
                                    ELastNotif            = userData?.ELastNotif,
                                    ELiked                = userData?.ELiked,
                                    ELikedPage            = userData?.ELikedPage,
                                    EMentioned            = userData?.EMentioned,
                                    EProfileWallPost      = userData?.EProfileWallPost,
                                    ESentmeMsg            = userData?.ESentmeMsg,
                                    EShared               = userData?.EShared,
                                    EVisited              = userData?.EVisited,
                                    EWondered             = userData?.EWondered,
                                    EmailNotification     = userData?.EmailNotification,
                                    FollowPrivacy         = userData?.FollowPrivacy,
                                    FriendPrivacy         = userData?.FriendPrivacy,
                                    GenderText            = userData?.GenderText,
                                    InfoFile              = userData?.InfoFile,
                                    IosMDeviceId          = userData?.IosMDeviceId,
                                    IosNDeviceId          = userData?.IosNDeviceId,
                                    IsFollowing           = userData?.IsFollowing,
                                    IsFollowingMe         = userData?.IsFollowingMe,
                                    LastAvatarMod         = userData?.LastAvatarMod,
                                    LastCoverMod          = userData?.LastCoverMod,
                                    LastDataUpdate        = userData?.LastDataUpdate,
                                    LastFollowId          = userData?.LastFollowId,
                                    LastLoginData         = userData?.LastLoginData,
                                    LastseenStatus        = userData?.LastseenStatus,
                                    LastseenTimeText      = userData?.LastseenTimeText,
                                    LastseenUnixTime      = userData?.LastseenUnixTime,
                                    MessagePrivacy        = userData?.MessagePrivacy,
                                    NewEmail              = userData?.NewEmail,
                                    NewPhone              = userData?.NewPhone,
                                    NotificationSettings  = userData?.NotificationSettings,
                                    NotificationsSound    = userData?.NotificationsSound,
                                    OrderPostsBy          = userData?.OrderPostsBy,
                                    PaypalEmail           = userData?.PaypalEmail,
                                    PostPrivacy           = userData?.PostPrivacy,
                                    Referrer              = userData?.Referrer,
                                    ShareMyData           = userData?.ShareMyData,
                                    ShareMyLocation       = userData?.ShareMyLocation,
                                    ShowActivitiesPrivacy = userData?.ShowActivitiesPrivacy,
                                    TwoFactor             = userData?.TwoFactor,
                                    TwoFactorVerified     = userData?.TwoFactorVerified,
                                    Url                   = userData?.Url,
                                    VisitPrivacy          = userData?.VisitPrivacy,
                                    Vk             = userData?.Vk,
                                    Wallet         = userData?.Wallet,
                                    WorkingLink    = userData?.WorkingLink,
                                    Youtube        = userData?.Youtube,
                                    City           = userData?.City,
                                    Points         = userData?.Points,
                                    DailyPoints    = userData?.DailyPoints,
                                    State          = userData?.State,
                                    Zip            = userData?.Zip,
                                    IsAdmin        = userData?.IsAdmin,
                                    IsBlocked      = userData?.IsBlocked,
                                    MemberId       = userData?.MemberId,
                                    PointDayExpire = userData?.PointDayExpire,
                                    UserPlatform   = userData?.UserPlatform,
                                    Details        = new DetailsUnion()
                                    {
                                        DetailsClass = new Details(),
                                    },
                                };

                                var duration = WoWonderTools.GetDuration(DataPost.StoryFilePath);

                                if (item.DurationsList == null)
                                {
                                    item.DurationsList = new List <long>()
                                    {
                                        Long.ParseLong(duration)
                                    }
                                }
                                ;
                                else
                                {
                                    item.DurationsList.Add(Long.ParseLong(duration));
                                }

                                modelStory.StoryList?.Add(item);
                            }
                        }

                        modelStory.NotifyDataSetChanged();
                        GlobalContextTabbed.LastStoriesTab.ShowEmptyPage();

                        if (SettingsPrefFragment.SSoundControl)
                        {
                            Methods.AudioRecorderAndPlayer.PlayAudioFromAsset("PopNotificationPost.mp3");
                        }
                    }
                }
                else
                {
                    Methods.DisplayReportResult(GlobalContextTabbed, respond);
                }

                RemoveNotification();
            }
            catch (Exception e)
            {
                RemoveNotification();
                Console.WriteLine(e);
            }
        }
Пример #5
0
        private async Task LoadStory()
        {
            if (Methods.CheckConnectivity())
            {
                var checkSection = PostFeedAdapter.ListDiffer.FirstOrDefault(a => a.TypeView == PostModelType.Story);
                if (checkSection != null)
                {
                    if (checkSection.StoryList == null)
                    {
                        checkSection.StoryList = new ObservableCollection <GetUserStoriesObject.StoryObject>();
                    }

                    (int apiStatus, var respond) = await RequestsAsync.Story.Get_UserStories();

                    if (apiStatus == 200)
                    {
                        if (respond is GetUserStoriesObject result)
                        {
                            foreach (var item in result.Stories)
                            {
                                var check = checkSection.StoryList.FirstOrDefault(a => a.UserId == item.UserId);
                                if (check != null)
                                {
                                    foreach (var item2 in item.Stories)
                                    {
                                        item.DurationsList ??= new List <long>();

                                        //image and video
                                        var mediaFile = !item2.Thumbnail.Contains("avatar") && item2.Videos.Count == 0 ? item2.Thumbnail : item2.Videos[0].Filename;

                                        var type = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                        if (type != "Video")
                                        {
                                            Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                            item.DurationsList.Add(10000L);
                                        }
                                        else
                                        {
                                            var fileName = mediaFile.Split('/').Last();
                                            mediaFile = WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                            var duration = WoWonderTools.GetDuration(mediaFile);
                                            item.DurationsList.Add(Long.ParseLong(duration));
                                        }
                                    }

                                    check.Stories = item.Stories;
                                }
                                else
                                {
                                    foreach (var item1 in item.Stories)
                                    {
                                        item.DurationsList ??= new List <long>();

                                        //image and video
                                        var mediaFile = !item1.Thumbnail.Contains("avatar") && item1.Videos.Count == 0 ? item1.Thumbnail : item1.Videos[0].Filename;

                                        var type1 = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                        if (type1 != "Video")
                                        {
                                            Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                            item.DurationsList.Add(10000L);
                                        }
                                        else
                                        {
                                            var fileName = mediaFile.Split('/').Last();
                                            WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                            var duration = WoWonderTools.GetDuration(mediaFile);
                                            item.DurationsList.Add(Long.ParseLong(duration));
                                        }
                                    }

                                    checkSection.StoryList.Add(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        Methods.DisplayReportResult(Activity, respond);
                    }

                    if (checkSection.StoryList.Count > 4)
                    {
                        PostFeedAdapter.HolderStory.AboutMore.Visibility     = ViewStates.Visible;
                        PostFeedAdapter.HolderStory.AboutMoreIcon.Visibility = ViewStates.Visible;
                    }
                    else
                    {
                        PostFeedAdapter.HolderStory.AboutMore.Visibility     = ViewStates.Invisible;
                        PostFeedAdapter.HolderStory.AboutMoreIcon.Visibility = ViewStates.Invisible;
                    }

                    var d = new Runnable(() => { PostFeedAdapter.NotifyItemChanged(PostFeedAdapter.ListDiffer.IndexOf(checkSection)); }); d.Run();
                }
            }
            else
            {
                Toast.MakeText(Context, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
        }
Пример #6
0
        private async Task LoadStory()
        {
            if (Methods.CheckConnectivity())
            {
                (int apiStatus, var respond) = await RequestsAsync.Story.Get_UserStories();

                if (apiStatus == 200)
                {
                    if (respond is GetUserStoriesObject result)
                    {
                        foreach (var item in result.Stories)
                        {
                            var check = MAdapter.StoryList.FirstOrDefault(a => a.UserId == item.UserId);
                            if (check != null)
                            {
                                foreach (var item2 in item.Stories)
                                {
                                    if (item.DurationsList == null)
                                    {
                                        item.DurationsList = new List <long>();
                                    }

                                    //image and video
                                    var mediaFile = !item2.Thumbnail.Contains("avatar") && item2.Videos.Count == 0 ? item2.Thumbnail : item2.Videos[0].Filename;

                                    var type = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                    if (type != "Video")
                                    {
                                        Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                        item.DurationsList.Add(AppSettings.StoryDuration);
                                    }
                                    else
                                    {
                                        var fileName = mediaFile.Split('/').Last();
                                        mediaFile = WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                        var duration = WoWonderTools.GetDuration(mediaFile);
                                        item.DurationsList.Add(Long.ParseLong(duration));
                                    }
                                }

                                check.Stories = item.Stories;
                            }
                            else
                            {
                                foreach (var item1 in item.Stories)
                                {
                                    if (item.DurationsList == null)
                                    {
                                        item.DurationsList = new List <long>();
                                    }

                                    //image and video
                                    var mediaFile = !item1.Thumbnail.Contains("avatar") && item1.Videos.Count == 0 ? item1.Thumbnail : item1.Videos[0].Filename;

                                    var type1 = Methods.AttachmentFiles.Check_FileExtension(mediaFile);
                                    if (type1 != "Video")
                                    {
                                        Glide.With(Context).Load(mediaFile).Apply(new RequestOptions().SetDiskCacheStrategy(DiskCacheStrategy.All).CenterCrop()).Preload();
                                        item.DurationsList.Add(AppSettings.StoryDuration);
                                    }
                                    else
                                    {
                                        var fileName = mediaFile.Split('/').Last();
                                        WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, mediaFile);

                                        var duration = WoWonderTools.GetDuration(mediaFile);
                                        item.DurationsList.Add(Long.ParseLong(duration));
                                    }
                                }

                                MAdapter.StoryList.Add(item);
                            }
                        }

                        Activity.RunOnUiThread(() => { MAdapter.NotifyDataSetChanged(); });
                    }
                }
                else
                {
                    Methods.DisplayReportResult(Activity, respond);
                }

                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.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
            }
        }