Example #1
0
        private void OnProfileSubItemCLick(View view)
        {
            switch (view.Id)
            {
            case Resource.Id.HamburgerProfileItemNotifications:
                OnHamburgerItemClick(PageIndex.PageNotificationHub);
                break;

            case Resource.Id.HamburgerProfileItemMessages:
                OnHamburgerItemClick(PageIndex.PageMessanging);
                break;

            case Resource.Id.HamburgerProfileItemSupport:
                _supportMenu = FlyoutMenuBuilder.BuildGenericFlyout(this, view,
                                                                    new List <string> {
                    "Feedback", "Review", "Donate Google", "Donate PayPal", "Turn on ads"
                }, OnSupportMenuSelection);
                _supportMenu.Show();
                _supportMenu.OnHiddenWithoutSelection += (sender, args) =>
                {
                    ViewModelLocator.NavMgr.RegisterOneTimeOverride(new RelayCommand(() => _drawer.CloseDrawer()));
                };
                break;
            }
        }
Example #2
0
 private void OnTopAnimeMore(View view)
 {
     _moreMenu = FlyoutMenuBuilder.BuildGenericFlyout(this, view,
                                                      Enum.GetValues(typeof(TopAnimeType)).Cast <TopAnimeType>().Select(type => type.ToString()).ToList(),
                                                      i =>
     {
         ViewModel.Navigate(PageIndex.PageTopAnime, AnimeListPageNavigationArgs.TopAnime((TopAnimeType)i));
         _moreMenu.Dismiss(true);
         _drawer.CloseDrawer();
     });
     _moreMenu.Show();
 }
Example #3
0
 private void OnAnimeListMore(View view)
 {
     _moreMenu = FlyoutMenuBuilder.BuildGenericFlyout(this, view,
                                                      Enum.GetValues(typeof(AnimeStatus)).Cast <AnimeStatus>().Select(type => Utilities.StatusToString((int)type)).ToList(),
                                                      i =>
     {
         ViewModel.Navigate(PageIndex.PageTopAnime, new AnimeListPageNavigationArgs(i, AnimeListWorkModes.Anime));
         _moreMenu.Dismiss(true);
         _drawer.CloseDrawer();
     });
     _moreMenu.Show();
 }
        //private void OnCompleted(ImageViewAsync imageViewAsync)
        //{
        //    Activity?.RunOnUiThread(() =>
        //    {
        //        try
        //        {
        //            var parent = (imageViewAsync.Parent as View);
        //            var vm = parent.Tag.Unwrap<WallpaperItemViewModel>();
        //            if (!string.IsNullOrEmpty(vm.Resolution))
        //                return;

        //            var bounds = imageViewAsync.Drawable.Bounds;
        //            vm.Resolution = $"{bounds.Right}x{bounds.Bottom}";
        //            parent.FindViewById<TextView>(Resource.Id.WallpapersPageItemResolution).Text = vm.Resolution;

        //            imageViewAsync.Visibility = ViewStates.Visible;
        //        }
        //        catch (Exception)
        //        {
        //            // user navigated out and image has loaded in background
        //        }

        //    });
        //}

        private void OnLongClickAction(View view)
        {
            _menuContext = view.Tag.Unwrap <WallpaperItemViewModel>();
            _menu        = FlyoutMenuBuilder.BuildGenericFlyout(Context, view, new List <string>
            {
                "Save",
                "Copy link & open waifu2x",
                "Open on reddit",
                "Copy link",
            }, OnMenuSelected);
            _menu.Show();
        }
Example #5
0
        protected override void RootContainerInit()
        {
            ForumIndexPageBoardItemIcon.Typeface = FontManager.GetTypeface(Context, FontManager.TypefacePath);
            if (!ViewModel.ArePeekPostsAvailable)
            {
                _binding = this.SetBinding(() => _parentViewModel.LoadingSideContentVisibility).WhenSourceChanges(() =>
                {
                    if (_parentViewModel.LoadingSideContentVisibility)
                    {
                        ForumIndexPageBoardItemBoardProgressBar.Visibility = ViewStates.Visible;
                        ForumIndexPageBoardItemPeekPostSection.Visibility  = ViewStates.Invisible;
                    }
                    else
                    {
                        ForumIndexPageBoardItemBoardProgressBar.Visibility = ViewStates.Gone;
                        ForumIndexPageBoardItemPeekPostSection.Visibility  = ViewStates.Visible;
                        OnFinishedLoading();
                        BindModelFull();
                        _binding?.Detach();
                        _binding = null;
                    }
                });
            }

            ForumIndexPageBoardItemRootContainer.SetOnLongClickListener(new OnLongClickListener(view =>
            {
                var pinned = ViewModelLocator.ForumsMain.PinnedBoards.Contains(ViewModel.Board);
                _menu      = FlyoutMenuBuilder.BuildGenericFlyout(Context, ForumIndexPageBoardItemRootContainer,
                                                                  new List <string> {
                    pinned ? "Remove from favourites" :  "Add to favourites"
                }, i =>
                {
                    if (pinned)
                    {
                        ViewModelLocator.ForumsMain.RemovePinnedBoardCommand.Execute(ViewModel.Board);
                    }
                    else
                    {
                        ViewModel.AddToFavouritesCommand.Execute(ViewModel.Board);
                    }

                    _menu.Dismiss(true);
                });
                _menu.Show();
            }));

            ForumIndexPageBoardItemPeekPost1Title.Click +=
                (sender, args) => _parentViewModel.GoToLastPostCommand.Execute(ViewModel.Entry.PeekPosts.First());

            ForumIndexPageBoardItemPeekPost2Title.Click +=
                (sender, args) => _parentViewModel.GoToLastPostCommand.Execute(ViewModel.Entry.PeekPosts.Last());
        }
Example #6
0
 private void ForumsMainPageMoreButtonOnClick(object sender, EventArgs eventArgs)
 {
     if (_moreMenu == null)
     {
         _moreMenu = FlyoutMenuBuilder.BuildGenericFlyout(Activity, ForumsMainPageMoreButton, new List <string>
         {
             "My recent topics",
             "My watched topics",
             "MALClient's topic",
         }, OnMoreMenuSelected);
     }
     _moreMenu.Show();
 }
 private void OnLongClickAction(View view)
 {
     _menu = FlyoutMenuBuilder.BuildGenericFlyout(Context, view,
                                                  new List <string> {
         "Pin", "Pin to lastpost"
     }, i =>
     {
         var vm = (view.Parent as View).Tag.Unwrap <ForumTopicEntryViewModel>();
         if (i == 0)
         {
             vm.PinCommand.Execute(null);
         }
         else
         {
             vm.PinLastpostCommand.Execute(null);
         }
         _menu.Dismiss(true);
     });
     _menu.Show();
 }
Example #8
0
        private void InitBindings()
        {
            Bindings.Add(
                this.SetBinding(() => ViewModel.CurrentStatus,
                                () => MainPageCurrentStatus.Text));


            Bindings.Add(
                this.SetBinding(() => ViewModel.RefreshButtonVisibility,
                                () => MainPageRefreshButton.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));
            MainPageRefreshButton.Click += (sender, args) => ViewModel.RefreshDataCommand.Execute(null);

            Bindings.Add(
                this.SetBinding(() => ViewModel.SearchToggleVisibility,
                                () => MainPageSearchView.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));
            Bindings.Add(
                this.SetBinding(() => ViewModel.SearchInputVisibility).WhenSourceChanges(() =>
            {
                MainPageSearchView.Iconified = !ViewModel.SearchInputVisibility;
                if (ViewModel.SearchInputVisibility)
                {
                    MainPageSearchView.SetQuery(ViewModel.CurrentSearchQuery, false);
                }
                MainPageSearchView.ClearFocus();
            }));


            Bindings.Add(this.SetBinding(() => ViewModel.CurrentStatusSub).WhenSourceChanges(() =>
            {
                MainPageCurrentSatusSubtitle.Text = ViewModel.CurrentStatusSub;
                if (string.IsNullOrEmpty(ViewModel.CurrentStatusSub))
                {
                    MainPageCurrentSatusSubtitle.Visibility = ViewStates.Gone;
                    MainPageCurrentStatus.SetMaxLines(2);
                }
                else
                {
                    MainPageCurrentSatusSubtitle.Visibility = ViewStates.Visible;
                    MainPageCurrentStatus.SetMaxLines(1);
                }
            }));

            _searchFrame = MainPageSearchView.FindViewById(Resource.Id.search_edit_frame);

            Bindings.Add(this.SetBinding(() => ViewModel.SearchToggleLock).WhenSourceChanges(
                             () =>
            {
                if (ViewModel.SearchToggleLock)
                {
                    MainPageSearchView.FindViewById(Resource.Id.search_close_btn).Alpha     = 0;
                    MainPageSearchView.FindViewById(Resource.Id.search_close_btn).Clickable = false;
                    if (ViewModel.CurrentMainPage == PageIndex.PageSearch)
                    {
                        InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                        imm.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.NotAlways);
                    }
                }
                else
                {
                    MainPageSearchView.FindViewById(Resource.Id.search_close_btn).Alpha     = 1;
                    MainPageSearchView.FindViewById(Resource.Id.search_close_btn).Clickable = true;
                }
            }));

            //MainPageSearchView.LayoutChange += MainPageSearchViewOnLayoutChange;

            //var padding = (int)(11*Resources.DisplayMetrics.Density);
            //searchBtn.SetScaleType(ImageView.ScaleType.FitEnd);
            //searchBtn.SetPadding(padding, padding, padding, padding);
            var observer       = _searchFrame.ViewTreeObserver;
            var prevVisibility = _searchFrame.Visibility;

            observer.GlobalLayout += (sender, args) =>
            {
                if (prevVisibility == _searchFrame.Visibility)
                {
                    return;
                }
                prevVisibility = _searchFrame.Visibility;
                MainPageCurrentStatus.Visibility = Converters.VisibilityInverterConverter(_searchFrame.Visibility);
                var param = MainPageSearchView.LayoutParameters as LinearLayout.LayoutParams;
                Debug.WriteLine(_searchFrame.Visibility);
                if (_searchFrame.Visibility == ViewStates.Visible)
                {
                    var diff = ViewModel.SearchToggleStatus != true;
                    ViewModel.SearchToggleStatus = true;
                    param.Width = ViewGroup.LayoutParams.MatchParent;
                    param.SetMargins(0, 0, DimensionsHelper.DpToPx(20), 0);
                    param.Weight = 1;
                    if (diff)
                    {
                        MainPageSearchView.RequestFocusFromTouch();
                        InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                        imm.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.None);
                    }
                }
                else
                {
                    var diff = ViewModel.SearchToggleStatus != false;
                    ViewModel.SearchToggleStatus = false;
                    param.Width = (int)DimensionsHelper.DpToPx(50);
                    param.SetMargins(0, 0, 0, 0);
                    param.Weight = 0;
                    if (diff)
                    {
                        InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
                        imm.HideSoftInputFromWindow(MainPageSearchView.WindowToken, HideSoftInputFlags.None);
                    }
                }
            };

            _searchSuggestionAdapter = new SimpleCursorAdapter(this, Resource.Layout.SuggestionItem,
                                                               null, new string[] { "hint" }, new int[]
            {
                Resource.Id.SuggestionItemTextView
            });

            //
            MainPageStatusContainer.SetOnClickListener(new OnClickListener(view =>
            {
                if (ViewModel.CurrentMainPage == PageIndex.PageAnimeList)
                {
                    if (ViewModelLocator.AnimeList.WorkMode == AnimeListWorkModes.SeasonalAnime)
                    {
                        _upperFilterMenu = FlyoutMenuBuilder.BuildGenericFlyout(this, MainPageCurrentStatus,
                                                                                ViewModelLocator.AnimeList.SeasonSelection.Select(season => season.Name).ToList(),
                                                                                OnUpperStatusSeasonSelected);
                    }
                    else
                    {
                        _upperFilterMenu = AnimeListPageFlyoutBuilder.BuildForAnimeStatusSelection(this, MainPageCurrentStatus,
                                                                                                   OnUpperFlyoutStatusChanged, (AnimeStatus)ViewModelLocator.AnimeList.CurrentStatus,
                                                                                                   ViewModelLocator.AnimeList.IsMangaWorkMode);
                    }

                    _upperFilterMenu.Show();
                }
            }));


            Bindings.Add(this.SetBinding(() => ViewModel.MediaElementVisibility)
                         .WhenSourceChanges(() =>
            {
                if (ViewModel.MediaElementVisibility)
                {
                    MainPageVideoViewContainer.Visibility = ViewStates.Visible;
                    MainPageVideoView.Visibility          = ViewStates.Visible;
                    MainUpperNavBar.Visibility            = ViewStates.Gone;
                    MainPageVideoView.SetZOrderOnTop(true);
                    _drawer?.DrawerLayout.SetDrawerLockMode(DrawerLayout.LockModeLockedClosed);
                }
                else
                {
                    MainPageVideoViewContainer.Visibility = ViewStates.Gone;
                    MainPageVideoView.Visibility          = ViewStates.Gone;
                    MainUpperNavBar.Visibility            = ViewStates.Visible;
                    MainPageVideoView.SetZOrderOnTop(false);
                    _drawer?.DrawerLayout.SetDrawerLockMode(DrawerLayout.LockModeUnlocked);
                    ViewModelLocator.NavMgr.ResetOneTimeOverride();
                }
            }));



            Bindings.Add(
                this.SetBinding(() => ViewModel.MediaElementSource).WhenSourceChanges(() =>
            {
                if (string.IsNullOrEmpty(ViewModel.MediaElementSource))
                {
                    return;
                }

                var mediaController = new MediaController(this);
                mediaController.SetAnchorView(MainPageVideoView);
                MainPageVideoView.SetMediaController(mediaController);
                MainPageVideoView.SetVideoURI(Uri.Parse(ViewModel.MediaElementSource));
                MainPageVideoView.RequestFocus();
            }));

            MainPageSearchView.SuggestionsAdapter = _searchSuggestionAdapter;
            MainPageSearchView.QueryTextChange   += MainPageSearchViewOnQueryTextChange;
            MainPageSearchView.QueryTextSubmit   += MainPageSearchViewOnQueryTextSubmit;
            MainPageSearchView.SuggestionClick   += MainPageSearchViewOnSuggestionClick;
            MainPageCloseVideoButton.Click       += MainPageCloseVideoButtonOnClick;
            MainPageCopyVideoLinkButton.Click    += MainPageCopyVideoLinkButtonOnClick;
            MainPageVideoView.Prepared           += MainPageVideoViewOnPrepared;
            MainPageSearchView.Visibility         = ViewStates.Visible;
            ((EditText)MainPageSearchView.FindViewById(Resource.Id.search_src_text)).SetTextColor(Color.White);


            MainPageHamburgerButton.Click += MainPageHamburgerButtonOnClick;
            ViewModel.PropertyChanged     += ViewModelOnPropertyChanged;
            BuildDrawer();
            _drawer.OnDrawerItemClickListener = new HamburgerItemClickListener(OnHamburgerItemClick);

            MainPageCloseVideoButton.SetZ(0);
            MainPageCopyVideoLinkButton.SetZ(0);
        }
Example #9
0
        protected override void InitBindings()
        {
            var swipeRefresh = RootView as SwipeRefreshLayout;
            var footerHolder = new FrameLayout(Context)
            {
                LayoutParameters = new AbsListView.LayoutParams(-1, -2)
            };
            var footer = new Button(Context)
            {
                Text             = "Load more",
                LayoutParameters = new ViewGroup.LayoutParams(-1, -2)
            };

            footer.SetAllCaps(false);
            footer.BackgroundTintList = ColorStateList.ValueOf(new Color(ResourceExtension.AccentColourDark));
            footer.SetOnClickListener(new OnClickListener(view => ViewModel.LoadMoreCommand.Execute(null)));
            footer.SetTextColor(Color.White);
            footerHolder.AddView(footer);
            _loadMoreFooter = footerHolder;


            RootView.ViewTreeObserver.GlobalLayout += (sender, args) =>
            {
                Rect r = new Rect();
                RootView.GetWindowVisibleDisplayFrame(r);
                int keypadHeight = RootView.RootView.Height - r.Bottom;

                if (keypadHeight > RootView.Height * 0.15)
                {
                    AnimeListPageActionButton.Hide();
                }
                else
                {
                    AnimeListPageActionButton.Show();
                }
            };
            //AnimeListPageGridView.ScrollingCacheEnabled = false;


            Bindings.Add(
                this.SetBinding(() => ViewModel.Loading,
                                () => AnimeListPageLoadingSpinner.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));


            Bindings.Add(
                this.SetBinding(() => ViewModel.AppbarBtnPinTileVisibility,
                                () => AnimeListPageSeasonMenu.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));

            Bindings.Add(
                this.SetBinding(() => ViewModel.AppBtnSortingVisibility,
                                () => AnimeListPageSortMenu.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));

            Bindings.Add(
                this.SetBinding(() => ViewModel.EmptyNoticeVisibility,
                                () => AnimeListPageEmptyNotice.Visibility)
                .ConvertSourceToTarget(Converters.BoolToVisibility));

            ViewModel.PropertyChanged         += AnimeListOnPropertyChanged;
            ViewModel.ScrollIntoViewRequested += ViewModelOnScrollIntoViewRequested;


            AnimeListPageActionButton.LongClickable = true;
            AnimeListPageActionButton.SetOnLongClickListener(new OnLongClickListener(view =>
            {
                var items = new List <string>();

                if (ViewModel.AppBtnListSourceVisibility)
                {
                    items.Add(FabMenuSetListSource);
                }
                if (ViewModel.LoadAllDetailsButtonVisiblity)
                {
                    items.Add(FabMenuLoadDetails);
                }
                items.Add(FabMenuDisplayModes);
                _fabMenu = FlyoutMenuBuilder.BuildGenericFlyout(Activity, AnimeListPageActionButton, items,
                                                                OnFabMenuItemClicked);
                _fabMenu.Tag = items;
                _fabMenu.Show();
            }));

            swipeRefresh.NestedScrollingEnabled = true;
            swipeRefresh.Refresh += (sender, args) =>
            {
                swipeRefresh.Refreshing = false;

                ViewModel.RefreshCommand.Execute(null);
            };

            Bindings.Add(this.SetBinding(() => ViewModel.WorkMode).WhenSourceChanges(InitActionMenu));

            InitDrawer();
        }