mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Declare LayoutManager for RecyclerView in ViewPostDetailFragment.
This commit is contained in:
parent
f6aca0e9a0
commit
4f9bd0cde0
@ -7,7 +7,6 @@ import android.content.pm.PackageManager;
|
|||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
@ -190,7 +189,6 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (path.matches(RPAN_BROADCAST_PATTERN)) {
|
} else if (path.matches(RPAN_BROADCAST_PATTERN)) {
|
||||||
Intent intent = new Intent(this, RPANActivity.class);
|
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));
|
intent.putExtra(RPANActivity.EXTRA_RPAN_BROADCAST_FULLNAME_OR_ID, path.substring(path.lastIndexOf('/') + 1));
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} else if (authority.equals("redd.it") && path.matches(REDD_IT_POST_PATTERN)) {
|
} else if (authority.equals("redd.it") && path.matches(REDD_IT_POST_PATTERN)) {
|
||||||
|
@ -216,7 +216,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
private boolean mSwipeUpToHideFab;
|
private boolean mSwipeUpToHideFab;
|
||||||
private boolean mExpandChildren;
|
private boolean mExpandChildren;
|
||||||
private int mWindowWidth;
|
private int mWindowWidth;
|
||||||
private LinearLayoutManager mLinearLayoutManager;
|
|
||||||
private ConcatAdapter mConcatAdapter;
|
private ConcatAdapter mConcatAdapter;
|
||||||
private PostDetailRecyclerViewAdapter mPostAdapter;
|
private PostDetailRecyclerViewAdapter mPostAdapter;
|
||||||
private CommentsRecyclerViewAdapter mCommentsAdapter;
|
private CommentsRecyclerViewAdapter mCommentsAdapter;
|
||||||
@ -261,13 +260,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
mUnsavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_border_toolbar_24dp);
|
mUnsavedIcon = getMenuItemIcon(R.drawable.ic_bookmark_border_toolbar_24dp);
|
||||||
|
|
||||||
if (getResources().getBoolean(R.bool.isTablet) || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
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 = 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()) {
|
if (activity != null && activity.isImmersiveInterface()) {
|
||||||
@ -319,9 +312,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
|
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
|
||||||
int visibleItemCount = mLinearLayoutManager.getChildCount();
|
int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount();
|
||||||
int totalItemCount = mLinearLayoutManager.getItemCount();
|
int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount();
|
||||||
int firstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
|
int firstVisibleItemPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
|
||||||
|
|
||||||
if (mCommentsAdapter != null && mCommentsAdapter.getItemCount() >= 1 && (visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
if (mCommentsAdapter != null && mCommentsAdapter.getItemCount() >= 1 && (visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
||||||
fetchMoreComments();
|
fetchMoreComments();
|
||||||
@ -755,8 +748,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void goToTop() {
|
public void goToTop() {
|
||||||
if (mLinearLayoutManager != null) {
|
((LinearLayoutManager) mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(0, 0);
|
||||||
mLinearLayoutManager.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) {
|
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
|
||||||
int visibleItemCount = mLinearLayoutManager.getChildCount();
|
int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount();
|
||||||
int totalItemCount = mLinearLayoutManager.getItemCount();
|
int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount();
|
||||||
int firstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
|
int firstVisibleItemPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
|
||||||
|
|
||||||
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
||||||
fetchMoreComments();
|
fetchMoreComments();
|
||||||
@ -1382,9 +1376,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
|
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
|
||||||
int visibleItemCount = mLinearLayoutManager.getChildCount();
|
int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount();
|
||||||
int totalItemCount = mLinearLayoutManager.getItemCount();
|
int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount();
|
||||||
int firstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
|
int firstVisibleItemPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
|
||||||
|
|
||||||
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
||||||
fetchMoreComments();
|
fetchMoreComments();
|
||||||
@ -1714,36 +1708,28 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void scrollToNextParentComment() {
|
public void scrollToNextParentComment() {
|
||||||
if (mLinearLayoutManager != null) {
|
int currentPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
|
||||||
int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
|
if (mCommentsAdapter != null) {
|
||||||
if (mCommentsAdapter != null) {
|
int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
|
||||||
int nextParentPosition = mCommentsAdapter.getNextParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
|
if (nextParentPosition < 0) {
|
||||||
if (nextParentPosition < 0) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? nextParentPosition + 1 : nextParentPosition);
|
|
||||||
if (mLinearLayoutManager != null) {
|
|
||||||
mIsSmoothScrolling = true;
|
|
||||||
mLinearLayoutManager.startSmoothScroll(mSmoothScroller);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? nextParentPosition + 1 : nextParentPosition);
|
||||||
|
mIsSmoothScrolling = true;
|
||||||
|
((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).startSmoothScroll(mSmoothScroller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollToPreviousParentComment() {
|
public void scrollToPreviousParentComment() {
|
||||||
if (mLinearLayoutManager != null) {
|
int currentPosition = ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
|
||||||
int currentPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
|
if (mCommentsAdapter != null) {
|
||||||
if (mCommentsAdapter != null) {
|
int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
|
||||||
int previousParentPosition = mCommentsAdapter.getPreviousParentCommentPosition(mCommentsRecyclerView == null ? currentPosition - 1 : currentPosition);
|
if (previousParentPosition < 0) {
|
||||||
if (previousParentPosition < 0) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? previousParentPosition + 1 : previousParentPosition);
|
|
||||||
if (mLinearLayoutManager != null) {
|
|
||||||
mIsSmoothScrolling = true;
|
|
||||||
mLinearLayoutManager.startSmoothScroll(mSmoothScroller);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? previousParentPosition + 1 : previousParentPosition);
|
||||||
|
mIsSmoothScrolling = true;
|
||||||
|
((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).startSmoothScroll(mSmoothScroller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
android:id="@+id/post_detail_recycler_view_view_post_detail_fragment"
|
android:id="@+id/post_detail_recycler_view_view_post_detail_fragment"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
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
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/comments_recycler_view_view_post_detail_fragment"
|
android:id="@+id/comments_recycler_view_view_post_detail_fragment"
|
||||||
@ -30,7 +32,8 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:paddingBottom="144dp"
|
android:paddingBottom="144dp"
|
||||||
android:clipToPadding="false" />
|
android:clipToPadding="false"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -22,7 +22,9 @@
|
|||||||
android:id="@+id/post_detail_recycler_view_view_post_detail_fragment"
|
android:id="@+id/post_detail_recycler_view_view_post_detail_fragment"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
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
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/comments_recycler_view_view_post_detail_fragment"
|
android:id="@+id/comments_recycler_view_view_post_detail_fragment"
|
||||||
@ -30,7 +32,8 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:paddingBottom="144dp"
|
android:paddingBottom="144dp"
|
||||||
android:clipToPadding="false" />
|
android:clipToPadding="false"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:paddingBottom="144dp"
|
android:paddingBottom="144dp"
|
||||||
android:clipToPadding="false" />
|
android:clipToPadding="false"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user