Exemple #1
0
        public void Refresh()
        {
            base.OnResume();

            string extra = "a";

            try{
                if (vm != null)
                {
                    vm.SyncPeriod();
                    vm.Rebind();
                }
                extra = "b";
                if (todayAdapter != null)
                {
                    recycler.GetItemAnimator().RemoveDuration = 250;
                    recycler.GetItemAnimator().AddDuration    = 250;

                    List <Entry> current = Cache.GetEntryCache(vm.date.Date)[(int)Period];   //
                    int          i       = 0;
                    int          c       = 0;

                    extra = "c";

                    foreach (var e in current)
                    {
                        while (todayAdapter.ItemCount > i && todayAdapter.getItem(i) != e)
                        {
                            todayAdapter.remove(i);
                            c++;
                        }
                        if (todayAdapter.ItemCount <= i)
                        {
                            todayAdapter.add(e, i);
                            c++;
                        }
                        i++;
                    }

                    while (todayAdapter.ItemCount > i)
                    {
                        todayAdapter.remove(i);
                        c++;
                    }

                    if (c == 0 || todayAdapter.ItemCount == 0)
                    {
                        todayAdapter.NotifyDataSetChanged();
                    }

                    extra = "d";


                    UpdateEmptyVisibility();
                }
            } catch (Exception ex) { LittleWatson.ReportException(ex, extra); }
        }
Exemple #2
0
        private async void SetUpContentRecycler(RecyclerView recyclerView, View view)
        {
            ((SimpleItemAnimator)recyclerView.GetItemAnimator()).SupportsChangeAnimations = false;
            recyclerView.SetLayoutManager(new LinearLayoutManager(Context));
            recyclerView.AddItemDecoration(new VerticalSpaceItemDecoration(20)
            {
                ShouldShowBeforeFirst = true
            });

            _currentPath = FilePathHelper.INITIAL_LOCAL_DIRECTORY;
            _isAtRoot    = true;

            _localFetcher = new LocalFetcher(FilePathHelper.INITIAL_LOCAL_DIRECTORY);

            //var thumbnailGenerator = new ThumbnailGenerator();
            //_previewManager = new PreviewManager(thumbnailGenerator);

            await _localFetcher.Fetch();

            _contentAdapter            = new ContentAdapter(Activity, _localFetcher.RootContents.Cast <IContent>().ToList());
            _contentAdapter.ItemClick += (s, args) => OpenContent(args.Item);

            //_contentAdapter.SetMultiChoiceModeListener(this);
            //_contentAdapter.ItemClick += FragmentHelper.Push(Activity, IncidentDetailsFragment.Instantiate(args.Item.PetID, args.Item.IncidentTypeID));

            recyclerView.SetAdapter(_contentAdapter);
        }
Exemple #3
0
        public override void OnAttachedToRecyclerView(RecyclerView recyclerView)
        {
            base.OnAttachedToRecyclerView(recyclerView);
            links = new LinkDecorator(recyclerView.Context, this);
            recyclerView.AddItemDecoration(links);
            recyclerView.GetItemAnimator().ChangeDuration = 0;

            RefreshContent();
            dm.onDeviceManagerEvent += OnDeviceManagerEvent;
            ion.currentWorkbench.onWorkbenchEvent += OnWorkbenchEvent;
            ion.currentAnalyzer.onAnalyzerEvent   += OnAnalyzerEvent;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            LinearLayoutManager layoutManager = new LinearLayoutManager(this);

            recyclerView = FindViewById <RecyclerView>(Resource.Id.recycler_view);

            recyclerView.SetItemAnimator(new LandingAnimator());
            recyclerView.GetItemAnimator().AddDuration    = 500;
            recyclerView.GetItemAnimator().RemoveDuration = 500;

            recyclerView.SetAdapter(new SwipeActionAdapter(this));

            recyclerView.SetLayoutManager(layoutManager);

            recyclerView.RefreshDrawableState();
        }
Exemple #5
0
        void ReplaceCell(object sender, NotifyCollectionChangedEventArgs e)
        {
            var section    = sender as Section;
            var startIndex = RowIndexFromChildCollection(section, e.OldStartingIndex);
            var repCell    = e.NewItems[0] as Cell;

            this[startIndex] = new RowInfo {
                Section  = section,
                Cell     = repCell,
                ViewType = (ViewType)ViewTypes[repCell.GetType()],
            };

            // Stop animation.
            (_recyclerView.GetItemAnimator() as DefaultItemAnimator).SupportsChangeAnimations = false;

            _adapter.NotifyItemRangeChanged(startIndex, 1);

            new Handler().PostDelayed(() =>
            {
                // Restart animation.
                (_recyclerView.GetItemAnimator() as DefaultItemAnimator).SupportsChangeAnimations = true;
            }, 100);
        }
Exemple #6
0
        private void SetUpPlaylistRecycler(RecyclerView recyclerView, View view)
        {
            ((SimpleItemAnimator)recyclerView.GetItemAnimator()).SupportsChangeAnimations = false;
            recyclerView.SetLayoutManager(new LinearLayoutManager(Context));
            recyclerView.AddItemDecoration(new VerticalSpaceItemDecoration(20)
            {
                ShouldShowBeforeFirst = true
            });

            _playlistAdapter = new PlaylistAdapter(Activity, GetPlaylists());
            //_playlistAdapter.SetMultiChoiceModeListener(this);
            _playlistAdapter.ItemClick += (s, args) => FragmentHelper.Push(Activity, PlaylistFragment.Instantiate(args.Item));

            recyclerView.SetAdapter(_playlistAdapter);
        }
Exemple #7
0
        private void SetUpLoggerRecycler(RecyclerView recyclerView, View view)
        {
            ((SimpleItemAnimator)recyclerView.GetItemAnimator()).SupportsChangeAnimations = false;
            recyclerView.SetLayoutManager(new LinearLayoutManager(Context));
            recyclerView.AddItemDecoration(new VerticalSpaceItemDecoration(20)
            {
                ShouldShowBeforeFirst = true
            });

            /*_loggerAdapter = new IncidentLoggerAdapter(Activity, GetIncidentLoggers().ToList());
             * //_loggerAdapter.SetMultiChoiceModeListener(this);
             * _loggerAdapter.ItemClick += (s, args) => FragmentHelper.Push(Activity, IncidentDetailsFragment.Instantiate(args.Item.PetID, args.Item.IncidentTypeID));
             * _loggerAdapter.IncidentLogged += LoggerAdapter_IncidentLogged;
             *
             * recyclerView.SetAdapter(_loggerAdapter);*/
        }
        private void CreateRowView()
        {
            _rows = new RecyclerView(Context);
            ((SimpleItemAnimator)_rows.GetItemAnimator()).SupportsChangeAnimations = false;

            var layoutManager = new LinearLayoutManager(Context);

            _rows.SetLayoutManager(layoutManager);

            var dividerDecoration = new DividerItemDecoration(Context, layoutManager.Orientation);

            dividerDecoration.SetDrawable(HorizontalRowDivider);
            _rows.AddItemDecoration(dividerDecoration);

            if (LazyLoad)
            {
                _rows.ScrollChange += (s, e) =>
                {
                    int firstVisibleItemPosition = layoutManager.FindFirstVisibleItemPosition();

                    if (!_gettingRows && firstVisibleItemPosition > 0 && _adapter.ItemCount % LazyLoadLimit == 0 && firstVisibleItemPosition + _rows.ChildCount >= _adapter.ItemCount)
                    {
                        _gettingRows = true;

                        var dialog = new ProgressDialog(Context, Resource.Style.ProgressDialogTheme)
                        {
                            Indeterminate = true
                        };
                        dialog.SetCancelable(false);
                        dialog.Show();

                        try
                        {
                            Task.Run(() => _adapter.AddRows(GetNextRowSet()));
                        }
                        finally
                        {
                            dialog.Dismiss();
                        }

                        _gettingRows = false;
                    }
                };
            }
        }
Exemple #9
0
        private void SetupRecyclerView()
        {
            // Touch listeners.
            itemTouchListener = new ItemTouchListener(recyclerView, this);
            recyclerView.AddOnItemTouchListener(itemTouchListener);

            var touchCallback = new SwipeDismissCallback(ItemTouchHelper.Up | ItemTouchHelper.Down, ItemTouchHelper.Left, this);
            var touchHelper   = new ItemTouchHelper(touchCallback);

            touchHelper.AttachToRecyclerView(recyclerView);

            // Decorations.
            dividerDecoration = new DividerItemDecoration(Activity, DividerItemDecoration.VerticalList);
            shadowDecoration  = new ShadowItemDecoration(Activity);
            recyclerView.AddItemDecoration(dividerDecoration);
            recyclerView.AddItemDecoration(shadowDecoration);

            recyclerView.GetItemAnimator().SupportsChangeAnimations = false;
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            ((MyPublicationsActivity)Activity).PublicationListFragment = this;
            Log.Info("dbg", "set PublicationListFragment.");

            var v = inflater.Inflate(Resource.Layout.publicationlist_fragment, container, false);

            tvNoTitleMessage   = v.FindViewById <TextView>(Resource.Id.tvNoTitleMessage);
            tvNoHistoryMessage = v.FindViewById <TextView>(Resource.Id.tvNoHistoryMessage);

            publicationfilter = v.FindViewById <Spinner>(Resource.Id.publicationfilter);
            ArrayAdapter aa = ArrayAdapter.CreateFromResource(Activity, Resource.Array.PublicationFilter, Android.Resource.Layout.SimpleSpinnerItem);

            aa.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            publicationfilter.Adapter       = aa;
            publicationfilter.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);

            rcPublicationList                = v.FindViewById <RecyclerView>(Resource.Id.rcPublicationList);
            publistLayoutManager             = new LinearLayoutManager(Activity);
            publistLayoutManager.Orientation = LinearLayoutManager.Vertical;
            rcPublicationList.SetLayoutManager(publistLayoutManager);
            prcAdaptor = new PublicationsAdaptor(Activity);
            prcAdaptor.HasStableIds = true;
            rcPublicationList.SetAdapter(prcAdaptor);
            rcPublicationList.GetItemAnimator().SupportsChangeAnimations = false;

            llHistoryListContainer            = v.FindViewById <LinearLayout>(Resource.Id.llHistoryListContainer);
            llHistoryListContainer.Visibility = ViewStates.Invisible;

            bool originalyEmptyPublicationList = DataCache.INSTATNCE.PublicationManager.IsPublicationListEmpty();

            //tvNoTitleMessage.Visibility = originalyEmptyPublicationList ? ViewStates.Visible : ViewStates.Gone;
            tvNoTitleMessage.Visibility = ViewStates.Gone;

            // Only when truely new create view, the wait dialog should be poped up.
            // Rotation of screen will not popup wait dialog.
            bool newCreated = savedInstanceState == null;

            GetPublicationListOnline(originalyEmptyPublicationList && newCreated);

            return(v);
        }
Exemple #11
0
        public override void OnDraw(Canvas canvas, RecyclerView parent, RecyclerView.State state)
        {
            if (!initiated)
            {
                Init();
            }

            if (parent.GetItemAnimator().IsRunning)
            {
                View lastViewComingDown = null;
                View firstViewComingUp  = null;

                // this is fixed
                int left  = 0;
                int right = parent.Width;

                // this we need to find out
                int top    = 0;
                int bottom = 0;

                // find relevant translating views
                int childCount = parent.GetLayoutManager().ChildCount;
                for (int i = 0; i < childCount; i++)
                {
                    View child = parent.GetLayoutManager().GetChildAt(i);
                    if (child.TranslationY < 0)
                    {
                        // view is coming down
                        lastViewComingDown = child;
                    }
                    else if (child.TranslationY > 0)
                    {
                        // view is coming up
                        if (firstViewComingUp == null)
                        {
                            firstViewComingUp = child;
                        }
                    }
                }

                if (lastViewComingDown != null && firstViewComingUp != null)
                {
                    // views are coming down AND going up to fill the void
                    top    = lastViewComingDown.Bottom + (int)lastViewComingDown.TranslationY;
                    bottom = firstViewComingUp.Top + (int)firstViewComingUp.TranslationY;
                }
                else if (lastViewComingDown != null)
                {
                    // views are going down to fill the void
                    top    = lastViewComingDown.Bottom + (int)lastViewComingDown.TranslationY;
                    bottom = lastViewComingDown.Bottom;
                }
                else if (firstViewComingUp != null)
                {
                    // views are coming up to fill the void
                    top    = firstViewComingUp.Top;
                    bottom = firstViewComingUp.Top + (int)firstViewComingUp.TranslationY;
                }

                background.SetBounds(left, top, right, bottom);
                background.Draw(canvas);
            }

            int dividerLeft  = parent.PaddingLeft;
            int dividerRight = parent.Width - parent.PaddingRight;

            int childCount1 = parent.ChildCount;

            for (int i = 0; i < childCount1; i++)
            {
                View child = parent.GetChildAt(i);

                RecyclerView.LayoutParams lParams = (RecyclerView.LayoutParams)child.LayoutParameters;

                int dividerTop    = child.Bottom + lParams.BottomMargin;
                int dividerBottom = dividerTop + divider.IntrinsicHeight;

                divider.SetBounds(dividerLeft, dividerTop, dividerRight, dividerBottom);
                divider.Draw(canvas);
            }

            base.OnDraw(canvas, parent, state);
        }