Example #1
0
        public static void DataTemplate(IMerchItem item, IMerchItemHolderYahoo holder, int position)
        {
            var yahooItem = (YahooItem)item.Item;

            MerchItemHolderTemplate.CommonFeedItemTemplate(item, holder);

            holder.Title.Text = item.Item.Name;
            holder.DetailBids.SetText(GetYahooItemLabel("Bids:", yahooItem.BidsCount.ToString()),
                                      TextView.BufferType.Spannable);
            holder.DetailEndsIn.SetText(GetYahooItemLabel("Ends in:", SharedUtil.TimeDiffToString((DateTime.UtcNow - yahooItem.EndTime).Duration())),
                                        TextView.BufferType.Spannable);
            holder.DetailCondition.SetText(GetYahooItemLabel("Condition:", yahooItem.Condition.ToString()),
                                           TextView.BufferType.Spannable);

            //if (yahooItem.BuyoutPrice != 0)
            //{
            //    holder.PriceSubtitle.Text = $"{yahooItem.BuyoutPrice}¥";
            //}

            if (yahooItem.Tax == 0)
            {
                holder.DetailsTax.Visibility = ViewStates.Gone;
            }
            else
            {
                holder.DetailsTax.Visibility = ViewStates.Visible;
                holder.DetailsTax.SetText(GetYahooItemLabel("Tax:", $"+{yahooItem.Tax}%"),
                                          TextView.BufferType.Spannable);
            }

            holder.DetailShipping.Visibility = BindingConverters.BoolToVisibility(yahooItem.IsShippingFree);
        }
Example #2
0
        public void UpdateTabIcons()
        {
            EmptyState.Visibility = BindingConverters.BoolToVisibility(ViewModel.FeedTabEntries.Count == 0);

            if (ViewModel.FeedTabEntries.Count <= 1)
            {
                TabStrip.Visibility = ViewStates.Gone;
                return;
            }

            TabStrip.Visibility = ViewStates.Visible;

            if (ViewModel.ContainsAggregate)
            {
                for (int i = 0; i < TabStrip.TabCount; i++)
                {
                    TabStrip.GetTabAt(i).SetIcon(Util.IndexToIconResource(i));
                }
            }
            else
            {
                for (int i = 1; i < TabStrip.TabCount + 1; i++)
                {
                    TabStrip.GetTabAt(i - 1).SetIcon(Util.IndexToIconResource(i));
                }
            }
        }
Example #3
0
        private void DataTemplate(CrawlerSetViewModel item, CrawlerSetHolder holder, int position)
        {
            holder.Title.Text = item.BackingModel.Name;
            holder.IndexIcon.SetImageResource(Util.IndexToIconResource(position + 1));
            holder.FavouriteIndicator.Visibility = BindingConverters.BoolToVisibility(item.IsFavourite);
            if (item.BackingModel.Descriptors?.Any() ?? false)
            {
                holder.EmptyNotice.Visibility = ViewStates.Gone;
                holder.CrawlerSummaryRecyclerView.Visibility = ViewStates.Visible;
                holder.CrawlerSummaryRecyclerView.SetAdapter(
                    new ObservableRecyclerAdapter <CrawlerDescriptor, CrawlerSetSummaryEntryHolder>(
                        item.BackingModel.Descriptors,
                        CrawlerSummaryEntryDataTemplate,
                        LayoutInflater,
                        Resource.Layout.item_crawler_set_summary)
                {
                    StretchContentHorizonatally = true
                });
            }
            else
            {
                holder.EmptyNotice.Visibility = ViewStates.Visible;
                holder.CrawlerSummaryRecyclerView.Visibility = ViewStates.Gone;
            }

            holder.ClickSurface.SetOnClickCommand(ViewModel.NavigateSetCommand, item);
            holder.MoreButton.SetOnClickListener(new OnClickListener(view => { HandleSetPopupMenu(item, holder); }));
        }
Example #4
0
 public static void SetUpWithEmptyState <T>(this ObservableCollection <T> collection, View emptyState)
 {
     collection.CollectionChanged += (sender, args) =>
     {
         emptyState.Visibility = BindingConverters.BoolToVisibility(collection.Count == 0);
     };
     emptyState.Visibility = BindingConverters.BoolToVisibility(collection.Count == 0);
 }
            protected override void SetBindings()
            {
                Bindings.Add(this.SetBinding(() => ViewModel.IsLoading).WhenSourceChanges(() =>
                {
                    LoadingSpinner.Visibility = BindingConverters.BoolToVisibility(ViewModel.IsLoading, ViewStates.Invisible);
                    DetailSection.Visibility  = BindingConverters.BoolToVisibilityInverted(ViewModel.IsLoading, ViewStates.Invisible);

                    if (!ViewModel.IsLoading)
                    {
                        MerchItemYahooHolderTemplate.DataTemplate(ViewModel, this, AdapterPosition);
                        if (Math.Abs(ViewModel.Price - CrawlerConstants.InvalidPrice) < 0.0001)
                        {
                            Price.Text = AppResources.Item_WatchedItem_AuctionEnded;
                            Price.SetTextColor(ThemeManager.RedColour);
                        }
                    }
                }));
            }
Example #6
0
        internal static void CommonFeedItemTemplate(IMerchItem item, IMerchItemHolder holder)
        {
            holder.Price.Text = item.Item.Price + "¥";
            ImageService.Instance.LoadUrl(item.Item.ImageUrl).Retry(2, 1000).Into(holder.ImageLeft);

            if (item is FeedItemViewModel feedViewModel)
            {
                holder.NewAlertSection.Visibility = BindingConverters.BoolToVisibility(feedViewModel.IsNew);
                switch (feedViewModel.PriceChange)
                {
                case PriceChange.Stale:
                    holder.PriceTrendIcon.Visibility = ViewStates.Gone;
                    holder.PriceSubtitle.Visibility  = ViewStates.Gone;
                    break;

                case PriceChange.Decrease:
                    holder.PriceSubtitle.Text        = $"({feedViewModel.PriceDifference:N0}¥)";
                    holder.PriceTrendIcon.Visibility = ViewStates.Visible;
                    holder.PriceSubtitle.Visibility  = ViewStates.Visible;
                    holder.PriceTrendIcon.SetImageResource(Resource.Drawable.icon_chevron_triple_down);
                    holder.PriceTrendIcon.ImageTintList = ColorStateList.ValueOf(ThemeManager.LimeColour);
                    break;

                case PriceChange.Increase:
                    holder.PriceSubtitle.Text        = $"(+{feedViewModel.PriceDifference:N0}¥)";
                    holder.PriceTrendIcon.Visibility = ViewStates.Visible;
                    holder.PriceSubtitle.Visibility  = ViewStates.Visible;
                    holder.PriceTrendIcon.SetImageResource(Resource.Drawable.icon_chevron_triple_up);
                    holder.PriceTrendIcon.ImageTintList = ColorStateList.ValueOf(ThemeManager.RedColour);
                    break;
                }
            }
            else
            {
                holder.NewAlertSection.Visibility = ViewStates.Gone;
                holder.PriceTrendIcon.Visibility  = ViewStates.Gone;
                holder.PriceSubtitle.Visibility   = ViewStates.Gone;
            }
        }