//Event More >> Show Menu (CopeLink , Share)
        private void ImageMoreOnClick(object sender, EventArgs eventArgs)
        {
            try
            {
                var ctw   = new ContextThemeWrapper(this, Resource.Style.PopupMenuStyle);
                var popup = new PopupMenu(ctw, ImageMore);
                popup.MenuInflater.Inflate(Resource.Menu.MoreCommunities_NotEdit_Menu, popup.Menu);
                popup.Show();
                popup.MenuItemClick += (o, e) =>
                {
                    try
                    {
                        var Id = e.Item.ItemId;
                        switch (Id)
                        {
                        case Resource.Id.menu_CopeLink:
                            OnCopyLink_Button_Click();
                            break;

                        case Resource.Id.menu_Share:
                            OnShare_Button_Click();
                            break;
                        }
                    }
                    catch (Exception exception)
                    {
                        Crashes.TrackError(exception);
                    }
                };
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Esempio n. 2
0
        private void InitHandlers(TaskListViewHolder vh)
        {
            vh.CheckBox.Click += (s, e) =>
            {
                CheckboxClickHandler?.Invoke(this, vh.AdapterPosition);
            };

            var toolbar = vh.ItemView.FindViewById <ImageView>(Resource.Id.task_toolbar);

            toolbar.Click += (sender, args) =>
            {
                var popup = new PopupMenu(_context, toolbar);

                popup.Inflate(Resource.Menu.menu_task);
                popup.MenuItemClick += (o, eventArgs) =>
                {
                    if (eventArgs.Item.ItemId == Resource.Id.userTask_task_delete)
                    {
                        InvokeDeleteHandler(vh.AdapterPosition);
                    }
                    else if (eventArgs.Item.ItemId == Resource.Id.userTask_task_edit)
                    {
                        EditHandler?.Invoke(this, vh.AdapterPosition);
                    }
                };
                popup.Show();
            };
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = new CategoryPickerView(this.Activity, SelectedLocation);

            //This simply opens up the favorite category fragment
            ((MainActivity)Activity).OptionItemSelected += (sender, e) =>
            {
                if (e.Item.TitleFormatted.ToString() == "Favorite")
                {
                    var transaction = Activity.SupportFragmentManager.BeginTransaction();
                    FavoriteCategoriesFragment favoriteFragment = new FavoriteCategoriesFragment();
                    favoriteFragment.SelectedLocation = SelectedLocation;

                    transaction.Replace(Resource.Id.frameLayout, favoriteFragment);
                    transaction.AddToBackStack(null);
                    transaction.Commit();
                }
            };

            //This handles favoriting and unfavoriting categories
            view.CategoryLongClick += (sender, e) =>
            {
                var menu           = new Android.Support.V7.Widget.PopupMenu(this.Activity, e.SelectedView);
                var presentAlready = MainActivity.databaseConnection.FavoriteCategoryAlreadyPresent(e.Selected.Key);

                if (presentAlready)
                {
                    menu.Inflate(Resource.Menu.UnfavoriteMenu);
                }
                else
                {
                    menu.Inflate(Resource.Menu.FavoriteMenu);
                }

                menu.Show();
                menu.MenuItemClick += async(s, ev) =>
                {
                    if (presentAlready)
                    {
                        await MainActivity.databaseConnection.DeleteFavoriteCategoryAsync(e.Selected.Key);
                    }
                    else
                    {
                        await MainActivity.databaseConnection.AddNewFavoriteCategoryAsync(e.Selected.Key, e.Selected.Value);
                    }

                    if (MainActivity.databaseConnection.StatusCode == Models.codes.ok)
                    {
                        Toast.MakeText(this.Activity, $"Successfully (un)favorited: {e.Selected.Value}", ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(this.Activity, $"Something went wrong, we're sorry!", ToastLength.Short).Show();
                    }
                };
            };

            return(view);
        }
Esempio n. 4
0
 /// <summary>
 /// Handles the actions when an adapter item is longclicked
 /// </summary>
 /// <param name="sender">the adapter item</param>
 /// <param name="e">the event args</param>
 void Adapter_ItemLongClick(object sender, RecyclerClickEventArgs e)
 {
     selectedItem = e.Position;
     contextMenu  = new PopupMenu(this.Context, e.View);
     contextMenu.Inflate(Resource.Menu.browse_recipe_context_menus);
     contextMenu.MenuItemClick += OnContextMenuItemClick;
     contextMenu.Show();
 }
Esempio n. 5
0
        private void ShowSortPopup(View sortAnchor)
        {
            var popup = new PopupMenu(this, sortAnchor);

            popup.MenuInflater.Inflate(Resource.Menu.idea_sort_menu, popup.Menu);
            popup.SetOnMenuItemClickListener(this);
            popup.Show();
        }
            public void OnClick(View v)
            {
                var popupMenu = new Android.Support.V7.Widget.PopupMenu(_context, v);

                popupMenu.Menu.Add(0, 0, 0, new Java.Lang.String(Mvx.Resolve <ILocalizationService>().GetLocalizableString(BasketConstants.RESX_NAME, "Basket_DeleteItem")));
                popupMenu.SetOnMenuItemClickListener(this);
                popupMenu.Show();
            }
        private void Adapter_OnMoreClicked(object sender, Alansa.Droid.Adapters.GenericViewHolder holder)
        {
            clickPos = holder.AdapterPosition;
            var anchor = holder.GetView <ImageView>("MoreVert");
            var popup  = new PopupMenu(this, anchor);

            popup.MenuInflater.Inflate(Resource.Menu.course_list_popup_menu, popup.Menu);
            popup.SetOnMenuItemClickListener(this);
            popup.Show();
        }
Esempio n. 8
0
        private void ShowPopupMenu(View overflow)
        {
            Android.Support.V7.Widget.PopupMenu popup
                = new Android.Support.V7.Widget.PopupMenu(_context, overflow);
            MenuInflater inflater = popup.MenuInflater;

            inflater.Inflate(Resource.Menu.MenuAlbum, popup.Menu);
            popup.MenuItemClick += Popup_MenuItemClick;
            popup.Show();
        }
Esempio n. 9
0
        void ShowRemovePopup(View view, int position)
        {
            Android.Support.V7.Widget.PopupMenu popupMenu = new Android.Support.V7.Widget.PopupMenu(_context, view);
            var menuOpts = popupMenu.Menu;

            popupMenu.Inflate(Resource.Layout.delete_photo_popup);

            popupMenu.MenuItemClick += (s1, arg1) =>
            {
                Photos.RemoveAt(position);
                this.NotifyDataSetChanged();
            };
            popupMenu.Show();
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = new CategoryPickerView(this.Activity, SelectedLocation);

            //This simply opens up the favorite category fragment
            ((MainActivity)Activity).OptionItemSelected += (sender, e) =>
            {
                if (e.Item.TitleFormatted.ToString() == "Favorite")
                {
                    var transaction = Activity.SupportFragmentManager.BeginTransaction();
                    FavoriteCategoriesFragment favoriteFragment = new FavoriteCategoriesFragment();
                    favoriteFragment.SelectedLocation = SelectedLocation;

                    transaction.Replace(Resource.Id.frameLayout, favoriteFragment);
                    transaction.AddToBackStack(null);
                    transaction.Commit();
                }
            };

            //This handles favoriting and unfavoriting categories
            view.CategoryLongClick += (sender, e) =>
            {
                var menu = new Android.Support.V7.Widget.PopupMenu(this.Activity, e.SelectedView);
                var presentAlready = MainActivity.databaseConnection.FavoriteCategoryAlreadyPresent(e.Selected.Key);

                if (presentAlready)
                    menu.Inflate(Resource.Menu.UnfavoriteMenu);
                else
                    menu.Inflate(Resource.Menu.FavoriteMenu);

                menu.Show();
                menu.MenuItemClick += async (s, ev) =>
                {
                    if (presentAlready)
                        await MainActivity.databaseConnection.DeleteFavoriteCategoryAsync(e.Selected.Key);
                    else
                        await MainActivity.databaseConnection.AddNewFavoriteCategoryAsync(e.Selected.Key, e.Selected.Value);

                    if (MainActivity.databaseConnection.StatusCode == Models.codes.ok)
                        Toast.MakeText(this.Activity, $"Successfully (un)favorited: {e.Selected.Value}", ToastLength.Short).Show();
                    else
                        Toast.MakeText(this.Activity, $"Something went wrong, we're sorry!", ToastLength.Short).Show();
                };
            };

            return view;
        }
Esempio n. 11
0
        private void FromButton_Click(object sender, EventArgs e)
        {
            PopupMenu menu = new PopupMenu(this, sender as View);

            menu.MenuItemClick += (s, a) =>
            {
                if (a.Item.ItemId == 0)
                {
                    UpdateAutoFrom();
                }
                else if (a.Item.ItemId == 1)
                {
                    fromTextView.RequestFocus();
                    fromTextView.ShowDropDown();
                    fromTextView.SelectAll();

                    fromTextView.PostDelayed(() =>
                    {
                        InputMethodManager inputMethodManager = GetSystemService(Context.InputMethodService) as InputMethodManager;
                        inputMethodManager.ShowSoftInput(fromTextView, ShowFlags.Forced);
                    }, 250);
                }
                else
                {
                    Stop stop = TramUrWayApplication.GetStop(a.Item.ItemId);
                    fromTextView.Text = stop.Name;
                }
            };

            // Auto: based on current location and favorites
            if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.AccessFineLocation) == Permission.Granted)
            {
                menu.Menu.Add(1, 0, 1, "Automatique").SetIcon(Resource.Drawable.ic_place);
            }

            // Favorite stops
            foreach (Stop stop in TramUrWayApplication.Config.FavoriteStops.GroupBy(s => s.Name).Select(g => g.First()))
            {
                menu.Menu.Add(1, stop.Id, 2, stop.Name);
            }

            // Other: focus the search box and trigger autocomplete
            menu.Menu.Add(1, 1, 3, "Autre ...");

            menu.Show();
        }
Esempio n. 12
0
        void ShowPopup(View view)
        {
            Android.Support.V7.Widget.PopupMenu popupMenu = new Android.Support.V7.Widget.PopupMenu(_context, view);
            var menuOpts = popupMenu.Menu;

            popupMenu.Inflate(Resource.Layout.camOrGalleryMenu);

            popupMenu.MenuItemClick += (s1, arg1) =>
            {
                if (_nativeMethods.AreStorageAndCamPermissionsGranted(_context))
                {
                    if (arg1.Item.TitleFormatted.ToString() == _context.GetString(Resource.String.takePhoto))
                    {
                        try
                        {
                            if (_pictureMethods.IsThereAnAppToTakePictures(_context))
                            {
                                PictureMethods.CameraOrGalleryIndicator = Constants.camera;
                                _pictureMethods.CreateDirectoryForPictures();
                                _pictureMethods.TakeAPicture(_context);
                            }
                        }
                        catch
                        {
                            Toast.MakeText(_context, TranslationHelper.GetString("failedToOpenTheCamera", _ci), ToastLength.Long).Show();
                        }
                    }
                    if (arg1.Item.TitleFormatted.ToString() == _context.GetString(Resource.String.uploadFromGallery))
                    {
                        PictureMethods.CameraOrGalleryIndicator = "gallery";
                        var imageIntent = new Intent();
                        imageIntent.SetType("image/*");
                        //imageIntent.SetType("file/*");
                        imageIntent.SetAction(Intent.ActionGetContent);
                        _context.StartActivityForResult(
                            Intent.CreateChooser(imageIntent, "Select photo"), 0);
                    }
                }
                else
                {
                    _nativeMethods.CheckStoragePermissions(_context);
                }
            };
            popupMenu.Show();
        }
Esempio n. 13
0
 public MainRecViewHolder(View itemView, Action <string> listener, Action <string> longListener, bool menu) : base(itemView)
 {
     TxtView        = ItemView.FindViewById <TextView>(Resource.Id.main_rec_txtview);
     TxtView.Click += (obj, sender) => listener(TxtView.Text);
     if (menu)
     {
         TxtView.LongClick += (obj, sened) =>
         {
             PopupMenu popupMenu = new PopupMenu(ItemView.Context, itemView);
             popupMenu.Inflate(Resource.Menu.popup_menu);
             popupMenu.MenuItemClick += (s1, arg1) =>
             {
                 longListener(TxtView.Text);
             };
             popupMenu.Show();
         };
     }
 }
Esempio n. 14
0
 private void BaseCrawlerTemplate(CrawlerDescriptorViewModel item, ICrawlerHolder holder)
 {
     holder.ViewModelProxy = item;
     holder.ClickSurface.SetOnClickCommand(ViewModel.SelectCrawlerDescriptorCommand, item);
     holder.ClickSurface.SetOnLongClickListener(new OnLongClickListener(view =>
     {
         var menu = new PopupMenu(Activity, holder.ItemView);
         menu.Menu.Add(AppResources.Generic_Delete);
         menu.MenuItemClick += (sender, args) =>
         {
             if (args.Item.ItemId == 0)
             {
                 ViewModel.RemoveDescriptorCommand.Execute(item);
             }
         };
         menu.Show();
     }));
 }
Esempio n. 15
0
        private void MainActivity_Click(object sender, System.EventArgs e)
        {
            Android.Support.V7.Widget.PopupMenu popupMenu = new Android.Support.V7.Widget.PopupMenu(this, FindViewById <Button>(Resource.Id.contextMenuBn));

            popupMenu.Inflate(Resource.Menu.home);

            popupMenu.MenuItemClick += (s1, arg1) =>
            {
                if (arg1.Item.TitleFormatted.ToString() == "Change Destination")
                {
                    StartActivity(new Intent(this, typeof(ChangeDestination)));
                }
                if (arg1.Item.TitleFormatted.ToString() == "Filter")
                {
                    StartActivity(new Intent(this, typeof(FilterActivity)));
                }
                if (arg1.Item.TitleFormatted.ToString() == "Search")
                {
                    Toast.MakeText(this, "Search", ToastLength.Short).Show();
                    StartActivity(new Intent(this, typeof(FilterActivity)));
                }
                if (arg1.Item.TitleFormatted.ToString() == "Add Experience (for pals)")
                {
                    RecyclerViewSample.Activities.MapForChooseTourCoordsActivity.chosenLatOfExp = null;
                    RecyclerViewSample.Activities.MapForChooseTourCoordsActivity.chosenLngOfExp = null;
                    if (isLogined == false)
                    {
                        loginOrRegFragment.Show(fragmentManager, "fragmentManager");
                    }
                    else
                    {
                        StartActivity(new Intent(this, typeof(RecyclerViewSampl.AddNewTourActivity)));
                    }
                }
            };
            try
            {
                popupMenu.Show();
            }
            catch
            {
            }
        }
Esempio n. 16
0
            private void ViewHolder_Click3(object sender, EventArgs e)
            {
                Context wrapper = new ContextThemeWrapper(view.Context, Resource.Style.EditPopup);

                Android.Support.V7.Widget.PopupMenu popup = new Android.Support.V7.Widget.PopupMenu(wrapper, view.FindViewById <ImageButton>(Resource.Id.popup));
                popup.MenuInflater.Inflate(Resource.Menu.edit_menu, popup.Menu);
                popup.MenuItemClick += Popup_MenuItemClick;

                if (currentedit.failed)
                {
                    popup.Menu.FindItem(Resource.Id.restart_menu_item).SetVisible(true);
                }
                else
                {
                    popup.Menu.FindItem(Resource.Id.restart_menu_item).SetVisible(false);
                }

                //if (currentedit.progress > 97 && !currentedit.fail)
                //    popup.Menu.FindItem(Resource.Id.share_menu_item).SetVisible(true);
                //else
                //popup.Menu.FindItem(Resource.Id.share_menu_item).SetVisible(false);

                if (currentedit.code == null)
                {
                    popup.Menu.FindItem(Resource.Id.delete_menu_item).SetVisible(true);
                }
                else
                {
                    popup.Menu.FindItem(Resource.Id.delete_menu_item).SetVisible(false);
                }

                if (adpt.CurrentEvent == null)
                {
                    popup.Menu.FindItem(Resource.Id.copy_menu_item).SetVisible(false);
                }
                else
                {
                    popup.Menu.FindItem(Resource.Id.copy_menu_item).SetVisible(true);
                }


                popup.Show();
            }
Esempio n. 17
0
        void LayerButton_Click(object sender, EventArgs e)
        {
            var button = sender as ImageButton;
            var popup  = new Android.Support.V7.Widget.PopupMenu(this, button);

            popup.Inflate(Resource.Menu.layers);
            var menu = popup.Menu;
            var item = menu.GetItem(0);

            item.SetChecked(settings.PokemonEnabled);
            item = menu.GetItem(1);
            item.SetChecked(settings.GymsEnabled);
            item = menu.GetItem(2);
            item.SetChecked(settings.RaidsEnabled);
            item = menu.GetItem(3);
            item.SetChecked(settings.NinetyOnlyEnabled);
            popup.MenuItemClick += Popup_MenuItemClick;
            popup.Show();
        }
Esempio n. 18
0
 public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
 {
     if (position == ItemCount - 1 && !PlaylistTracks.instance.fullyLoadded)
     {
         int pad = MainActivity.instance.DpToPx(30);
         ((RecyclerView.LayoutParams)viewHolder.ItemView.LayoutParameters).TopMargin    = pad;
         ((RecyclerView.LayoutParams)viewHolder.ItemView.LayoutParameters).BottomMargin = pad;
     }
     else if (position == 0 && !PlaylistTracks.instance.useHeader)
     {
         View header = viewHolder.ItemView;
         header.FindViewById <TextView>(Resource.Id.headerNumber).Text = tracks.Count + " " + (tracks.Count < 2 ? MainActivity.instance.GetString(Resource.String.element) : MainActivity.instance.GetString(Resource.String.elements));
         if (!header.FindViewById <ImageButton>(Resource.Id.headerPlay).HasOnClickListeners)
         {
             header.FindViewById <ImageButton>(Resource.Id.headerPlay).Click    += (sender, e0) => { SongManager.PlayInOrder(tracks); };
             header.FindViewById <ImageButton>(Resource.Id.headerShuffle).Click += (sender, e0) =>
             {
                 SongManager.Shuffle(tracks);
             };
             header.FindViewById <ImageButton>(Resource.Id.headerMore).Click += (sender, e0) =>
             {
                 Android.Support.V7.Widget.PopupMenu menu = new Android.Support.V7.Widget.PopupMenu(MainActivity.instance, header.FindViewById <ImageButton>(Resource.Id.headerMore));
                 menu.Inflate(Resource.Menu.playlist_smallheader_more);
                 menu.SetOnMenuItemClickListener(PlaylistTracks.instance);
                 menu.Show();
             };
         }
     }
     else if (BaseCount == 0)
     {
         ((TextView)viewHolder.ItemView).Text = MainActivity.instance.GetString(Resource.String.playlist_empty);
     }
     else if (tracks != null)
     {
         OnBindViewHolder(viewHolder, tracks[position - ItemBefore]);
     }
     else
     {
         base.OnBindViewHolder(viewHolder, position);
     }
 }
Esempio n. 19
0
        //public async Task<bool> checkStoragePermissions()
        //{
        //    PermissionStatus permissionStatus = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Storage);

        //    if (permissionStatus != PermissionStatus.Granted)
        //    {
        //        var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Location });
        //        permissionStatus = results[Permission.Location];
        //        request_runtime_permissions();
        //        return false;
        //    }
        //    else
        //    {
        //        //Toast.MakeText(this, TranslationHelper.GetString("permissionsNeeded", ci), ToastLength.Long).Show();
        //        return true;
        //    }
        //}

        //private const int REQUEST_PERMISSION_CODE = 1000;
        //public void request_runtime_permissions()
        //{
        //    if (Build.VERSION.SdkInt >= Build.VERSION_CODES.M)
        //        if (
        //                     _context.CheckSelfPermission(Manifest.Permission.Camera) != Android.Content.PM.Permission.Granted
        //                  || _context.CheckSelfPermission(Manifest.Permission.ReadExternalStorage) != Android.Content.PM.Permission.Granted
        //                  || _context.CheckSelfPermission(Manifest.Permission.WriteExternalStorage) != Android.Content.PM.Permission.Granted)
        //        {
        //            ActivityCompat.RequestPermissions(_context, new String[]
        //            {
        //                        Manifest.Permission.Camera,
        //                        Manifest.Permission.ReadExternalStorage,
        //                        Manifest.Permission.WriteExternalStorage,
        //            }, REQUEST_PERMISSION_CODE);
        //        }
        //        else
        //        {
        //            ActivityCompat.RequestPermissions(_context, new String[]
        //            {
        //                        Manifest.Permission.Camera,
        //                        Manifest.Permission.ReadExternalStorage,
        //                        Manifest.Permission.WriteExternalStorage,
        //            }, REQUEST_PERMISSION_CODE);
        //        }
        //}

        void ShowAlternativePopup(View view, int position)
        {
            Android.Support.V7.Widget.PopupMenu popupMenu = new Android.Support.V7.Widget.PopupMenu(_context, view);
            var menuOpts = popupMenu.Menu;

            popupMenu.Inflate(Resource.Layout.photo_option);

            popupMenu.MenuItemClick += async(s1, arg1) =>
            {
                //if (_nativeMethods.AreStorageAndCamPermissionsGranted(_context))
                //{
                if (arg1.Item.TitleFormatted.ToString() == _context.GetString(Resource.String.edit))
                {
                    _personalImageViewHolder.ActivityIndicator.Visibility = ViewStates.Visible;
                    _personalImageViewHolder.ImageIv.Visibility           = ViewStates.Gone;

                    var uri = await _nativeMethods.ExportBitmapAsJpegAndGetUri(Photos[position]);

                    _personalImageViewHolder.ActivityIndicator.Visibility = ViewStates.Gone;
                    _personalImageViewHolder.ImageIv.Visibility           = ViewStates.Visible;
                    try
                    {
                        _personalDataActivity.StartCropActivity(uri, _context, position);
                    }
                    catch (Exception ex)
                    {
                    }
                }
                if (arg1.Item.TitleFormatted.ToString() == _context.GetString(Resource.String.removePhoto))
                {
                    Photos.RemoveAt(position);
                    this.NotifyDataSetChanged();
                }
                //}
                //else
                //_nativeMethods.CheckStoragePermissions(_context);
            };
            popupMenu.Show();
        }
Esempio n. 20
0
        private void ToButton_Click(object sender, EventArgs e)
        {
            PopupMenu menu = new PopupMenu(this, sender as View);

            menu.MenuItemClick += (s, a) =>
            {
                if (a.Item.ItemId == 1)
                {
                    toTextView.RequestFocus();
                    toTextView.ShowDropDown();
                    toTextView.SelectAll();

                    toTextView.PostDelayed(() =>
                    {
                        InputMethodManager inputMethodManager = GetSystemService(Context.InputMethodService) as InputMethodManager;
                        inputMethodManager.ShowSoftInput(toTextView, ShowFlags.Forced);
                    }, 250);
                }
                else
                {
                    Stop stop = TramUrWayApplication.GetStop(a.Item.ItemId);
                    toTextView.Text = stop.Name;
                }
            };

            // Favorite stops
            foreach (Stop stop in TramUrWayApplication.Config.FavoriteStops.GroupBy(s => s.Name).Select(g => g.First()))
            {
                menu.Menu.Add(1, stop.Id, 2, stop.Name);
            }

            // Other: focus the search box and trigger autocomplete
            menu.Menu.Add(1, 1, 3, "Autre ...");

            menu.Show();
        }
Esempio n. 21
0
        public void Initialize(Movies_AdapterViewHolder holder, Get_Movies_Object.Movie movie)
        {
            try
            {
                var CoverSplit     = movie.cover.Split('/').Last();
                var getImage_Cover = IMethods.MultiMedia.GetMediaFrom_Disk(IMethods.IPath.FolderDiskMovie, CoverSplit);
                if (getImage_Cover != "File Dont Exists")
                {
                    if (holder.VideoImage.Tag?.ToString() != "loaded")
                    {
                        ImageServiceLoader.Load_Image(holder.VideoImage, "ImagePlacholder.jpg", getImage_Cover);
                        holder.VideoImage.Tag = "loaded";
                    }
                }
                else
                {
                    if (holder.VideoImage.Tag?.ToString() != "loaded")
                    {
                        IMethods.MultiMedia.DownloadMediaTo_DiskAsync(IMethods.IPath.FolderDiskMovie, movie.cover);
                        ImageServiceLoader.Load_Image(holder.VideoImage, "ImagePlacholder.jpg", movie.cover);
                        holder.VideoImage.Tag = "loaded";
                    }
                }

                string name = IMethods.Fun_String.DecodeString(IMethods.Fun_String.DecodeStringWithEnter(movie.name));
                holder.Txt_Title.Text       = name;
                holder.Txt_Description.Text = IMethods.Fun_String.SubStringCutOf(movie.description, 50);
                holder.Txt_duration.Text    = movie.duration + " " + Activity_Context.GetText(Resource.String.Lbl_Min);
                holder.Txt_ViewsCount.Text  = movie.views + " " + Activity_Context.GetText(Resource.String.Lbl_Views);

                IMethods.Set_TextViewIcon("1", holder.MenueView, IonIcons_Fonts.AndroidMoreVertical);

                if (!holder.MenueView.HasOnClickListeners)
                {
                    holder.MenueView.Click += (sender, args) =>
                    {
                        try
                        {
                            var ctw   = new ContextThemeWrapper(Activity_Context, Resource.Style.PopupMenuStyle);
                            var popup = new PopupMenu(ctw, holder.MenueView);
                            popup.MenuInflater.Inflate(Resource.Menu.MoreCommunities_NotEdit_Menu, popup.Menu);
                            popup.Show();
                            popup.MenuItemClick += (o, eventArgs) =>
                            {
                                var Id = eventArgs.Item.ItemId;
                                switch (Id)
                                {
                                case Resource.Id.menu_CopeLink:
                                    OnCopeLink_Button_Click(movie);
                                    break;

                                case Resource.Id.menu_Share:
                                    OnShare_Button_Click(movie);
                                    break;
                                }
                            };
                        }
                        catch (Exception e)
                        {
                            Crashes.TrackError(e);
                        }
                    }
                }
                ;
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
            }
        }
Esempio n. 22
0
 void PopupMenu.IOnDismissListener.OnDismiss(PopupMenu menu)
 {
     _adapter.SelectedItem = null;
 }
Esempio n. 23
0
        private void ShowPopupMenu(int itemPosition)
        {
            _participantsAdapter.SelectedItem = _participantsAdapter.Items[itemPosition];

            PopupMenu menu = new PopupMenu(this, _participantsRecyclerView.FindViewHolderForAdapterPosition(itemPosition).ItemView);
            menu.SetOnMenuItemClickListener(this);
            menu.SetOnDismissListener(this);
            menu.Inflate(Resource.Menu.ParticipantsPopup);
            menu.Show();
        }
Esempio n. 24
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. 25
0
 public void OnDismiss(PopupMenu menu)
 {
     _participantsAdapter.SelectedItem = null;
 }
Esempio n. 26
0
 public override void OnDismiss(PopupMenu menu)
 {
     Adapter.SelectedItem = null;
 }
Esempio n. 27
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            View          itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.activity_gpx, parent, false);
            GPXViewHolder vh       = new GPXViewHolder(itemView, OnClick);

            vh.img_more.Click += (o, e) =>
            {
                Android.Support.V7.Widget.PopupMenu popup = new Android.Support.V7.Widget.PopupMenu(parent.Context, vh.img_more);
                popup.Inflate(Resource.Menu.menu_gpx);

                popup.MenuItemClick += async(s, args) =>
                {
                    switch (args.Item.ItemId)
                    {
                    case Resource.Id.gpx_menu_followroute:
                        Log.Information($"Follow route '{vh.Name.Text}'");

                        //Get the route
                        var      route    = RouteDatabase.GetRouteAsync(vh.Id).Result;
                        GpxClass gpx      = GpxClass.FromXml(route.GPX);
                        string   mapRoute = Import.GPXtoRoute(gpx.Routes[0]).Item1;

                        //Add GPX to Map
                        Import.AddRouteToMap(mapRoute);

                        //Center on imported route
                        var   bounds = gpx.GetBounds();
                        Point p      = Utils.Misc.CalculateCenter((double)bounds.maxlat, (double)bounds.minlon, (double)bounds.minlat, (double)bounds.maxlon);
                        var   sphericalMercatorCoordinate = SphericalMercator.FromLonLat(p.X, p.Y);
                        Fragment_map.mapControl.Navigator.CenterOn(sphericalMercatorCoordinate);

                        //Zoom
                        Fragment_map.mapControl.Navigator.ZoomTo(PrefsActivity.MaxZoom);

                        //Switch to map
                        MainActivity.SwitchFragment("Fragment_map", (FragmentActivity)parent.Context);

                        //Start recording
                        RecordTrack.StartTrackTimer();
                        NavigationView nav      = MainActivity.mContext.FindViewById <NavigationView>(Resource.Id.nav_view);
                        var            item_nav = nav.Menu.FindItem(Resource.Id.nav_recordtrack);
                        item_nav.SetTitle("Stop Recording");

                        break;

                    case Resource.Id.gpx_menu_showonmap:
                        Log.Information($"Show route on map '{vh.Name.Text}'");

                        //Get the route
                        var      route_1    = RouteDatabase.GetRouteAsync(vh.Id).Result;
                        GpxClass gpx_1      = GpxClass.FromXml(route_1.GPX);
                        string   mapRoute_1 = Import.GPXtoRoute(gpx_1.Routes[0]).Item1;

                        //Add GPX to Map
                        Import.AddRouteToMap(mapRoute_1);

                        //Center on imported route
                        var   bounds_1 = gpx_1.GetBounds();
                        Point p_1      = Utils.Misc.CalculateCenter((double)bounds_1.maxlat, (double)bounds_1.minlon, (double)bounds_1.minlat, (double)bounds_1.maxlon);
                        var   sphericalMercatorCoordinate_1 = SphericalMercator.FromLonLat(p_1.X, p_1.Y);
                        Fragment_map.mapControl.Navigator.CenterOn(sphericalMercatorCoordinate_1);

                        //Zoom
                        Fragment_map.mapControl.Navigator.ZoomTo(PrefsActivity.MaxZoom);

                        //Switch to map
                        MainActivity.SwitchFragment("Fragment_map", (FragmentActivity)parent.Context);

                        break;

                    case Resource.Id.gpx_menu_deleteroute:
                        Log.Information($"Delete route '{vh.Name.Text}'");

                        Show_Dialog msg1 = new Show_Dialog(MainActivity.mContext);
                        if (await msg1.ShowDialog($"Delete", $"Delete '{vh.Name.Text}' ?", Android.Resource.Attribute.DialogIcon, true, Show_Dialog.MessageResult.YES, Show_Dialog.MessageResult.NO) == Show_Dialog.MessageResult.YES)
                        {
                            _ = Data.RouteDatabase.DeleteRouteAsync(vh.Id);
                            mGpxData.RemoveAt(vh.AdapterPosition);
                            NotifyDataSetChanged();
                        }

                        break;

                    case Resource.Id.gpx_menu_reverseroute:
                        Log.Information($"Reverse route '{vh.Name.Text}'");

                        //Get the route
                        var      route_to_reverse = RouteDatabase.GetRouteAsync(vh.Id).Result;
                        GpxClass gpx_to_reverse   = GpxClass.FromXml(route_to_reverse.GPX);
                        gpx_to_reverse.Routes[0].rtept.Reverse();

                        //Reverse and save as new entry
                        route_to_reverse.Name        += " - reversed";
                        route_to_reverse.Description += " - reversed";
                        route_to_reverse.Id           = 0;
                        route_to_reverse.GPX          = gpx_to_reverse.ToXml();
                        RouteDatabase.SaveRouteAsync(route_to_reverse).Wait();

                        //Update RecycleView with new entry
                        int i = Fragment_gpx.mAdapter.mGpxData.Add(route_to_reverse);
                        Fragment_gpx.mAdapter.NotifyItemInserted(i);

                        break;

                    case Resource.Id.gpx_menu_exportgpx:
                        Log.Information($"Export route '{vh.Name.Text}'");

                        //Get the route
                        var      route_to_export = RouteDatabase.GetRouteAsync(vh.Id).Result;
                        GpxClass gpx_to_export   = GpxClass.FromXml(route_to_export.GPX);

                        /**/    //Ask user for name and folder
                        string gpxPath = Path.Combine(MainActivity.rootPath, "Exported -" + DateTime.Now.ToString("yyyy-MM-dd HH-mm") + ".gpx");
                        gpx_to_export.ToFile(gpxPath);

                        break;

                    case Resource.Id.gpx_menu_saveofflinemap:
                        Log.Information($"Download and save offline map '{vh.Name.Text}'");
                        Toast.MakeText(parent.Context, "save offline map " + vh.AdapterPosition.ToString(), ToastLength.Short).Show();
                        break;
                    }
                };

                popup.Show();
            };

            return(vh);
        }

        private void OnClick(int obj)
        {
            ItemClick?.Invoke(this, obj);
        }

        /*public static void MAdapter_ItemClick(object sender, int e)
         * {
         *  int gpxNum = e + 1;
         *  Toast.MakeText(MainActivity.mContext, "This is route/track number " + gpxNum, ToastLength.Short).Show();
         * }*/
    }
}
Esempio n. 28
0
 public void Include(Android.Support.V7.Widget.PopupMenu menu)
 {
     menu.MenuItemClick += (sender, e) => { menu.Show(); };
 }
Esempio n. 29
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();
        }
Esempio n. 30
0
 public abstract void OnDismiss(PopupMenu menu);
Esempio n. 31
0
 public override void OnDismiss(PopupMenu menu)
 {
     throw new NotImplementedException();
 }
Esempio n. 32
0
 public override void OnDismiss(PopupMenu menu)
 {
 }
Esempio n. 33
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                Position = position;

                var item = SubscriptionsList[Position];
                if (item != null)
                {
                    if (item.Type == ItemType.Channel)
                    {
                        if (viewHolder is SubscriptionsAdapterViewHolder holder)
                        {
                            if (ChannelAdapter == null)
                            {
                                ChannelAdapter = new ChannelAdapter(ActivityContext)
                                {
                                    ChannelList = new ObservableCollection <UserDataObject>()
                                };

                                LinearLayoutManager layoutManager = new LinearLayoutManager(ActivityContext, LinearLayoutManager.Horizontal, false);
                                holder.MRecycler.SetLayoutManager(layoutManager);
                                holder.MRecycler.GetLayoutManager().ItemPrefetchEnabled = true;

                                var sizeProvider = new FixedPreloadSizeProvider(10, 10);
                                var preLoader    = new RecyclerViewPreloader <UserDataObject>(ActivityContext, ChannelAdapter, sizeProvider, 10);
                                holder.MRecycler.AddOnScrollListener(preLoader);
                                holder.MRecycler.SetAdapter(ChannelAdapter);
                                ChannelAdapter.ItemClick += ChannelAdapterOnOnItemClick;
                            }

                            if (item.ChannelList.Count > 0)
                            {
                                if (ChannelAdapter.ChannelList.Count == 0)
                                {
                                    ChannelAdapter.ChannelList = new ObservableCollection <UserDataObject>(item.ChannelList);
                                    ChannelAdapter.NotifyDataSetChanged();
                                }
                                else if (ChannelAdapter.ChannelList != null && ChannelAdapter.ChannelList.Count != item.ChannelList.Count)
                                {
                                    ChannelAdapter.ChannelList = new ObservableCollection <UserDataObject>(item.ChannelList);
                                    ChannelAdapter.NotifyDataSetChanged();
                                }
                            }

                            holder.MainLinear.Visibility = ViewStates.Visible;
                            holder.MoreText.Visibility   = ChannelAdapter.ChannelList?.Count >= 5 ? ViewStates.Visible : ViewStates.Invisible;
                            holder.TitleText.Text        = ActivityContext.GetString(Resource.String.Lbl_All_Channal);
                        }
                    }
                    else if (item.Type == ItemType.Video)
                    {
                        if (viewHolder is VideoRowAdapterViewHolder videoRow)
                        {
                            GlideImageLoader.LoadImage(ActivityContext, item.VideoData.Thumbnail, videoRow.VideoImage, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                            videoRow.TxtDuration.Text = Methods.FunString.SplitStringDuration(item.VideoData.Duration);
                            videoRow.TxtTitle.Text    = Methods.FunString.DecodeString(item.VideoData.Title);

                            videoRow.TxtChannelName.Text = AppTools.GetNameFinal(item.VideoData.Owner);

                            videoRow.TxtViewsCount.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(item.VideoData.Views)) + " " + ActivityContext.GetText(Resource.String.Lbl_Views);

                            FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, videoRow.MenueView, IonIconsFonts.AndroidMoreVertical);

                            //Verified
                            if (item.VideoData.Owner.Verified == "1")
                            {
                                videoRow.IconVerified.Visibility = ViewStates.Visible;
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, videoRow.IconVerified, IonIconsFonts.CheckmarkCircled);
                            }
                            else
                            {
                                videoRow.IconVerified.Visibility = ViewStates.Gone;
                            }

                            if (!videoRow.MenueView.HasOnClickListeners)
                            {
                                videoRow.MenueView.Click += (sender, args) =>
                                {
                                    ContextThemeWrapper ctw   = new ContextThemeWrapper(ActivityContext, Resource.Style.PopupMenuStyle);
                                    PopupMenu           popup = new PopupMenu(ctw, videoRow.MenueView);
                                    popup.MenuInflater.Inflate(Resource.Menu.Video_More_Menue, popup.Menu);

                                    popup.Show();
                                    popup.MenuItemClick += (o, eventArgs) =>
                                    {
                                        try
                                        {
                                            var id = eventArgs.Item.ItemId;
                                            switch (id)
                                            {
                                            case Resource.Id.menu_AddWatchLater:
                                                LibrarySynchronizer.AddToWatchLater(item.VideoData);
                                                break;

                                            case Resource.Id.menu_AddPlaylist:
                                                LibrarySynchronizer.AddToPlaylist(item.VideoData);
                                                break;

                                            case Resource.Id.menu_Remove:
                                                OnMenuRemove_Click(item.VideoData);
                                                break;

                                            case Resource.Id.menu_Share:
                                                LibrarySynchronizer.ShareVideo(item.VideoData);
                                                break;

                                            case Resource.Id.menu_Report:
                                                LibrarySynchronizer.AddReportVideo(item.VideoData);
                                                break;
                                            }
                                        }
                                        catch (Exception exception)
                                        {
                                            Console.WriteLine(exception);
                                        }
                                    };
                                }
                            }
                            ;

                            //Set Badge on videos
                            AppTools.ShowGlobalBadgeSystem(videoRow.VideoType, item.VideoData);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Esempio n. 34
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is PlayListsAdapterViewHolder holder)
                {
                    if (AppSettings.FlowDirectionRightToLeft)
                    {
                        holder.RelativeLayoutMain.LayoutDirection = LayoutDirection.Rtl;
                        holder.TxtPlayListName.TextDirection      = TextDirection.Rtl;
                    }

                    var item = PlayListsList[position];
                    if (item != null)
                    {
                        GlideImageLoader.LoadImage(ActivityContext, item.Thumbnail, holder.VideoImage, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);

                        holder.TxtIcon.Visibility = ViewStates.Visible;
                        FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.TxtIcon, IonIconsFonts.IosFilm);

                        holder.TxtNumber.Text              = item.Count.ToString();
                        holder.TxtPlayListName.Text        = Methods.FunString.DecodeString(item.Name);
                        holder.TxtPlayListDescription.Text = Methods.FunString.DecodeString(item.Description);
                        holder.TxtViewsCount.Text          = item.Count + " " + ActivityContext.GetText(Resource.String.Lbl_Videos);

                        if (!holder.MenueView.HasOnClickListeners)
                        {
                            holder.MenueView.Click += (sender, args) =>
                            {
                                ContextThemeWrapper ctw   = new ContextThemeWrapper(ActivityContext, Resource.Style.PopupMenuStyle);
                                PopupMenu           popup = new PopupMenu(ctw, holder.MenueView);
                                popup.MenuInflater.Inflate(Resource.Menu.Playlist_menu, popup.Menu);
                                popup.Show();
                                popup.MenuItemClick += (o, eventArgs) =>
                                {
                                    try
                                    {
                                        var id = eventArgs.Item.ItemId;
                                        switch (id)
                                        {
                                        case Resource.Id.menu_EditPlaylist:
                                            LibrarySynchronizer.EditPlaylist(item);
                                            break;

                                        case Resource.Id.menu_Remove:
                                            OnMenuRemove_Click(item);
                                            break;
                                        }
                                    }
                                    catch (Exception exception)
                                    {
                                        Console.WriteLine(exception);
                                        ;
                                    }
                                };
                            }
                        }
                        ;
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Esempio n. 35
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is WatchLaterVideoRowAdapterViewHolder holder)
                {
                    var item = VideoList[position];
                    if (item != null)
                    {
                        if (item.Videos != null)
                        {
                            GlideImageLoader.LoadImage(ActivityContext, item.Videos?.VideoAdClass.Thumbnail, holder.VideoImage, ImageStyle.CenterCrop, ImagePlaceholders.Drawable);


                            holder.TxtDuration.Text = Methods.FunString.SplitStringDuration(item.Videos?.VideoAdClass.Duration);
                            holder.TxtTitle.Text    = Methods.FunString.DecodeString(item.Videos?.VideoAdClass.Title);

                            holder.TxtChannelName.Text = AppTools.GetNameFinal(item.Videos?.VideoAdClass.Owner);

                            holder.TxtViewsCount.Text = Methods.FunString.FormatPriceValue(Convert.ToInt32(item.Videos?.VideoAdClass.Views)) + " " + ActivityContext.GetText(Resource.String.Lbl_Views);

                            FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.MenueView, IonIconsFonts.AndroidMoreVertical);

                            //Verified
                            if (item.Videos?.VideoAdClass.Owner.Verified == "1")
                            {
                                holder.IconVerified.Visibility = ViewStates.Visible;
                                FontUtils.SetTextViewIcon(FontsIconFrameWork.IonIcons, holder.IconVerified, IonIconsFonts.CheckmarkCircled);
                            }
                            else
                            {
                                holder.IconVerified.Visibility = ViewStates.Gone;
                            }

                            if (!holder.MenueView.HasOnClickListeners)
                            {
                                holder.MenueView.Click += (sender, args) =>
                                {
                                    ContextThemeWrapper ctw   = new ContextThemeWrapper(ActivityContext, Resource.Style.PopupMenuStyle);
                                    PopupMenu           popup = new PopupMenu(ctw, holder.MenueView);
                                    if (Type == "MyChannel")
                                    {
                                        popup.MenuInflater.Inflate(Resource.Menu.MyVideoMore_Menu, popup.Menu);
                                    }
                                    else
                                    {
                                        popup.MenuInflater.Inflate(Resource.Menu.Video_More_Menue, popup.Menu);
                                    }

                                    popup.Show();
                                    popup.MenuItemClick += (o, eventArgs) =>
                                    {
                                        try
                                        {
                                            var id = eventArgs.Item.ItemId;
                                            switch (id)
                                            {
                                            case Resource.Id.menu_AddWatchLater:
                                                LibrarySynchronizer.AddToWatchLater(item.Videos?.VideoAdClass);
                                                break;

                                            case Resource.Id.menu_AddPlaylist:
                                                LibrarySynchronizer.AddToPlaylist(item.Videos?.VideoAdClass);
                                                break;

                                            case Resource.Id.menu_Remove:
                                                OnMenuRemove_Click(item);
                                                break;

                                            case Resource.Id.menu_Share:
                                                LibrarySynchronizer.ShareVideo(item.Videos?.VideoAdClass);
                                                break;

                                            case Resource.Id.menu_Report:
                                                LibrarySynchronizer.AddReportVideo(item.Videos?.VideoAdClass);
                                                break;
                                            }
                                        }
                                        catch (Exception exception)
                                        {
                                            Console.WriteLine(exception);
                                        }
                                    };
                                }
                            }
                            ;

                            //Set Badge on videos
                            AppTools.ShowGlobalBadgeSystem(holder.VideoType, item.Videos?.VideoAdClass);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Esempio n. 36
0
        public static void ShowPopup(Context context, string indicator, string blacklist, View view, string chatId)
        {
            Android.Support.V7.Widget.PopupMenu popup_menu = new Android.Support.V7.Widget.PopupMenu(context, view);
            var menuOpts = popup_menu.Menu;

            if (indicator == "dialog_popup_menu")
            {
                popup_menu.Inflate(Resource.Layout.dialog_popup_menu);
                if (blacklist == "to_blacklist")
                {
                    menuOpts.GetItem(2).SetTitle(Resource.String.restore_conversation);
                }
            }
            else if (indicator == "dialog_with_user_popup_menu")
            {
                popup_menu.Inflate(Resource.Layout.dialog_with_user_popup_menu);
                if (blacklist == "to_blacklist")
                {
                    menuOpts.GetItem(1).SetTitle(Resource.String.restore_conversation);
                }
            }
            else if (indicator == "dialog_popup_menu_on")
            {
                popup_menu.Inflate(Resource.Layout.dialog_popup_menu_on);
                if (blacklist == "to_blacklist")
                {
                    menuOpts.GetItem(2).SetTitle(Resource.String.restore_conversation);
                }
            }
            else if (indicator == "dialog_with_user_popup_menu_on")
            {
                popup_menu.Inflate(Resource.Layout.dialog_with_user_popup_menu_on);
                if (blacklist == "to_blacklist")
                {
                    menuOpts.GetItem(1).SetTitle(Resource.String.restore_conversation);
                }
            }
            popup_menu.MenuItemClick += (s1, arg1) =>
            {
                if (arg1.Item.TitleFormatted.ToString() == context.GetString(Resource.String.feedback_text))
                {
                    context.StartActivity(typeof(FeedbackChooseCategoryActivity));
                }
                if (arg1.Item.TitleFormatted.ToString() == context.GetString(Resource.String.clear_chat_history))
                {
                    title_acceptTV.Text      = context.GetString(Resource.String.clear_chat_history) + "?";
                    popup_menu_value         = context.GetString(Resource.String.clear_chat_history);
                    tint_acceptLL.Visibility = ViewStates.Visible;
                }
                if (arg1.Item.TitleFormatted.ToString() == context.GetString(Resource.String.blacklist))
                {
                    if (blacklist == "to_blacklist")
                    {
                        title_acceptTV.Text = context.GetString(Resource.String.remove_from_blacklist) + "?";
                    }
                    else
                    {
                        title_acceptTV.Text = context.GetString(Resource.String.move_to_blacklist) + "?";
                    }
                    popup_menu_value         = context.GetString(Resource.String.blacklist);
                    tint_acceptLL.Visibility = ViewStates.Visible;
                }
                if (arg1.Item.TitleFormatted.ToString() == context.GetString(Resource.String.restore_conversation))
                {
                    title_acceptTV.Text      = context.GetString(Resource.String.remove_from_blacklist) + "?";
                    popup_menu_value         = context.GetString(Resource.String.blacklist);
                    tint_acceptLL.Visibility = ViewStates.Visible;
                }
                if (arg1.Item.TitleFormatted.ToString() == context.GetString(Resource.String.turn_off_notifications))
                {
                    title_acceptTV.Text      = context.GetString(Resource.String.turn_off_notifications) + "?";
                    popup_menu_value         = context.GetString(Resource.String.turn_off_notifications);
                    tint_acceptLL.Visibility = ViewStates.Visible;
                }
                if (arg1.Item.TitleFormatted.ToString() == context.GetString(Resource.String.turn_on_notifications))
                {
                    title_acceptTV.Text      = context.GetString(Resource.String.turn_on_notifications) + "?";
                    popup_menu_value         = context.GetString(Resource.String.turn_on_notifications);
                    tint_acceptLL.Visibility = ViewStates.Visible;
                }
                yes_acceptTV.Click += async(s, e) =>
                {
                    if (popup_menu_value == context.GetString(Resource.String.clear_chat_history))
                    {
                        activityIndicatorAccept.Visibility = ViewStates.Visible;
                        var clear_his = await dialogMethods.ClearHistory(userMethods.GetUsersAuthToken(), chatId);

                        activityIndicatorAccept.Visibility = ViewStates.Gone;
                        tint_acceptLL.Visibility           = ViewStates.Gone;
                        var intent = new Intent(context, typeof(ChatListActivity));
                        intent.SetFlags(ActivityFlags.NewTask);
                        context.StartActivity(intent);
                        activity.Finish();
                    }
                    if (popup_menu_value == context.GetString(Resource.String.blacklist))
                    {
                        if (blacklist == "to_blacklist")
                        {
                            var end_conv = await dialogMethods.CloseChat(userMethods.GetUsersAuthToken(), chatId, false);

                            blacklist = "";
                        }
                        else
                        {
                            var end_conv = await dialogMethods.CloseChat(userMethods.GetUsersAuthToken(), chatId, true);

                            blacklist = "to_blacklist";
                        }

                        activityIndicatorAccept.Visibility = ViewStates.Visible;
                        activityIndicatorAccept.Visibility = ViewStates.Gone;
                        tint_acceptLL.Visibility           = ViewStates.Gone;
                        var intent = new Intent(context, typeof(ChatListActivity));
                        intent.SetFlags(ActivityFlags.NewTask);
                        context.StartActivity(intent);
                        activity.Finish();
                    }
                    if (popup_menu_value == context.GetString(Resource.String.turn_off_notifications))
                    {
                        activityIndicatorAccept.Visibility = ViewStates.Visible;
                        var turn_off_notifs = await dialogMethods.ToggleNotifications(userMethods.GetUsersAuthToken(), chatId, 0);

                        activityIndicatorAccept.Visibility = ViewStates.Gone;
                        tint_acceptLL.Visibility           = ViewStates.Gone;
                        var intent = new Intent(context, typeof(ChatListActivity));
                        intent.SetFlags(ActivityFlags.NewTask);
                        context.StartActivity(intent);
                        activity.Finish();
                    }
                    if (popup_menu_value == context.GetString(Resource.String.turn_on_notifications))
                    {
                        activityIndicatorAccept.Visibility = ViewStates.Visible;
                        var turn_on_notifs = await dialogMethods.ToggleNotifications(userMethods.GetUsersAuthToken(), chatId, 1);

                        activityIndicatorAccept.Visibility = ViewStates.Gone;
                        tint_acceptLL.Visibility           = ViewStates.Gone;
                        var intent = new Intent(context, typeof(ChatListActivity));
                        intent.SetFlags(ActivityFlags.NewTask);
                        context.StartActivity(intent);
                        activity.Finish();
                    }
                };
            };
            try
            { popup_menu.Show(); }
            catch { }
        }
Esempio n. 37
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            if (position == 0)
            {
                QueueHeader holder = (QueueHeader)viewHolder;
                if (!holder.Shuffle.HasOnClickListeners)
                {
                    holder.Shuffle.Click += (sender, e) =>
                    {
                        Intent intent = new Intent(MainActivity.instance, typeof(MusicPlayer));
                        intent.SetAction("RandomizeQueue");
                        MainActivity.instance.StartService(intent);
                    };
                }

                if (MusicPlayer.repeat)
                {
                    holder.Repeat.SetColorFilter(Color.Argb(255, 21, 183, 237), PorterDuff.Mode.Multiply);
                }
                else
                {
                    holder.Repeat.ClearColorFilter();
                }

                if (!holder.Repeat.HasOnClickListeners)
                {
                    holder.Repeat.Click += (sender, e) => { MusicPlayer.Repeat(); }
                }
                ;

                if (!holder.More.HasOnClickListeners)
                {
                    holder.More.Click += (sender, e) =>
                    {
                        PopupMenu menu = new PopupMenu(MainActivity.instance, holder.More);
                        menu.Inflate(Resource.Menu.queue_more);
                        menu.SetOnMenuItemClickListener(Queue.instance);
                        menu.Show();
                    };
                }
                return;
            }

            if (position + 1 == ItemCount)
            {
                QueueFooter holder = (QueueFooter)viewHolder;
                holder.SwitchButton.Checked = MusicPlayer.useAutoPlay;

                if ((MusicPlayer.CurrentID() == ItemCount - 2 || MusicPlayer.CurrentID() == ItemCount - 3) && MusicPlayer.useAutoPlay)
                {
                    holder.Autoplay.Visibility = ViewStates.Visible;

                    if (!holder.ItemView.HasOnClickListeners)
                    {
                        holder.ItemView.Click += (sender, eventArg) =>
                        {
                            Intent intent = new Intent(MainActivity.instance, typeof(MusicPlayer));
                            intent.SetAction("Next");
                            MainActivity.instance.StartService(intent);
                        }
                    }
                    ;

                    if (MusicPlayer.autoPlay.Count > 0)
                    {
                        holder.RightIcon.Visibility = ViewStates.Visible;

                        Song ap = MusicPlayer.autoPlay[0];
                        holder.NextTitle.Text = ap.Title;

                        holder.NextTitle.SetTextColor(Color.White);
                        holder.NextTitle.SetBackgroundResource(Android.Resource.Color.Transparent);
                        if (ap.IsYt)
                        {
                            Picasso.With(MainActivity.instance).Load(ap.Album).Placeholder(Resource.Drawable.noAlbum).Transform(new RemoveBlackBorder(true)).Into(holder.NextAlbum);
                        }
                        else
                        {
                            var songCover       = Android.Net.Uri.Parse("content://media/external/audio/albumart");
                            var nextAlbumArtUri = ContentUris.WithAppendedId(songCover, ap.AlbumArt);

                            Picasso.With(MainActivity.instance).Load(nextAlbumArtUri).Placeholder(Resource.Drawable.noAlbum).Resize(400, 400).CenterCrop().Into(holder.NextAlbum);
                        }
                    }
                    else
                    {
                        int    count = new Random().Next(6, 15);
                        string title = "a";
                        while (count > 0)
                        {
                            title += "a";
                            count--;
                        }

                        holder.NextTitle.Text = title;
                        holder.NextTitle.SetTextColor(Color.Transparent);
                        holder.NextTitle.SetBackgroundResource(Resource.Color.background_material_dark);
                        holder.NextAlbum.SetImageResource(Resource.Color.background_material_dark);
                        holder.RightIcon.Visibility = ViewStates.Gone;
                    }
                }
                else
                {
                    holder.Autoplay.Visibility = ViewStates.Gone;
                }

                if (!holder.SwitchButton.HasOnClickListeners)
                {
                    holder.SwitchButton.Click += (sender, e) =>
                    {
                        MusicPlayer.useAutoPlay = !MusicPlayer.useAutoPlay;
                        NotifyItemChanged(ItemCount - 1, "UseAutoplay");

                        if (MusicPlayer.useAutoPlay)
                        {
                            MusicPlayer.Repeat(false);
                            if (MusicPlayer.autoPlay?.Count == 0)
                            {
                                MusicPlayer.instance.GenerateAutoPlay(false);
                            }
                        }
                        else
                        {
                            MusicPlayer.autoPlay.Clear();
                        }
                    };
                }
            }
            else
            {
                position--;
                SongHolder holder = (SongHolder)viewHolder;

                holder.reorder.SetColorFilter(Color.White);
                holder.Title.SetTextColor(Color.White);
                holder.youtubeIcon.SetColorFilter(Color.White);
                holder.reorder.Visibility = ViewStates.Visible;
                holder.more.Visibility    = ViewStates.Gone;
                holder.RightButtons.SetBackgroundResource(Resource.Drawable.darkLinear);
                int dp = MainActivity.instance.DpToPx(5);
                ((RelativeLayout.LayoutParams)holder.RightButtons.LayoutParameters).RightMargin = dp;
                holder.TextLayout.SetPadding(dp, 0, dp, 0);
                if (position == MusicPlayer.CurrentID())
                {
                    holder.status.Visibility = ViewStates.Visible;
                    holder.status.SetTextColor(MusicPlayer.isRunning ? Color.Argb(255, 244, 81, 30) : Color.Argb(255, 66, 165, 245));

                    string          status     = MusicPlayer.isRunning ? Queue.instance.GetString(Resource.String.playing) : Queue.instance.GetString(Resource.String.paused);
                    SpannableString statusText = new SpannableString(status);
                    statusText.SetSpan(new BackgroundColorSpan(Color.ParseColor("#8C000000")), 0, status.Length, SpanTypes.InclusiveInclusive);
                    holder.status.TextFormatted = statusText;
                }
                else
                {
                    holder.status.Visibility = ViewStates.Gone;
                }


                Song song = MusicPlayer.queue.Count <= position ? null : MusicPlayer.queue[position];
                if (song == null)
                {
                    if (holder.Title.Text.Length == 0)
                    {
                        holder.Title.Text = "aizquruhgqognbq";
                    }
                    if (holder.Artist.Text.Length == 0)
                    {
                        holder.Artist.Text = "ZJKGNZgzn";
                    }

                    holder.Title.SetTextColor(Color.Transparent);
                    holder.Title.SetBackgroundResource(Resource.Color.background_material_dark);
                    holder.Artist.SetTextColor(Color.Transparent);
                    holder.Artist.SetBackgroundResource(Resource.Color.background_material_dark);
                    holder.AlbumArt.SetImageResource(Resource.Color.background_material_dark);

                    MusicPlayer.RemotePlayer.MediaQueue.GetItemAtIndex(position);
                    return;
                }
                else
                {
                    holder.Title.SetBackgroundResource(0);
                    holder.Artist.SetBackgroundResource(0);
                }

                SpannableString titleText = new SpannableString(song.Title);
                titleText.SetSpan(new BackgroundColorSpan(Color.ParseColor("#8C000000")), 0, song.Title.Length, SpanTypes.InclusiveInclusive);
                holder.Title.TextFormatted = titleText;
                holder.Title.SetMaxLines(2);

                holder.Artist.Visibility = ViewStates.Gone;

                if (song.AlbumArt == -1 || song.IsYt)
                {
                    if (song.Album != null)
                    {
                        Picasso.With(Application.Context).Load(song.Album).Placeholder(Resource.Color.background_material_dark).Transform(new RemoveBlackBorder(true)).Into(holder.AlbumArt);
                    }
                    else
                    {
                        Picasso.With(Application.Context).Load(Resource.Color.background_material_dark).Transform(new RemoveBlackBorder(true)).Into(holder.AlbumArt);
                    }
                }
                else
                {
                    var songCover       = Android.Net.Uri.Parse("content://media/external/audio/albumart");
                    var songAlbumArtUri = ContentUris.WithAppendedId(songCover, song.AlbumArt);

                    Picasso.With(Application.Context).Load(songAlbumArtUri).Placeholder(Resource.Color.background_material_dark).Resize(400, 400).CenterCrop().Into(holder.AlbumArt);
                }

                if (song.IsLiveStream)
                {
                    holder.Live.Visibility = ViewStates.Visible;
                }
                else
                {
                    holder.Live.Visibility = ViewStates.Gone;
                }


                if (!holder.reorder.HasOnClickListeners)
                {
                    holder.reorder.Touch += (sender, e) =>
                    {
                        Queue.instance.itemTouchHelper.StartDrag(viewHolder);
                        MainActivity.instance.contentRefresh.Enabled = false;
                    };
                }

                if (song.IsParsed != true && song.IsYt)
                {
                    holder.youtubeIcon.SetImageResource(Resource.Drawable.needProcessing);
                    holder.youtubeIcon.Visibility = ViewStates.Visible;
                }
                else if (song.IsParsed == true && song.IsYt)
                {
                    holder.youtubeIcon.SetImageResource(Resource.Drawable.PublicIcon);
                    holder.youtubeIcon.Visibility = ViewStates.Visible;
                }
                else
                {
                    holder.youtubeIcon.Visibility = ViewStates.Gone;
                }
            }
        }
Esempio n. 38
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();
        }