// http://martynnw.blogspot.co.uk/2014/10/xamarin-android-listviews-checkboxes-on.html

        /*private void SourceItemLongClicked
         * (
         *  object sender,
         *  AdapterView.ItemLongClickEventArgs arguments
         * )
         * {
         *  EditObject(_browseSourcesAdapter[arguments.Position].Key.SourceObjects[0]);
         * }*/

        protected override void OnResume()
        {
            bool initializeAdapter = ((BrowseViewState == null) ||
                                      (PortableObjectRepository <Activity> .HasUnreadSourceChanges));

            if (initializeAdapter)
            {
                List <PortableBaseSource> objectSources
                    = PortableObjectRepository <Activity> .GetObjectSources().OrderBy
                      (
                          objectSource => (!objectSource.IsEnabled) +
                          objectSource.ProviderName +
                          objectSource.SourceName +
                          objectSource.SourceDetails
                      )
                      .ToList();

                _sourceListAdapter = new AndroidBrowseSourcesAdapter
                                     (
                    RunOnUiThread,

                    (viewGroup) => LayoutInflater.Inflate(ItemLayoutResource,
                                                          viewGroup,
                                                          attachToRoot: false),

                    () => { return(BrowseFooterFragment.GetScaleType()); },
                    (scaleType) => BrowseFooterFragment.SetScaleType(scaleType),

                    () => { return(Resources); },

                    this.EditObject,

                    objectSources,

                    onCorrupt: (imageException,
                                imageView) =>
                {
                    this.HandleCorruptObject
                    (
                        imageException,
                        imageView,
                        getCount: () => { return(CorruptMesssageCount); },
                        setCount: (currentMassageCount) => { CorruptMesssageCount = currentMassageCount; }
                    );
                }
                                     );
            }

            base.OnResume();

            _sourceListAdapter.StartTimer(SlideInterval);
        }
Esempio n. 2
0
        protected override void OnResume()
        {
            bool initializeAdapter = ((BrowseViewState == null) ||
                                      (PortableObjectRepository <Activity> .HasUnreadSourceChanges));

            if (initializeAdapter)
            {
                List <ObjectItem> objectRenderers;

                try
                {
                    objectRenderers
                        = PortableObjectRepository <Activity> .GetEnabledObjects <ObjectItem>()
                          .ToList();
                }
                catch (Exception exception)
                {
                    IsHandlingException = true;

                    base.OnResume();

                    AndroidCrapApplication.ShowExceptionAndExit(this,
                                                                exception);
                    return;
                }

                _objectViewAdapter = new AndroidBrowseObjectsAdapter
                                     (
                    RunOnUiThread,

                    (viewGroup) =>
                {
                    try
                    {
                        return(LayoutInflater.Inflate(ItemLayoutResource,
                                                      viewGroup,
                                                      attachToRoot: false));
                    }
                    catch (Exception exception)
                    {
                        throw exception;
                    }
                },

                    () => { return(BrowseFooterFragment.GetScaleType()); },
                    (scaleType) => BrowseFooterFragment.SetScaleType(scaleType),

                    () => { return(Resources); },

                    LoadingResource,

                    this.EditObject,

                    objectRenderers,

                    getString: (resource) => GetString(resource),

                    onCorrupt: (imageException,
                                imageView) =>
                {
                    this.HandleCorruptObject
                    (
                        imageException,
                        imageView,
                        getCount: () => { return(CorruptMesssageCount); },
                        setCount: (currentMassageCount) => { CorruptMesssageCount = currentMassageCount; }
                    );
                }
                                     );
            }

            base.OnResume();

            AbstractBrowseView.ItemClick -= ObjectItemClicked;
            AbstractBrowseView.ItemClick += ObjectItemClicked;

            bool isDataChanged = false;

            PortableBaseObject pendingObject = PortableObjectRepository <Activity> .PopPendingObject();

            while (pendingObject != null)
            {
                _objectViewAdapter.AddPendingObject(pendingObject);

                isDataChanged = true;

                pendingObject = PortableObjectRepository <Activity> .PopPendingObject();
            }

            if (isDataChanged)
            {
                _objectViewAdapter.NotifyDataSetChanged();
            }
        }