mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Fix an issue in respect subreddit recommended comment sort type. Dirty workaround for sensitive swipe sensitivity in ViewPager2 in MainActivity.
This commit is contained in:
parent
01f15625a3
commit
ddebd6086d
@ -72,11 +72,11 @@ dependencies {
|
|||||||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
|
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
|
||||||
implementation 'com.github.santalu:aspect-ratio-imageview:1.0.9'
|
implementation 'com.github.santalu:aspect-ratio-imageview:1.0.9'
|
||||||
implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
|
implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
|
||||||
implementation 'io.noties.markwon:core:4.6.0'
|
implementation 'io.noties.markwon:core:4.5.0'
|
||||||
implementation 'io.noties.markwon:linkify:4.6.0'
|
implementation 'io.noties.markwon:linkify:4.5.0'
|
||||||
implementation 'io.noties.markwon:ext-strikethrough:4.6.0'
|
implementation 'io.noties.markwon:ext-strikethrough:4.5.0'
|
||||||
implementation 'io.noties.markwon:simple-ext:4.6.0'
|
implementation 'io.noties.markwon:simple-ext:4.5.0'
|
||||||
implementation 'io.noties.markwon:recycler-table:4.6.0'
|
implementation 'io.noties.markwon:recycler-table:4.5.0'
|
||||||
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.21'
|
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.21'
|
||||||
implementation 'com.github.Ferfalk:SimpleSearchView:0.1.4'
|
implementation 'com.github.Ferfalk:SimpleSearchView:0.1.4'
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ dependencies {
|
|||||||
annotationProcessor 'com.evernote:android-state-processor:1.4.1'
|
annotationProcessor 'com.evernote:android-state-processor:1.4.1'
|
||||||
implementation 'com.nex3z:flow-layout:1.3.0'
|
implementation 'com.nex3z:flow-layout:1.3.0'
|
||||||
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
implementation 'com.r0adkll:slidableactivity:2.1.0'
|
||||||
implementation 'com.atlassian.commonmark:commonmark:0.15.2'
|
implementation 'com.atlassian.commonmark:commonmark:0.14.0'
|
||||||
implementation 'com.google.code.gson:gson:2.8.6'
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
|
implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
|
||||||
implementation "com.thefuntasty.hauler:core:3.1.0"
|
implementation "com.thefuntasty.hauler:core:3.1.0"
|
||||||
|
@ -55,6 +55,7 @@ import com.google.android.material.tabs.TabLayoutMediator;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -814,6 +815,19 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
Field recyclerViewField = ViewPager2.class.getDeclaredField("mRecyclerView");
|
||||||
|
recyclerViewField.setAccessible(true);
|
||||||
|
|
||||||
|
RecyclerView recyclerView = (RecyclerView) recyclerViewField.get(viewPager2);
|
||||||
|
|
||||||
|
Field touchSlopField = RecyclerView.class.getDeclaredField("mTouchSlop");
|
||||||
|
touchSlopField.setAccessible(true);
|
||||||
|
|
||||||
|
int touchSlop = (int) touchSlopField.get(recyclerView);
|
||||||
|
touchSlopField.set(recyclerView, touchSlop * 4);
|
||||||
|
} catch (NoSuchFieldException | IllegalAccessException ignore) {}
|
||||||
|
|
||||||
loadSubscriptions();
|
loadSubscriptions();
|
||||||
|
|
||||||
subscribedSubredditViewModel = new ViewModelProvider(this,
|
subscribedSubredditViewModel = new ViewModelProvider(this,
|
||||||
|
@ -832,67 +832,71 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
|
|||||||
});
|
});
|
||||||
mRecyclerView.setAdapter(mAdapter);
|
mRecyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
ParseComment.parseComment(response.body(), new ArrayList<>(), mLocale,
|
if (mRespectSubredditRecommendedSortType) {
|
||||||
mExpandChildren, new ParseComment.ParseCommentListener() {
|
fetchCommentsRespectRecommendedSort(false);
|
||||||
@Override
|
} else {
|
||||||
public void onParseCommentSuccess(ArrayList<Comment> expandedComments, String parentId, ArrayList<String> moreChildrenFullnames) {
|
ParseComment.parseComment(response.body(), new ArrayList<>(), mLocale,
|
||||||
ViewPostDetailActivity.this.children = moreChildrenFullnames;
|
mExpandChildren, new ParseComment.ParseCommentListener() {
|
||||||
|
@Override
|
||||||
|
public void onParseCommentSuccess(ArrayList<Comment> expandedComments, String parentId, ArrayList<String> moreChildrenFullnames) {
|
||||||
|
ViewPostDetailActivity.this.children = moreChildrenFullnames;
|
||||||
|
|
||||||
hasMoreChildren = children.size() != 0;
|
hasMoreChildren = children.size() != 0;
|
||||||
mAdapter.addComments(expandedComments, hasMoreChildren);
|
mAdapter.addComments(expandedComments, hasMoreChildren);
|
||||||
|
|
||||||
if (children.size() > 0) {
|
if (children.size() > 0) {
|
||||||
mRecyclerView.clearOnScrollListeners();
|
mRecyclerView.clearOnScrollListeners();
|
||||||
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||||
super.onScrolled(recyclerView, dx, dy);
|
super.onScrolled(recyclerView, dx, dy);
|
||||||
if (!mIsSmoothScrolling && !mLockFab) {
|
if (!mIsSmoothScrolling && !mLockFab) {
|
||||||
if (!recyclerView.canScrollVertically(1)) {
|
if (!recyclerView.canScrollVertically(1)) {
|
||||||
fab.hide();
|
fab.hide();
|
||||||
} else {
|
|
||||||
if (dy > 0) {
|
|
||||||
if (mSwipeUpToHideFab) {
|
|
||||||
fab.show();
|
|
||||||
} else {
|
|
||||||
fab.hide();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (mSwipeUpToHideFab) {
|
if (dy > 0) {
|
||||||
fab.hide();
|
if (mSwipeUpToHideFab) {
|
||||||
|
fab.show();
|
||||||
|
} else {
|
||||||
|
fab.hide();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fab.show();
|
if (mSwipeUpToHideFab) {
|
||||||
|
fab.hide();
|
||||||
|
} else {
|
||||||
|
fab.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
|
||||||
|
int visibleItemCount = mLinearLayoutManager.getChildCount();
|
||||||
|
int totalItemCount = mLinearLayoutManager.getItemCount();
|
||||||
|
int firstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
|
||||||
|
|
||||||
|
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
||||||
|
fetchMoreComments();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
|
@Override
|
||||||
int visibleItemCount = mLinearLayoutManager.getChildCount();
|
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||||
int totalItemCount = mLinearLayoutManager.getItemCount();
|
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||||
int firstVisibleItemPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
|
mIsSmoothScrolling = false;
|
||||||
|
|
||||||
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
|
||||||
fetchMoreComments();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
|
||||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
|
||||||
mIsSmoothScrolling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onParseCommentFailed() {
|
public void onParseCommentFailed() {
|
||||||
mAdapter.initiallyLoadCommentsFailed();
|
mAdapter.initiallyLoadCommentsFailed();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user