From 8048ad343eb3b49ce3e509ea0edaf3d4b16e1363 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Tue, 23 Feb 2016 16:34:14 +0100 Subject: [PATCH] add toast for suggestion error handling --- .../java/org/schabi/newpipe/VideoItemListActivity.java | 7 +++++++ .../java/org/schabi/newpipe/VideoItemListFragment.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java index e60c4d176..1ee1eb1e6 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListActivity.java @@ -15,6 +15,7 @@ import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.inputmethod.InputMethodManager; +import android.widget.Toast; import org.schabi.newpipe.extractor.ExtractionException; import org.schabi.newpipe.extractor.SearchEngine; @@ -89,6 +90,8 @@ public class VideoItemListActivity extends AppCompatActivity getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch(NullPointerException e) { Log.e(TAG, "Could not get widget with focus"); + Toast.makeText(VideoItemListActivity.this, "Could not get widget with focus", + Toast.LENGTH_SHORT).show(); e.printStackTrace(); } // clear focus @@ -168,8 +171,12 @@ public class VideoItemListActivity extends AppCompatActivity ArrayListsuggestions = engine.suggestionList(query,searchLanguage,new Downloader()); h.post(new SuggestionResultRunnable(suggestions)); } catch (ExtractionException e) { + Toast.makeText(VideoItemListActivity.this, getString(R.string.parsing_error), + Toast.LENGTH_SHORT).show(); e.printStackTrace(); } catch (IOException e) { + Toast.makeText(VideoItemListActivity.this, getString(R.string.network_error), + Toast.LENGTH_SHORT).show(); e.printStackTrace(); } } diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java index 999f6875b..e6a6a5060 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java @@ -186,8 +186,12 @@ public class VideoItemListFragment extends ListFragment { videoListAdapter.addVideoList(list); terminateThreads(); } catch(java.lang.IllegalStateException e) { + Toast.makeText(getActivity(), "Trying to set value while activity doesn't exist anymore.", + Toast.LENGTH_SHORT).show(); Log.w(TAG, "Trying to set value while activity doesn't exist anymore."); } catch(Exception e) { + Toast.makeText(getActivity(), getString(R.string.general_error), + Toast.LENGTH_SHORT).show(); e.printStackTrace(); } finally { loadingNextPage = false;