private void ViewModelOnScrollRequest(AnimeItemViewModel item, bool select = false) { switch (ViewModel.DisplayMode) { case AnimeListDisplayModes.IndefiniteCompactList: AnimeCompactItemsIndefinite.ScrollIntoView(item); if (select) { AnimeCompactItemsIndefinite.SelectedItem = item; AnimeCompactItemsIndefinite.Focus(FocusState.Pointer); } break; case AnimeListDisplayModes.IndefiniteList: AnimesItemsIndefinite.ScrollIntoView(item); if (select) { AnimesItemsIndefinite.SelectedItem = item; AnimesItemsIndefinite.Focus(FocusState.Pointer); } break; case AnimeListDisplayModes.IndefiniteGrid: AnimesGridIndefinite.ScrollIntoView(item); if (select) { AnimesGridIndefinite.SelectedItem = item; AnimesGridIndefinite.Focus(FocusState.Pointer); } break; default: throw new ArgumentOutOfRangeException(); } }
private async void AnimeListPageGridViewOnItemClick(AnimeItemViewModel model) { await Task.Delay(75); //let's behold this ripple effect var args = ViewModelLocator.GeneralMain.GetCurrentListOrderParams(); args.SelectedItemIndex = ViewModel.AnimeItems.IndexOf(model); model.NavigateDetails(null, args); }
private void ViewModelOnScrollIntoViewRequested(AnimeItemViewModel item, bool select) { var list = SwipeRefreshLayout.ScrollingView as AbsListView; if (item != ViewModel.AnimeItems.FirstOrDefault() && list.Adapter is IBugFixingGridViewAdapter adapter) { adapter.HandledGridViewBug = true; } list?.SetSelection(ViewModel.AnimeItems.IndexOf(item)); }
//private StorageFile _originaPickedStorageFile; //private async void LoadSelectedImage() //{ // var fp = new FileOpenPicker(); // fp.ViewMode = PickerViewMode.Thumbnail; // fp.SuggestedStartLocation = PickerLocationId.PicturesLibrary; // fp.FileTypeFilter.Add(".png"); // fp.FileTypeFilter.Add(".jpg"); // var file = await fp.PickSingleFileAsync(); // if (file != null) // { // _selectedImageOptionIndex = 1; // ImagePreviewVisibility = Visibility.Visible; // RaisePropertyChanged(() => SelectedImageOptionIndex); // } // _originaPickedStorageFile = file; // var bmp = new BitmapImage(); // var bmp1 = new BitmapImage(); // using (var fs = (await file.OpenStreamForReadAsync()).AsRandomAccessStream()) // { // bmp.SetSource(fs); // fs.Seek(0); // bmp1.SetSource(fs); // } // PreviewImageWide = bmp1; // PreviewImageNormal = bmp; //} //public async void HidePinDialog() //{ // var sb = ViewModelLocator.Main.View.HidePinDialogStoryboard; // sb.Completed += SbOnCompleted; // sb.Begin(); //} public void Load(AnimeItemViewModel data) { GeneralVisibility = Visibility.Visible; _lastCroppedFileName = null; _lastCroppedFileNameWide = null; EntryData = data; ResetCrop(); ResetCrop(true); RaisePropertyChanged(() => EntryData); }
private static void CleanupWatchedDialog() { ViewModelLocator.NavMgr.ResetOneTimeMainOverride(); _watchedDialogBindings.ForEach(binding => binding.Detach()); _watchedDialogBindings = new List <Binding>(); _watchedDialog?.Dismiss(); _watchedDialog = null; _watchedDialogContext = null; _watchedDialogAction = null; }
public static void BuildWatchedDialog(AnimeItemViewModel ViewModel, Action <AnimeItemViewModel, string> action = null, bool volumes = false) { _watchedDialogContext = ViewModel; _watchedDialogAction = action; var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext); dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeItemWatchedDialog)); dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes); dialogBuilder.SetOnDismissListener(new DialogDismissedListener(CleanupWatchedDialog)); dialogBuilder.SetOnDismissListener( new DialogDismissedListener(() => ViewModelLocator.NavMgr.ResetOneTimeOverride())); ViewModelLocator.NavMgr.RegisterOneTimeMainOverride(new RelayCommand(CleanupWatchedDialog)); _watchedDialog = dialogBuilder.Create(); var view = _watchedDialog.HolderView; view.FindViewById <ImageButton>(Resource.Id.AnimeItemWatchedDialogAcceptButton) .SetCommand("Click", new RelayCommand( () => { if (!volumes) { ViewModel.OnFlyoutEpsKeyDown.Execute(null); } else { action.Invoke(_watchedDialogContext, _watchedDialog.HolderView.FindViewById <TextView>( Resource.Id.AnimeItemWatchedDialogTextInput).Text); } CleanupWatchedDialog(); })); var grid = view.FindViewById <GridView>(Resource.Id.AnimeItemWatchedDialogEpisodesGridView); if (volumes) { grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, ViewModel.MyVolumes, ViewModel.AllVolumes); view.FindViewById <TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text = "Read volumes"; } else { var input = view.FindViewById <EditText>(Resource.Id.AnimeItemWatchedDialogTextInput); _watchedDialogBindings.Add(new Binding <string, string>(ViewModel, () => ViewModel.WatchedEpsInput, input, () => input.Text, BindingMode.TwoWay)); grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, ViewModel.MyEpisodesFocused, ViewModel.AllEpisodesFocused); view.FindViewById <TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text = ViewModel.WatchedEpsLabel; } grid.ItemClick += GridOnItemClick; _watchedDialog.Show(); }
private static void CleanupWatchedDialog() { if (_watchedDialog != null) { AndroidUtilities.HideKeyboard(); _watchedDialog.Dismiss(); } _watchedDialogBindings.ForEach(binding => binding.Detach()); _watchedDialogBindings = new List <Binding>(); _watchedDialog = null; _watchedDialogContext = null; _watchedDialogAction = null; MainActivity.CurrentContext.DialogToCollapseOnBack = null; }
public ComparisonItemViewModel(AnimeItemViewModel myEntry, AnimeItemViewModel otherEntry) { MyEntry = myEntry; OtherEntry = otherEntry; var setBasicData = false; if (MyEntry != null) { MyEntry.ChangedScore += EntryOnChangedScore; MyEntry.ChangedAuth += MyEntryOnChangedAuth; MyEntry.ChangedWatched += EntryOnChangedWatched; Title = MyEntry.Title; ImgUrl = MyEntry.ImgUrl; Id = MyEntry.Id; setBasicData = true; } if (OtherEntry != null) { OtherEntry.ChangedScore += EntryOnChangedScore; OtherEntry.ChangedWatched += EntryOnChangedWatched; if (!setBasicData) { Title = OtherEntry.Title; ImgUrl = OtherEntry.ImgUrl; Id = OtherEntry.Id; } } IsComparisonValid = myEntry != null && otherEntry != null; UpdateScoreDiff(); UpdateWatchedDiff(); }
private void Loadimage(AnimeItemViewModel vm, RemoteViews views) { var bitmap = ImageService.Instance.LoadUrl(vm.ImgUrl).AsBitmapDrawableAsync().Result; views.SetImageViewBitmap(Resource.Id.Image, bitmap.Bitmap); }
public AnimeItem(AnimeItemViewModel vm) { InitializeComponent(); DataContext = vm; }
public static void BuildWatchedDialog(AnimeItemViewModel viewModel, Action <AnimeItemViewModel, string> action = null, bool volumes = false) { try { _watchedDialogContext = viewModel; _watchedDialogAction = action; var dialogBuilder = DialogPlus.NewDialog(MainActivity.CurrentContext); dialogBuilder.SetGravity((int)GravityFlags.Top); dialogBuilder.SetContentHolder(new ViewHolder(Resource.Layout.AnimeItemWatchedDialog)); dialogBuilder.SetContentBackgroundResource(ResourceExtension.BrushFlyoutBackgroundRes); dialogBuilder.SetOnDismissListener(new DialogDismissedListener(CleanupWatchedDialog)); dialogBuilder.SetContentBackgroundResource(ResourceExtension.AccentColourDarkRes); _watchedDialog = dialogBuilder.Create(); var view = _watchedDialog.HolderView; view.FindViewById <ImageButton>(Resource.Id.AnimeItemWatchedDialogAcceptButton) .SetCommand("Click", new RelayCommand( () => { if (action == null) { viewModel.OnFlyoutEpsKeyDown.Execute(null); } else { action.Invoke(_watchedDialogContext, _watchedDialog.HolderView.FindViewById <TextView>( Resource.Id.AnimeItemWatchedDialogTextInput).Text); } CleanupWatchedDialog(); })); var grid = view.FindViewById <GridView>(Resource.Id.AnimeItemWatchedDialogEpisodesGridView); if (volumes) { grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, viewModel.MyVolumes, viewModel.AllVolumes, null); view.FindViewById <TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text = "Read volumes"; grid.Post(() => { try { grid.SetSelection( GetRightMostIndex( (grid.Adapter as WatchedDialogAdapter).Items.IndexOf(viewModel.MyVolumes))); } catch (Exception) { //welp } }); } else { int?currentEp = null; if (viewModel.Airing) { if (ResourceLocator.AiringInfoProvider.TryGetCurrentEpisode(viewModel.Id, out int ep)) { currentEp = ep; } } grid.Adapter = new WatchedDialogAdapter(MainActivity.CurrentContext, viewModel.MyEpisodes, viewModel.AllEpisodes, currentEp); view.FindViewById <TextView>(Resource.Id.AnimeItemWatchedDialogTitleTextView).Text = viewModel.ParentAbstraction.RepresentsAnime ? "Watched episodes" : "Read chapters"; grid.Post(() => { try { grid.SetSelection( GetRightMostIndex( (grid.Adapter as WatchedDialogAdapter).Items.IndexOf(viewModel.MyEpisodes))); } catch (Exception) { //welp } }); } if (grid.Adapter.Count > 16 && MainActivity.CurrentContext.Resources.Configuration.Orientation == Orientation.Portrait) { grid.LayoutParameters.Height = DimensionsHelper.DpToPx(180); } if (action == null) { var input = view.FindViewById <EditText>(Resource.Id.AnimeItemWatchedDialogTextInput); _watchedDialogBindings.Add(new Binding <string, string>(viewModel, () => viewModel.WatchedEpsInput, input, () => input.Text, BindingMode.TwoWay)); } grid.ItemClick += GridOnItemClick; _watchedDialog.Show(); MainActivity.CurrentContext.DialogToCollapseOnBack = _watchedDialog; int GetRightMostIndex(int source) { var rest = (source + 1) % grid.NumColumns; source -= rest; return(source - 1); } } catch (Exception e) { //TODO Get from hovckey ResourceLocator.SnackbarProvider.ShowText("An unknown error occurred, cause has been logged. I'll fix it in next update."); ResourceLocator.TelemetryProvider.LogEvent($"BuildWatchedDialog Crash: {e} , {viewModel.Title}, {action == null}, {volumes}, {e.Source}"); } }
public AnimeGridItem(AnimeItemViewModel vm) { DataContext = vm; InitializeComponent(); vm.ViewGrid = this; }
public static DroppyMenuPopup BuildForAnimeItemTags(Context context, View parent, AnimeItemViewModel viewModel, Action callback) { AnimeListPageFlyoutBuilder.ParamRelativeLayout = new ViewGroup.LayoutParams(DimensionsHelper.DpToPx(150), DimensionsHelper.DpToPx(38)); var droppyBuilder = new DroppyMenuPopup.Builder(context, parent); AnimeListPageFlyoutBuilder.InjectAnimation(droppyBuilder); var listener = new Action <int>(i => callback.Invoke()); droppyBuilder.AddMenuItem(new DroppyMenuCustomItem(AnimeListPageFlyoutBuilder.BuildItem(context, "Tags:", listener, 0, ResourceExtension.BrushRowAlternate2, null, false, GravityFlags.CenterHorizontal))); droppyBuilder.AddMenuItem(new DroppyMenuCustomItem(new DroppyMenuSeparatorView(context))); droppyBuilder.AddMenuItem(new DroppyMenuCustomItem(AnimeListPageFlyoutBuilder.BuildItem(context, viewModel.Notes, listener, 1, null, null, false, GravityFlags.CenterHorizontal))); return(droppyBuilder.Build()); }
public static DroppyMenuPopup BuildForAnimeItem(Context context, View parent, AnimeItemViewModel viewModel, Action <AnimeGridItemMoreFlyoutButtons> callback, bool forceSmall = false) { AnimeListPageFlyoutBuilder.ParamRelativeLayout = new ViewGroup.LayoutParams(DimensionsHelper.DpToPx(150), DimensionsHelper.DpToPx(38)); var droppyBuilder = new DroppyMenuPopup.Builder(context, parent); AnimeListPageFlyoutBuilder.InjectAnimation(droppyBuilder); var listener = new Action <int>(i => callback.Invoke((AnimeGridItemMoreFlyoutButtons)i)); droppyBuilder.AddMenuItem(new DroppyMenuCustomItem(AnimeListPageFlyoutBuilder.BuildItem(context, "Copy to clipboard", listener, 0))); droppyBuilder.AddMenuItem(new DroppyMenuCustomItem(AnimeListPageFlyoutBuilder.BuildItem(context, "Open in browser", listener, 1))); if (!forceSmall && viewModel.Auth) { droppyBuilder.AddSeparator(); droppyBuilder.AddMenuItem(new DroppyMenuCustomItem(AnimeListPageFlyoutBuilder.BuildItem(context, "Set status", listener, 2))); droppyBuilder.AddMenuItem(new DroppyMenuCustomItem(AnimeListPageFlyoutBuilder.BuildItem(context, "Set score", listener, 3))); droppyBuilder.AddMenuItem(new DroppyMenuCustomItem(AnimeListPageFlyoutBuilder.BuildItem(context, "Set watched", listener, 4))); } return(droppyBuilder.Build()); }
public AnimeCompactItem(AnimeItemViewModel vm) { this.InitializeComponent(); DataContext = vm; vm.ViewCompact = this; }
public AnimeItem(AnimeItemViewModel vm) { InitializeComponent(); vm.ViewList = this; DataContext = vm; }
private void OnItemClick(AnimeItemViewModel animeItemViewModel) { animeItemViewModel.NavigateDetails(PageIndex.PageCalendar); }
public void ShowScoreDialog(AnimeItemViewModel vm) { AnimeUpdateDialogBuilder.BuildScoreDialog(vm, f => vm.ChangeScore(f.ToString("N0"))); }
private void OnItemClickAction(AnimeItemViewModel animeItemViewModel) { ViewModel.TemporarilySelectedAnimeItem = animeItemViewModel; }
public async Task <IActionResult> Item(int?id) { if (id == null) { return(NotFound()); } var anime = await _context.AnimeItem.FirstOrDefaultAsync(a => a.Id == id); if (anime == null) { return(NotFound()); } else { var name = User.FindFirstValue(ClaimTypes.Name); if (name == null) { var reviewList = await _context.AnimeReviews.Where(a => a.AnimeItemId == anime.Id).OrderByDescending(a => a.Id).Take(5).ToListAsync <AnimeReviews>(); var users = new List <User>(); foreach (var review in reviewList) { var username = await _context.User.FirstOrDefaultAsync(a => a.Id == review.UserId); users.Add(username); } var viewModel = new AnimeItemViewModel { Anime = anime, UserList = users, ReviewsList = reviewList }; return(View(viewModel)); } else { var user = await _context.User.FirstOrDefaultAsync(a => a.UserName == name); var animeList = await _context.AnimeList.Where(a => a.UserId == user.Id).ToListAsync(); bool onList = false; foreach (var animeListItem in animeList) { if (animeListItem.AnimeItemId == anime.Id) { onList = true; } } var reviewList = await _context.AnimeReviews.Where(a => a.AnimeItemId == anime.Id).OrderByDescending(a => a.Id).Take(5).ToListAsync <AnimeReviews>(); var users = new List <User>(); foreach (var review in reviewList) { var username = await _context.User.FirstOrDefaultAsync(a => a.Id == review.UserId); users.Add(username); } var userFavorite = await _context.Favorites.FirstOrDefaultAsync(a => a.UserId == user.Id); bool isUserFavorite = false; if (userFavorite == null) { isUserFavorite = false; } else if (userFavorite.AnimeItemId == anime.Id) { isUserFavorite = true; } var viewModel = new AnimeItemViewModel { Anime = anime, UserList = users, ReviewsList = reviewList, UserListContains = onList, UserFavoriteContains = isUserFavorite }; return(View(viewModel)); } } }