Пример #1
0
        //Function add data story
        public void AddDataStory()
        {
            try
            {
                ListOfStories.Clear();

                if (_Story_Data != null)
                {
                    IMethods.Set_TextViewIcon("1", BackIcon, IonIcons_Fonts.AndroidArrowBack);

                    //ImageServiceLoader.Load_Image(UserProfileImage, "no_profile_image.png", _Story_Data.user_data.avatar, 1);
                    ImageCacheLoader.LoadImage(_Story_Data.user_data.avatar, UserProfileImage, false, true);

                    User_ID  = _Story_Data.user_id;
                    Story_ID = _Story_Data.id;

                    string name = IMethods.Fun_String.DecodeString(_Story_Data.user_data.name);
                    usernameText.Text = name;
                    Txt_LastSeen.Text = _Story_Data.expire;

                    //Successfully read
                    _Story_Data.Profile_indicator = AppSettings.Story_Read_Color;

                    //Set show or not icon delete
                    DeleteStory_Icon.Visibility = _Story_Data.is_owner ? ViewStates.Visible : ViewStates.Invisible;

                    var getStory = Classes.StoryList.FirstOrDefault(a => a.Value == User_ID);
                    if (getStory.Value != null)
                    {
                        if (Classes.StoryList?.FirstOrDefault(a => a.Value == User_ID).Key?.Count == 0)
                        {
                            var ckd = Last_Stroies_Fragment.StoryAdapter?.mStoryList?.FirstOrDefault(a => a.user_id == User_ID);
                            if (ckd != null)
                            {
                                ckd.Profile_indicator = AppSettings.Story_Read_Color;
                            }
                        }

                        count = getStory.Key.Count;

                        foreach (var story in getStory.Key)
                        {
                            string storyAbout = "";

                            if (!string.IsNullOrEmpty(_Story_Data.description))
                            {
                                storyAbout = story.description;
                            }
                            else if (!string.IsNullOrEmpty(_Story_Data.title))
                            {
                                storyAbout = story.title;
                            }

                            //image and video
                            if (!story.thumbnail.Contains("avatar"))
                            {
                                string[] data = new string[] { story.id, storyAbout };
                                ListOfStories?.Add(story.thumbnail, data);
                            }

                            if (story.images?.Count > 0)
                            {
                                for (int i = 0; i < story.images?.Count; i++)
                                {
                                    string[] data = new string[] { story.id, storyAbout };
                                    ListOfStories.Add(story.images[i].filename, data);
                                }
                            }

                            if (story.videos?.Count > 0)
                            {
                                for (int i = 0; i < story.videos?.Count; i++)
                                {
                                    string[] data = new string[] { story.id, storyAbout };
                                    ListOfStories.Add(story.videos[i].filename, data);
                                }
                            }
                        }
                    }

                    count = ListOfStories.Count;
                    CountStoryText.Text = count.ToString();
                }

                Timerstory          = new Timer();
                Timerstory.Interval = 6000;
                Timerstory.Elapsed += Timerstory_Elapsed;
                Timerstory.Start();

                Timerprogress          = new Timer();
                Timerprogress.Interval = 60;
                Timerprogress.Elapsed += Timerprogress_Elapsed;
                Timerprogress.Start();
                progrescount = 0;

                countstory = -1; // starts the list from the first url

                RunOnUiThread(ChangeStoryView);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #2
0
        //Function add data story
        public void AddDataStory()
        {
            try
            {
                ListOfStories.Clear();
                if (_Story_Data != null)
                {
                    IMethods.Set_TextViewIcon("1", BackIcon, IonIcons_Fonts.AndroidArrowBack);
                    IMethods.Load_Image_From_Url(UserProfileImage, _Story_Data.user_data.avatar);

                    User_ID  = _Story_Data.user_id;
                    Story_ID = _Story_Data.id;

                    usernameText.Text = _Story_Data.user_data.name;
                    Txt_LastSeen.Text = _Story_Data.expire;

                    //Successfully read
                    _Story_Data.Profile_indicator = Settings.Story_Read_Color;

                    //Set show or not icon delete
                    DeleteStory_Icon.Visibility = _Story_Data.is_owner ? ViewStates.Visible : ViewStates.Invisible;

                    var getStory = Classes.StoryList.FirstOrDefault(a => a.Value == User_ID);
                    if (getStory.Value != null)
                    {
                        count = getStory.Key.Count;

                        foreach (var story in getStory.Key)
                        {
                            string storyAbout = "";

                            if (!string.IsNullOrEmpty(_Story_Data.description))
                            {
                                storyAbout = _Story_Data.description;
                            }
                            else if (!string.IsNullOrEmpty(_Story_Data.title))
                            {
                                storyAbout = _Story_Data.title;
                            }

                            //image and video
                            if (!story.thumbnail.Contains("avatar"))
                            {
                                string[] data = new string[] { story.id, storyAbout };
                                ListOfStories?.Add(story.thumbnail, data);
                            }

                            if (story.images?.Count > 0)
                            {
                                for (int i = 0; i < story.images?.Count; i++)
                                {
                                    string[] data = new string[] { story.id, storyAbout };
                                    ListOfStories.Add(story.images[i].filename, data);
                                }
                            }

                            if (story.videos?.Count > 0)
                            {
                                for (int i = 0; i < story.videos?.Count; i++)
                                {
                                    string[] data = new string[] { story.id, storyAbout };
                                    ListOfStories.Add(story.videos[i].filename, data);
                                }
                            }
                        }
                    }
                    count = ListOfStories.Count;
                    CountStoryText.Text = count.ToString();
                }

                Timerstory          = new Timer();
                Timerstory.Interval = 6000;
                Timerstory.Elapsed += Timerstory_Elapsed;
                Timerstory.Start();

                Timerprogress          = new Timer();
                Timerprogress.Interval = 60;
                Timerprogress.Elapsed += Timerprogress_Elapsed;
                Timerprogress.Start();
                progrescount = 0;

                countstory = -1; // starts the list from the first url

                RunOnUiThread(ChangeStoryView);
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }