Exemplo n.º 1
0
        public void Initialize(StoryAdapterViewHolder holder, Get_Stories_Object.Story Story)
        {
            try
            {
                var StorySplit     = Story.thumbnail.Split('/').Last();
                var getImage_Story = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskStory, StorySplit);
                if (getImage_Story != "File Dont Exists")
                {
                    if (holder.Image.Tag?.ToString() != "loaded")
                    {
                        ImageServiceLoader.Load_Image(holder.Image, "ImagePlacholder.jpg", getImage_Story, 1, true, 10);
                        holder.Image.Tag = "loaded";
                    }
                }
                else
                {
                    if (holder.Image.Tag?.ToString() != "loaded")
                    {
                        IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskStory, Story.thumbnail);
                        ImageServiceLoader.Load_Image(holder.Image, "ImagePlacholder.jpg", Story.thumbnail, 1, true, 10);
                        holder.Image.Tag = "loaded";
                    }
                }

                holder.Circleindicator.BorderColor = Color.ParseColor(Settings.MainColor);

                string name = IMethods.Fun_String.DecodeString(IMethods.Fun_String.DecodeStringWithEnter(Story.user_data.name));
                holder.Name.Text = name;
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Exemplo n.º 2
0
 // Function Video
 public void Add(Get_Stories_Object.Story Story)
 {
     try
     {
         var check = mStorylList.FirstOrDefault(a => a.id == Story.id);
         if (check == null)
         {
             mStorylList.Add(Story);
             NotifyItemInserted(mStorylList.IndexOf(mStorylList.Last()));
         }
     }
     catch (Exception exception)
     {
         Crashes.TrackError(exception);
     }
 }
Exemplo n.º 3
0
 public void Remove(Get_Stories_Object.Story Story)
 {
     try
     {
         var Index = mStorylList.IndexOf(mStorylList.FirstOrDefault(a => a.id == Story.id));
         if (Index != -1)
         {
             mStorylList.Remove(Story);
             NotifyItemRemoved(Index);
             NotifyItemRangeRemoved(0, ItemCount);
         }
     }
     catch (Exception e)
     {
         Crashes.TrackError(e);
     }
 }
Exemplo n.º 4
0
        //Event Click Add Story
        public void OnClick(View v)
        {
            try
            {
                if (IMethods.CheckConnectivity())
                {
                    if (Type == "image")
                    {
                        //Send image function
                        var file = Android.Net.Uri.FromFile(new File(Uri));
                        PikedImage = IMethods.Fun_String.TrimTo(file.Path.Split('/').Last(), 30);
                        var stream = IMethods.MultiMedia.GetMedia_as_Stream(file.Path);

                        var check = ActivityListItems.FirstOrDefault(a => a.Label == PikedImage);
                        if (check == null)
                        {
                            ActivityListItems.Add(new Classes.Storyitems
                            {
                                Label         = PikedImage,
                                ImageFullPath = file.Path,
                                ImageStream   = stream
                            });
                        }

                        var Attach = ActivityListItems.FirstOrDefault(a => a.Label == PikedImage);
                        if (Attach != null)
                        {
                            var streams = new List <Stream>();

                            foreach (var Atta in ActivityListItems)
                            {
                                if (Atta.ImageStream != null)
                                {
                                    streams.Add(Atta.ImageStream);
                                }
                            }

                            unixTimestamp = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds;
                            Time          = Convert.ToString(unixTimestamp);

                            List <Get_Stories_Object.Story> listOfStories = new List <Get_Stories_Object.Story>();
                            var checkUser = News_Feed_Fragment.StoryAdapter?.mStorylList?.FirstOrDefault(a => a.user_id == UserDetails.User_id);
                            if (checkUser != null)
                            {
                                var checkUserExits = Classes.StoryList.FirstOrDefault(a => a.Value == checkUser.user_id);
                                if (checkUserExits.Value == null)
                                {
                                    var ch = checkUserExits.Key.FirstOrDefault(a => a.id == checkUser.id);
                                    if (ch == null)
                                    {
                                        Get_Stories_Object.Story story = new Get_Stories_Object.Story();
                                        story.user_data = new Get_Stories_Object.User_Data();

                                        story.thumbnail = file.Path;
                                        story.id        = Time;
                                        story.user_id   = UserDetails.User_id;

                                        if (!string.IsNullOrEmpty(UserDetails.Full_name))
                                        {
                                            story.user_data.name = UserDetails.Full_name;
                                        }
                                        else
                                        {
                                            story.user_data.name = UserDetails.Username;
                                        }

                                        story.user_data.avatar = UserDetails.avatar;
                                        story.title            = Txt_AboutStory.MessageText;
                                        story.description      = Txt_AboutStory.MessageText;
                                        story.is_owner         = true;
                                        story.type             = "image";

                                        listOfStories.Add(story);

                                        Classes.StoryList.Add(listOfStories, story.user_id);
                                    }
                                }
                                else
                                {
                                    foreach (var item in Classes.StoryList.Keys.ToList())
                                    {
                                        string userId = item.FirstOrDefault(a => a.user_id == checkUser.user_id)?.user_id;
                                        if (checkUserExits.Value == userId)
                                        {
                                            Get_Stories_Object.Story story = new Get_Stories_Object.Story();
                                            story.user_data = new Get_Stories_Object.User_Data();

                                            story.thumbnail = file.Path;
                                            story.id        = Time;
                                            story.user_id   = UserDetails.User_id;

                                            if (!string.IsNullOrEmpty(UserDetails.Full_name))
                                            {
                                                story.user_data.name = UserDetails.Full_name;
                                            }
                                            else
                                            {
                                                story.user_data.name = UserDetails.Username;
                                            }

                                            story.user_data.avatar = UserDetails.avatar;
                                            story.title            = Txt_AboutStory.MessageText;
                                            story.description      = Txt_AboutStory.MessageText;
                                            story.is_owner         = true;
                                            story.type             = "image";

                                            var ch = item.FirstOrDefault(a => a.id == story.id);
                                            if (ch == null)
                                            {
                                                item.Add(story);
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                Get_Stories_Object.Story story = new Get_Stories_Object.Story();
                                story.user_data = new Get_Stories_Object.User_Data();

                                story.thumbnail = file.Path;
                                story.id        = Time;
                                story.user_id   = UserDetails.User_id;

                                if (!string.IsNullOrEmpty(UserDetails.Full_name))
                                {
                                    story.user_data.name = UserDetails.Full_name;
                                }
                                else
                                {
                                    story.user_data.name = UserDetails.Username;
                                }

                                story.user_data.avatar = UserDetails.avatar;
                                story.title            = Txt_AboutStory.MessageText;
                                story.description      = Txt_AboutStory.MessageText;
                                story.is_owner         = true;
                                story.type             = "image";

                                News_Feed_Fragment.StoryAdapter?.Add(story);

                                listOfStories.Clear();

                                var checkUserExits = Classes.StoryList.FirstOrDefault(a => a.Value == story.user_id);
                                if (checkUserExits.Value == null)
                                {
                                    listOfStories.Add(story);
                                    Classes.StoryList.Add(listOfStories, story.user_id);
                                }
                            }

                            Task.Factory.StartNew(async() =>
                            {
                                //just pass file_path and type video or image
                                var(Api_status, Respond) = await Client.Story.Create_Story(Txt_AboutStory.MessageText, Txt_AboutStory.MessageText, file.Path, "image");
                                if (Api_status == 200)
                                {
                                    if (Respond is Create_Story_Object result)
                                    {
                                        Console.WriteLine(result.story_id);

                                        Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Short).Show();
                                    }
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_something_went_wrong), ToastLength.Short).Show();
                                }
                            });
                            Finish();
                        }
                    }
                    else
                    {
                        VideoTimer.Enabled = false;
                        VideoTimer.Stop();

                        //Send image function
                        var file = Android.Net.Uri.FromFile(new File(Uri));

                        List <Get_Stories_Object.Story> listOfStories = new List <Get_Stories_Object.Story>();

                        var checkUser = News_Feed_Fragment.StoryAdapter?.mStorylList?.FirstOrDefault(a => a.user_id == UserDetails.User_id);
                        if (checkUser != null)
                        {
                            if (Classes.StoryList == null)
                            {
                                return;
                            }

                            var checkUserExits = Classes.StoryList.FirstOrDefault(a => a.Value == checkUser.user_id);
                            if (checkUserExits.Value == null)
                            {
                                var ch = checkUserExits.Key.FirstOrDefault(a => a.id == checkUser.id);
                                if (ch == null)
                                {
                                    Get_Stories_Object.Story story = new Get_Stories_Object.Story();
                                    story.user_data = new Get_Stories_Object.User_Data();

                                    story.thumbnail = file.Path;
                                    story.id        = Time;
                                    story.user_id   = UserDetails.User_id;
                                    if (!string.IsNullOrEmpty(UserDetails.Full_name))
                                    {
                                        story.user_data.name = UserDetails.Full_name;
                                    }
                                    else
                                    {
                                        story.user_data.name = UserDetails.Username;
                                    }
                                    story.user_data.avatar = UserDetails.avatar;
                                    story.title            = Txt_AboutStory.MessageText;
                                    story.description      = Txt_AboutStory.MessageText;
                                    story.is_owner         = true;
                                    story.type             = "video";

                                    listOfStories.Add(story);

                                    Classes.StoryList.Add(listOfStories, story.user_id);
                                }
                            }
                            else
                            {
                                if (Classes.StoryList == null)
                                {
                                    return;
                                }

                                foreach (var item in Classes.StoryList?.Keys.ToList())
                                {
                                    string userId = item.FirstOrDefault(a => a.user_id == checkUser.user_id)?.user_id;
                                    if (checkUserExits.Value == userId)
                                    {
                                        Get_Stories_Object.Story story = new Get_Stories_Object.Story();
                                        story.user_data = new Get_Stories_Object.User_Data();

                                        story.thumbnail = file.Path;
                                        story.id        = Time;
                                        story.user_id   = UserDetails.User_id;
                                        if (!string.IsNullOrEmpty(UserDetails.Full_name))
                                        {
                                            story.user_data.name = UserDetails.Full_name;
                                        }
                                        else
                                        {
                                            story.user_data.name = UserDetails.Username;
                                        }
                                        story.user_data.avatar = UserDetails.avatar;
                                        story.title            = Txt_AboutStory.MessageText;
                                        story.description      = Txt_AboutStory.MessageText;
                                        story.is_owner         = true;
                                        story.type             = "video";

                                        var ch = item.FirstOrDefault(a => a.id == story.id);
                                        if (ch == null)
                                        {
                                            item.Add(story);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Get_Stories_Object.Story story = new Get_Stories_Object.Story();
                            story.user_data = new Get_Stories_Object.User_Data();

                            story.thumbnail = file.Path;
                            story.id        = Time;
                            story.user_id   = UserDetails.User_id;
                            if (!string.IsNullOrEmpty(UserDetails.Full_name))
                            {
                                story.user_data.name = UserDetails.Full_name;
                            }
                            else
                            {
                                story.user_data.name = UserDetails.Username;
                            }
                            story.user_data.avatar = UserDetails.avatar;
                            story.title            = Txt_AboutStory.MessageText;
                            story.description      = Txt_AboutStory.MessageText;
                            story.is_owner         = true;
                            story.type             = "video";

                            News_Feed_Fragment.StoryAdapter?.Add(story);

                            listOfStories.Clear();

                            var checkUserExits = Classes.StoryList.FirstOrDefault(a => a.Value == story.user_id);
                            if (checkUserExits.Value == null)
                            {
                                listOfStories.Add(story);
                                Classes.StoryList.Add(listOfStories, story.user_id);
                            }
                        }

                        Task.Factory.StartNew(async() =>
                        {
                            //just pass file_path and type video or image
                            var(Api_status, Respond) = await Client.Story.Create_Story(Txt_AboutStory.MessageText,
                                                                                       Txt_AboutStory.MessageText, file.Path, "video");
                            if (Api_status == 200)
                            {
                                if (Respond is Create_Story_Object result)
                                {
                                    Console.WriteLine(result.story_id);

                                    Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Short).Show();

                                    //Snackbar.Make(Last_Stroies_Fragment.LastStoriessRecyler, Language.Lbl_Done, Snackbar.LengthLong).Show();
                                }
                            }
                            else
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_something_went_wrong),
                                               ToastLength.Short).Show();
                                //Snackbar.Make(Last_Stroies_Fragment.LastStoriessRecyler, Language.Lbl_Something_went_wrong, Snackbar.LengthLong).Show();
                            }
                        });

                        Finish();
                    }
                }
                else
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)
                    .Show();
                }

                Finish();
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }