diff options
Diffstat (limited to '')
5 files changed, 40 insertions, 49 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java index b5452989..2a26ae10 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -7,7 +7,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; -import android.util.Log; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; @@ -190,7 +189,6 @@ public class LinkResolverActivity extends AppCompatActivity { startActivity(intent); } else if (path.matches(RPAN_BROADCAST_PATTERN)) { Intent intent = new Intent(this, RPANActivity.class); - Log.i("asdfasdf", "sd " + path); intent.putExtra(RPANActivity.EXTRA_RPAN_BROADCAST_FULLNAME_OR_ID, path.substring(path.lastIndexOf('/') + 1)); startActivity(intent); } else if (authority.equals("redd.it") && path.matches(REDD_IT_POST_PATTERN)) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index 386aad91..4edf51a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -216,7 +216,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic private boolean mSwipeUpToHideFab; private boolean mExpandChildren; private int mWindowWidth; - private LinearLayoutManager mLinearLayoutManager; private ConcatAdapter mConcatAdapter; private PostDetailRecyclerViewAdapter mPostAdapter; private CommentsRecyclerViewAdapter mCommentsAdapter; @@ -261,13 +260,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic mUnsavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_border_toolbar_24dp); if (getResources().getBoolean(R.bool.isTablet) || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { - mLinearLayoutManager = new LinearLayoutManager(activity); mCommentsRecyclerView = rootView.findViewById(R.id.comments_recycler_view_view_post_detail_fragment); - mCommentsRecyclerView.setLayoutManager(mLinearLayoutManager); - mRecyclerView.setLayoutManager(new LinearLayoutManager(activity)); - } else { - mLinearLayoutManager = new LinearLayoutManager(activity); - mRecyclerView.setLayoutManager(mLinearLayoutManager); } if (activity != null && activity.isImmersiveInterface()) { @@ -319,9 +312,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } if (!isLoadingMoreChildren && loadMoreChildrenSuccess) { - int visibleItemCount = mLinearLayoutManager.getChildCount(); - int totalItemCount = mLinearLayoutManager.getItemCount(); - int firstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); + int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount(); + int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount(); + int firstVisibleItemPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition(); if (mCommentsAdapter != null && mCommentsAdapter.getItemCount() >= 1 && (visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) { fetchMoreComments(); @@ -755,8 +748,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } public void goToTop() { - if (mLinearLayoutManager != null) { - mLinearLayoutManager.scrollToPositionWithOffset(0, 0); + ((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); + if (mCommentsRecyclerView != null) { + ((LinearLayoutManager) mCommentsRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0); } } @@ -1244,9 +1238,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } if (!isLoadingMoreChildren && loadMoreChildrenSuccess) { - int visibleItemCount = mLinearLayoutManager.getChildCount(); - int totalItemCount = mLinearLayoutManager.getItemCount(); - int firstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); + int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount(); + int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount(); + int firstVisibleItemPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition(); if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) { fetchMoreComments(); @@ -1382,9 +1376,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } if (!isLoadingMoreChildren && loadMoreChildrenSuccess) { - int visibleItemCount = mLinearLayoutManager.getChildCount(); - int totalItemCount = mLinearLayoutManager.getItemCount(); - int firstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); + int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount(); + int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount(); + int firstVisibleItemPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition(); if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) { fetchMoreComments(); @@ -1714,36 +1708,28 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } public void scrollToNextParentComment() { - if (mLinearLayoutManager != null) { - int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); - if (mCommentsAdapter != null) { - int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); - if (nextParentPosition < 0) { - return; - } - mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? nextParentPosition + 1 : nextParentPosition); - if (mLinearLayoutManager != null) { - mIsSmoothScrolling = true; - mLinearLayoutManager.startSmoothScroll(mSmoothScroller); - } + int currentPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition(); + if (mCommentsAdapter != null) { + int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); + if (nextParentPosition < 0) { + return; } + mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? nextParentPosition + 1 : nextParentPosition); + mIsSmoothScrolling = true; + ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).startSmoothScroll(mSmoothScroller); } } public void scrollToPreviousParentComment() { - if (mLinearLayoutManager != null) { - int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition(); - if (mCommentsAdapter != null) { - int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); - if (previousParentPosition < 0) { - return; - } - mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? previousParentPosition + 1 : previousParentPosition); - if (mLinearLayoutManager != null) { - mIsSmoothScrolling = true; - mLinearLayoutManager.startSmoothScroll(mSmoothScroller); - } + int currentPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition(); + if (mCommentsAdapter != null) { + int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition); + if (previousParentPosition < 0) { + return; } + mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? previousParentPosition + 1 : previousParentPosition); + mIsSmoothScrolling = true; + ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).startSmoothScroll(mSmoothScroller); } } diff --git a/app/src/main/res/layout-land/fragment_view_post_detail.xml b/app/src/main/res/layout-land/fragment_view_post_detail.xml index 6d0beecc..2b107e94 100644 --- a/app/src/main/res/layout-land/fragment_view_post_detail.xml +++ b/app/src/main/res/layout-land/fragment_view_post_detail.xml @@ -22,7 +22,9 @@ android:id="@+id/post_detail_recycler_view_view_post_detail_fragment" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" /> + android:layout_weight="1" + android:clipToPadding="false" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/comments_recycler_view_view_post_detail_fragment" @@ -30,7 +32,8 @@ android:layout_height="match_parent" android:layout_weight="1" android:paddingBottom="144dp" - android:clipToPadding="false" /> + android:clipToPadding="false" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> </LinearLayout> diff --git a/app/src/main/res/layout-sw600dp/fragment_view_post_detail.xml b/app/src/main/res/layout-sw600dp/fragment_view_post_detail.xml index 6d0beecc..d7fd9d2a 100644 --- a/app/src/main/res/layout-sw600dp/fragment_view_post_detail.xml +++ b/app/src/main/res/layout-sw600dp/fragment_view_post_detail.xml @@ -22,7 +22,9 @@ android:id="@+id/post_detail_recycler_view_view_post_detail_fragment" android:layout_width="0dp" android:layout_height="match_parent" - android:layout_weight="1" /> + android:layout_weight="1" + android:clipToPadding="false" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/comments_recycler_view_view_post_detail_fragment" @@ -30,7 +32,8 @@ android:layout_height="match_parent" android:layout_weight="1" android:paddingBottom="144dp" - android:clipToPadding="false" /> + android:clipToPadding="false" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> </LinearLayout> diff --git a/app/src/main/res/layout/fragment_view_post_detail.xml b/app/src/main/res/layout/fragment_view_post_detail.xml index 7875516b..6a6a4a4d 100644 --- a/app/src/main/res/layout/fragment_view_post_detail.xml +++ b/app/src/main/res/layout/fragment_view_post_detail.xml @@ -17,7 +17,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="144dp" - android:clipToPadding="false" /> + android:clipToPadding="false" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |