Beispiel #1
0
        public async void StartSyncing(string playlistName)
        {
            int LocalIndex = LocalPlaylists.FindIndex(x => x.Name == playlistName);

            if (LocalIndex != -1)
            {
                LocalPlaylists.RemoveAt(LocalIndex);
                adapter.NotifyItemRemoved(LocalIndex);
                if (LocalPlaylists.Count == 1)
                {
                    LocalPlaylists.Add(new PlaylistItem("EMPTY", -1)
                    {
                        Owner = Resources.GetString(Resource.String.local_playlist_empty)
                    });
                    adapter.NotifyItemInserted(1);
                }
                await Task.Delay(500);
            }

            int YoutubeIndex = YoutubePlaylists.FindIndex(x => x.Name == playlistName);

            if (YoutubeIndex != -1)
            {
                YoutubePlaylists[YoutubeIndex].SyncState = SyncState.Loading;
                PlaylistHolder holder = (PlaylistHolder)ListView.GetChildViewHolder(ListView.GetChildAt(LocalPlaylists.Count + YoutubeIndex));
                holder.sync.Visibility        = ViewStates.Gone;
                holder.SyncLoading.Visibility = ViewStates.Visible;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 单击事件
        /// </summary>
        /// <returns><c>true</c>, if single tap up was oned, <c>false</c> otherwise.</returns>
        /// <param name="e">E.</param>
        public override bool OnSingleTapUp(MotionEvent e)
        {
            View child = m_RecyclerView.FindChildViewUnder(e.GetX(), e.GetY());

            if (child != null)
            {
                RecyclerView.ViewHolder vh = m_RecyclerView.GetChildViewHolder(child);
                int position = vh.LayoutPosition;
                if (m_IRecyclerViewClickListerner != null)
                {
                    m_IRecyclerViewClickListerner.OnItemClick(child, position);
                }
            }
            return(true);
        }
Beispiel #3
0
        public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state)
        {
            var left  = parent.Left;
            var right = parent.Right;

            var        childCount = parent.ChildCount;
            ViewHolder prevHolder = null;

            for (var i = 0; i < childCount; i++)
            {
                var child  = parent.GetChildAt(i);
                var holder = parent.GetChildViewHolder(child) as ViewHolder;

                if (prevHolder != null && prevHolder is IHeaderViewHolder && !_settingsView.ShowSectionTopBottomBorder ||
                    holder is IFooterViewHolder && !_settingsView.ShowSectionTopBottomBorder ||
                    holder is IFooterViewHolder && !holder.RowInfo.Section.Any() ||
                    holder is IHeaderViewHolder ||
                    !SectionIsVisible(holder?.RowInfo.Section) ||
                    !CellIsVisible(holder?.RowInfo.Cell))
                {
                    prevHolder = holder;
                    continue;
                }

                var bottom = child.Top;
                var top    = bottom - _drawable.IntrinsicHeight;
                _drawable.SetBounds(left, top, right, bottom);
                _drawable.Draw(c);

                prevHolder = holder;
            }
        }
Beispiel #4
0
        public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state)
        {
            base.GetItemOffsets(outRect, view, parent, state);

            var holder   = parent.GetChildViewHolder(view);
            var position = holder.BindingAdapterPosition;

            if (parent.GetAdapter() is IReadOnlyViewModels <object> viewModels)
            {
                var count = viewModels.ViewModels.Count;
                if (count == 0)
                {
                    return;
                }
                else if (position == 0)
                {
                    if (!noTop)
                    {
                        outRect.Top = height;
                    }
                }
                if (position < viewModels.ViewModels.Count - 1)
                {
                    outRect.Bottom = height;
                }
                else
                {
                    outRect.Bottom = PaddingBottomWithHeight ? paddingBottom + height : (paddingBottom == 0 ? height : paddingBottom);
                }
            }
        }
            public override void GetItemOffsets(Rect outRect, Android.Views.View view, RecyclerView parent, RecyclerView.State state)
            {
                var holder       = parent.GetChildViewHolder(view) as ContentViewHolder;
                var position     = parent.GetChildAdapterPosition(view);
                var realPosition = position;

                if (_renderer._hCollectionView.IsInfinite)
                {
                    realPosition = _renderer.Adapter.GetRealPosition(position);
                }

                if (holder.IsHeader)
                {
                    outRect.Right = _renderer._firstSpacing;
                    if (position != 0)
                    {
                        outRect.Left = _renderer._lastSpacing;
                    }

                    return;
                }

                if (position == 0 || _renderer.Adapter.FirstSectionItems.Contains(realPosition))
                {
                    return;
                }

                outRect.Left = _renderer._spacing;
            }
Beispiel #6
0
        public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state)
        {
            base.GetItemOffsets(outRect, view, parent, state);

            var holder = parent.GetChildViewHolder(view);

            if (holder is IReadOnlyViewFor <IReadOnlyItemViewGroup> vf)
            {
                var lastPosition = holder.BindingAdapterPosition - 1;
                if (lastPosition >= 0 && parent.GetAdapter() is
                    IReadOnlyViewModels <IReadOnlyItemViewGroup> viewModels)
                {
                    var list = viewModels.ViewModels;
                    if (lastPosition < list.Count)
                    {
                        var nextItem = list[lastPosition];
                        if (vf.ViewModel?.ItemViewGroup != nextItem?.ItemViewGroup)
                        {
                            // 根据视图模型中的组判断上一个元素是否和当前元素的组值相同,不同则在顶部添加高度实现间距
                            outRect.Top = height;
                        }
                    }
                }
            }
        }
Beispiel #7
0
        public override void GetItemOffsets(ARect outRect, AView view, RecyclerView parent, RecyclerView.State state)
        {
            base.GetItemOffsets(outRect, view, parent, state);

            if (_adjustedVerticalSpacing == -1)
            {
                _adjustedVerticalSpacing = (int)parent.Context.ToPixels(_verticalSpacing);
            }

            if (_adjustedHorizontalSpacing == -1)
            {
                _adjustedHorizontalSpacing = (int)parent.Context.ToPixels(_horizontalSpacing);
            }

            var itemViewType = parent.GetChildViewHolder(view).ItemViewType;

            if (itemViewType == ItemViewType.Header)
            {
                if (_orientation == ItemsLayoutOrientation.Vertical)
                {
                    outRect.Bottom = _adjustedVerticalSpacing;
                }
                else
                {
                    outRect.Right = _adjustedHorizontalSpacing;
                }

                return;
            }

            if (itemViewType == ItemViewType.Footer)
            {
                return;
            }

            var spanIndex = 0;

            if (view.LayoutParameters is GridLayoutManager.LayoutParams gridLayoutParameters)
            {
                spanIndex = gridLayoutParameters.SpanIndex;
            }

            var spanGroupIndex = GetSpanGroupIndex(view, parent);

            if (_orientation == ItemsLayoutOrientation.Vertical)
            {
                outRect.Left = spanIndex == 0 ? 0 : _adjustedHorizontalSpacing;
                outRect.Top  = spanGroupIndex == 0 ? 0 : _adjustedVerticalSpacing;
            }

            if (_orientation == ItemsLayoutOrientation.Horizontal)
            {
                outRect.Top  = spanIndex == 0 ? 0 : _adjustedVerticalSpacing;
                outRect.Left = spanGroupIndex == 0 ? 0 : _adjustedHorizontalSpacing;
            }
        }
Beispiel #8
0
        public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state)
        {
            var holder = parent.GetChildViewHolder(view) as ViewHolder;

            if (!CellIsVisible(holder?.RowInfo.Cell))
            {
                return;
            }

            outRect.Set(0, _drawable.IntrinsicHeight, 0, 0);
        }
Beispiel #9
0
        public override void GetItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state)
        {
            base.GetItemOffsets(outRect, view, parent, state);

            var holder   = parent.GetChildViewHolder(view);
            var position = holder.BindingAdapterPosition;

            if (parent.GetAdapter() is IReadOnlyViewModels <object> viewModels)
            {
                if (position < viewModels.ViewModels.Count - 1)
                {
                    // 除了末尾项之外,底部添加相同的间距
                    outRect.Bottom = height;
                }
            }
        }
        public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state)
        {
            var childCount = parent.ChildCount;

            if (childCount == 0)
            {
                return;
            }

            for (int i = 0; i + 1 < childCount; i++)
            {
                var child      = parent.GetChildAt(i);
                var viewHolder = parent.GetChildViewHolder(child);

                Type     type       = viewHolder.GetType();
                object[] attributes = type.GetCustomAttributes(typeof(ShadowAttribute), false);

                if (attributes.Length != 1)
                {
                    continue;
                }

                ShadowAttribute shadowAttr = attributes [0] as ShadowAttribute;

                if (ShouldDraw(child) && shadowAttr != null)
                {
                    var m     = shadowAttr.Modes;
                    var left  = parent.PaddingLeft;
                    var right = child.Right + child.PaddingRight;

                    if (m.HasFlag(top) && topShadowHeightInPixels > 0 && parent.GetChildAdapterPosition(child) != 0)
                    {
                        var shadowBottom = child.Top + topShadowHeightInPixels;
                        shadow.SetBounds(left, child.Top, right, shadowBottom);
                        shadow.Draw(c);
                    }

                    if (m.HasFlag(bottom) && bottomShadowHeightInPixels > 0)
                    {
                        var reverseShadowTop = child.Bottom - bottomShadowHeightInPixels;
                        reverseShadow.SetBounds(left, reverseShadowTop, right, child.Bottom);
                        reverseShadow.Draw(c);
                    }
                }
            }
        }
Beispiel #11
0
        internal void ResolveItem(float x, float y)
        {
            _touchedView = _recyclerView.FindChildViewUnder(x, y);
            if (_touchedView == null)
            {
                //no child under
                _frontView = null;
                return;
            }

            // check if the view is being animated. in that case do not allow to move it
            if (RunningAnimationsOn.Contains(_touchedView))
            {
                _frontView = null;
                return;
            }

            InitViewForItem((SwipeViewHolder <M>)_recyclerView.GetChildViewHolder(_touchedView));
        }
            public override void GetItemOffsets(Rect outRect, Android.Views.View view, RecyclerView parent, RecyclerView.State state)
            {
                var holder       = parent.GetChildViewHolder(view) as ContentViewHolder;
                var position     = parent.GetChildAdapterPosition(view);
                var realPosition = position;

                if (_renderer._hCollectionView.IsInfinite)
                {
                    realPosition = _renderer.Adapter.GetRealPosition(position);
                }

                if (holder.IsHeader)
                {
                    outRect.Right = _renderer._firstSpacing;
                    if (position != 0)
                    {
                        outRect.Left = _renderer._lastSpacing;
                    }

                    return;
                }

                // Disabled grouping first spacing is applied at the first cell.
                if (!_renderer._hCollectionView.IsGroupingEnabled && position == 0)
                {
                    outRect.Left = _renderer._firstSpacing;
                }

                // Group last or single last spacing is applied at the last cell.
                if (position == _renderer.Adapter.ItemCount - 1)
                {
                    outRect.Right = _renderer._lastSpacing;
                }

                if (position == 0 || _renderer.Adapter.FirstSectionItems.Contains(realPosition))
                {
                    return;
                }

                outRect.Left = _renderer._spacing;
            }
        public override void OnDraw (Canvas c, RecyclerView parent, RecyclerView.State state)
        {
            var childCount = parent.ChildCount;

            if (childCount == 0) {
                return;
            }

            for (int i = 0; i+1 < childCount; i++) {
                var child = parent.GetChildAt (i);
                var viewHolder = parent.GetChildViewHolder (child);

                Type type = viewHolder.GetType ();
                object[] attributes = type.GetCustomAttributes (typeof (ShadowAttribute), false);

                if (attributes.Length != 1) {
                    continue;
                }

                ShadowAttribute shadowAttr = attributes [0] as ShadowAttribute;

                if (ShouldDraw (child) && shadowAttr != null) {

                    var m = shadowAttr.Modes;
                    var left = parent.PaddingLeft;
                    var right = child.Right + child.PaddingRight;

                    if (m.HasFlag (top) && topShadowHeightInPixels > 0 && parent.GetChildAdapterPosition (child) != 0) {
                        var shadowBottom = child.Top + topShadowHeightInPixels;
                        shadow.SetBounds (left, child.Top, right, shadowBottom);
                        shadow.Draw (c);
                    }

                    if (m.HasFlag (bottom) && bottomShadowHeightInPixels > 0) {
                        var reverseShadowTop = child.Bottom - bottomShadowHeightInPixels;
                        reverseShadow.SetBounds (left, reverseShadowTop, right, child.Bottom);
                        reverseShadow.Draw (c);
                    }
                }
            }
        }
Beispiel #14
0
        public override void OnDraw(Canvas c, RecyclerView parent, RecyclerView.State state)
        {
            int left  = parent.Left;
            int right = parent.Right;

            int childCount = parent.ChildCount;
            CustomViewHolder?prevHolder = null;

            for (var i = 0; i < childCount; i++)
            {
                View?child = parent.GetChildAt(i);

                if (child is null)
                {
                    continue;
                }
                if (!(parent.GetChildViewHolder(child) is CustomViewHolder holder))
                {
                    continue;
                }
                if (holder.RowInfo is null)
                {
                    continue;
                }
                if ((prevHolder is IHeaderViewHolder && !_SettingsView.ShowSectionTopBottomBorder) ||
                    (holder is IFooterViewHolder && !_SettingsView.ShowSectionTopBottomBorder) ||
                    (holder is IFooterViewHolder && !holder.RowInfo.Section.Any()) ||
                    (holder is IHeaderViewHolder || !holder.RowInfo.Section.IsVisible))
                {
                    prevHolder = holder;
                    continue;
                }

                int bottom = child.Top;
                int top    = bottom - _Drawable.IntrinsicHeight;
                _Drawable.SetBounds(left, top, right, bottom);
                _Drawable.Draw(c);

                prevHolder = holder;
            }
        }
Beispiel #15
0
    public void RefreshCurrent()
    {
        System.Console.WriteLine("&Queue current refreshing, isPlaying: " + MusicPlayer.isRunning);
        ListView.InvalidateItemDecorations();

        int first = ((LinearLayoutManager)ListView.GetLayoutManager()).FindFirstVisibleItemPosition();
        int last  = ((LinearLayoutManager)ListView.GetLayoutManager()).FindLastVisibleItemPosition();

        for (int i = first; i <= last; i++)
        {
            View child = ((LinearLayoutManager)ListView.GetLayoutManager()).FindViewByPosition(i);
            if (child != null && ListView.GetChildViewHolder(child) is SongHolder holder)
            {
                if (SongParser.playPosition == i - 1)
                {
                    holder.status.Visibility = ViewStates.Visible;
                    holder.status.SetTextColor(Color.Argb(255, 0, 255, 255));

                    string          status     = MainActivity.instance.GetString(Resource.String.loading);
                    SpannableString statusText = new SpannableString(status);
                    statusText.SetSpan(new BackgroundColorSpan(Color.ParseColor("#8C000000")), 0, status.Length, SpanTypes.InclusiveInclusive);
                    holder.status.TextFormatted = statusText;
                }
                else if (MusicPlayer.CurrentID() == i - 1) //The -1 is because the first displayed item of the queue is a header.
                {
                    holder.status.Visibility = ViewStates.Visible;
                    holder.status.SetTextColor(MusicPlayer.isRunning ? Color.Argb(255, 244, 81, 30) : Color.Argb(255, 66, 165, 245));

                    string          status     = MusicPlayer.isRunning ? MainActivity.instance.GetString(Resource.String.playing) : MainActivity.instance.GetString(Resource.String.paused);
                    SpannableString statusText = new SpannableString(status);
                    statusText.SetSpan(new BackgroundColorSpan(Color.ParseColor("#8C000000")), 0, status.Length, SpanTypes.InclusiveInclusive);
                    holder.status.TextFormatted = statusText;
                }
                else
                {
                    holder.status.Visibility = ViewStates.Gone;
                }
            }
        }
    }
 private void View_Click(object sender, EventArgs e)
 {
     RecyclerView.ViewHolder holder = mRecyclerview.GetChildViewHolder(((View)sender));
     mAction.Invoke(mRecyclerview, holder.AdapterPosition, ((View)sender));
 }