aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-12-25 13:50:40 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-12-25 13:50:40 +0000
commit9af6c4077a4b97cd84cf1f8832d59076b7026387 (patch)
tree6963e8a7e48129456bae939efb25d1a46e5f8296 /app/src/main
parente2af6dc9091b000d358e76474729a32d19136bf4 (diff)
downloadinfinity-for-reddit-9af6c4077a4b97cd84cf1f8832d59076b7026387.tar
infinity-for-reddit-9af6c4077a4b97cd84cf1f8832d59076b7026387.tar.gz
infinity-for-reddit-9af6c4077a4b97cd84cf1f8832d59076b7026387.tar.bz2
infinity-for-reddit-9af6c4077a4b97cd84cf1f8832d59076b7026387.tar.lz
infinity-for-reddit-9af6c4077a4b97cd84cf1f8832d59076b7026387.tar.xz
infinity-for-reddit-9af6c4077a4b97cd84cf1f8832d59076b7026387.tar.zst
infinity-for-reddit-9af6c4077a4b97cd84cf1f8832d59076b7026387.zip
Fix app crashes when suggesting title in PostLinkActivity.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
index 3bfb4573..34dff394 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
@@ -362,7 +362,19 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
if (response.isSuccessful()) {
- titleEditText.setText(response.body().substring(response.body().indexOf("<title>") + 7, response.body().indexOf("</title>")));
+ String body = response.body();
+ if (body != null) {
+ int start = body.indexOf("<title>");
+ if (start >= 0) {
+ int end = body.indexOf("</title>");
+ if (end > start) {
+ titleEditText.setText(body.substring(start + 7, end));
+ return;
+ }
+ }
+ }
+
+ Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(PostLinkActivity.this, R.string.suggest_title_failed, Toast.LENGTH_SHORT).show();
}