From c100d15ba8324019b100e537b7c68fba3b427cd9 Mon Sep 17 00:00:00 2001 From: mauriciocolli Date: Fri, 17 Mar 2017 11:50:27 -0300 Subject: [PATCH 1/2] Fix bug when fetching unavailable content - Fix #482 - When opening a invalid/deleted/unavailable video, the popup was just printing the error, now it shows a message to the user and exits --- .../org/schabi/newpipe/player/PopupVideoPlayer.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java index 7d211ecdb..7d6345a8a 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -819,8 +819,15 @@ public class PopupVideoPlayer extends Service implements StateInterface { } }); } catch (Exception e) { - e.printStackTrace(); + if (DEBUG) e.printStackTrace(); + mainHandler.post(new Runnable() { + @Override + public void run() { + Toast.makeText(PopupVideoPlayer.this, R.string.content_not_available, Toast.LENGTH_SHORT).show(); + } + }); + stopSelf(); } } } -} \ No newline at end of file +} From e406ba094cf8aa81e9af5c9dfa1187e66c38005f Mon Sep 17 00:00:00 2001 From: mauriciocolli Date: Fri, 17 Mar 2017 12:09:20 -0300 Subject: [PATCH 2/2] Improve bug detection - Show a message with the appropriate error (network error) --- .../java/org/schabi/newpipe/player/PopupVideoPlayer.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java index 7d6345a8a..95ce2e69c 100644 --- a/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/PopupVideoPlayer.java @@ -818,6 +818,15 @@ public class PopupVideoPlayer extends Service implements StateInterface { }); } }); + } catch (IOException ie) { + if (DEBUG) ie.printStackTrace(); + mainHandler.post(new Runnable() { + @Override + public void run() { + Toast.makeText(PopupVideoPlayer.this, R.string.network_error, Toast.LENGTH_SHORT).show(); + } + }); + stopSelf(); } catch (Exception e) { if (DEBUG) e.printStackTrace(); mainHandler.post(new Runnable() {