From 6fa18662d15ef3e08aa13b3a1a9dd6fa54ec5ba8 Mon Sep 17 00:00:00 2001 From: Ninjaman494 Date: Sun, 7 Mar 2021 18:39:14 -0500 Subject: [PATCH] IllegalStateException on Error Dialog in Search Activity (#57) * Updated onBackPressed to finish * Fixed deprecation warning --- .../koreanconjugator/conjugations/ConjugationActivity.java | 2 +- .../koreanconjugator/conjugator/ConjugatorActivity.java | 4 ++-- .../koreanconjugator/display/DisplayActivity.java | 6 +++--- .../a494studios/koreanconjugator/search/SearchActivity.java | 2 +- .../search_results/SearchResultsActivity.java | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/a494studios/koreanconjugator/conjugations/ConjugationActivity.java b/app/src/main/java/com/a494studios/koreanconjugator/conjugations/ConjugationActivity.java index 22daa455..5ae4fd59 100644 --- a/app/src/main/java/com/a494studios/koreanconjugator/conjugations/ConjugationActivity.java +++ b/app/src/main/java/com/a494studios/koreanconjugator/conjugations/ConjugationActivity.java @@ -83,7 +83,7 @@ public void onDataReceived(List> conjugations) { public void onError(Throwable e) { e.printStackTrace(); Utils.handleError(e, ConjugationActivity.this,4, - (dialogInterface, i) -> ConjugationActivity.this.onBackPressed()); + (dialogInterface, i) -> ConjugationActivity.this.finish()); } }); diff --git a/app/src/main/java/com/a494studios/koreanconjugator/conjugator/ConjugatorActivity.java b/app/src/main/java/com/a494studios/koreanconjugator/conjugator/ConjugatorActivity.java index d3986a91..6c39ad7a 100644 --- a/app/src/main/java/com/a494studios/koreanconjugator/conjugator/ConjugatorActivity.java +++ b/app/src/main/java/com/a494studios/koreanconjugator/conjugator/ConjugatorActivity.java @@ -135,7 +135,7 @@ public void onError(Throwable e) { e.printStackTrace(); AppCompatActivity activity = ConjugatorActivity.this; Utils.handleError(e, activity,11, - (dialogInterface, i) -> activity.onBackPressed()); + (dialogInterface, i) -> activity.finish()); } @Override @@ -183,7 +183,7 @@ public void onDataReceived(List> conjugations) { public void onError(Throwable e) { e.printStackTrace(); Utils.handleError(e, ConjugatorActivity.this,10, - (dialogInterface, i) -> ConjugatorActivity.this.onBackPressed()); + (dialogInterface, i) -> ConjugatorActivity.this.finish()); } }); diff --git a/app/src/main/java/com/a494studios/koreanconjugator/display/DisplayActivity.java b/app/src/main/java/com/a494studios/koreanconjugator/display/DisplayActivity.java index 3a2be545..1b5dc507 100644 --- a/app/src/main/java/com/a494studios/koreanconjugator/display/DisplayActivity.java +++ b/app/src/main/java/com/a494studios/koreanconjugator/display/DisplayActivity.java @@ -44,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) { // Make sure extras were passed if(id == null){ Exception exception = new Exception("ID was null in DisplayActivity"); - Utils.handleError(exception, this, 5, (dialogInterface, i) -> onBackPressed()); + Utils.handleError(exception, this, 5, (dialogInterface, i) -> finish()); return; } @@ -66,7 +66,7 @@ protected void onCreate(Bundle savedInstanceState) { @Override public void onError(Throwable t) { t.printStackTrace(); - Utils.handleError(t, DisplayActivity.this,2, (dialogInterface, i) -> DisplayActivity.this.onBackPressed()); + Utils.handleError(t, DisplayActivity.this,2, (dialogInterface, i) -> DisplayActivity.this.finish()); } @Override @@ -111,7 +111,7 @@ public void onComplete() { // If no conjugations, create an empty list to prevent a null exception .map(o -> o instanceof String ? new FavoritesQuery.Data(new ArrayList<>()) - : ((Response) o).data()) + : ((Response) o).getData()) .subscribeWith(observer); LinearLayout linearLayout = findViewById(R.id.disp_root); diff --git a/app/src/main/java/com/a494studios/koreanconjugator/search/SearchActivity.java b/app/src/main/java/com/a494studios/koreanconjugator/search/SearchActivity.java index cc13af8e..3357aa1c 100644 --- a/app/src/main/java/com/a494studios/koreanconjugator/search/SearchActivity.java +++ b/app/src/main/java/com/a494studios/koreanconjugator/search/SearchActivity.java @@ -80,7 +80,7 @@ public void onNext(Response dataResponse) { @Override public void onError(Throwable e) { e.printStackTrace(); - Utils.handleError(e, SearchActivity.this, 1, (dialogInterface, i) -> SearchActivity.this.onBackPressed()); + Utils.handleError(e, SearchActivity.this, 1, (dialogInterface, i) -> SearchActivity.this.finish()); } @Override diff --git a/app/src/main/java/com/a494studios/koreanconjugator/search_results/SearchResultsActivity.java b/app/src/main/java/com/a494studios/koreanconjugator/search_results/SearchResultsActivity.java index d60a64df..7dd53a72 100644 --- a/app/src/main/java/com/a494studios/koreanconjugator/search_results/SearchResultsActivity.java +++ b/app/src/main/java/com/a494studios/koreanconjugator/search_results/SearchResultsActivity.java @@ -40,7 +40,7 @@ protected void onCreate(Bundle savedInstanceState) { String query = getIntent().getStringExtra(EXTRA_QUERY); if(query == null){ // Null check for extra Exception exception = new Exception("Query was null in SearchResultsActivity"); - Utils.handleError(exception, this, 6, (dialogInterface, i) -> onBackPressed()); + Utils.handleError(exception, this, 6, (dialogInterface, i) -> finish()); return; } @@ -130,7 +130,7 @@ public void onNext(Response dataResponse) { @Override public void onError(Throwable e) { e.printStackTrace(); - Utils.handleError(e, SearchResultsActivity.this, 3, (dialogInterface, i) -> SearchResultsActivity.this.onBackPressed()); + Utils.handleError(e, SearchResultsActivity.this, 3, (dialogInterface, i) -> SearchResultsActivity.this.finish()); } @Override