aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-10-04 07:11:53 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-10-04 07:11:53 +0000
commit9b24fff1608270e35742bd89762b5355a31b741c (patch)
treeb182ac6104e35d3685bf92a25771133729df2063 /app
parent11f6b5dc91028a26c6fb9906920682b250634ded (diff)
downloadinfinity-for-reddit-9b24fff1608270e35742bd89762b5355a31b741c.tar
infinity-for-reddit-9b24fff1608270e35742bd89762b5355a31b741c.tar.gz
infinity-for-reddit-9b24fff1608270e35742bd89762b5355a31b741c.tar.bz2
infinity-for-reddit-9b24fff1608270e35742bd89762b5355a31b741c.tar.lz
infinity-for-reddit-9b24fff1608270e35742bd89762b5355a31b741c.tar.xz
infinity-for-reddit-9b24fff1608270e35742bd89762b5355a31b741c.tar.zst
infinity-for-reddit-9b24fff1608270e35742bd89762b5355a31b741c.zip
Handle no browser when trying to opening links. Fixed app crashes in various cases.
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java30
3 files changed, 21 insertions, 17 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java
index 00d3bbd5..a95c4f96 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java
@@ -207,7 +207,11 @@ public class LinkResolverActivity extends AppCompatActivity {
if (!packageNames.isEmpty()) {
intent.setPackage(packageNames.get(0));
- startActivity(intent);
+ try {
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(this, R.string.no_browser_found, Toast.LENGTH_SHORT).show();
+ }
} else {
Toast.makeText(this, R.string.no_browser_found, Toast.LENGTH_SHORT).show();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
index b2afe3d2..bb835b49 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
@@ -640,7 +640,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
}
private void refresh(boolean fetchPost, boolean fetchComments) {
- if (!isRefreshing) {
+ if (mAdapter != null && !isRefreshing) {
isRefreshing = true;
mChildrenStartingIndex = 0;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index 11b68da8..f7e16eb1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -979,14 +979,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
private int getParentPosition(int position) {
- if (position >= mVisibleComments.size()) {
- return -1;
- }
-
- int childDepth = mVisibleComments.get(position).getDepth();
- for (int i = position; i >= 0; i--) {
- if (mVisibleComments.get(i).getDepth() < childDepth) {
- return i;
+ if (position < mVisibleComments.size()) {
+ int childDepth = mVisibleComments.get(position).getDepth();
+ for (int i = position; i >= 0; i--) {
+ if (mVisibleComments.get(i).getDepth() < childDepth) {
+ return i;
+ }
}
}
return -1;
@@ -1557,13 +1555,15 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
expandButton.setOnClickListener(view -> {
if (expandButton.getVisibility() == View.VISIBLE) {
int commentPosition = mIsSingleCommentThreadMode ? getAdapterPosition() - 2 : getAdapterPosition() - 1;
- if (mVisibleComments.get(commentPosition).isExpanded()) {
- collapseChildren(commentPosition);
- expandButton.setImageResource(R.drawable.ic_expand_more_black_20dp);
- } else {
- expandChildren(commentPosition);
- mVisibleComments.get(commentPosition).setExpanded(true);
- expandButton.setImageResource(R.drawable.ic_expand_less_black_20dp);
+ if(commentPosition < mVisibleComments.size()) {
+ if (mVisibleComments.get(commentPosition).isExpanded()) {
+ collapseChildren(commentPosition);
+ expandButton.setImageResource(R.drawable.ic_expand_more_black_20dp);
+ } else {
+ expandChildren(commentPosition);
+ mVisibleComments.get(commentPosition).setExpanded(true);
+ expandButton.setImageResource(R.drawable.ic_expand_less_black_20dp);
+ }
}
}
});