コード例 #1
0
        public override bool OnContextItemSelected(IMenuItem item)
        {
            var position = item.Order;

            var model = RecyclerViewAdapter.GetItemInList(position);

            if (model == null)
            {
                return(base.OnContextItemSelected(item));
            }
            if (model.Outlet == null)
            {
                return(base.OnContextItemSelected(item));
            }

            switch (item.TitleFormatted.ToString().ToLower())
            {
            case "delete":
                Shared.SelectedCard.RemoveOutlet(model.Outlet);

                var replacementItems = Shared.GetTableItems();
                RecyclerViewAdapter.ListItems.RemoveAt(position);

                RecyclerViewAdapter.NotifyItemRemoved(position);
                RecyclerViewAdapter.NotifyItemChanged(0);
                break;

            default: break;
            }

            return(base.OnContextItemSelected(item));
        }
コード例 #2
0
        public override void OnStart()
        {
            base.OnStart();

            RowEditedBroadcastReceiver = new ActionBroadcastReceiver();
            RowEditedBroadcastReceiver.NotificationReceived += (obj) =>
            {
                var position = obj.GetIntExtra(SettingsShared.ItemClickedBroadcastReceiverKeyPosition, -1);
                if (position == -1)
                {
                    return;
                }

                var text = obj.GetStringExtra(SettingsShared.ItemClickedBroadcastReceiverKeyValue);
                if (String.IsNullOrEmpty(text))
                {
                    return;
                }

                var model = RecyclerViewAdapter.GetItemInList(position);
                if (String.IsNullOrEmpty(model.Placeholder))
                {
                    return;
                }

                if (model.Placeholder.Equals(NewCardShared.new_card_model_title_placeholder, StringComparison.InvariantCultureIgnoreCase))
                {
                    model.SelectedCard.UpdateStringProperty(() => model.SelectedCard.Title, text.Trim());
                    model.SelectedCard.ShowFront();
                }
                else if (model.Placeholder.Equals(NewCardShared.new_card_model_display_name_placeholder, StringComparison.InvariantCultureIgnoreCase))
                {
                    model.SelectedCard.UpdateStringProperty(() => model.SelectedCard.UserDisplayName, text.Trim());
                    model.SelectedCard.ShowFront();
                }

                else if (model.Placeholder.Equals(NewCardShared.new_card_model_company_name, StringComparison.InvariantCultureIgnoreCase))
                {
                    model.SelectedCard.UpdateStringProperty(() => model.SelectedCard.CompanyName, text.Trim());
                    model.SelectedCard.ShowBack();
                }

                Activity.RunOnUiThread(() =>
                {
                    RecyclerViewAdapter.NotifyItemChanged(0);
                });
            };
            Activity.RegisterReceiver(RowEditedBroadcastReceiver, new IntentFilter(Strings.InternalNotifications.notification_table_row_editing_changed));


            //todo: break this down into individual notificaions so you dont have to update all 3 rows every time
            CardEditingChangedBroadcaseReceiver = new ActionBroadcastReceiver();
            CardEditingChangedBroadcaseReceiver.NotificationReceived += (obj) =>
            {
                Activity.RunOnUiThread(() =>
                {
                    var replacementItems = Shared.GetTableItems();

                    var nameIndex = 1;
                    RecyclerViewAdapter.ListItems[nameIndex] = replacementItems[nameIndex];

                    var titleIndex = 2;
                    RecyclerViewAdapter.ListItems[titleIndex] = replacementItems[titleIndex];

                    var companyNameIndex = 5;
                    RecyclerViewAdapter.ListItems[companyNameIndex] = replacementItems[companyNameIndex];

                    RecyclerViewAdapter.NotifyItemRangeChanged(nameIndex, companyNameIndex);
                });
            };
            Activity.RegisterReceiver(CardEditingChangedBroadcaseReceiver, new IntentFilter(Strings.InternalNotifications.notification_card_editing_changed));


            NoOutletsTappedBroadcastReceiver = new ActionBroadcastReceiver();
            NoOutletsTappedBroadcastReceiver.NotificationReceived += (obj) =>
            {
                Activity.RunOnUiThread(() =>
                {
                    RecyclerView.ScrollToPosition(RecyclerViewAdapter.ListItems.Count - 1);
                });
            };
            Activity.RegisterReceiver(NoOutletsTappedBroadcastReceiver, new IntentFilter(Strings.InternalNotifications.notification_no_outlets_tapped));

            CardUserImageClickedBroadcastReceiver = new ActionBroadcastReceiver();
            CardUserImageClickedBroadcastReceiver.NotificationReceived += (obj) =>
            {
                Activity.RunOnUiThread(() =>
                {
                    var cell = RecyclerView.FindViewHolderForAdapterPosition(0) as CardCell;
                    if (cell == null)
                    {
                        return;
                    }

                    var imgView = cell.GetUserImageView();
                    if (imgView == null)
                    {
                        return;
                    }

                    ShowImageChooser(imgView, Shared.SelectedCard.LocalHeaderURL, Shared.SelectedCard.GetRemoteHeaderUrlCached(), "Profile.png", SelectUserImagePhotoRequestCode);
                });
            };
            Activity.RegisterReceiver(CardUserImageClickedBroadcastReceiver, new IntentFilter(Strings.InternalNotifications.notification_card_user_image_clicked));

            CardCompanyLogoImageClickedBroadcastReceiver = new ActionBroadcastReceiver();
            CardCompanyLogoImageClickedBroadcastReceiver.NotificationReceived += (obj) =>
            {
                Activity.RunOnUiThread(() =>
                {
                    var cell = RecyclerView.FindViewHolderForAdapterPosition(0) as CardCell;
                    if (cell == null)
                    {
                        return;
                    }

                    var imgView = cell.GetCompanyLogoImageView();
                    if (imgView == null)
                    {
                        return;
                    }

                    ShowImageChooser(imgView, Shared.SelectedCard.LocalHeaderURL, Shared.SelectedCard.GetRemoteHeaderUrlCached(), "Logo.png", SelectCompanyLogoPhotoRequestCode);
                });
            };
            Activity.RegisterReceiver(CardCompanyLogoImageClickedBroadcastReceiver, new IntentFilter(Strings.InternalNotifications.notification_company_logo_image_clicked));
        }