public override Dialog OnCreateDialog(Bundle bundle) { base.OnCreateDialog (bundle); catalogs = new CheckinShared.CatalogDB (); LayoutInflater inflater = Activity.LayoutInflater; View view = inflater.Inflate (Resource.Layout.AddCatalog, null); EditText textName = view.FindViewById<EditText> (Resource.Id.txtAgregarCatalogo); AlertDialog.Builder builder = new AlertDialog.Builder(Activity); builder.SetTitle ("Crear catálogo"); builder.SetView (view); builder.SetPositiveButton ("Crear", delegate (object sender, DialogClickEventArgs e) { Catalog catalog = new Catalog (); if (textName.Text.Length != 0) { catalog.Name = textName.Text; catalog.Quantity = 0; catalog.UserId = AppHelper.GetCurrentUser(Activity).Id; catalogs.Insert(catalog); catalog.SaveToParse(); Console.WriteLine("ParentFragment: " + ParentFragment); ((CatalogsFragment) ((MainActivity) Activity).CurrentFragment()).AddCatalog(catalog); } }); builder.SetNegativeButton ("Salir", delegate (object sender, DialogClickEventArgs e) { }); return builder.Create (); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.Inflate(Resource.Layout.CatalogsFragment, container, false); catalogs = new CheckinShared.CatalogDB (); Activity.SetProgressBarIndeterminateVisibility (false); Activity.SetProgressBarVisibility (false); ProgressBar progressbarSearch = rootView.FindViewById<ProgressBar> (Resource.Id.CatalogListprogressBar); progressbarSearch.Visibility = ViewStates.Gone; listViewCatalogs = rootView.FindViewById<ListView> (Resource.Id.CatalogListView); adapter = new CatalogAdapter (Activity); SearchView searchViewCatalog = rootView.FindViewById<SearchView> (Resource.Id.CatalogListsearchView1); listViewCatalogs.Adapter = adapter; Toast.MakeText(Activity, catalogs.Count() + " catálogos creados", ToastLength.Long).Show(); listViewCatalogs.ItemLongClick += delegate(object sender, AdapterView.ItemLongClickEventArgs e) { DeleteCatalogDialogFragment dialog = new DeleteCatalogDialogFragment(); dialog.Catalog = adapter.GetCatalog(e.Position); dialog.Show(FragmentManager, "DeleteCatalogDialogFragment"); }; listViewCatalogs.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs e) { Intent intent = new Intent (Activity, typeof(CatalogActivity)); intent.PutExtra("Name",adapter.GetCatalog(e.Position).Name); intent.PutExtra("Id",adapter.GetCatalog(e.Position).Id); // StartActivityForResult (intent, 18); StartActivity(intent); }; searchViewCatalog.QueryTextSubmit += delegate(object sender, SearchView.QueryTextSubmitEventArgs e) { Console.WriteLine(searchViewCatalog.Query); progressbarSearch.Visibility = ViewStates.Visible; adapter.Clear(); foreach (Catalog catalog in catalogs.All()) { if(searchViewCatalog.Query.IndexOf(catalog.Name) != -1) { adapter.Add(catalog); } } progressbarSearch.Visibility = ViewStates.Gone; }; searchViewCatalog.Close += delegate(object sender, SearchView.CloseEventArgs e) { progressbarSearch.Visibility = ViewStates.Gone; }; RefreshList (); return rootView; }
public override Dialog OnCreateDialog(Bundle bundle) { base.OnCreateDialog (bundle); LayoutInflater inflater = Activity.LayoutInflater; View view = inflater.Inflate (Resource.Layout.DeleteCatalog, null); TextView textViewDeleteCatalogName = view.FindViewById<TextView> (Resource.Id.textViewDeleteCatalogName); TextView textViewDeleteCatalogQuantity = view.FindViewById<TextView> (Resource.Id.textViewDeleteCatalogQuantity); if (Catalog != null) { textViewDeleteCatalogName.Text = "Nombre: " + Catalog.Name; textViewDeleteCatalogQuantity.Text = "Cantidad de Peliculas: " + Catalog.Quantity.ToString(); } AlertDialog.Builder builder = new AlertDialog.Builder(Activity); builder.SetTitle ("¿Desea eliminar este catálogo?"); builder.SetView (view); builder.SetPositiveButton ("Sí", delegate (object sender, DialogClickEventArgs e) { CheckinShared.CatalogDB catalogs = new CheckinShared.CatalogDB (); int IdCatalog = Catalog.Id; if (catalogs.Delete(Catalog)) { CheckinShared.MoviexCatalogDB moviexcatalogs = new MoviexCatalogDB(); foreach(MoviexCatalog moviexcatalog in moviexcatalogs.All()) { if(moviexcatalog.IdCatalog == IdCatalog) { moviexcatalogs.Delete(moviexcatalog); } } ((CatalogsFragment) ((MainActivity) Activity).CurrentFragment()).Adapter.Remove(Catalog); Toast.MakeText(Activity, "Catálogo eliminado", ToastLength.Long).Show(); } }); builder.SetNegativeButton ("No", delegate (object sender, DialogClickEventArgs e) { }); return builder.Create (); }
async protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); movies = new CheckinShared.MovieDB (); catalogs = new CheckinShared.CatalogDB (); SetContentView (Resource.Layout.AddMovieToCatalog); idCatalog = Intent.GetIntExtra ("Id", -1); int movieId = this.Intent.GetIntExtra ("movieId", 0); movie = movies.Get (movieId); TMDB api = new TMDB (); if (movie.Overview == null) { JObject movieJSON = await api.Find (movie.ApiId) as JObject; movie.Overview = movieJSON ["overview"].ToString (); movies.Update (movie); } JObject movieCreditsJSON = await api.GetCredits (movie.ApiId) as JObject; if (movie.Director == "" || movie.Director == null) { if (movieCreditsJSON ["crew"].Count () > 0) { for (var i = 0; i < movieCreditsJSON ["crew"].Count (); i++) { var credit = movieCreditsJSON ["crew"] [i]; if (credit ["job"].ToString () == "Director") { movie.Director = credit ["name"].ToString (); break; } } } movies.Update (movie); } if (movie.Cast == "" || movie.Cast == null) { movie.Cast = ""; for (var i = 0; i < movieCreditsJSON ["cast"].Count (); i++) { movie.Cast += movieCreditsJSON ["cast"] [i] ["name"].ToString () + "\n"; } movies.Update (movie); } movie.SaveToParse (); EditText textNombre = FindViewById<EditText> (Resource.Id.txtNombrePelicula); textNombre.Text += movie.Title; EditText textDirector = FindViewById<EditText> (Resource.Id.txtDirectorPelicula); textDirector.Text += movie.Director; EditText textFecha = FindViewById<EditText> (Resource.Id.txtAñoEstrenoPelicula); if (movie.Year != null) { textFecha.Text += movie.Year; } EditText textDescripcion = FindViewById<EditText> (Resource.Id.txtDescripcion); textDescripcion.Text += movie.Overview; imgFoto = FindViewById<ImageView> (Resource.Id.imgFoto); if (movie.PosterPath != null) { Koush.UrlImageViewHelper.SetUrlDrawable (imgFoto, movie.PosterPath); } Spinner spinnerMovieType = FindViewById<Spinner> (Resource.Id.spinnerMovieType); Button btnGuardar = FindViewById<Button> (Resource.Id.btnGuardarPelicula); Button btnCancelar = FindViewById<Button> (Resource.Id.btnCancelarPelicula); btnGuardar.Click += (object sender, EventArgs e) => { moviexcatalog = new MoviexCatalog (); movies = new CheckinShared.MovieDB (); moviexcatalogs = new CheckinShared.MoviexCatalogDB (); catalogs = new CheckinShared.CatalogDB (); Intent intent = new Intent (); movie = movies.Insert (movie); moviexcatalog.IdMovie = movie.Id; if (spinnerMovieType.SelectedItemPosition == 0) { moviexcatalog.MovieType = "Physical"; } else { moviexcatalog.MovieType = "Digital"; } if (Camera._file != null) { moviexcatalog.PhotoPath = Camera._file.Path; } else { moviexcatalog.PhotoPath = movie.PosterPath; } if (idCatalog != -1) { Catalog catalog = new Catalog (); moviexcatalog.IdCatalog = idCatalog; catalog = catalogs.Get (idCatalog); catalog.Quantity += 1; catalogs.Update (catalog); intent.PutExtra ("movieId", movie.Id); } moviexcatalogs.Insert (moviexcatalog); moviexcatalog.SaveToParse (); if (idCatalog != -1) { catalogs.Get (idCatalog).SaveToParse (); } System.Console.WriteLine (moviexcatalog.PhotoPath); intent.PutExtra ("moviexCatalogId", moviexcatalog.Id); SetResult (Result.Ok, intent); Finish (); }; btnCancelar.Click += (object sender, EventArgs e) => { Intent intent = new Intent (); SetResult (Result.Canceled, intent); Finish (); }; imgFoto.Click += (object sender, EventArgs e) => { if (IsThereAnAppToTakePictures ()) { CreateDirectoryForPictures (); TakeAPicture (sender, e); } }; ActionBar.SetDisplayHomeAsUpEnabled (true); ActionBar.SetDisplayShowTitleEnabled (true); ActionBar.SetDisplayShowHomeEnabled (true); }
public override bool OnOptionsItemSelected (IMenuItem item) { if (item.ItemId == 1) { MoviexCatalog moviexcatalog = new MoviexCatalog (); movies = new CheckinShared.MovieDB (); moviexcatalogs = new CheckinShared.MoviexCatalogDB (); catalogs = new CheckinShared.CatalogDB (); Intent intent = new Intent (); movie.Poster = Camera.bitmap; movie = movies.Insert (movie); moviexcatalog.IdMovie = movie.Id; if (idCatalog != -1) { Catalog catalog = new Catalog (); moviexcatalog.IdCatalog = idCatalog; moviexcatalogs.Insert (moviexcatalog); catalog = catalogs.Get (idCatalog); catalog.Quantity += 1; catalogs.Update (catalog); intent.PutExtra ("movieId", movie.Id); } SetResult (Result.Ok, intent); Finish (); } return base.OnOptionsItemSelected (item); }