From 6d9d3101c12828b01e02af45afaf0266bd2f84ab Mon Sep 17 00:00:00 2001 From: dkanada Date: Wed, 17 Jul 2019 23:56:05 -0700 Subject: [PATCH] add some logging --- app/src/main/AndroidManifest.xml | 2 +- .../adapter/AlbumCoverPagerAdapter.java | 4 +- .../adapter/album/AlbumAdapter.java | 4 +- .../adapter/album/HorizontalAlbumAdapter.java | 4 +- .../adapter/artist/ArtistAdapter.java | 4 +- .../gramophone/adapter/song/SongAdapter.java | 4 +- ...lideModule.java => CustomGlideModule.java} | 2 +- ...edTarget.java => CustomPaletteTarget.java} | 4 +- .../audiocover/AudioFileCoverFetcher.java | 9 +- .../audiocover/AudioFileCoverLoader.java | 2 - .../glide/audiocover/AudioFileCoverUtils.java | 18 +-- .../ui/activities/AlbumDetailActivity.java | 4 +- .../ui/activities/ArtistDetailActivity.java | 4 +- app/src/main/res/raw/notices.xml | 133 ------------------ 14 files changed, 27 insertions(+), 171 deletions(-) rename app/src/main/java/com/kabouzeid/gramophone/glide/{PhonographGlideModule.java => CustomGlideModule.java} (93%) rename app/src/main/java/com/kabouzeid/gramophone/glide/{PhonographColoredTarget.java => CustomPaletteTarget.java} (91%) delete mode 100644 app/src/main/res/raw/notices.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 24bd676c..c5e2b4ef 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -82,7 +82,7 @@ android:name="com.lge.support.SPLIT_WINDOW" android:value="true" /> { private InputStream stream; public AudioFileCoverFetcher(AudioFileCover model) { - this.model = model; } @Override public String getId() { - // makes sure we never ever return null here + // make sure we never return null here return String.valueOf(model.filePath); } @Override public InputStream loadData(final Priority priority) throws Exception { - final MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(model.filePath); @@ -49,12 +47,13 @@ public class AudioFileCoverFetcher implements DataFetcher { @Override public void cleanup() { - // already cleaned up in loadData and ByteArrayInputStream will be GC'd + // already cleaned up in loadData if (stream != null) { try { stream.close(); - } catch (IOException ignore) { + } catch (IOException e) { // can't do much about it + e.printStackTrace(); } } } diff --git a/app/src/main/java/com/kabouzeid/gramophone/glide/audiocover/AudioFileCoverLoader.java b/app/src/main/java/com/kabouzeid/gramophone/glide/audiocover/AudioFileCoverLoader.java index 883fb117..df6a21d5 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/glide/audiocover/AudioFileCoverLoader.java +++ b/app/src/main/java/com/kabouzeid/gramophone/glide/audiocover/AudioFileCoverLoader.java @@ -13,7 +13,6 @@ import java.io.InputStream; /** * @author Karim Abou Zeid (kabouzeid) */ - public class AudioFileCoverLoader implements StreamModelLoader { @Override @@ -32,4 +31,3 @@ public class AudioFileCoverLoader implements StreamModelLoader { } } } - diff --git a/app/src/main/java/com/kabouzeid/gramophone/glide/audiocover/AudioFileCoverUtils.java b/app/src/main/java/com/kabouzeid/gramophone/glide/audiocover/AudioFileCoverUtils.java index 51cbf994..e3072fb0 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/glide/audiocover/AudioFileCoverUtils.java +++ b/app/src/main/java/com/kabouzeid/gramophone/glide/audiocover/AudioFileCoverUtils.java @@ -4,22 +4,16 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.IOException; import java.io.InputStream; -import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException; -import org.jaudiotagger.audio.exceptions.ReadOnlyFileException; import org.jaudiotagger.audio.mp3.MP3File; -import org.jaudiotagger.tag.TagException; import org.jaudiotagger.tag.images.Artwork; public class AudioFileCoverUtils { - public static final String[] FALLBACKS = {"cover.jpg", "album.jpg", "folder.jpg", "cover.png", "album.png", "folder.png"}; - public static InputStream fallback(String path) throws FileNotFoundException { - // Method 1: use embedded high resolution album art if there is any + // use embedded high resolution album art try { MP3File mp3File = new MP3File(path); if (mp3File.hasID3v2Tag()) { @@ -29,14 +23,12 @@ public class AudioFileCoverUtils { return new ByteArrayInputStream(imageData); } } - // If there are any exceptions, we ignore them and continue to the other fallback method - } catch (ReadOnlyFileException ignored) { - } catch (InvalidAudioFrameException ignored) { - } catch (TagException ignored) { - } catch (IOException ignored) { + } catch (Exception e) { + // log exceptions and continue to the other fallback method + e.printStackTrace(); } - // Method 2: look for album art in external files + // look for album art in external files final File parent = new File(path).getParentFile(); for (String fallback : FALLBACKS) { File cover = new File(parent, fallback); diff --git a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/AlbumDetailActivity.java b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/AlbumDetailActivity.java index 6cc7ad67..2a729892 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/AlbumDetailActivity.java +++ b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/AlbumDetailActivity.java @@ -26,7 +26,7 @@ import com.kabouzeid.gramophone.adapter.song.AlbumSongAdapter; import com.kabouzeid.gramophone.dialogs.AddToPlaylistDialog; import com.kabouzeid.gramophone.dialogs.DeleteSongsDialog; import com.kabouzeid.gramophone.dialogs.SleepTimerDialog; -import com.kabouzeid.gramophone.glide.PhonographColoredTarget; +import com.kabouzeid.gramophone.glide.CustomPaletteTarget; import com.kabouzeid.gramophone.glide.SongGlideRequest; import com.kabouzeid.gramophone.helper.MusicPlayerRemote; import com.kabouzeid.gramophone.interfaces.CabHolder; @@ -143,7 +143,7 @@ public class AlbumDetailActivity extends AbsSlidingMusicPanelActivity implements .checkIgnoreMediaStore(this) .generatePalette(this).build() .dontAnimate() - .into(new PhonographColoredTarget(albumArtImageView) { + .into(new CustomPaletteTarget(albumArtImageView) { @Override public void onColorReady(int color) { setColors(color); diff --git a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/ArtistDetailActivity.java b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/ArtistDetailActivity.java index f0e026a0..1b0dfd62 100644 --- a/app/src/main/java/com/kabouzeid/gramophone/ui/activities/ArtistDetailActivity.java +++ b/app/src/main/java/com/kabouzeid/gramophone/ui/activities/ArtistDetailActivity.java @@ -34,7 +34,7 @@ import com.kabouzeid.gramophone.adapter.song.ArtistSongAdapter; import com.kabouzeid.gramophone.dialogs.AddToPlaylistDialog; import com.kabouzeid.gramophone.dialogs.SleepTimerDialog; import com.kabouzeid.gramophone.glide.ArtistGlideRequest; -import com.kabouzeid.gramophone.glide.PhonographColoredTarget; +import com.kabouzeid.gramophone.glide.CustomPaletteTarget; import com.kabouzeid.gramophone.helper.MusicPlayerRemote; import com.kabouzeid.gramophone.interfaces.CabHolder; import com.kabouzeid.gramophone.interfaces.LoaderIds; @@ -187,7 +187,7 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement ArtistGlideRequest.Builder.from(Glide.with(this), artist) .generatePalette(this).build() .dontAnimate() - .into(new PhonographColoredTarget(artistImage) { + .into(new CustomPaletteTarget(artistImage) { @Override public void onColorReady(int color) { setColors(color); diff --git a/app/src/main/res/raw/notices.xml b/app/src/main/res/raw/notices.xml deleted file mode 100644 index aca186cb..00000000 --- a/app/src/main/res/raw/notices.xml +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - Advanced RecyclerView - https://github.com/h6ah4i/android-advancedrecyclerview - Copyright (C) 2015 Haruki Hasegawa - Apache Software License 2.0 - - - android-issue-reporter - https://github.com/HeinrichReimer/android-issue-reporter - Copyright 2016 Heinrich Reimer - Apache Software License 2.0 - - - Android-ObservableScrollView - https://github.com/ksoichiro/Android-ObservableScrollView - Copyright 2014 Soichiro Kashima - Apache Software License 2.0 - - - Android Open Source Project - http://developer.android.com/tools/support-library/index.html - Copyright (C) 2016 The Android Open Source Project - Apache Software License 2.0 - - - Android Sliding Up Panel - https://github.com/umano/AndroidSlidingUpPanel - - Apache Software License 2.0 - - - Android Support Libraries - http://developer.android.com/tools/support-library/index.html - Copyright (C) 2016 The Android Open Source Project - Apache Software License 2.0 - - - Android In-App Billing v3 Library - https://github.com/anjlab/android-inapp-billing-v3 - Copyright 2014 AnjLab - Apache Software License 2.0 - - - Butter Knife - https://github.com/JakeWharton/butterknife - Copyright 2013 Jake Wharton - Apache Software License 2.0 - - - Eleven - https://github.com/CyanogenMod/android_packages_apps_Eleven - Copyright (c) 2014, The CyanogenMod Project - Apache Software License 2.0 - - - Glide - https://github.com/bumptech/glide - - - Launcher 3 - https://android.googlesource.com/platform/packages/apps/Launcher3 - Copyright (C) 2010 The Android Open Source Project - Apache Software License 2.0 - - - Linear Layout Manager - https://github.com/serso/android-linear-layout-manager - Copyright 2014 serso aka se.solovyev - Apache Software License 2.0 - - - Material Contextual Action Bar - https://github.com/afollestad/material-cab - Copyright 2016 Aidan Follestad - Apache Software License 2.0 - - - Material Dialogs - https://github.com/afollestad/material-dialogs - Copyright (c) 2015 Aidan Michael Follestad - MIT License - - - Material Intro - https://github.com/HeinrichReimer/material-intro - Copyright 2016 Heinrich Reimer - MIT License - - - OkHttp - https://github.com/square/okhttp - - Apache Software License 2.0 - - - RecyclerView-FastScroll - https://github.com/timusus/RecyclerView-FastScroll - Copyright (C) 2016 Tim Malseed - Apache Software License 2.0 - - - Retrofit - https://github.com/square/retrofit - Copyright 2013 Square, Inc. - Apache Software License 2.0 - - - SeekArc - https://github.com/Triggertrap/SeekArc - Copyright (c) 2013 Triggertrap Ltd - Author Neil Davies - - MIT License - - \ No newline at end of file