コード例 #1
0
        public UpgradeGoProAdapter(Activity context)
        {
            try
            {
                ActivityContext = context;
                WoTextDecorator = new WoTextDecorator();

                //PlansList.Add(new UpgradeGoProClass { Id = 1, HexColor = "#4c7737", PlanText = Resource.String.go_pro_plan_1,PlanTime="",PlanPrice="" ImageResource = Resource.Drawable.gopro_medal });

                for (int i = 0; i < AppSettings.LimitGoProPlansCountsTo + 1; i++)
                {
                    string name       = "go_pro_plan_" + i;
                    int?   resourceId = ActivityContext.Resources.GetIdentifier(name, "array", ActivityContext.ApplicationInfo.PackageName);

                    if (resourceId == 0)
                    {
                        continue;
                    }

                    string[] plan = ActivityContext.Resources.GetStringArray(resourceId.Value);
                    resourceId = ActivityContext.Resources.GetIdentifier("ic_plan_" + i, "drawable", ActivityContext.ApplicationInfo.PackageName);
                    if (resourceId == 0)
                    {
                        continue;
                    }

                    var price = plan[1];
                    if (ListUtils.SettingsSiteList != null)
                    {
                        switch (i)
                        {
                        case 1:
                            price = ListUtils.SettingsSiteList?.WeeklyPrice;
                            break;

                        case 2:
                            price = ListUtils.SettingsSiteList?.MonthlyPrice;
                            break;

                        case 3:
                            price = ListUtils.SettingsSiteList?.YearlyPrice;
                            break;

                        case 4:
                            price = ListUtils.SettingsSiteList?.LifetimePrice;
                            break;
                        }
                    }

                    PlansList.Add(new UpgradeGoProClass {
                        Id = i, HexColor = plan[3], PlanText = plan[0], PlanPrice = price, PlanTime = plan[2], ImageResource = resourceId.Value
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #2
0
 public FeedCombiner(PostDataObject post, List <AdapterModelsClass> diffList, Context context)
 {
     MainContext       = context;
     PostFeedType      = PostFunctions.GetAdapterType(post);
     PostModelResolver = new PostModelResolver(context, PostFeedType);
     PostCollection    = post;
     PostList          = diffList;
     TextDecorator     = new WoTextDecorator();
 }
コード例 #3
0
        public UpgradeGoProAdapter(Activity context)
        {
            try
            {
                ActivityContext = context;
                WoTextDecorator = new WoTextDecorator();

                //PlansList.Add(new UpgradeGoProClass { Id = 1, HexColor = "#4c7737", PlanText = Resource.String.go_pro_plan_1,PlanTime="",PlanPrice="" ImageResource = Resource.Drawable.gopro_medal });
                //<item>STAR</item>
                //<item>$3</item>
                //<item>Per Week</item>
                //<item>#4c7737</item>

                switch (ListUtils.SettingsSiteList?.ProPackagesTypes?.Count)
                {
                case > 0:
                {
                    foreach (var type in ListUtils.SettingsSiteList?.ProPackagesTypes)    //"1": "star"
                    {
                        var resourceId = ActivityContext.Resources?.GetIdentifier("ic_plan_" + type.Key, "drawable", ActivityContext.PackageName) ?? 0;
                        switch (resourceId)
                        {
                        case 0:
                            continue;

                        default:
                        {
                            var proClass = new UpgradeGoProClass
                            {
                                Id            = type.Key,
                                HexColor      = GetColor(type.Key),
                                PlanText      = type.Value,
                                PlanPrice     = GetPrice(type.Value),
                                PlanTime      = GetTime(type.Value),
                                PlanArray     = GetPlanArray(type.Value),
                                ImageResource = resourceId,
                            };

                            PlansList.Add(proClass);
                            break;
                        }
                        }
                    }

                    break;
                }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #4
0
        private void LoadPost()
        {
            try
            {
                PostObject = JsonConvert.DeserializeObject <PostDataObject>(Intent?.GetStringExtra("PostObject"));
                if (PostObject != null)
                {
                    var readMoreOption = new StReadMoreOption.Builder()
                                         .TextLength(200, StReadMoreOption.TypeCharacter)
                                         .MoreLabel(GetText(Resource.String.Lbl_ReadMore))
                                         .LessLabel(GetText(Resource.String.Lbl_ReadLess))
                                         .MoreLabelColor(Color.ParseColor(AppSettings.MainColor))
                                         .LessLabelColor(Color.ParseColor(AppSettings.MainColor))
                                         .LabelUnderLine(true)
                                         .Build();

                    if (SecondReactionButton != null)
                    {
                        switch (AppSettings.PostButton)
                        {
                        case PostButtonSystem.ReactionDefault:
                        case PostButtonSystem.ReactionSubShine:
                        case PostButtonSystem.Like:
                            MainSectionButton.WeightSum     = 3;
                            SecondReactionButton.Visibility = ViewStates.Gone;
                            break;

                        case PostButtonSystem.Wonder:
                            MainSectionButton.WeightSum     = 4;
                            SecondReactionButton.Visibility = ViewStates.Visible;

                            SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_action_wowonder, 0, 0, 0);
                            SecondReactionButton.Text = Application.Context.GetText(Resource.String.Btn_Wonder);
                            break;

                        case PostButtonSystem.DisLike:
                            MainSectionButton.WeightSum     = 4;
                            SecondReactionButton.Visibility = ViewStates.Visible;

                            SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(Resource.Drawable.ic_action_dislike, 0, 0, 0);
                            SecondReactionButton.Text = Application.Context.GetText(Resource.String.Btn_Dislike);
                            break;

                        default:
                            MainSectionButton.WeightSum     = 3;
                            SecondReactionButton.Visibility = ViewStates.Gone;
                            break;
                        }
                    }

                    var publisher = PostObject.Publisher ?? PostObject.UserData;
                    if (publisher != null)
                    {
                        if (PostObject.PostPrivacy == "4")
                        {
                            Username.Text = GetText(Resource.String.Lbl_Anonymous);
                            GlideImageLoader.LoadImage(this, "user_anonymous", UserAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                        }
                        else
                        {
                            GlideImageLoader.LoadImage(this, publisher.Avatar, UserAvatar, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);

                            var postDataDecoratedContent = new WoTextDecorator().SetupStrings(PostObject, this);
                            Username.SetText(postDataDecoratedContent, TextView.BufferType.Spannable);
                        }

                        if (PostExtrasLayout != null)
                        {
                            PostExtrasLayout.Visibility = PostObject.IsPostBoosted == "0" ? ViewStates.Gone : ViewStates.Visible;
                        }

                        if (string.IsNullOrEmpty(PostObject.Orginaltext))
                        {
                            if (Description.Visibility != ViewStates.Gone)
                            {
                                Description.Visibility = ViewStates.Gone;
                            }
                        }
                        else
                        {
                            if (Description.Visibility != ViewStates.Visible)
                            {
                                Description.Visibility = ViewStates.Visible;
                            }

                            if (!Description.Text.Contains(GetText(Resource.String.Lbl_ReadMore)) && !Description.Text.Contains(GetText(Resource.String.Lbl_ReadLess)))
                            {
                                if (PostObject.RegexFilterList != null & PostObject.RegexFilterList?.Count > 0)
                                {
                                    Description.SetAutoLinkOnClickListener(this, PostObject.RegexFilterList);
                                }
                                else
                                {
                                    Description.SetAutoLinkOnClickListener(this, new Dictionary <string, string>());
                                }

                                readMoreOption.AddReadMoreTo(Description, new String(PostObject.Orginaltext));
                            }
                            else if (Description.Text.Contains(GetText(Resource.String.Lbl_ReadLess)))
                            {
                                readMoreOption.AddReadLess(Description, new String(PostObject.Orginaltext));
                            }
                            else
                            {
                                Description.Text = PostObject.Orginaltext;
                            }
                        }

                        bool success = int.TryParse(PostObject.Time, out var number);
                        TimeText.Text = success ? Methods.Time.TimeAgo(number, false) : PostObject.Time;

                        if (PrivacyPostIcon != null && !string.IsNullOrEmpty(PostObject.PostPrivacy) && publisher.UserId == UserDetails.UserId)
                        {
                            if (PostObject.PostPrivacy == "0") //Everyone
                            {
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, PrivacyPostIcon, FontAwesomeIcon.Globe);
                            }
                            else if (PostObject.PostPrivacy.Contains("ifollow") || PostObject.PostPrivacy == "2") //People_i_Follow
                            {
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, PrivacyPostIcon, FontAwesomeIcon.User);
                            }
                            else if (PostObject.PostPrivacy.Contains("me") || PostObject.PostPrivacy == "1") //People_Follow_Me
                            {
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, PrivacyPostIcon, FontAwesomeIcon.UserFriends);
                            }
                            else if (PostObject.PostPrivacy == "4") //Anonymous
                            {
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeSolid, PrivacyPostIcon, FontAwesomeIcon.UserSecret);
                            }
                            else //No_body)
                            {
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.FontAwesomeLight, PrivacyPostIcon, FontAwesomeIcon.Lock);
                            }

                            PrivacyPostIcon.Visibility = ViewStates.Visible;
                        }

                        if (CommentCount != null)
                        {
                            CommentCount.Text = PostObject.PostComments;
                        }
                    }

                    if (AppSettings.PostButton == PostButtonSystem.ReactionDefault || AppSettings.PostButton == PostButtonSystem.ReactionSubShine)
                    {
                        PostObject.Reaction ??= new WoWonderClient.Classes.Posts.Reaction();

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

                        if (PostObject.Reaction.IsReacted != null && PostObject.Reaction.IsReacted.Value)
                        {
                            if (!string.IsNullOrEmpty(PostObject.Reaction.Type))
                            {
                                var react = ListUtils.SettingsSiteList?.PostReactionsTypes?.FirstOrDefault(a => a.Value?.Id == PostObject.Reaction.Type).Value?.Id ?? "";
                                switch (react)
                                {
                                case "1":
                                    LikeButton.SetReactionPack(ReactConstants.Like);
                                    break;

                                case "2":
                                    LikeButton.SetReactionPack(ReactConstants.Love);
                                    break;

                                case "3":
                                    LikeButton.SetReactionPack(ReactConstants.HaHa);
                                    break;

                                case "4":
                                    LikeButton.SetReactionPack(ReactConstants.Wow);
                                    break;

                                case "5":
                                    LikeButton.SetReactionPack(ReactConstants.Sad);
                                    break;

                                case "6":
                                    LikeButton.SetReactionPack(ReactConstants.Angry);
                                    break;

                                default:
                                    LikeButton.SetReactionPack(ReactConstants.Default);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            LikeButton.SetReactionPack(ReactConstants.Default);
                        }
                    }
                    else
                    {
                        if (PostObject.IsLiked != null && PostObject.IsLiked.Value)
                        {
                            LikeButton.SetReactionPack(ReactConstants.Like);
                        }

                        if (LikeCount != null)
                        {
                            LikeCount.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(PostObject.PostLikes)) + " " + GetString(Resource.String.Btn_Likes);
                        }

                        if (SecondReactionButton != null)
                        {
                            switch (AppSettings.PostButton)
                            {
                            case PostButtonSystem.Wonder when PostObject.IsWondered != null && PostObject.IsWondered.Value:
                            {
                                Drawable unwrappedDrawable = AppCompatResources.GetDrawable(this, Resource.Drawable.ic_action_wowonder);
                                Drawable wrappedDrawable   = DrawableCompat.Wrap(unwrappedDrawable);
                                if (Build.VERSION.SdkInt <= BuildVersionCodes.Lollipop)
                                {
                                    DrawableCompat.SetTint(wrappedDrawable, Color.ParseColor("#f89823"));
                                }
                                else
                                {
                                    wrappedDrawable = wrappedDrawable.Mutate();
                                    wrappedDrawable.SetColorFilter(new PorterDuffColorFilter(Color.ParseColor("#f89823"), PorterDuff.Mode.SrcAtop));
                                }

                                SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(wrappedDrawable, null, null, null);

                                SecondReactionButton.Text = GetString(Resource.String.Lbl_wondered);
                                SecondReactionButton.SetTextColor(Color.ParseColor(AppSettings.MainColor));
                                break;
                            }

                            case PostButtonSystem.Wonder:
                            {
                                Drawable unwrappedDrawable = AppCompatResources.GetDrawable(this, Resource.Drawable.ic_action_wowonder);
                                Drawable wrappedDrawable   = DrawableCompat.Wrap(unwrappedDrawable);
                                if (Build.VERSION.SdkInt <= BuildVersionCodes.Lollipop)
                                {
                                    DrawableCompat.SetTint(wrappedDrawable, Color.ParseColor("#666666"));
                                }
                                else
                                {
                                    wrappedDrawable = wrappedDrawable.Mutate();
                                    wrappedDrawable.SetColorFilter(new PorterDuffColorFilter(Color.ParseColor("#666666"), PorterDuff.Mode.SrcAtop));
                                }
                                SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(wrappedDrawable, null, null, null);

                                SecondReactionButton.Text = GetString(Resource.String.Btn_Wonder);
                                SecondReactionButton.SetTextColor(Color.ParseColor("#444444"));
                                break;
                            }

                            case PostButtonSystem.DisLike when PostObject.IsWondered != null && PostObject.IsWondered.Value:
                            {
                                Drawable unwrappedDrawable = AppCompatResources.GetDrawable(this, Resource.Drawable.ic_action_dislike);
                                Drawable wrappedDrawable   = DrawableCompat.Wrap(unwrappedDrawable);

                                if (Build.VERSION.SdkInt <= BuildVersionCodes.Lollipop)
                                {
                                    DrawableCompat.SetTint(wrappedDrawable, Color.ParseColor("#f89823"));
                                }
                                else
                                {
                                    wrappedDrawable = wrappedDrawable.Mutate();
                                    wrappedDrawable.SetColorFilter(new PorterDuffColorFilter(Color.ParseColor("#f89823"), PorterDuff.Mode.SrcAtop));
                                }

                                SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(wrappedDrawable, null, null, null);

                                SecondReactionButton.Text = GetString(Resource.String.Lbl_disliked);
                                SecondReactionButton.SetTextColor(Color.ParseColor("#f89823"));
                                break;
                            }

                            case PostButtonSystem.DisLike:
                            {
                                Drawable unwrappedDrawable = AppCompatResources.GetDrawable(this, Resource.Drawable.ic_action_dislike);
                                Drawable wrappedDrawable   = DrawableCompat.Wrap(unwrappedDrawable);
                                if (Build.VERSION.SdkInt <= BuildVersionCodes.Lollipop)
                                {
                                    DrawableCompat.SetTint(wrappedDrawable, Color.ParseColor("#666666"));
                                }
                                else
                                {
                                    wrappedDrawable = wrappedDrawable.Mutate();
                                    wrappedDrawable.SetColorFilter(new PorterDuffColorFilter(Color.ParseColor("#666666"), PorterDuff.Mode.SrcAtop));
                                }

                                SecondReactionButton.SetCompoundDrawablesWithIntrinsicBounds(wrappedDrawable, null, null, null);

                                SecondReactionButton.Text = GetString(Resource.String.Btn_Dislike);
                                SecondReactionButton.SetTextColor(Color.ParseColor("#444444"));
                                break;
                            }
                            }
                        }
                    }

                    if (PostObject?.GetPostComments?.Count > 0)
                    {
                        var db = ClassMapper.Mapper?.Map <List <CommentObjectExtra> >(PostObject.GetPostComments);
                        MAdapter.CommentList = new ObservableCollection <CommentObjectExtra>(db);
                    }
                    else
                    {
                        MAdapter.CommentList = new ObservableCollection <CommentObjectExtra>();
                    }

                    MAdapter.NotifyDataSetChanged();
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
コード例 #5
0
        private void BindJobPost()
        {
            try
            {
                if (DataInfoObject != null)
                {
                    DataInfoObject = WoWonderTools.ListFilterJobs(DataInfoObject);

                    GlideImageLoader.LoadImage(this, DataInfoObject.Page.Avatar, JobAvatar, ImageStyle.RoundedCrop, ImagePlaceholders.Drawable);

                    var image = DataInfoObject.Image.Replace(Client.WebsiteUrl + "/", "");
                    if (!image.Contains("http"))
                    {
                        DataInfoObject.Image = Client.WebsiteUrl + "/" + image;
                    }
                    else
                    {
                        DataInfoObject.Image = image;
                    }

                    GlideImageLoader.LoadImage(this, DataInfoObject.Image, JobCoverImage, ImageStyle.FitCenter, ImagePlaceholders.Drawable);

                    if (DataInfoObject.IsOwner != null && DataInfoObject.IsOwner.Value)
                    {
                        TxtMore.Visibility = ViewStates.Visible;
                        JobButton.Text     = GetString(Resource.String.Lbl_show_applies) + " (" + DataInfoObject.ApplyCount + ")";
                        JobButton.Tag      = "ShowApply";
                    }

                    //Set Button if its applied
                    if (DataInfoObject.Apply == "true")
                    {
                        JobButton.Text    = GetString(Resource.String.Lbl_already_applied);
                        JobButton.Enabled = false;
                    }

                    JobTitle.Text = Methods.FunString.DecodeString(DataInfoObject.Title);

                    if (DataInfoObject.Page != null)
                    {
                        PageName.Text = "@" + Methods.FunString.DecodeString(DataInfoObject.Page.PageName.Replace("@", ""));
                        if (DataInfoObject.Page.IsPageOnwer != null && DataInfoObject.Page.IsPageOnwer.Value)
                        {
                            JobButton.Text = GetString(Resource.String.Lbl_show_applies) + " (" + DataInfoObject.ApplyCount + ")";
                        }
                    }

                    //Set Description
                    var description = Methods.FunString.DecodeString(DataInfoObject.Description);
                    Description.Text = description;
                    ReadMoreOption.AddReadMoreTo(Description, new String(description));

                    //Set Salary Date
                    string salaryDate = DataInfoObject.SalaryDate switch
                    {
                        "per_hour" => GetString(Resource.String.Lbl_per_hour),
                        "per_day" => GetString(Resource.String.Lbl_per_day),
                        "per_week" => GetString(Resource.String.Lbl_per_week),
                        "per_month" => GetString(Resource.String.Lbl_per_month),
                        "per_year" => GetString(Resource.String.Lbl_per_year),
                        _ => GetString(Resource.String.Lbl_Unknown)
                    };

                    MinimumNumber.Text = DataInfoObject.Minimum + " " + salaryDate;
                    MaximumNumber.Text = DataInfoObject.Maximum + " " + salaryDate;

                    //Set job Time
                    var jobInfo = IonIconsFonts.Pin + " " + DataInfoObject.Location + "  " + " ";
                    jobInfo += IonIconsFonts.Time + " " + Methods.Time.TimeAgo(Convert.ToInt32(DataInfoObject.Time), false) + " " + " ";

                    //Set job type
                    if (DataInfoObject.JobType == "full_time")
                    {
                        jobInfo += IonIconsFonts.IosBriefcase + " " + GetString(Resource.String.Lbl_full_time);
                    }
                    else if (DataInfoObject.JobType == "part_time")
                    {
                        jobInfo += IonIconsFonts.IosBriefcase + " " + GetString(Resource.String.Lbl_part_time);
                    }
                    else if (DataInfoObject.JobType == "internship")
                    {
                        jobInfo += IonIconsFonts.IosBriefcase + " " + GetString(Resource.String.Lbl_internship);
                    }
                    else if (DataInfoObject.JobType == "volunteer")
                    {
                        jobInfo += IonIconsFonts.IosBriefcase + " " + GetString(Resource.String.Lbl_volunteer);
                    }
                    else if (DataInfoObject.JobType == "contract")
                    {
                        jobInfo += IonIconsFonts.IosBriefcase + " " + GetString(Resource.String.Lbl_contract);
                    }
                    else
                    {
                        jobInfo += IonIconsFonts.IosBriefcase + " " + GetString(Resource.String.Lbl_Unknown);
                    }

                    var categoryName = CategoriesController.ListCategoriesJob.FirstOrDefault(categories => categories.CategoriesId == DataInfoObject.Category)?.CategoriesName;
                    jobInfo += " " + " " + IonIconsFonts.Pricetag + " " + categoryName;

                    var woTextDecorator = new WoTextDecorator
                    {
                        DecoratedContent = new SpannableString(jobInfo),
                        Content          = jobInfo
                    };
                    woTextDecorator.SetTextColor(IonIconsFonts.Pin, "#ff5722");
                    woTextDecorator.SetTextColor(IonIconsFonts.Time, "#4caf50");
                    woTextDecorator.SetTextColor(IonIconsFonts.IosBriefcase, "#2196f3");
                    woTextDecorator.SetTextColor(IonIconsFonts.Pricetag, "#795548");
                    woTextDecorator.Build(JobInfo, woTextDecorator.DecoratedContent);
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }