Esempio n. 1
0
        void mMainView_Click(object sender, EventArgs e)
        {
            //If there is a current item selected.
            if (_selectedItemPosition >= 0)
            {
                //Remove the activated state.
                var previousSelection = _recyclerView.FindViewHolderForAdapterPosition(_selectedItemPosition);

                if (previousSelection != null)
                {
                    previousSelection.ItemView.Selected = false;
                }
            }

            //Unbox the view.
            var newSelectedView = (global::Android.Views.View)sender;

            //Set selected property.
            newSelectedView.Selected = true;

            //Get the position of this view.
            int position = _recyclerView.GetChildAdapterPosition(newSelectedView);

            //Store the selected item position.
            _selectedItemPosition = position;

            var item = _flattenedItems == null?
                       Items.Cast <object>().ElementAt(position) :
                           _flattenedItems.ElementAt(position);

            Element.InvokeItemSelectedEvent(this, item);
        }
Esempio n. 2
0
 void OnItemLongClick(object sender, int position)
 {
     //display a popup menu when long pressing an item in the account list
     //handle the menu item (edit and delete options for accounts) click event
     try
     {
         Android.Widget.PopupMenu menu = new Android.Widget.PopupMenu(this, mRecyclerView.FindViewHolderForAdapterPosition(position).ItemView, Android.Views.GravityFlags.Right);
         menu.Inflate(Resource.Layout.popup_menu_transaction);
         menu.MenuItemClick += (s1, arg1) =>
         {
             if (arg1.Item.TitleFormatted.ToString() == "Delete")
             {
                 AlertDialog.Builder builder;
                 builder = new AlertDialog.Builder(this);
                 builder.SetTitle("Delete?");
                 builder.SetMessage("Are you sure you want to delete the transaction: " + transactions[position].Title);
                 builder.SetCancelable(false);
                 builder.SetPositiveButton("Yes", delegate { MainActivity.db.deleteTransaction(accountPK, transactions[position].PK); });
                 builder.SetNegativeButton("Cancel", delegate { builder.Dispose(); });
                 builder.Show();
             }
             Console.WriteLine(transactions[position].Title + " | " + arg1.Item.TitleFormatted + " selected");
         };
         menu.Show();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 3
0
        //We give the item and the index since the public "YoutubePlaylists" array is not updated yet.
        private void YoutubeItemSynced(PlaylistItem item, int syncedPlaylistIndex)
        {
            /*The display order is
             *  - Local Header
             *  - Local Playlists
             *  - Youtube Header
             *  - Synced Playlists
             *  Since local header and local playlists are both contained in the "LocalPlaylists" array, to get the position of the syncedPlaylist,
             *  we need to sum the LocalPlaylists count (this sum get the position of the youtube header) and then we add the syncedPlaylistIndex.*/
            PlaylistHolder holder = (PlaylistHolder)ListView.FindViewHolderForAdapterPosition(LocalPlaylists.Count + syncedPlaylistIndex);

            if (holder != null)
            {
                holder.Owner.Text = item.Owner;
                Picasso.With(Application.Context).Load(item.ImageURL).Placeholder(Resource.Color.background_material_dark).Resize(400, 400).CenterCrop().Into(holder.AlbumArt);

                if (item.HasWritePermission)
                {
                    holder.edit.Visibility = ViewStates.Visible;
                }

                holder.sync.SetImageResource(Resource.Drawable.Sync);
                holder.sync.Visibility        = ViewStates.Visible;
                holder.SyncLoading.Visibility = ViewStates.Gone;
            }
        }
Esempio n. 4
0
        protected override (int First, int Center, int Last) GetVisibleItemsIndex(RecyclerView recyclerView)
        {
            var firstVisibleItemIndex = -1;
            var lastVisibleItemIndex  = -1;
            var centerItemIndex       = -1;

            if (recyclerView.GetLayoutManager() is LinearLayoutManager linearLayoutManager)
            {
                var firstView  = recyclerView.FindViewHolderForAdapterPosition(linearLayoutManager.FindFirstVisibleItemPosition());
                var lastView   = recyclerView.FindViewHolderForAdapterPosition(linearLayoutManager.FindLastVisibleItemPosition());
                var centerView = recyclerView.GetCenteredView();
                firstVisibleItemIndex = GetIndexFromTemplatedCell(firstView?.ItemView);
                lastVisibleItemIndex  = GetIndexFromTemplatedCell(lastView?.ItemView);
                centerItemIndex       = GetIndexFromTemplatedCell(centerView);
            }

            return(firstVisibleItemIndex, centerItemIndex, lastVisibleItemIndex);
        }
Esempio n. 5
0
        public void SetCellTheme(IViewTheme viewTheme, ITextViewTheme textViewTheme, int index)
        {
            _selectedCell = index;

            var holder = RecyclerView.FindViewHolderForAdapterPosition(index) as ToolsViewHolder; // TODO: problem in indecies

            // TODO: while searching after click on item holder is null -> NullRefException
            SetCellTheme(holder, viewTheme, textViewTheme);
        }
        private void ParentProduct_Click(object sender, EventArgs e)
        {
            if (!GlobalVariables.mIsCheckoutFragmentMultiSizeAddOpened)
            {
                GlobalVariables.mIsCheckoutFragmentMultiSizeAddOpened = true;
                int position = mRecyclerView.GetChildAdapterPosition((View)sender);

                TextView prodName = mRecyclerView.FindViewHolderForAdapterPosition(position).ItemView.FindViewById <TextView>(Resource.Id.txtProductName);
                TextView prodId   = mRecyclerView.FindViewHolderForAdapterPosition(position).ItemView.FindViewById <TextView>(Resource.Id.txtProductId);

                GlobalVariables.mCurrentSelectedItemNameMultiSize = prodName.Text;
                GlobalVariables.mCurrentSelectedItemIdMultiSize   = Convert.ToInt32(prodId.Text);

                Intent intent = new Intent(mSupportFragment.Context, typeof(CheckoutFragmentMultiSizeAdd));
                intent.AddFlags(ActivityFlags.NoAnimation);
                mSupportFragment.StartActivityForResult(intent, 8);

                //Intent intent = new Intent(mCheckoutContext, typeof(CheckoutFragmentMultiSizeAdd));
                //intent.AddFlags(ActivityFlags.NoAnimation);
                //((Activity)mCheckoutContext).StartActivityForResult(intent, 8); //callback not working used global var instead to prevent double click
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            rootView      = (LinearLayout)inflater.Inflate(Resource.Layout.reading_and_writing_fragment, container, false);
            mRecyclerView = rootView.FindViewById <RecyclerView>(Resource.Id.recyclerView);

            mRecyclerView.HasFixedSize = true;

            mLayoutManager = new LinearLayoutManager(Activity);
            mRecyclerView.SetLayoutManager(mLayoutManager);

            mAdapter = new RecyclerViewAdapter(App.db.GetAllImages(), Activity);
            mRecyclerView.SetAdapter(mAdapter);

            if (App.CurrentImagePossition != -1)
            {
                if (!(mLayoutManager.FindFirstVisibleItemPosition() <= App.CurrentImagePossition && mLayoutManager.FindLastVisibleItemPosition() >= App.CurrentImagePossition))
                {
                    Activity.RunOnUiThread(() =>
                    {
                        mLayoutManager.ScrollToPositionWithOffset(App.CurrentImagePossition, 20);
                    });;
                }
                //StartPostponedEnterTransition();
            }
            else
            {
                //StartPostponedEnterTransition();
            }

            mAdapter.ItemClick += delegate
            {
                var view = mRecyclerView.FindViewHolderForAdapterPosition(mAdapter.ClickedPosition) as RecyclerViewHolder;

                var tmp = view.Slika.TransitionName;
                GuessingImageFragment gif = new GuessingImageFragment(mAdapter.clickedImage.Id);
                //gif.SharedElementEnterTransition = new AutoTransition();
                //gif.EnterTransition = new Fade();
                //setExitTransition(new Fade());
                Activity.FragmentManager.BeginTransaction()
                .Replace(App.fragmentContainer.Id, gif, "guessing")
                .AddSharedElement(view.Slika, mAdapter.clickedImage.Name)
                .AddToBackStack(null)
                .Commit();
                App.CurrentFragment = gif;
            };

            return(rootView);
        }
Esempio n. 8
0
        ARect GetViewRect(int index)
        {
            var holder = _recyclerView.FindViewHolderForAdapterPosition(index);
            var view   = holder?.ItemView;

            if (view == null)
            {
                return(null);
            }

            var viewRect = new ARect();

            view.GetGlobalVisibleRect(viewRect);

            return(viewRect);
        }
Esempio n. 9
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            bool success = true;

            for (int i = 0; i < Measurments.Count; i++)
            {
                var view        = recycler.FindViewHolderForAdapterPosition(i);
                var inputLayout = ((CachingViewHolder)view).FindCachedViewById <TextInputLayout>(Resource.Id.ValueInputLayout);
                var editText    = ((CachingViewHolder)view).FindCachedViewById <TextInputEditText>(Resource.Id.ValueEditText);
                if (editText.Text == "" || editText.Text == null)
                {
                    inputLayout.Error = "Field can't be empty!";
                    success           = false;
                }
                else if (!float.TryParse(editText.Text, out _))
                {
                    inputLayout.Error = "Field can only be number!";
                    success           = false;
                }
                else
                {
                    inputLayout.Error = null;
                    Measurments[i]    = editText.Text;
                }
            }

            if (success)
            {
                var values = new Dictionary <string, float>();

                for (int i = 0; i < Measurments.Count - 2; i++)
                {
                    values[Boiler.Template[i]] = float.Parse(Measurments[i + 2]);
                }

                var measurement = new Measurment(Boiler.Id)
                {
                    Temperature = float.Parse(Measurments[0]),
                    Level       = float.Parse(Measurments[1]),
                    Values      = values
                };

                Dismiss();
                completionSource.TrySetResult(measurement);
            }
        }
        void ShowCardMissingNameAlert()
        {
            var builder = new AlertDialog.Builder(Activity);

            builder.SetTitle(Strings.Alerts.card_missing_name);
            builder.SetCancelable(true);

            builder.SetPositiveButton(Strings.Basic.ok, (senderAlert, args) =>
            {
                var cell = RecyclerView.FindViewHolderForAdapterPosition(0) as CardCell;
                cell.FocusOnName();
            });
            builder.SetNegativeButton(Strings.Basic.delete_card, delegate
            {
                var activity = Activity as BaseActivity;
                activity?.HideKeyboard();
                activity?.PopFragmentOver();
            });
            builder.Show();
        }
Esempio n. 11
0
 //EVENT - triggered when an account is long clicked
 void OnItemLongClick(object sender, int position)
 {
     //display a popup menu
     try{
         Android.Widget.PopupMenu menu = new Android.Widget.PopupMenu(this, mRecyclerView.FindViewHolderForAdapterPosition(position).ItemView, Android.Views.GravityFlags.Right);
         menu.Inflate(Resource.Layout.popup_menu_account);
         menu.MenuItemClick += (s1, arg1) =>
         {
             //edit is selected from the popup menu
             if (arg1.Item.TitleFormatted.ToString() == "Edit")
             {
                 //Toast.MakeText(this, accounts[position].Name + " | " + arg1.Item.TitleFormatted + " selected", ToastLength.Short).Show();
                 var intent = new Intent(this, typeof(Add_Edit_Account));
                 intent.PutExtra("Type", "Edit");     //inform this is account edit
                 intent.PutExtra("AccountPK", accounts[position].PK);
                 StartActivity(intent);
             }
             //delete is selected from the popup menu
             else if (arg1.Item.TitleFormatted.ToString() == "Delete")
             {
                 //display a confirmation popup box with yes or cancel options
                 AlertDialog.Builder builder;
                 builder = new AlertDialog.Builder(this);
                 builder.SetTitle("Delete?");
                 builder.SetMessage("Are you sure you want to delete the account: " + accounts[position].Name);
                 builder.SetCancelable(false);
                 //when yes is selected - delete account
                 builder.SetPositiveButton("Yes", delegate { db.deleteAccount(accounts[position].PK); });
                 //when cancel is selected - close confirmation box with no action
                 builder.SetNegativeButton("Cancel", delegate { builder.Dispose(); });
                 builder.Show();
             }
             Console.WriteLine(accounts[position].Name + " | " + arg1.Item.TitleFormatted + " selected");
         };
         menu.Show();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 12
0
        private bool OnTouch(MotionEvent e)
        {
            if (_swipedPos < 0)
            {
                return(false);
            }
            var point = new Point((int)e.RawX, (int)e.RawY);

            RecyclerView.ViewHolder swipedViewHolder = _recyclerView.FindViewHolderForAdapterPosition(_swipedPos);
            View swipedItem = swipedViewHolder.ItemView;
            Rect rect       = new Rect();

            swipedItem.GetGlobalVisibleRect(rect);

            if (e.Action == MotionEventActions.Down || e.Action == MotionEventActions.Up || e.Action == MotionEventActions.Move)
            {
                if (rect.Top < point.Y && rect.Bottom > point.Y)
                {
                    //System.Diagnostics.Debug.WriteLine("Click should happen");
                    try
                    {
                        _gestureDetector.OnTouchEvent(e);
                    }
                    catch (Exception)
                    {
                        //for some reason it crashes with a disposed ex..
                        SetGestureDetector();
                        _gestureDetector.OnTouchEvent(e);
                    }
                }
                else
                {
                    //System.Diagnostics.Debug.WriteLine("No click..");
                    _recoverQueue.Enqueue(_swipedPos);
                    _swipedPos = -1;
                    RecoverSwipedItem();
                }
            }
            return(false);
        }
        public override void OnDetachedFromRecyclerView(RecyclerView recyclerView)
        {
            base.OnDetachedFromRecyclerView(recyclerView);
            if (workbench.isEditable)
            {
                dragger.AttachToRecyclerView(null);
            }

            for (int i = 0; i < ItemCount; i++)
            {
                var vh = recyclerView.FindViewHolderForAdapterPosition(i);
                if (vh is SwipeRecyclerView.ViewHolder)
                {
                    var svh = vh as SwipeRecyclerView.ViewHolder;
                    svh.Unbind();
                }
                else if (vh is RecordViewHolder)
                {
                    var rvh = vh as RecordViewHolder;
                    rvh.Unbind();
                }
            }
        }
Esempio n. 14
0
 private void ResolveItem(int adapterPosition)
 {
     InitViewForItem((SwipeViewHolder <M>)_recyclerView.FindViewHolderForAdapterPosition(adapterPosition));
 }
        public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (resultCode == (int)Android.App.Result.Ok)
            {
                if (data == null)
                {
                    return;
                }

                using (var bitmap = MediaStore.Images.Media.GetBitmap(Activity.ContentResolver, data.Data))
                {
                    var bytes = ImageUtils.ImagetoByteArray(bitmap, 100);
                    if (bytes == null)
                    {
                        return;
                    }

                    var cell = RecyclerView.FindViewHolderForAdapterPosition(0) as CardCell;
                    if (cell == null)
                    {
                        return;
                    }

                    var me = RealmUserServices.GetMe(false);

                    if (requestCode == SelectUserImagePhotoRequestCode)
                    {
                        var imageView = cell.GetUserImageView();
                        imageView.SetImageResource(Resource.Drawable.ic_noprofilewhite);
                        imageView.ShowLoadingIndicators();


                        var localUrl  = Shared.SelectedCard.LocalHeaderURL;
                        var remoteUrl = Shared.SelectedCard.RemoteHeaderURL;
                        var fileName  = "Header.png";

                        S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () =>
                        {
                            if (Activity == null)
                            {
                                return;
                            }
                            Activity.RunOnUiThread(async() =>
                            {
                                await ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All);//.InvalidateCacheEntryAsync(me.RemoteProfileImageURL, FFImageLoading.Cache.CacheType.All);
                                imageView.SetImage(Shared.SelectedCard.GetRemoteHeaderUrlCached(), Resource.Drawable.ic_noprofilewhite, Resource.Drawable.ic_noprofilewhite, Shared.SelectedCard.RemoteHeaderURL, WebImageView.DefaultCircleTransformation);
                            });
                        }, null);

                        return;
                    }

                    if (requestCode == SelectCompanyLogoPhotoRequestCode)
                    {
                        var imageView = cell.GetCompanyLogoImageView();
                        imageView.SetImageResource(Resource.Drawable.ic_buildings);
                        imageView.ShowLoadingIndicators();

                        var localUrl  = Shared.SelectedCard.LocalLogoURL;
                        var remoteUrl = Shared.SelectedCard.RemoteLogoURL;
                        var fileName  = "Logo.png";

                        S3Utils.UploadPhoto(bytes, localUrl, remoteUrl, fileName, () =>
                        {
                            if (Activity == null)
                            {
                                return;
                            }
                            Activity.RunOnUiThread(async() =>
                            {
                                await ImageService.Instance.InvalidateCacheAsync(FFImageLoading.Cache.CacheType.All);//.InvalidateCacheEntryAsync(me.RemoteProfileImageURL, FFImageLoading.Cache.CacheType.All);
                                imageView.SetImage(Shared.SelectedCard.GetRemoteLogoUrlCached(), Resource.Drawable.ic_buildings, Resource.Drawable.ic_buildings, Shared.SelectedCard.RemoteLogoURL, WebImageView.DefaultCircleTransformation);
                            });
                        }, null);

                        return;
                    }
                };
            }
        }
        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));
        }
Esempio n. 17
0
        void OnItemLongClick(object sender, int position)
        {
            var selected = listItems[position];

            Android.Support.V7.Widget.PopupMenu menu = new Android.Support.V7.Widget.PopupMenu(this, mRecyclerView.FindViewHolderForAdapterPosition(position).ItemView);

            currentItem = selected;

            var currentIndex = position;

            menu.Inflate(Resource.Menu.PopupMenu);


            var toastText = Resources.GetText(Resource.String.onDeletion);

            menu.MenuItemClick += (s1, arg1) =>
            {
                switch (arg1.Item.TitleFormatted.ToString())
                {
                case "Delete item":

                    listItems.Remove(selected);
                    mAdapter.NotifyDataSetChanged();

                    if (shareActionProvider != null)
                    {
                        shareActionProvider.SetShareIntent(CreateShareIntent());
                    }
                    Toast.MakeText(this, selected.title + toastText, ToastLength.Short).Show();

                    break;

                case "Poista ostos":

                    listItems.Remove(selected);
                    mAdapter.NotifyDataSetChanged();

                    if (shareActionProvider != null)
                    {
                        shareActionProvider.SetShareIntent(CreateShareIntent());
                    }
                    Toast.MakeText(this, selected.title + toastText, ToastLength.Short).Show();

                    break;

                case "Modify item":

                    Android.Support.V7.App.AlertDialog.Builder builder = new Android.Support.V7.App.AlertDialog.Builder(this);
                    LayoutInflater inflater   = this.LayoutInflater;
                    View           dialogView = inflater.Inflate(Resource.Layout.editItemDialog, null);
                    builder.SetView(dialogView);
                    var titleText  = Resources.GetText(Resource.String.modifyItem);
                    var cancelText = Resources.GetText(Resource.String.cancelText);

                    EditText edt = (EditText)dialogView.FindViewById(Resource.Id.edit1);
                    edt.Text = currentItem.title;

                    builder.SetTitle(titleText + " " + currentItem.title);
                    builder.SetPositiveButton("Ok", (senderAlert, args) =>
                    {
                        listItems[currentIndex].title = edt.Text;
                        mAdapter.NotifyDataSetChanged();
                    });

                    builder.SetNegativeButton(cancelText, (senderAlert, args) =>
                    {
                    });

                    Dialog dialog = builder.Create();
                    dialog.Show();
                    break;

                case "Muokkaa ostosta":

                    Android.Support.V7.App.AlertDialog.Builder builderSuomi = new Android.Support.V7.App.AlertDialog.Builder(this);
                    LayoutInflater inflaterSuomi   = this.LayoutInflater;
                    View           dialogViewSuomi = inflaterSuomi.Inflate(Resource.Layout.editItemDialog, null);
                    builderSuomi.SetView(dialogViewSuomi);
                    var titleTextSuomi  = Resources.GetText(Resource.String.modifyItem);
                    var cancelTextSuomi = Resources.GetText(Resource.String.cancelText);

                    EditText edtSuomi = (EditText)dialogViewSuomi.FindViewById(Resource.Id.edit1);
                    edtSuomi.Text = currentItem.title;

                    builderSuomi.SetTitle(titleTextSuomi + " " + currentItem.title);
                    builderSuomi.SetPositiveButton("Ok", (senderAlert, args) =>
                    {
                        listItems[currentIndex].title = edtSuomi.Text;
                        mAdapter.NotifyDataSetChanged();
                    });

                    builderSuomi.SetNegativeButton(cancelTextSuomi, (senderAlert, args) =>
                    {
                    });

                    Dialog dialogSuomi = builderSuomi.Create();
                    dialogSuomi.Show();
                    break;

                case "Take photo":
                    if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.Camera) != (int)Permission.Granted ||
                        ActivityCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != (int)Permission.Granted)
                    {
                        // Camera permission has not been granted
                        RequestPhotoPermissions();
                    }
                    else
                    {
                        Intent intent = new Intent(MediaStore.ActionImageCapture);

                        App._file = new File(App._dir, String.Format("myPhoto_{0}.jpg", Guid.NewGuid()));

                        intent.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file));

                        StartActivityForResult(intent, requestImageCapture);
                    }
                    break;

                case "Ota valokuva":
                    if (ActivityCompat.CheckSelfPermission(this, Manifest.Permission.Camera) != (int)Permission.Granted ||
                        ActivityCompat.CheckSelfPermission(this, Manifest.Permission.WriteExternalStorage) != (int)Permission.Granted)
                    {
                        // Camera permission has not been granted
                        RequestPhotoPermissions();
                    }
                    else
                    {
                        Intent intentSecond = new Intent(MediaStore.ActionImageCapture);

                        App._file = new File(App._dir, String.Format("myPhoto_{0}.jpg", Guid.NewGuid()));

                        intentSecond.PutExtra(MediaStore.ExtraOutput, Uri.FromFile(App._file));

                        StartActivityForResult(intentSecond, requestImageCapture);
                    }
                    break;

                case "Get image from gallery":
                    var galleryIntent = new Intent(Intent.ActionOpenDocument);
                    galleryIntent.AddCategory(Intent.CategoryOpenable);
                    galleryIntent.SetType("image/*");
                    StartActivityForResult(galleryIntent, pickImageId);
                    break;

                case "Hae kuva kuvagalleriasta":
                    var galleryIntentSecond = new Intent(Intent.ActionOpenDocument);
                    galleryIntentSecond.AddCategory(Intent.CategoryOpenable);
                    galleryIntentSecond.SetType("image/*");
                    StartActivityForResult(galleryIntentSecond, pickImageId);
                    break;

                case "Cancel":
                    break;

                case "Peruuta":
                    break;
                }
            };

            // Android 4 now has the DismissEvent
            menu.DismissEvent += (s2, arg2) =>
            {
                System.Console.WriteLine("menu dismissed");
            };
            menu.Show();
        }
Esempio n. 18
0
        private static void ShowPopupMenu(object sender, ListItemEventArgs args, RecyclerView rv, AddContactsScherm acs)
        {
            ListItemAdapter adapter = (ListItemAdapter) sender;
            adapter.SelectedItem = adapter.Items[args.Position];

            PopupMenu menu = new PopupMenu(acs, rv.FindViewHolderForAdapterPosition(args.Position).ItemView);
            menu.Menu.Add(0, 0, 0, "Add this user");
            menu.SetOnMenuItemClickListener(acs);
            menu.SetOnDismissListener(acs);
            menu.Show();
        }
Esempio n. 19
0
        private static void ShowPopupMenu(object sender, ListItemEventArgs args, RecyclerView rv, ContactFragment cf)
        {
            ListItemAdapter adapter = (ListItemAdapter) sender;
            adapter.SelectedItem = adapter.Items[args.Position];

            PopupMenu menu = new PopupMenu(cf.Activity, rv.FindViewHolderForAdapterPosition(args.Position).ItemView);
            menu.Menu.Add(0, 0, 0, "Remove this contact");
            menu.SetOnMenuItemClickListener(cf);
            menu.SetOnDismissListener(cf);
            menu.Show();
        }