예제 #1
0
        private async void LoadData()
        {
            try
            {
                DataStories = JsonConvert.DeserializeObject <GetUserStoriesObject.StoryObject>(Intent.GetStringExtra("DataItem"));
                if (DataStories != null)
                {
                    GlideImageLoader.LoadImage(this, DataStories.Avatar, UserImageView, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                    UsernameTextView.Text     = ObeeNetworkTools.GetNameFinal(DataStories);
                    DeleteIconView.Visibility = DataStories.Stories[0].IsOwner ? ViewStates.Visible : ViewStates.Invisible;

                    int count = DataStories.Stories.Count;
                    StoriesProgress.Visibility = ViewStates.Visible;
                    StoriesProgress.SetStoriesCount(count);   // <- set stories
                    StoriesProgress.SetStoriesListener(this); // <- set listener
                    //StoriesProgress.SetStoryDuration(10000L); // <- set a story duration

                    var fistStory = DataStories.Stories.FirstOrDefault();
                    if (fistStory != null)
                    {
                        StoriesProgress.SetStoriesCountWithDurations(DataStories.DurationsList.ToArray());

                        await SetStory(fistStory);

                        StoriesProgress.StartStories(); // <- start progress
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
예제 #2
0
        private void Initialize(ArticlesAdapterViewHolder holder, ArticleDataObject item)
        {
            try
            {
                var colorImage = Color.ParseColor(Methods.FunString.RandomColor());

                Glide.With(ActivityContext)
                .Load(item.Thumbnail)
                .Apply(RequestOptions.CenterCropTransform().Placeholder(new ColorDrawable(colorImage)).Fallback(new ColorDrawable(colorImage)).SetPriority(Priority.High))
                .Into(holder.Image);

                Glide.With(ActivityContext)
                .Load(item.Author.Avatar)
                .Apply(RequestOptions.CircleCropTransform())
                .Into(holder.UserImageProfile);

                holder.Category.SetBackgroundColor(colorImage);

                CategoriesController cat = new CategoriesController();
                string id = item.CategoryLink.Split('/').Last();
                holder.Category.Text = cat.Get_Translate_Categories_Communities(id, item.CategoryName);

                holder.Description.Text = Methods.FunString.DecodeString(item.Description);
                holder.Title.Text       = Methods.FunString.DecodeString(item.Title);
                holder.Username.Text    = ObeeNetworkTools.GetNameFinal(item.Author);
                holder.ViewMore.Text    = ActivityContext.GetText(Resource.String.Lbl_ReadMore) + " >"; //READ MORE &gt;
                holder.Time.Text        = item.Posted;

                if (!holder.UserItem.HasOnClickListeners)
                {
                    holder.UserItem.Click += (sender, args) =>
                    {
                        try
                        {
                            ObeeNetworkTools.OpenProfile(ActivityContext, item.Author.UserId, item.Author);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                }
                ;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
예제 #3
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is StoryAdapterViewHolder holder)
                {
                    var item = StoryList[position];
                    if (item != null)
                    {
                        if (item.Stories?.Count > 0 && item.Stories[0].Thumbnail.Contains("http"))
                        {
                            GlideImageLoader.LoadImage(ActivityContext, item.Stories[0]?.Thumbnail, holder.Image, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                        }
                        else if (item.Stories?.Count > 0)
                        {
                            Glide.With(ActivityContext).Load(new File(item.Stories[0].Thumbnail)).Apply(new RequestOptions().CircleCrop().Placeholder(Resource.Drawable.ImagePlacholder_circle).Error(Resource.Drawable.ImagePlacholder_circle)).Into(holder.Image);
                        }

                        if (item.Type == "Your")
                        {
                            holder.Circleindicator.Visibility = ViewStates.Invisible;
                        }
                        else
                        {
                            item.ProfileIndicator ??= AppSettings.MainColor;

                            holder.Circleindicator.BackgroundTintList = ColorStateList.ValueOf(Color.ParseColor(item.ProfileIndicator)); // Default_Color
                        }

                        holder.Name.Text = Methods.FunString.SubStringCutOf(ObeeNetworkTools.GetNameFinal(item), 12);

                        if (!holder.Circleindicator.HasOnClickListeners)
                        {
                            holder.Circleindicator.Click += (sender, e) => Click(new StoryAdapterClickEventArgs {
                                View = holder.MainView, Position = position
                            });
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
예제 #4
0
 private void LoadMyDate()
 {
     try
     {
         var dataUser = ListUtils.MyProfileList.FirstOrDefault();
         if (dataUser == null)
         {
             return;
         }
         TxtName.Text  = ObeeNetworkTools.GetNameFinal(dataUser);
         TxtPhone.Text = dataUser.PhoneNumber;
         TxtEmail.Text = dataUser.Email;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
        private void GetDataPost()
        {
            try
            {
                if (PostObject != null)
                {
                    if (PostObject.Reaction == null)
                    {
                        PostObject.Reaction = new Reaction();
                    }

                    if (PostObject.Reaction != null)
                    {
                        LikeCountBox.Text = PostObject.Reaction.Count + " " + GetString(Resource.String.Btn_Likes);
                    }
                    else
                    {
                        LikeCountBox.Text = "0 " + GetString(Resource.String.Btn_Likes);
                    }

                    if (PostObject.CommentsStatus == "0")
                    {
                        CommentsAdapter.CommentList.Clear();

                        CommentsAdapter.CommentList.Add(new CommentObjectExtra()
                        {
                            Id          = CommentsAdapter.EmptyState,
                            Text        = CommentsAdapter.EmptyState,
                            Orginaltext = GetText(Resource.String.Lbl_CommentsAreDisabledBy) + " " + ObeeNetworkTools.GetNameFinal(PostObject.Publisher),
                        });

                        CommentsAdapter.NotifyDataSetChanged();

                        CommentLayout.Visibility = ViewStates.Gone;
                    }
                    else
                    {
                        if (PostObject?.GetPostComments?.Count > 0)
                        {
                            var db = Mapper.Map <List <CommentObjectExtra> >(PostObject.GetPostComments);
                            CommentsAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(db);
                        }
                        else
                        {
                            CommentsAdapter.CommentList = new ObservableCollection <CommentObjectExtra>();
                        }

                        Methods.SetColorEditText(TxtComment, AppSettings.SetTabDarkTheme ? Color.White : Color.Black);

                        if (CommentsAdapter.CommentList.Count > 0)
                        {
                            CommentsAdapter?.NotifyDataSetChanged();
                        }


                        if (CommentsAdapter.CommentList.Count == 0)
                        {
                            StartApiService();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        private void GetDataArticles()
        {
            try
            {
                ArticleData = JsonConvert.DeserializeObject <ArticleDataObject>(Intent.GetStringExtra("ArticleObject"));
                if (ArticleData != null)
                {
                    GlideImageLoader.LoadImage(this, ArticleData.Author.Avatar, ImageUser, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                    GlideImageLoader.LoadImage(this, ArticleData.Thumbnail, ImageBlog, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                    TxtUsername.Text = ObeeNetworkTools.GetNameFinal(ArticleData.Author);

                    TxtTitle.Text = Methods.FunString.DecodeString(ArticleData.Title);
                    TxtViews.Text = ArticleData.View + " " + GetText(Resource.String.Lbl_Views);

                    string style = AppSettings.SetTabDarkTheme ? "<style type='text/css'>body{color: #fff; background-color: #282828;}</style>" : "<style type='text/css'>body{color: #444; background-color: #FFFAFA;}</style>";
                    string imageFullWidthStyle = "<style>img{display: inline;height: auto;max-width: 100%;}</style>";

                    string content;
                    if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
                    {
                        content = Html.FromHtml(ArticleData.Content, FromHtmlOptions.ModeCompact).ToString();
                    }
                    else
                    {
                        // This method is deprecated but need to use for old os devices
#pragma warning disable CS0618 // Type or member is obsolete
                        content = Html.FromHtml(ArticleData.Content).ToString();
#pragma warning restore CS0618 // Type or member is obsolete
                    }

                    //string content = Html.FromHtml(ArticleData.Content, FromHtmlOptions.ModeCompact).ToString();
                    DataWebHtml  = "<!DOCTYPE html>";
                    DataWebHtml += "<head><title></title>" + style + imageFullWidthStyle + "</head>";
                    DataWebHtml += "<body>" + content + "</body>";
                    DataWebHtml += "</html>";
                    // <meta name='viewport' content='width=device-width, user-scalable=no' />
                    TxtHtml.SetWebViewClient(new MyWebViewClient(this));
                    TxtHtml.Settings.LoadsImagesAutomatically = true;
                    TxtHtml.Settings.JavaScriptEnabled        = true;
                    TxtHtml.Settings.JavaScriptCanOpenWindowsAutomatically = true;
                    TxtHtml.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.NarrowColumns);
                    TxtHtml.Settings.DomStorageEnabled       = true;
                    TxtHtml.Settings.AllowFileAccess         = true;
                    TxtHtml.Settings.DefaultTextEncodingName = "utf-8";

                    TxtHtml.Settings.UseWideViewPort      = (true);
                    TxtHtml.Settings.LoadWithOverviewMode = (true);

                    TxtHtml.Settings.SetSupportZoom(false);
                    TxtHtml.Settings.BuiltInZoomControls = (false);
                    TxtHtml.Settings.DisplayZoomControls = (false);

                    int fontSize = (int)TypedValue.ApplyDimension(ComplexUnitType.Sp, 18, Resources.DisplayMetrics);
                    TxtHtml.Settings.DefaultFontSize = fontSize;

                    TxtHtml.LoadDataWithBaseURL(null, DataWebHtml, "text/html", "UTF-8", null);

                    bool   success  = int.TryParse(ArticleData.Posted, out var number);
                    string Timedate = "";
                    if (success)
                    {
                        TxtTime.Text = Timedate;
                        //TxtTime.Text = Methods.Time.TimeAgo(Convert.ToInt32(number));
                    }
                    else
                    {
                        TxtTime.Text = Timedate;
                        //TxtTime.Text = ArticleData.Posted;
                    }

                    if (Methods.CheckConnectivity())
                    {
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            () => RequestsAsync.Article.GetBlogById(ArticlesId)
                        });
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }