diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java | 14 |
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(); } |