public void afficherFilmChoisis(String titre) { Video film = this.obtenirVideo(titre); String catos = this.obtenirCategoriesEnString( comboCollection.getItemAt(comboCollection.getSelectedIndex()).toString()); if (mode[0].isSelected()) { String filmOuSerie = "SERIE TV"; String eval = ""; if (film.getEval() == 1) { eval = String.valueOf(film.getEval()) + " etoile"; } else if (film.getEval() > 1) { eval = String.valueOf(film.getEval()) + " etoiles"; } if (film.isFilm()) { filmOuSerie = "FILM"; } infos_film[0].setText(titre); infos_film[1].setText(String.valueOf(film.getAnnee())); infos_film[2].setText(filmOuSerie); infos_film[3].setText(eval); } else { textTitre.setText(film.getTitre()); textAnnee.setText(String.valueOf(film.getAnnee())); comboEval.setSelectedIndex(film.getEval()); boolean isFilm = film.isFilm(); if (isFilm) { comboType.setSelectedIndex(1); } else { comboType.setSelectedIndex(2); } } textCommentaires.setText(film.getCommentaires()); textCategories.setText(catos); }
public void sauvegarder() { final String PATH = "./videos.txt"; File fichier = new File(PATH); String formatDeSortie = ""; for (Video video : this.obtenirCollection()) { String catos = this.obtenirCategoriesEnString(video.getTitre()); catos = catos.replace("\n", "::"); String comments = video.getCommentaires(); comments = comments.replace("\n", "[*]"); formatDeSortie += video.getTitre() + "::"; formatDeSortie += video.getAnnee() + "::"; if (video.isFilm()) { formatDeSortie += "FILM" + "::"; } else { formatDeSortie += "SÉRIE TV" + "::"; } formatDeSortie += video.getEval() + "::"; formatDeSortie += comments; // Comments formatDeSortie += "::"; formatDeSortie += catos; // Catos formatDeSortie += "\r\n"; // Petit fix pour que les new lines append au fichier txt } formatDeSortie = formatDeSortie.substring(0, formatDeSortie.length() - 1); try { FileWriter ecrivain = new FileWriter(fichier); ecrivain.write(formatDeSortie); ecrivain.close(); } catch (IOException io) { io.getMessage(); } }
// Recherche avec les informations dans TITRE, ANNEE, TYPE, EVALUATION, COMMENTAIRES, CATEGORIES // en && // Considère les champs vides comme des */ALL // Donne un array de videos qui respecte la query public ArrayList<Video> rechercherVideos( String titre, int annee, int eval, int type, String categories) { ArrayList<Video> listeCollection = new ArrayList<>(); ArrayList<Video> correctCollection = new ArrayList<>(); for (String categorie : liste.obtenirCles()) { for (Video video : liste.obtenirElements(categorie)) { if (!listeCollection.contains(video)) { listeCollection.add(video); } } } correctCollection.addAll(listeCollection); String[] arrayCategories = categories.split("\\r?\\n"); if (!titre.equals("") && titre != null) { for (Video video : listeCollection) { if (!video.getTitre().contains(titre)) { correctCollection.remove(video); } } } if (annee != -1) { for (Video video : listeCollection) { if (video.getAnnee() != annee) { // correctCollection.add(video); correctCollection.remove(video); } } } if (type != -1) { boolean controle; if (type == 0) { controle = true; } else { controle = false; } for (Video video : listeCollection) { if (video.isFilm() != controle) { // correctCollection.add(video); correctCollection.remove(video); } } } ArrayList<Video> categoriesCollection = new ArrayList<Video>(); if (!categories.equals("")) { for (String categorie : arrayCategories) { for (String cato : liste.obtenirCles()) {} ArrayList<Video> f**k = liste.obtenirElements(liste.obtenirCles().get(liste.obtenirCles().indexOf(categorie))); // for(Video video : // liste.obtenirElements(liste.obtenirCles().get(liste.obtenirCles().indexOf(categorie)))){ // for(Video video : liste.obtenirElements(categorie)){ for (Video video : f**k) { if (!categoriesCollection.contains(video)) { categoriesCollection.add(video); } } } for (Video video : listeCollection) { if (!categoriesCollection.contains(video)) { correctCollection.remove(video); } } } return correctCollection; }