use of org.jaudiotagger.tag.TagException in project JamsMusicPlayer by psaravan.
the class AsyncGetAlbumArtTask method doInBackground.
@Override
protected Integer doInBackground(String... params) {
//First, we'll make a HTTP request to iTunes' servers with the album and artist name.
if (params.length == 2) {
artist = params[0];
album = params[1];
//Create duplicate strings that will be filtered out for the URL.
urlArtist = artist;
urlAlbum = album;
//Remove any unacceptable characters.
if (urlArtist.contains("#")) {
urlArtist = urlArtist.replace("#", "");
}
if (urlArtist.contains("$")) {
urlArtist = urlArtist.replace("$", "");
}
if (urlArtist.contains("@")) {
urlArtist = urlArtist.replace("@", "");
}
if (urlAlbum.contains("#")) {
urlAlbum = urlAlbum.replace("#", "");
}
if (urlAlbum.contains("$")) {
urlAlbum = urlAlbum.replace("$", "");
}
if (urlAlbum.contains("@")) {
urlAlbum = urlAlbum.replace("@", "");
}
//Replace any spaces in the artist and album fields with "%20".
if (urlArtist.contains(" ")) {
urlArtist = urlArtist.replace(" ", "%20");
}
if (urlAlbum.contains(" ")) {
urlAlbum = urlAlbum.replace(" ", "%20");
}
}
//Construct the url for the HTTP request.
URL uri = null;
try {
uri = new URL("http://itunes.apple.com/search?term=" + urlArtist + "+" + urlAlbum + "&entity=album");
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
return 1;
}
try {
//Create a new HTTP connection.
HttpURLConnection urlConnection = (HttpURLConnection) uri.openConnection();
urlConnection.connect();
//Set the destination directory for the xml file.
File SDCardRoot = Environment.getExternalStorageDirectory();
file = new File(SDCardRoot, "albumArt.xml");
//Create the OuputStream that will be used to store the downloaded data into the file.
FileOutputStream fileOutput = new FileOutputStream(file);
//Create the InputStream that will read the data from the HTTP connection.
InputStream inputStream = urlConnection.getInputStream();
//Total size of target file.
int totalSize = urlConnection.getContentLength();
//Temp variable that stores the number of downloaded bytes.
int downloadedSize = 0;
//Create a buffer to store the downloaded bytes.
byte[] buffer = new byte[1024];
int bufferLength = 0;
//Now read through the buffer and write the contents to the file.
while ((bufferLength = inputStream.read(buffer)) > 0) {
fileOutput.write(buffer, 0, bufferLength);
downloadedSize += bufferLength;
}
//Close the File Output Stream.
fileOutput.close();
} catch (MalformedURLException e) {
//TODO Auto-generated method stub
e.printStackTrace();
return 1;
} catch (IOException e) {
// TODO Auto-generated method stub
e.printStackTrace();
return 1;
}
//Create a File object that points to the downloaded file.
File phpSource = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/albumArt.xml");
String phpAsString = null;
try {
phpAsString = FileUtils.readFileToString(phpSource);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return 1;
}
//Extract the albumArt parameter from the PHP response.
artworkURL = StringUtils.substringBetween(phpAsString, "\"artworkUrl100\":\"", "\",");
if (artworkURL == null) {
//Check and see if a lower resolution image available.
artworkURL = StringUtils.substringBetween(phpAsString, "\"artworkUrl60\":\"", "\",");
if (artworkURL == null) {
URL_RETRIEVED = false;
return 1;
} else {
//Replace "100x100" with "600x600" to retrieve larger album art images.
artworkURL = artworkURL.replace("100x100", "600x600");
URL_RETRIEVED = true;
}
} else {
//Replace "100x100" with "600x600" to retrieve larger album art images.
artworkURL = artworkURL.replace("100x100", "600x600");
URL_RETRIEVED = true;
}
//Replace any rogue apostrophes.
if (album.contains("'")) {
album = album.replace("'", "''");
}
if (artist.contains("'")) {
artist = artist.replace("'", "''");
}
String selection = DBAccessHelper.SONG_ALBUM + "=" + "'" + album + "'" + " AND " + DBAccessHelper.SONG_ARTIST + "=" + "'" + artist + "'";
String[] projection = { DBAccessHelper._ID, DBAccessHelper.SONG_FILE_PATH };
Cursor cursor = mApp.getDBAccessHelper().getWritableDatabase().query(DBAccessHelper.MUSIC_LIBRARY_TABLE, projection, selection, null, null, null, null);
if (cursor.getCount() != 0) {
cursor.moveToFirst();
dataURIsList.add(cursor.getString(1));
while (cursor.moveToNext()) {
dataURIsList.add(cursor.getString(1));
}
}
cursor.close();
if (URL_RETRIEVED == true) {
artworkBitmap = mApp.getImageLoader().loadImageSync(artworkURL);
File artworkFile = new File(Environment.getExternalStorageDirectory() + "/artwork.jpg");
//Display the album art on the grid/listview so that the user knows that the download is complete.
publishProgress();
//Save the artwork.
try {
FileOutputStream out = new FileOutputStream(artworkFile);
artworkBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
return 1;
} finally {
for (int i = 0; i < dataURIsList.size(); i++) {
if (dataURIsList.get(i) != null) {
File audioFile = new File(dataURIsList.get(i));
AudioFile f = null;
try {
f = AudioFileIO.read(audioFile);
} catch (CannotReadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TagException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ReadOnlyFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidAudioFrameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Tag tag = null;
try {
if (f != null) {
tag = f.getTag();
} else {
continue;
}
} catch (Exception e) {
e.printStackTrace();
continue;
}
Artwork artwork = null;
try {
artwork = ArtworkFactory.createArtworkFromFile(artworkFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
setArtworkAsFile(artworkFile, dataURIsList.get(i));
continue;
} catch (Error e) {
e.printStackTrace();
setArtworkAsFile(artworkFile, dataURIsList.get(i));
continue;
}
if (artwork != null) {
try {
tag.setField(artwork);
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
setArtworkAsFile(artworkFile, dataURIsList.get(i));
continue;
} catch (Exception e) {
e.printStackTrace();
setArtworkAsFile(artworkFile, dataURIsList.get(i));
continue;
} catch (Error e) {
e.printStackTrace();
setArtworkAsFile(artworkFile, dataURIsList.get(i));
continue;
}
}
try {
f.commit();
} catch (CannotWriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
setArtworkAsFile(artworkFile, dataURIsList.get(i));
continue;
} catch (Error e) {
e.printStackTrace();
setArtworkAsFile(artworkFile, dataURIsList.get(i));
continue;
}
//Update the album art tag in Jams' database.
ContentValues values = new ContentValues();
String filePath = dataURIsList.get(i);
filePath = filePath.replace("'", "''");
String where = DBAccessHelper.SONG_FILE_PATH + "=" + "'" + filePath + "'";
values.put(DBAccessHelper.SONG_ALBUM_ART_PATH, "byte://" + dataURIsList.get(i));
mApp.getDBAccessHelper().getWritableDatabase().update(DBAccessHelper.MUSIC_LIBRARY_TABLE, values, where, null);
} else {
continue;
}
}
//Refresh the memory/disk cache for the ImageLoader instance.
try {
mApp.getImageLoader().clearMemoryCache();
mApp.getImageLoader().clearDiscCache();
} catch (Exception e) {
e.printStackTrace();
}
//Delete the temporary files once the artwork has been embedded.
artworkFile.delete();
file.delete();
}
}
return 0;
}
use of org.jaudiotagger.tag.TagException in project JamsMusicPlayer by psaravan.
the class ID3sAlbumEditorDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mApp = (Common) getActivity().getApplicationContext();
parentActivity = getActivity();
dialogFragment = this;
titlesList = new ArrayList<String>();
artistsList = new ArrayList<String>();
albumsList = new ArrayList<String>();
albumArtistsList = new ArrayList<String>();
genresList = new ArrayList<String>();
producersList = new ArrayList<String>();
yearsList = new ArrayList<String>();
trackNumbersList = new ArrayList<String>();
totalTracksList = new ArrayList<String>();
commentsList = new ArrayList<String>();
songURIsList = new ArrayList<String>();
songSourcesList = new ArrayList<String>();
songIdsList = new ArrayList<String>();
rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_edit_id3_artist_album_dialog, null);
titleText = (TextView) rootView.findViewById(R.id.edit_title_text);
artistText = (TextView) rootView.findViewById(R.id.edit_artist_text);
albumText = (TextView) rootView.findViewById(R.id.edit_album_text);
albumArtistText = (TextView) rootView.findViewById(R.id.edit_album_artist_text);
genreText = (TextView) rootView.findViewById(R.id.edit_genre_text);
producerText = (TextView) rootView.findViewById(R.id.edit_producer_text);
yearText = (TextView) rootView.findViewById(R.id.edit_year_text);
trackText = (TextView) rootView.findViewById(R.id.edit_track_text);
ofText = (TextView) rootView.findViewById(R.id.text_of);
commentsText = (TextView) rootView.findViewById(R.id.edit_comment_text);
titleEditText = (EditText) rootView.findViewById(R.id.edit_title_field);
artistEditText = (EditText) rootView.findViewById(R.id.edit_artist_field);
albumEditText = (EditText) rootView.findViewById(R.id.edit_album_field);
albumArtistEditText = (EditText) rootView.findViewById(R.id.edit_album_artist_field);
genreEditText = (EditText) rootView.findViewById(R.id.edit_genre_field);
producerEditText = (EditText) rootView.findViewById(R.id.edit_producer_field);
yearEditText = (EditText) rootView.findViewById(R.id.edit_year_field);
trackEditText = (EditText) rootView.findViewById(R.id.edit_track_field);
trackTotalEditText = (EditText) rootView.findViewById(R.id.edit_track_total_field);
commentsEditText = (EditText) rootView.findViewById(R.id.edit_comment_field);
titleCheckbox = (CheckBox) rootView.findViewById(R.id.title_checkbox);
artistCheckbox = (CheckBox) rootView.findViewById(R.id.artist_checkbox);
albumCheckbox = (CheckBox) rootView.findViewById(R.id.album_checkbox);
albumArtistCheckbox = (CheckBox) rootView.findViewById(R.id.album_artist_checkbox);
genreCheckbox = (CheckBox) rootView.findViewById(R.id.genre_checkbox);
producerCheckbox = (CheckBox) rootView.findViewById(R.id.producer_checkbox);
yearCheckbox = (CheckBox) rootView.findViewById(R.id.year_checkbox);
trackCheckbox = (CheckBox) rootView.findViewById(R.id.track_checkbox);
commentCheckbox = (CheckBox) rootView.findViewById(R.id.comment_checkbox);
titleText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
artistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
albumText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
albumArtistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
genreText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
producerText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
yearText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
trackText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
ofText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
commentsText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
titleText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
artistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
albumText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
albumArtistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
genreText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
producerText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
yearText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
trackText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
ofText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
commentsText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
titleEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
artistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
albumEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
albumArtistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
genreEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
producerEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
yearEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
trackEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
trackTotalEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
commentsEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
titleEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
artistEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
albumEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
albumArtistEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
genreEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
producerEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
yearEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
trackEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
trackTotalEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
commentsEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
//Keep all the fields locked by default.
titleCheckbox.setChecked(false);
artistCheckbox.setChecked(false);
albumCheckbox.setChecked(false);
albumArtistCheckbox.setChecked(false);
genreCheckbox.setChecked(false);
producerCheckbox.setChecked(false);
yearCheckbox.setChecked(false);
trackCheckbox.setChecked(false);
commentCheckbox.setChecked(false);
//Disable all EditTexts by default.
titleEditText.setEnabled(false);
artistEditText.setEnabled(false);
albumEditText.setEnabled(false);
albumArtistEditText.setEnabled(false);
genreEditText.setEnabled(false);
producerEditText.setEnabled(false);
yearEditText.setEnabled(false);
trackEditText.setEnabled(false);
commentsEditText.setEnabled(false);
//Register click registers on each checkbox.
titleCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
titleEdited = true;
titleEditText.setEnabled(true);
} else {
titleEdited = false;
titleEditText.setEnabled(false);
}
}
});
artistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
artistEdited = true;
artistEditText.setEnabled(true);
;
} else {
artistEdited = false;
artistEditText.setEnabled(false);
}
}
});
albumArtistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
albumEdited = true;
albumEditText.setEnabled(true);
;
} else {
albumEdited = false;
albumEditText.setEnabled(false);
}
}
});
albumCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
albumArtistEdited = true;
albumArtistEditText.setEnabled(true);
;
} else {
albumArtistEdited = false;
albumArtistEditText.setEnabled(false);
}
}
});
genreCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
genreEdited = true;
genreEditText.setEnabled(true);
;
} else {
genreEdited = false;
genreEditText.setEnabled(false);
}
}
});
producerCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
producerEdited = true;
producerEditText.setEnabled(true);
;
} else {
producerEdited = false;
producerEditText.setEnabled(false);
}
}
});
yearCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
yearEdited = true;
yearEditText.setEnabled(true);
;
} else {
yearEdited = false;
yearEditText.setEnabled(false);
}
}
});
trackCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
trackEdited = true;
trackEditText.setEnabled(true);
;
} else {
trackEdited = false;
trackEditText.setEnabled(false);
}
}
});
commentCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
commentEdited = true;
commentsEditText.setEnabled(true);
;
} else {
commentEdited = false;
commentsEditText.setEnabled(false);
}
}
});
//Get the album and artist name.
ARTIST = getArguments().getString("ARTIST");
ALBUM = getArguments().getString("ALBUM");
CALLING_FRAGMENT = getArguments().getString("CALLING_FRAGMENT");
if (ARTIST != null && ALBUM != null) {
songURIsList = getAllSongsInAlbum(ALBUM, ARTIST);
//Populate the ArrayLists with the song tags.
try {
getSongTags(songURIsList);
} catch (CannotReadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TagException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ReadOnlyFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidAudioFrameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Now check if any of the ArrayLists contain the same exact elements.
boolean titlesSame = checkIfAllElementsEqual(titlesList);
boolean artistsSame = checkIfAllElementsEqual(artistsList);
boolean albumsSame = checkIfAllElementsEqual(albumsList);
boolean albumArtistsSame = checkIfAllElementsEqual(albumArtistsList);
boolean genresSame = checkIfAllElementsEqual(genresList);
boolean producersSame = checkIfAllElementsEqual(producersList);
boolean yearsSame = checkIfAllElementsEqual(yearsList);
boolean tracksSame = checkIfAllElementsEqual(trackNumbersList);
boolean totalTracksSame = checkIfAllElementsEqual(totalTracksList);
boolean commentsSame = checkIfAllElementsEqual(commentsList);
//Populate the EditTexts.
setEditorFields(titlesSame, titlesList, titleEditText);
setEditorFields(artistsSame, artistsList, artistEditText);
setEditorFields(albumsSame, albumsList, albumEditText);
setEditorFields(albumArtistsSame, albumArtistsList, albumArtistEditText);
setEditorFields(genresSame, genresList, genreEditText);
setEditorFields(producersSame, producersList, producerEditText);
setEditorFields(yearsSame, yearsList, yearEditText);
setEditorFields(tracksSame, trackNumbersList, trackEditText);
setEditorFields(totalTracksSame, totalTracksList, trackTotalEditText);
setEditorFields(commentsSame, commentsList, commentsEditText);
}
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
//Set the dialog title.
builder.setTitle(R.string.edit_tags);
builder.setView(rootView);
builder.setNeutralButton(R.string.save, new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
AsyncSaveAlbumTagsTask asyncSaveAlbumTagsTask = new AsyncSaveAlbumTagsTask(getActivity(), getActivity());
asyncSaveAlbumTagsTask.execute();
}
});
builder.setNegativeButton(R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
clearArrayLists();
dialogFragment.dismiss();
}
});
return builder.create();
}
use of org.jaudiotagger.tag.TagException in project JamsMusicPlayer by psaravan.
the class ID3sArtistEditorDialog method getSongTags.
//This method loops through all the songs and saves their tags into ArrayLists.
public void getSongTags(ArrayList<String> dataURIsList) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException {
for (int i = 0; i < dataURIsList.size(); i++) {
try {
File file = new File(dataURIsList.get(i));
AudioFile audioFile = AudioFileIO.read(file);
titlesList.add(audioFile.getTag().getFirst(FieldKey.TITLE));
artistsList.add(audioFile.getTag().getFirst(FieldKey.ARTIST));
albumsList.add(audioFile.getTag().getFirst(FieldKey.ALBUM));
albumArtistsList.add(audioFile.getTag().getFirst(FieldKey.ALBUM_ARTIST));
genresList.add(audioFile.getTag().getFirst(FieldKey.GENRE));
producersList.add(audioFile.getTag().getFirst(FieldKey.PRODUCER));
yearsList.add(audioFile.getTag().getFirst(FieldKey.YEAR));
trackNumbersList.add(audioFile.getTag().getFirst(FieldKey.TRACK));
totalTracksList.add(audioFile.getTag().getFirst(FieldKey.TRACK_TOTAL));
commentsList.add(audioFile.getTag().getFirst(FieldKey.COMMENT));
} catch (Exception e) {
e.printStackTrace();
continue;
}
}
}
use of org.jaudiotagger.tag.TagException in project JamsMusicPlayer by psaravan.
the class ID3sSongEditorDialog method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
mContext = getActivity();
parentActivity = getActivity();
dialogFragment = this;
rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_edit_id3_artist_album_dialog, null);
titleText = (TextView) rootView.findViewById(R.id.edit_title_text);
artistText = (TextView) rootView.findViewById(R.id.edit_artist_text);
albumText = (TextView) rootView.findViewById(R.id.edit_album_text);
albumArtistText = (TextView) rootView.findViewById(R.id.edit_album_artist_text);
genreText = (TextView) rootView.findViewById(R.id.edit_genre_text);
producerText = (TextView) rootView.findViewById(R.id.edit_producer_text);
yearText = (TextView) rootView.findViewById(R.id.edit_year_text);
trackText = (TextView) rootView.findViewById(R.id.edit_track_text);
ofText = (TextView) rootView.findViewById(R.id.text_of);
commentsText = (TextView) rootView.findViewById(R.id.edit_comment_text);
titleEditText = (EditText) rootView.findViewById(R.id.edit_title_field);
artistEditText = (EditText) rootView.findViewById(R.id.edit_artist_field);
albumEditText = (EditText) rootView.findViewById(R.id.edit_album_field);
albumArtistEditText = (EditText) rootView.findViewById(R.id.edit_album_artist_field);
genreEditText = (EditText) rootView.findViewById(R.id.edit_genre_field);
producerEditText = (EditText) rootView.findViewById(R.id.edit_producer_field);
yearEditText = (EditText) rootView.findViewById(R.id.edit_year_field);
trackEditText = (EditText) rootView.findViewById(R.id.edit_track_field);
trackTotalEditText = (EditText) rootView.findViewById(R.id.edit_track_total_field);
commentsEditText = (EditText) rootView.findViewById(R.id.edit_comment_field);
titleCheckbox = (CheckBox) rootView.findViewById(R.id.title_checkbox);
artistCheckbox = (CheckBox) rootView.findViewById(R.id.artist_checkbox);
albumCheckbox = (CheckBox) rootView.findViewById(R.id.album_checkbox);
albumArtistCheckbox = (CheckBox) rootView.findViewById(R.id.album_artist_checkbox);
genreCheckbox = (CheckBox) rootView.findViewById(R.id.genre_checkbox);
producerCheckbox = (CheckBox) rootView.findViewById(R.id.producer_checkbox);
yearCheckbox = (CheckBox) rootView.findViewById(R.id.year_checkbox);
trackCheckbox = (CheckBox) rootView.findViewById(R.id.track_checkbox);
commentCheckbox = (CheckBox) rootView.findViewById(R.id.comment_checkbox);
titleText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
artistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
albumText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
albumArtistText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
genreText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
producerText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
yearText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
trackText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
ofText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
commentsText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
titleText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
artistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
albumText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
albumArtistText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
genreText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
producerText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
yearText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
trackText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
ofText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
commentsText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG);
titleEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
artistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
albumEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
albumArtistEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
genreEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
producerEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
yearEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
trackEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
trackTotalEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
commentsEditText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light"));
titleEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
artistEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
albumEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
albumArtistEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
genreEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
producerEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
yearEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
trackEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
trackTotalEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
commentsEditText.setPaintFlags(titleText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);
//Keep all the fields locked by default.
titleCheckbox.setChecked(false);
artistCheckbox.setChecked(false);
albumCheckbox.setChecked(false);
albumArtistCheckbox.setChecked(false);
genreCheckbox.setChecked(false);
producerCheckbox.setChecked(false);
yearCheckbox.setChecked(false);
trackCheckbox.setChecked(false);
commentCheckbox.setChecked(false);
//Disable all EditTexts by default.
titleEditText.setEnabled(false);
artistEditText.setEnabled(false);
albumEditText.setEnabled(false);
albumArtistEditText.setEnabled(false);
genreEditText.setEnabled(false);
producerEditText.setEnabled(false);
yearEditText.setEnabled(false);
trackEditText.setEnabled(false);
commentsEditText.setEnabled(false);
//Register click registers on each checkbox.
titleCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
titleEdited = true;
titleEditText.setEnabled(true);
} else {
titleEdited = false;
titleEditText.setEnabled(false);
}
}
});
artistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
artistEdited = true;
artistEditText.setEnabled(true);
;
} else {
artistEdited = false;
artistEditText.setEnabled(false);
}
}
});
albumArtistCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
albumEdited = true;
albumEditText.setEnabled(true);
;
} else {
albumEdited = false;
albumEditText.setEnabled(false);
}
}
});
albumCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
albumArtistEdited = true;
albumArtistEditText.setEnabled(true);
;
} else {
albumArtistEdited = false;
albumArtistEditText.setEnabled(false);
}
}
});
genreCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
genreEdited = true;
genreEditText.setEnabled(true);
;
} else {
genreEdited = false;
genreEditText.setEnabled(false);
}
}
});
producerCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
producerEdited = true;
producerEditText.setEnabled(true);
;
} else {
producerEdited = false;
producerEditText.setEnabled(false);
}
}
});
yearCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
yearEdited = true;
yearEditText.setEnabled(true);
;
} else {
yearEdited = false;
yearEditText.setEnabled(false);
}
}
});
trackCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
trackEdited = true;
trackEditText.setEnabled(true);
;
} else {
trackEdited = false;
trackEditText.setEnabled(false);
}
}
});
commentCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton checkbox, boolean checked) {
if (checked == true) {
commentEdited = true;
commentsEditText.setEnabled(true);
;
} else {
commentEdited = false;
commentsEditText.setEnabled(false);
}
}
});
//Get the song uri.
SONG_URI = getArguments().getString("SONG");
//Get the calling Fragment and retrieve the child view from it.
CALLING_FRAGMENT = getArguments().getString("CALLING_FRAGMENT");
if (SONG_URI != null) {
//Populate the ArrayLists with the song tags.
try {
getSongTags(SONG_URI);
} catch (CannotReadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TagException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ReadOnlyFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidAudioFrameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
//Set the dialog title.
builder.setTitle(R.string.edit_tags);
builder.setView(rootView);
builder.setPositiveButton(R.string.save, new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
dialogFragment.dismiss();
boolean saveSucceeded = saveSongTags(SONG_URI);
//Check if the write operations succeeded. If they didn't, display an error message.
if (saveSucceeded == true) {
Toast.makeText(getActivity().getApplicationContext(), R.string.song_tags_saved, Toast.LENGTH_SHORT).show();
/* //Reinitialize the calling fragment.
if (CALLING_FRAGMENT.equals("SONGS_FRAGMENT")) {
} else if (CALLING_FRAGMENT.equals("ARTISTS_FLIPPED_SONGS_FRAGMENT")) {
//ArtistsFlippedSongsFragment.getCursor();
ArtistsFlippedSongsFragment.songsListViewAdapter.notifyDataSetChanged();
} else if (CALLING_FRAGMENT.equals("ALBUMS_FLIPPED_FRAGMENT")) {
AlbumsFlippedFragment.getCursor();
AlbumsFlippedFragment.albumsFlippedListViewAdapter.notifyDataSetChanged();
} else if (CALLING_FRAGMENT.equals("ALBUM_ARTISTS_FLIPPED_SONGS_FRAGMENT")) {
AlbumArtistsFlippedSongsFragment.getCursor();
AlbumArtistsFlippedSongsFragment.songsListViewAdapter.notifyDataSetChanged();
} else if (CALLING_FRAGMENT.equals("GENRES_FLIPPED_SONGS_FRAGMENT")) {
GenresFlippedFragment.getCursor();
GenresFlippedFragment.genresFlippedListViewAdapter.notifyDataSetChanged();
}*/
} else {
Toast.makeText(parentActivity, R.string.error_occurred_tags, Toast.LENGTH_LONG).show();
}
}
});
builder.setNegativeButton(R.string.cancel, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return builder.create();
}
use of org.jaudiotagger.tag.TagException in project JamsMusicPlayer by psaravan.
the class ID3sSongEditorDialog method saveSongTags.
//This method is called if the user touches the 'OK' button when they're editing an individual song's tags.
public boolean saveSongTags(String uri) {
File file = new File(uri);
AudioFile audioFile = null;
//Update the DB entries.
DBAccessHelper dbHelper = new DBAccessHelper(mContext.getApplicationContext());
//Escape any rogue apostrophes.
if (SONG_URI.contains("'")) {
SONG_URI = SONG_URI.replace("'", "''");
}
String whereClause = DBAccessHelper.SONG_FILE_PATH + "=" + "'" + SONG_URI + "'";
ContentValues values = new ContentValues();
try {
audioFile = AudioFileIO.read(file);
} catch (CannotReadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (TagException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ReadOnlyFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidAudioFrameException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Tag tag = audioFile.getTag();
if (tag != null) {
if (titleEdited == false) {
//Don't do anything here. The user didn't change the title.
} else {
try {
tag.setField(FieldKey.TITLE, titleEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String title = titleEditText.getText().toString();
if (title.contains("'")) {
title = title.replace("'", "''");
}
values.put(DBAccessHelper.SONG_TITLE, title);
}
if (albumEdited == false) {
//Don't do anything here. The user didn't change the album.
} else {
try {
tag.setField(FieldKey.ALBUM, albumEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String album = albumEditText.getText().toString();
if (album.contains("'")) {
album = album.replace("'", "''");
}
values.put(DBAccessHelper.SONG_ALBUM, album);
}
if (artistEdited == false) {
//Don't do anything here. The user didn't change the artist.
} else {
try {
tag.setField(FieldKey.ARTIST, artistEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String artist = artistEditText.getText().toString();
if (artist.contains("'")) {
artist = artist.replace("'", "''");
}
values.put(DBAccessHelper.SONG_ARTIST, artist);
}
if (albumArtistEdited == false) {
//Don't do anything here. The user didn't change the album artist.
} else {
try {
tag.setField(FieldKey.ALBUM_ARTIST, albumArtistEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String albumArtist = albumArtistEditText.getText().toString();
if (albumArtist.contains("'")) {
albumArtist = albumArtist.replace("'", "''");
}
values.put(DBAccessHelper.SONG_ALBUM_ARTIST, albumArtist);
}
if (genreEdited == false) {
//Don't do anything here. The user didn't change the genre.
} else {
try {
tag.setField(FieldKey.GENRE, genreEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (producerEdited == false) {
//Don't do anything here. The user didn't change the producer.
} else {
try {
tag.setField(FieldKey.PRODUCER, producerEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (yearEdited == false) {
//Don't do anything here. The user didn't change the year.
} else {
try {
tag.setField(FieldKey.YEAR, yearEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String year = yearEditText.getText().toString();
if (year.contains("'")) {
year = year.replace("'", "''");
}
values.put(DBAccessHelper.SONG_YEAR, year);
}
if (trackEdited == false) {
//Don't do anything here. The user didn't change the track number.
} else {
try {
tag.setField(FieldKey.TRACK, trackEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String track = trackEditText.getText().toString();
if (track.contains("'")) {
track = track.replace("'", "''");
}
values.put(DBAccessHelper.SONG_TRACK_NUMBER, track);
}
try {
tag.setField(FieldKey.TRACK_TOTAL, trackTotalEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (commentEdited == false) {
//Don't do anything here. The user didn't change the comments.
} else {
try {
tag.setField(FieldKey.COMMENT, commentsEditText.getText().toString());
} catch (KeyNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FieldDataInvalidException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchElementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
audioFile.commit();
} catch (CannotWriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Write the values to the DB.
if (values.size() != 0) {
//Write the values to the DB.
try {
dbHelper.getWritableDatabase().update(DBAccessHelper.MUSIC_LIBRARY_TABLE, values, whereClause, null);
dbHelper.close();
dbHelper = null;
} catch (Exception e) {
e.printStackTrace();
}
}
} else {
Toast.makeText(mContext, R.string.unable_to_edit_song_tags, Toast.LENGTH_SHORT).show();
}
return true;
}
Aggregations