Disable ViewPager2's swiping if swipe between posts is disabled.

This commit is contained in:
Alex Ning 2021-05-31 00:00:34 +08:00
parent 0f33ef627e
commit c4276736ae
2 changed files with 8 additions and 6 deletions

View File

@ -167,16 +167,15 @@ dependencies {
// RecyclerView fast scrolling // RecyclerView fast scrolling
implementation 'me.zhanghai.android.fastscroll:library:1.1.5' implementation 'me.zhanghai.android.fastscroll:library:1.1.5'
// Crash screen
implementation 'com.melegy.redscreenofdeath:red-screen-of-death:0.1.2'
implementation 'net.lingala.zip4j:zip4j:2.7.0' implementation 'net.lingala.zip4j:zip4j:2.7.0'
implementation 'org.apache.commons:commons-io:1.3.2' implementation 'org.apache.commons:commons-io:1.3.2'
implementation "androidx.startup:startup-runtime:1.0.0" implementation "androidx.startup:startup-runtime:1.0.0"
implementation 'com.github.FunkyMuse:Crashy:1.1.0' implementation 'com.github.FunkyMuse:Crashy:1.1.0'
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" //implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation 'androidx.palette:palette:1.0.0'
/**** Builds and flavors ****/ /**** Builds and flavors ****/

View File

@ -165,9 +165,12 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
} }
boolean swipeBetweenPosts = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_BETWEEN_POSTS, false); boolean swipeBetweenPosts = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_BETWEEN_POSTS, false);
if (!swipeBetweenPosts && mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) { if (!swipeBetweenPosts) {
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
mSlidrInterface = Slidr.attach(this); mSlidrInterface = Slidr.attach(this);
} }
viewPager2.setUserInputEnabled(false);
}
postFragmentId = getIntent().getLongExtra(EXTRA_POST_FRAGMENT_ID, -1); postFragmentId = getIntent().getLongExtra(EXTRA_POST_FRAGMENT_ID, -1);
if (swipeBetweenPosts && posts == null && postFragmentId > 0) { if (swipeBetweenPosts && posts == null && postFragmentId > 0) {
EventBus.getDefault().post(new NeedForPostListFromPostFragmentEvent(postFragmentId)); EventBus.getDefault().post(new NeedForPostListFromPostFragmentEvent(postFragmentId));