Exemple #1
0
        private void BtnDownloadOnClick(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(Link))
                {
                    return;
                }

                var fileName = Link.Split('/').Last();
                Link = WoWonderTools.GetFile("", Methods.Path.FolderDcimFile, fileName, Link);

                var    fileSplit = Link.Split('/').Last();
                string getFile   = Methods.MultiMedia.GetMediaFrom_Disk(Methods.Path.FolderDcimFile, fileSplit);
                if (getFile != "File Dont Exists")
                {
                    File file2    = new File(getFile);
                    var  photoUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);

                    Intent openFile = new Intent(Intent.ActionView, photoUri);
                    openFile.SetFlags(ActivityFlags.NewTask);
                    openFile.SetFlags(ActivityFlags.GrantReadUriPermission);
                    StartActivity(openFile);
                }
                else
                {
                    Intent intent = new Intent(Intent.ActionView, Uri.Parse(Link));
                    StartActivity(intent);
                }

                Toast.MakeText(this, GetText(Resource.String.Lbl_YourFileIsDownloaded), ToastLength.Long)?.Show();
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Exemple #2
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);
            }
        }
Exemple #3
0
        public void LoadCommentData(CommentObjectExtra item, CommentAdapterViewHolder holder)
        {
            try
            {
                if (!string.IsNullOrEmpty(item.Orginaltext) || !string.IsNullOrWhiteSpace(item.Orginaltext))
                {
                    var text = Methods.FunString.DecodeString(item.Orginaltext);
                    ReadMoreOption.AddReadMoreTo(holder.CommentText, new Java.Lang.String(text));
                }
                else
                {
                    holder.CommentText.Visibility = ViewStates.Gone;
                }

                holder.TimeTextView.Text = Methods.Time.TimeAgo(Convert.ToInt32(item.Time), false);
                holder.UserName.Text     = item.Publisher.Name;

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

                var textHighLighter = item.Publisher.Name;
                var textIsPro       = string.Empty;

                if (item.Publisher.Verified == "1")
                {
                    textHighLighter += " " + IonIconsFonts.CheckmarkCircle;
                }

                if (item.Publisher.IsPro == "1")
                {
                    textIsPro        = " " + IonIconsFonts.Flash;
                    textHighLighter += textIsPro;
                }

                var decorator = TextDecorator.Decorate(holder.UserName, textHighLighter).SetTextStyle((int)TypefaceStyle.Bold, 0, item.Publisher.Name.Length);

                if (item.Publisher.Verified == "1")
                {
                    decorator.SetTextColor(Resource.Color.Post_IsVerified, IonIconsFonts.CheckmarkCircle);
                }

                if (item.Publisher.IsPro == "1")
                {
                    decorator.SetTextColor(Resource.Color.text_color_in_between, textIsPro);
                }

                decorator.Build();

                //Image
                if (holder.ItemViewType == 1 || holder.CommentImage != null)
                {
                    if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/")))
                    {
                        File file2    = new File(item.CFile);
                        var  photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);
                        Glide.With(ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(holder.CommentImage);

                        //GlideImageLoader.LoadImage(ActivityContext,item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                    }
                    else
                    {
                        if (!item.CFile.Contains(Client.WebsiteUrl))
                        {
                            item.CFile = WoWonderTools.GetTheFinalLink(item.CFile);
                        }

                        GlideImageLoader.LoadImage(ActivityContext, item.CFile, holder.CommentImage, ImageStyle.CenterCrop, ImagePlaceholders.Color);
                        item.CFile = WoWonderTools.GetFile("", Methods.Path.FolderDiskImage, item.CFile.Split('/').Last(), item.CFile);
                    }
                }

                //Voice
                if (holder.VoiceLayout != null && !string.IsNullOrEmpty(item.Record))
                {
                    LoadAudioItem(holder, item);
                }

                var repliesCount = !string.IsNullOrEmpty(item.RepliesCount) ? item.RepliesCount : item.Replies ?? "";
                if (repliesCount != "0" && !string.IsNullOrEmpty(repliesCount))
                {
                    holder.ReplyTextView.Text = ActivityContext.GetText(Resource.String.Lbl_Reply) + " " + "(" + repliesCount + ")";
                }

                if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                {
                    item.Reaction ??= new Reaction();

                    holder.CountRating.Text = item.Reaction.Count + " " + ActivityContext.GetString(Resource.String.Lbl_Reactions);
                    holder.RatingBar.Rating = (float)Convert.ToDouble(item.Reaction.Type);
                    if (holder.RatingBar.Rating > 0)
                    {
                        holder.RatingText.Text = item.Reaction.Type;
                    }
                    else
                    {
                        holder.RatingText.Text = "0.0";
                    }

                    //if (item.Reaction.Count > 0)
                    //{
                    //    holder.CountLikeSection.Visibility = ViewStates.Visible;
                    //    holder.CountLike.Text = Methods.FunString.FormatPriceValue(item.Reaction.Count);
                    //}
                    //else
                    //{
                    //    holder.CountLikeSection.Visibility = ViewStates.Gone;
                    //}

                    if (item.Reaction.IsReacted != null && item.Reaction.IsReacted.Value)
                    {
                        if (!string.IsNullOrEmpty(item.Reaction.Type))
                        {
                            var react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Id == item.Reaction.Type).Value?.Id ?? "";
                            switch (react)
                            {
                            case "1":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Like);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);
                                break;

                            case "2":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Love);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_love);
                                break;

                            case "3":
                                ReactionComment.SetReactionPack(holder, ReactConstants.HaHa);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_haha);
                                break;

                            case "4":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Wow);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_wow);
                                break;

                            case "5":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Sad);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_sad);
                                break;

                            case "6":
                                ReactionComment.SetReactionPack(holder, ReactConstants.Angry);
                                holder.LikeTextView.Tag = "Liked";
                                holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_angry);
                                break;

                            default:
                                holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                                holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                                holder.LikeTextView.Tag = "Like";

                                if (item.Reaction.Count > 0)
                                {
                                    holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);
                                }

                                break;
                            }
                        }
                    }
                    else
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                        holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.LikeTextView.Tag = "Like";
                        if (item.Reaction.Count > 0)
                        {
                            holder.ImageCountLike.SetImageResource(Resource.Drawable.emoji_like);
                        }
                    }
                }
                else if (AppSettings.PostButton == PostButtonSystem.Wonder || AppSettings.PostButton == PostButtonSystem.DisLike)
                {
                    if (item.Reaction?.IsReacted != null && !item.Reaction.IsReacted.Value)
                    {
                        ReactionComment.SetReactionPack(holder, ReactConstants.Default);
                    }

                    if (item.IsCommentLiked)
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                        holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.LikeTextView.Tag = "Liked";
                    }

                    switch (AppSettings.PostButton)
                    {
                    case PostButtonSystem.Wonder when item.IsCommentWondered:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_wondered);
                        holder.DislikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.DislikeTextView.Tag = "Disliked";
                        break;
                    }

                    case PostButtonSystem.Wonder:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Wonder);
                        holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.DislikeTextView.Tag = "Dislike";
                        break;
                    }

                    case PostButtonSystem.DisLike when item.IsCommentWondered:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Lbl_disliked);
                        holder.DislikeTextView.SetTextColor(Color.ParseColor("#f89823"));
                        holder.DislikeTextView.Tag = "Disliked";
                        break;
                    }

                    case PostButtonSystem.DisLike:
                    {
                        holder.DislikeTextView.Text = ActivityContext.GetString(Resource.String.Btn_Dislike);
                        holder.DislikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.DislikeTextView.Tag = "Dislike";
                        break;
                    }
                    }
                }
                else
                {
                    if (item.IsCommentLiked)
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Liked);
                        holder.LikeTextView.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                        holder.LikeTextView.Tag = "Liked";
                    }
                    else
                    {
                        holder.LikeTextView.Text = ActivityContext.GetText(Resource.String.Btn_Like);
                        holder.LikeTextView.SetTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
                        holder.LikeTextView.Tag = "Like";
                    }
                }

                holder.TimeTextView.Tag = "true";
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        private async Task SetStory(GetUserStoriesObject.StoryObject.Story story)
        {
            try
            {
                StoryId = story.Id;
                LastSeenTextView.Text = Methods.Time.TimeAgo(Convert.ToInt32(story.Posted));

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

                if (StoryVideoView == null)
                {
                    InitVideoView();
                }

                string caption = "";
                if (!string.IsNullOrEmpty(story.Description))
                {
                    caption = story.Description;
                }
                else if (!string.IsNullOrEmpty(story.Title))
                {
                    caption = story.Title;
                }

                if (string.IsNullOrEmpty(caption) || string.IsNullOrWhiteSpace(caption))
                {
                    StoryaboutLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    StoryaboutLayout.Visibility = ViewStates.Visible;
                    CaptionStoryTextView.Text   = Methods.FunString.DecodeString(caption);
                }

                if (StoryVideoView == null)
                {
                    InitVideoView();
                }

                var type = Methods.AttachmentFiles.Check_FileExtension(MediaFile);
                if (type == "Video")
                {
                    //Show a progress
                    //RunOnUiThread(() => { try { AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading)); }catch (Exception e) { Console.WriteLine(e); } });

                    var fileName = MediaFile.Split('/').Last();
                    MediaFile = WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, MediaFile);

                    StoryImageView.Visibility = ViewStates.Gone;
                    StoryVideoView.Visibility = ViewStates.Visible;
                    if (MediaFile.Contains("http"))
                    {
                        StoryVideoView.SetVideoURI(Uri.Parse(MediaFile));
                        StoryVideoView.Start();
                    }
                    else
                    {
                        var file = Uri.FromFile(new File(MediaFile));
                        StoryVideoView.SetVideoPath(file.Path);
                        StoryVideoView.Start();
                    }

                    await Task.Delay(500);
                }
                else
                {
                    StoryImageView.Visibility = ViewStates.Visible;
                    StoryVideoView.Visibility = ViewStates.Gone;

                    Glide.With(this).Load(MediaFile).Apply(new RequestOptions()).Into(StoryImageView);

                    // GlideImageLoader.LoadImage(this,story.MediaFile, StoryImageView, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void MAdapterOnItemClick(object sender, Holders.MesClickEventArgs e)
        {
            try
            {
                if (e.Position <= -1)
                {
                    return;
                }
                var item = MAdapter.GetItem(e.Position);
                if (item != null)
                {
                    switch (e.Type)
                    {
                    case Holders.TypeClick.Text:
                    case Holders.TypeClick.Contact:
                        item.MesData.ShowTimeText = !item.MesData.ShowTimeText;
                        MAdapter.NotifyItemChanged(MAdapter.DifferList.IndexOf(item));
                        break;

                    case Holders.TypeClick.File:
                    {
                        var    fileName  = item.MesData.Media.Split('/').Last();
                        string imageFile = Methods.MultiMedia.CheckFileIfExits(item.MesData.Media);
                        if (imageFile != "File Dont Exists")
                        {
                            try
                            {
                                var    extension = fileName.Split('.').Last();
                                string mimeType  = MimeTypeMap.GetMimeType(extension);

                                Intent openFile = new Intent();
                                openFile.SetFlags(ActivityFlags.NewTask);
                                openFile.SetFlags(ActivityFlags.GrantReadUriPermission);
                                openFile.SetAction(Intent.ActionView);
                                openFile.SetDataAndType(Uri.Parse(imageFile), mimeType);
                                StartActivity(openFile);
                            }
                            catch (Exception exception)
                            {
                                Methods.DisplayReportResultTrack(exception);
                            }
                        }
                        else
                        {
                            var    extension = fileName.Split('.').Last();
                            string mimeType  = MimeTypeMap.GetMimeType(extension);

                            Intent i = new Intent(Intent.ActionView);
                            i.SetData(Uri.Parse(item.MesData.Media));
                            i.SetType(mimeType);
                            StartActivity(i);
                            // Toast.MakeText(MainActivity, MainActivity.GetText(Resource.String.Lbl_something_went_wrong), ToastLength.Long)?.Show();
                        }

                        break;
                    }

                    case Holders.TypeClick.Video:
                    {
                        var fileName  = item.MesData.Media.Split('/').Last();
                        var mediaFile = WoWonderTools.GetFile(UserId, Methods.Path.FolderDcimVideo, fileName, item.MesData.Media);

                        string imageFile = Methods.MultiMedia.CheckFileIfExits(mediaFile);
                        if (imageFile != "File Dont Exists")
                        {
                            File file2    = new File(mediaFile);
                            var  mediaUri = FileProvider.GetUriForFile(this, PackageName + ".fileprovider", file2);

                            if (AppSettings.OpenVideoFromApp)
                            {
                                Intent intent = new Intent(this, typeof(VideoFullScreenActivity));
                                intent.PutExtra("videoUrl", mediaUri.ToString());
                                StartActivity(intent);
                            }
                            else
                            {
                                Intent intent = new Intent();
                                intent.SetAction(Intent.ActionView);
                                intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                                intent.SetDataAndType(mediaUri, "video/*");
                                StartActivity(intent);
                            }
                        }
                        else
                        {
                            if (AppSettings.OpenVideoFromApp)
                            {
                                Intent intent = new Intent(this, typeof(VideoFullScreenActivity));
                                intent.PutExtra("videoUrl", item.MesData.Media);
                                StartActivity(intent);
                            }
                            else
                            {
                                Intent intent = new Intent(Intent.ActionView, Uri.Parse(item.MesData.Media));
                                StartActivity(intent);
                            }
                        }

                        break;
                    }

                    case Holders.TypeClick.Image:
                    {
                        if (AppSettings.OpenImageFromApp)
                        {
                            Intent intent = new Intent(this, typeof(ImageViewerActivity));
                            intent.PutExtra("Id", UserId);
                            intent.PutExtra("SelectedItem", JsonConvert.SerializeObject(item.MesData));
                            StartActivity(intent);
                        }
                        else
                        {
                            var fileName  = item.MesData.Media.Split('/').Last();
                            var mediaFile = WoWonderTools.GetFile(UserId, Methods.Path.FolderDcimImage, fileName, item.MesData.Media);

                            string imageFile = Methods.MultiMedia.CheckFileIfExits(mediaFile);
                            if (imageFile != "File Dont Exists")
                            {
                                File file2    = new File(mediaFile);
                                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(mediaFile));
                                StartActivity(intent);
                            }
                        }

                        break;
                    }

                    case Holders.TypeClick.Map:
                    {
                        // Create a Uri from an intent string. Use the result to create an Intent.
                        var uri    = Uri.Parse("geo:" + item.MesData.Lat + "," + item.MesData.Lng);
                        var intent = new Intent(Intent.ActionView, uri);
                        intent.SetPackage("com.google.android.apps.maps");
                        intent.AddFlags(ActivityFlags.NewTask);
                        StartActivity(intent);
                        break;
                    }
                    }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
            }
        }
Exemple #6
0
        //Download Info
        private async void MAdapterOnItemClick(object sender, MyInformationAdapterClickEventArgs e)
        {
            try
            {
                if (!Methods.CheckConnectivity())
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                    return;
                }

                var position = e.Position;
                switch (position)
                {
                case > -1:
                {
                    var item = MAdapter.GetItem(position);
                    if (item != null)
                    {
                        //Show a progress
                        AndHUD.Shared.Show(this, GetText(Resource.String.Lbl_Loading));

                        var(apiStatus, respond) = await RequestsAsync.Global.DownloadInfoAsync(item.Type);

                        switch (apiStatus)
                        {
                        case 200:
                        {
                            switch (respond)
                            {
                            case DownloadInfoObject result:
                            {
                                Link = result.Link;
                                var fileName = Link.Split('/').Last();
                                WoWonderTools.GetFile("", Methods.Path.FolderDcimFile, fileName, Link);

                                BtnDownload.Visibility = ViewStates.Visible;

                                Toast.MakeText(this, GetText(Resource.String.Lbl_YourFileIsReady), ToastLength.Long)?.Show();

                                AndHUD.Shared.Dismiss(this);
                                break;
                            }
                            }

                            break;
                        }

                        default:
                            Methods.DisplayAndHudErrorResult(this, respond);
                            break;
                        }
                    }

                    break;
                }
                }
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
                AndHUD.Shared.Dismiss(this);
            }
        }
        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();
            }
        }
Exemple #8
0
        private void LoadAudioItem(CommentAdapterViewHolder soundViewHolder, int position, CommentObjectExtra item)
        {
            try
            {
                item.SoundViewHolder ??= soundViewHolder;

                soundViewHolder.VoiceLayout.Visibility = ViewStates.Visible;

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

                var mediaFile = WoWonderTools.GetFile(item.PostId, Methods.Path.FolderDcimSound, fileName, item.Record);
                soundViewHolder.DurationVoice.Text = string.IsNullOrEmpty(item.MediaDuration)
                    ? Methods.AudioRecorderAndPlayer.GetTimeString(Methods.AudioRecorderAndPlayer.Get_MediaFileDuration(mediaFile))
                    : item.MediaDuration;

                soundViewHolder.PlayButton.Visibility = ViewStates.Visible;

                if (!soundViewHolder.PlayButton.HasOnClickListeners)
                {
                    soundViewHolder.PlayButton.Click += (o, args) =>
                    {
                        try
                        {
                            if (PositionSound != position)
                            {
                                var list = CommentList.Where(a => a.MediaPlayer != null).ToList();
                                if (list.Count > 0)
                                {
                                    foreach (var extra in list)
                                    {
                                        if (extra.MediaPlayer != null)
                                        {
                                            extra.MediaPlayer.Stop();
                                            extra.MediaPlayer.Reset();
                                        }
                                        extra.MediaPlayer = null;
                                        extra.MediaTimer  = null;

                                        extra.MediaPlayer?.Release();
                                        extra.MediaPlayer = null;
                                    }
                                }
                            }

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

                            if (item.MediaPlayer == null)
                            {
                                PositionSound    = position;
                                item.MediaPlayer = new Android.Media.MediaPlayer();
                                item.MediaPlayer.SetAudioAttributes(new AudioAttributes.Builder().SetUsage(AudioUsageKind.Media).SetContentType(AudioContentType.Music).Build());

                                item.MediaPlayer.Completion += (sender, e) =>
                                {
                                    try
                                    {
                                        soundViewHolder.PlayButton.Tag = "Play";
                                        //soundViewHolder.PlayButton.SetImageResource(item.ModelType == MessageModelType.LeftAudio ? Resource.Drawable.ic_play_dark_arrow : Resource.Drawable.ic_play_arrow);
                                        soundViewHolder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);

                                        item.MediaIsPlaying = false;

                                        item.MediaPlayer.Stop();
                                        item.MediaPlayer.Reset();
                                        item.MediaPlayer = null;

                                        item.MediaTimer.Enabled = false;
                                        item.MediaTimer.Stop();
                                        item.MediaTimer = null;
                                    }
                                    catch (Exception exception)
                                    {
                                        Console.WriteLine(exception);
                                    }
                                };

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

                                        if (item.MediaTimer == null)
                                        {
                                            item.MediaTimer = new Timer {
                                                Interval = 1000
                                            }
                                        }
                                        ;

                                        item.MediaPlayer.Start();

                                        //var durationOfSound = item.MediaPlayer.Duration;

                                        item.MediaTimer.Elapsed += (sender, eventArgs) =>
                                        {
                                            ActivityContext.RunOnUiThread(() =>
                                            {
                                                try
                                                {
                                                    if (item.MediaTimer.Enabled)
                                                    {
                                                        if (item.MediaPlayer.CurrentPosition <= item.MediaPlayer.Duration)
                                                        {
                                                            soundViewHolder.DurationVoice.Text = Methods.AudioRecorderAndPlayer.GetTimeString(item.MediaPlayer.CurrentPosition);
                                                        }
                                                        else
                                                        {
                                                            soundViewHolder.DurationVoice.Text = Methods.AudioRecorderAndPlayer.GetTimeString(item.MediaPlayer.Duration);

                                                            soundViewHolder.PlayButton.Tag = "Play";
                                                            //soundViewHolder.PlayButton.SetImageResource(item.ModelType == MessageModelType.LeftAudio ? Resource.Drawable.ic_play_dark_arrow : Resource.Drawable.ic_play_arrow);
                                                            soundViewHolder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);
                                                        }
                                                    }
                                                }
                                                catch (Exception e)
                                                {
                                                    Console.WriteLine(e);
                                                    soundViewHolder.PlayButton.Tag = "Play";
                                                }
                                            });
                                        };
                                        item.MediaTimer.Start();
                                    }
                                    catch (Exception e)
                                    {
                                        Console.WriteLine(e);
                                    }
                                };

                                if (mediaFile.Contains("http"))
                                {
                                    item.MediaPlayer.SetDataSource(ActivityContext, Uri.Parse(mediaFile));
                                    item.MediaPlayer.PrepareAsync();
                                }
                                else
                                {
                                    File file2    = new File(mediaFile);
                                    var  photoUri = FileProvider.GetUriForFile(ActivityContext, ActivityContext.PackageName + ".fileprovider", file2);

                                    item.MediaPlayer.SetDataSource(ActivityContext, photoUri);
                                    item.MediaPlayer.Prepare();
                                }

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

                                    item.MediaIsPlaying = true;
                                    item.MediaPlayer?.Start();

                                    if (item.MediaTimer != null)
                                    {
                                        item.MediaTimer.Enabled = true;
                                        item.MediaTimer.Start();
                                    }
                                }
                                else if (soundViewHolder.PlayButton.Tag.ToString() == "Pause")
                                {
                                    soundViewHolder.PlayButton.Tag = "Play";
                                    //soundViewHolder.PlayButton.SetImageResource(item.ModelType == MessageModelType.LeftAudio ? Resource.Drawable.ic_play_dark_arrow : Resource.Drawable.ic_play_arrow);
                                    soundViewHolder.PlayButton.SetImageResource(Resource.Drawable.ic_play_dark_arrow);

                                    item.MediaIsPlaying = false;
                                    item.MediaPlayer?.Pause();

                                    if (item.MediaTimer != null)
                                    {
                                        item.MediaTimer.Enabled = false;
                                        item.MediaTimer.Stop();
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };
                }

                item.SoundViewHolder ??= soundViewHolder;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemple #9
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);
            }
        }
Exemple #10
0
        public void OpenImageLightBox(CommentObjectExtra item)
        {
            try
            {
                if (item == null)
                {
                    return;
                }
                string imageUrl;

                if (!string.IsNullOrEmpty(item.CFile) && (item.CFile.Contains("file://") || item.CFile.Contains("content://") || item.CFile.Contains("storage") || item.CFile.Contains("/data/user/0/")))
                {
                    imageUrl = item.CFile;
                }
                else
                {
                    if (!item.CFile.Contains(Client.WebsiteUrl))
                    {
                        item.CFile = WoWonderTools.GetTheFinalLink(item.CFile);
                    }

                    imageUrl = item.CFile;
                }

                MainContext.RunOnUiThread(() =>
                {
                    var media = WoWonderTools.GetFile("", Methods.Path.FolderDiskImage, imageUrl.Split('/').Last(), imageUrl);
                    if (media.Contains("http"))
                    {
                        Intent intent = new Intent(Intent.ActionView, Uri.Parse(media));
                        MainContext.StartActivity(intent);
                    }
                    else
                    {
                        Java.IO.File file2 = new Java.IO.File(media);
                        var photoUri       = FileProvider.GetUriForFile(MainContext, MainContext.PackageName + ".fileprovider", file2);

                        Intent intent = new Intent(Intent.ActionPick);
                        intent.SetAction(Intent.ActionView);
                        intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                        intent.SetDataAndType(photoUri, "image/*");
                        MainContext.StartActivity(intent);
                    }

                    //var getImage = Methods.MultiMedia.GetMediaFrom_Gallery(Methods.Path.FolderDcimImage, fileName);
                    //if (getImage != "File Dont Exists")
                    //{
                    //    Java.IO.File file2 = new Java.IO.File(getImage);
                    //    var photoUri = FileProvider.GetUriForFile(MainContext, MainContext.PackageName + ".fileprovider", file2);

                    //    Intent intent = new Intent(Intent.ActionPick);
                    //    intent.SetAction(Intent.ActionView);
                    //    intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                    //    intent.SetDataAndType(photoUri, "image/*");
                    //    MainContext.StartActivity(intent);
                    //}
                    //else
                    //{
                    //    string filename = imageUrl.Split('/').Last();
                    //    string filePath = Path.Combine(Methods.Path.FolderDcimImage);
                    //    string mediaFile = filePath + "/" + filename;

                    //    if (!Directory.Exists(filePath))
                    //        Directory.CreateDirectory(filePath);

                    //    if (!File.Exists(mediaFile))
                    //    {
                    //        WebClient webClient = new WebClient();
                    //        AndHUD.Shared.Show(MainContext, MainContext.GetText(Resource.String.Lbl_Loading));

                    //        webClient.DownloadDataAsync(new Uri(imageUrl));
                    //        webClient.DownloadProgressChanged += (sender, args) =>
                    //        {
                    //            //var progress = args.ProgressPercentage;
                    //            // holder.loadingProgressview.Progress = progress;
                    //            //Show a progress
                    //            AndHUD.Shared.Show(MainContext, MainContext.GetText(Resource.String.Lbl_Loading));
                    //        };
                    //        webClient.DownloadDataCompleted += (s, e) =>
                    //        {
                    //            try
                    //            {
                    //                File.WriteAllBytes(mediaFile, e.Result);

                    //                getImage = Methods.MultiMedia.GetMediaFrom_Gallery(Methods.Path.FolderDcimImage, fileName);
                    //                if (getImage != "File Dont Exists")
                    //                {
                    //                    Java.IO.File file2 = new Java.IO.File(getImage);

                    //                    Android.Net.Uri photoUri = FileProvider.GetUriForFile(MainContext, MainContext.PackageName + ".fileprovider", file2);

                    //                    Intent intent = new Intent(Intent.ActionPick);
                    //                    intent.SetAction(Intent.ActionView);
                    //                    intent.AddFlags(ActivityFlags.GrantReadUriPermission);
                    //                    intent.SetDataAndType(photoUri, "image/*");
                    //                    MainContext.StartActivity(intent);
                    //                }
                    //                else
                    //                {
                    //                    Toast.MakeText(MainContext, MainContext.GetText(Resource.String.Lbl_something_went_wrong), ToastLength.Long)?.Show();
                    //                }
                    //            }
                    //            catch (Exception exception)
                    //            {
                    //                Methods.DisplayReportResultTrack(exception);
                    //            }

                    //            //var mediaScanIntent = new Intent(Intent?.ActionMediaScannerScanFile);
                    //            //mediaScanIntent?.SetData(Uri.FromFile(new File(mediaFile)));
                    //            //Application.Context.SendBroadcast(mediaScanIntent);

                    //            // Tell the media scanner about the new file so that it is
                    //            // immediately available to the user.
                    //            MediaScannerConnection.ScanFile(Application.Context, new[] { mediaFile }, null, null);

                    //            AndHUD.Shared.Dismiss(MainContext);
                    //        };
                    //    }
                    //}
                });
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Exemple #11
0
        private async Task SetStory(GetUserStoriesObject.StoryObject.Story story)
        {
            try
            {
                StoryId = story.Id;
                LastSeenTextView.Text = Methods.Time.TimeAgo(Convert.ToInt32(story.Posted), false);

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

                if (StoryVideoView == null)
                {
                    InitVideoView();
                }

                string caption = "";
                if (!string.IsNullOrEmpty(story.Description))
                {
                    caption = story.Description;
                }
                else if (!string.IsNullOrEmpty(story.Title))
                {
                    caption = story.Title;
                }

                if (string.IsNullOrEmpty(caption) || string.IsNullOrWhiteSpace(caption))
                {
                    StoryAboutLayout.Visibility = ViewStates.Gone;
                }
                else
                {
                    StoryAboutLayout.Visibility = ViewStates.Visible;
                    CaptionStoryTextView.Text   = Methods.FunString.DecodeString(caption);
                }

                if (StoryVideoView == null)
                {
                    InitVideoView();
                }

                var type = Methods.AttachmentFiles.Check_FileExtension(MediaFile);
                if (type == "Video")
                {
                    var fileName = MediaFile.Split('/').Last();
                    MediaFile = WoWonderTools.GetFile(DateTime.Now.Day.ToString(), Methods.Path.FolderDiskStory, fileName, MediaFile);

                    StoryImageView.Visibility = ViewStates.Gone;
                    StoryVideoView.Visibility = ViewStates.Visible;
                    if (MediaFile.Contains("http"))
                    {
                        StoryVideoView.SetVideoURI(Uri.Parse(MediaFile));
                        StoryVideoView.Start();
                    }
                    else
                    {
                        var file = Uri.FromFile(new File(MediaFile));
                        StoryVideoView.SetVideoPath(file?.Path);
                        StoryVideoView.Start();
                    }

                    await Task.Delay(500);
                }
                else
                {
                    StoryImageView.Visibility = ViewStates.Visible;
                    StoryVideoView.Visibility = ViewStates.Gone;

                    Glide.With(this).Load(MediaFile).Apply(new RequestOptions()).Into(StoryImageView);
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Exemple #12
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();
            }
        }
Exemple #13
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();
            }
        }