Exemplo n.º 1
0
        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 ();
        }
Exemplo n.º 2
0
        public bool Delete(Catalog catalog)
        {
            lock (locker) {
                int flag = database.Delete<Catalog> (catalog.Id);

                if (flag == 1) {
                    return true;
                } else {
                    return false;
                }
            }
        }
Exemplo n.º 3
0
 public void Add(Catalog catalog)
 {
     catalogsList.Add (catalog);
 }
Exemplo n.º 4
0
 public void Remove(Catalog catalog)
 {
     catalogsList.Remove (catalog);
 }
Exemplo n.º 5
0
 public void Insert(Catalog catalog, int position)
 {
     catalogsList.Insert (position, catalog);
 }
Exemplo n.º 6
0
 public void AddCatalog(Catalog catalog)
 {
     adapter.Add (catalog);
 }
Exemplo n.º 7
0
 public void RemoveCatalog(Catalog catalog)
 {
     adapter.Remove (catalog);
 }
Exemplo n.º 8
0
        public bool Update(Catalog catalog)
        {
            lock (locker) {
                int flag = database.Update (catalog);

                if (flag == 1) {
                    return true;
                } else {
                    return false;
                }
            }
        }
Exemplo n.º 9
0
 public Catalog Insert(Catalog catalog)
 {
     lock (locker) {
         database.Insert (catalog);
         return catalog;
     }
 }
Exemplo n.º 10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            catalog = new Catalog ();
            catalog.Name = Intent.GetStringExtra ("Name");
            catalog.Id = Intent.GetIntExtra ("Id", -1);

            SetContentView (Resource.Layout.CheckinsFragment);

            listViewMovies = FindViewById<ListView> (Resource.Id.listViewMovies);
            adapter = new MovieCatalogAdapter (this);
            listViewMovies.Adapter = adapter;

            movies = new CheckinShared.MovieDB ();
            moviexcatalogs = new CheckinShared.MoviexCatalogDB ();

            listViewMovies.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => {
                Movie movie = movies.Get (adapter.GetMovie (e.Position).IdMovie);

                Intent intent = new Intent (this, typeof(MovieActivity));
                intent.PutExtra ("movieId", movie.Id);
                intent.PutExtra ("mode", "info");

                StartActivity (intent);
            };

            ActualizarLista ();

            ActionBar.SetDisplayHomeAsUpEnabled (true);
            ActionBar.SetDisplayShowTitleEnabled (true);
            ActionBar.SetDisplayShowHomeEnabled (true);
        }
		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);
		}