Пример #1
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         UpdateOverFragmentBroadcastReceiver?.Dispose();
         UpdateOverFragmentBroadcastReceiver = null;
     }
 }
Пример #2
0
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         ItemClickedBroadcastReceiver?.Dispose();
         ItemClickedBroadcastReceiver = null;
     }
 }
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         RowEditedBroadcastReceiver?.Dispose();
         RowEditedBroadcastReceiver = null;
     }
 }
        public override void OnResume()
        {
            base.OnResume();

            AskForLocationPermissionIfNecessary(Permission.Location);

            TapToShareBroadCastReceiver = new ActionBroadcastReceiver();
            TapToShareBroadCastReceiver.NotificationReceived += (obj) =>
            {
                Activity.RunOnUiThread(() =>
                {
                    if (Shared.State == SharingShared.SharingState.DisplayPurposesOnly)
                    {
                        //todo
                        return;
                    }

                    if (Shared.State == SharingShared.SharingState.PermissionDenied)
                    {
                        //todo
                        return;
                    }

                    //make sure at least one outlet is selected
                    if (!Shared.SelectedCard.Outlets.Any(c => !c.Omitted))
                    {
                        return;
                    }

                    if (ButtonLocked)
                    {
                        return;
                    }
                    ButtonLocked = true;

                    if (Shared.Sharing)
                    {
                        StopSharing();
                    }
                    else
                    {
                        StartSharing();
                    }
                });
            };
            Activity.RegisterReceiver(TapToShareBroadCastReceiver, new IntentFilter(SharingShared.TapToShareBroadCastReceiverClicked));
        }
Пример #5
0
        protected override void OnResume()
        {
            base.OnResume();

            UpdateOverFragmentBroadcastReceiver = new ActionBroadcastReceiver();
            UpdateOverFragmentBroadcastReceiver.NotificationReceived += (obj) =>
            {
                var className = obj.GetStringExtra(UpdateOverFragmentBroadcastReceiverKeyFileName);
                if (String.IsNullOrEmpty(className))
                {
                    return;
                }

                AddFragmentOver(className);
            };
            RegisterReceiver(UpdateOverFragmentBroadcastReceiver, new IntentFilter(UpdateOverFragmentBroadcastReceiverKey));
        }
Пример #6
0
        public override void OnResume()
        {
            base.OnResume();


            OutletClickedBroadcastReceiver = new ActionBroadcastReceiver();
            OutletClickedBroadcastReceiver.NotificationReceived += (obj) =>
            {
                Activity.RunOnUiThread(() =>
                {
                    var position = obj.GetIntExtra(MyCardsShared.ItemClickedBroadcastReceiverKeyPosition, -1);
                    if (position == -1)
                    {
                        return;
                    }

                    var item = RecyclerViewAdapter.GetItemInList(position);

                    RecyclerView_ItemClick(item, position);
                });
            };
            Activity.RegisterReceiver(OutletClickedBroadcastReceiver, new IntentFilter(CardFront.ItemClickedBroadcastReceiverKey));



            CardClickedBroadcastReceiver = new ActionBroadcastReceiver();
            CardClickedBroadcastReceiver.NotificationReceived += (obj) =>
            {
                Activity.RunOnUiThread(() =>
                {
                    var position = obj.GetIntExtra(MyCardsShared.ItemClickedBroadcastReceiverKeyPosition, -1);
                    if (position == -1)
                    {
                        return;
                    }

                    var item = RecyclerViewAdapter.GetItemInList(position);

                    RecyclerView_ItemClick(item, position);
                });
            };
            Activity.RegisterReceiver(CardClickedBroadcastReceiver, new IntentFilter(MyCardsShared.ItemClickedBroadcastReceiverKeyCardClicked));
        }
        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));
        }