public override bool OnOptionsItemSelected
        (
            IMenuItem menuItem
        )
        {
            switch (menuItem.ItemId)
            {
            case Resource.Id.EditSourceItem:
            {
                //EditSourceClicked();

                var objectGridIntent = new Intent(this,
                                                  typeof(AndroidObjectGridActivity));

                StartActivity(objectGridIntent);

                break;
            }

            case Resource.Id.MoreOptionsItem:
            {
                BrowseFooterFragment.ShowPopupMenu(Resource.Menu.BrowseViewPopupMenu);

                break;
            }

            default:
            {
                throw new InvalidOperationException(menuItem.TitleFormatted.ToString());
            }
            }

            return(base.OnOptionsItemSelected(menuItem));
        }
示例#2
0
        protected override void OnResume()
        {
            base.OnResume();

            if (IsHandlingException)
            {
                return;
            }

            BrowseFooterFragment = FragmentManager.FindFragmentById <AndroidBrowseFooterFragment>
                                   (
                Resource.Id.BrowseFooterFragment
                                   );

            AbstractBrowseView = FindViewById <AbsListView>(BrowseViewId);

            BrowseViewAdapter = GetBrowseAdapter();

            BrowseFooterFragment.ConfigureBrowsingFor
            (
                AbstractBrowseView,

                getThumbnailWidth: () =>
            {
                return(BrowseViewAdapter.GetThumbnailWidth());
            },

                viewTypeChanged: () =>
            {
                ToggleBrowseActivity();
            },

                scaleTypeChanged: () =>
            {
                BrowseViewAdapter.NotifyDataSetChanged();
            }
            );

            if (AbstractBrowseView.Adapter == null)
            {
                AbstractBrowseView.Adapter = BrowseViewAdapter;
            }

            if (BrowseViewState != null)
            {
                AbstractBrowseView.OnRestoreInstanceState(BrowseViewState);
            }
            else
            {
                TryRestoreFirstPosition();
            }

            //_browseObjectsList.ChoiceMode = ChoiceMode.Multiple;
            //AbsListView.IMultiChoiceModeListener multiChoiceModeListener = new MultiChoiceModeListener();
            //_browseObjectsList.SetMultiChoiceModeListener(multiChoiceModeListener);
        }
        // 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);
        }
示例#4
0
        public override bool OnOptionsItemSelected
        (
            IMenuItem menuItem
        )
        {
            switch (menuItem.ItemId)
            {
            case Resource.Id.AddObjectItem:
            {
                AddImageClicked();

                break;
            }

            case Resource.Id.SearchObjectsItem:
            {
                SearchObjectsClicked();

                break;
            }

            /*case Resource.Id.DeleteObjectItem:
             * {
             *  DeleteReceiptClicked();
             *
             *  break;
             * }*/

            case Resource.Id.MoreOptionsItem:
            {
                BrowseFooterFragment.ShowPopupMenu(Resource.Menu.BrowseViewPopupMenu);

                break;
            }

            default:
            {
                throw new InvalidOperationException(menuItem.TitleFormatted.ToString());
            }
            }

            return(base.OnOptionsItemSelected(menuItem));
        }
示例#5
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();
            }
        }