mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Fix swipe on two missed activities.
This commit is contained in:
parent
b5fec7dac7
commit
cad9912eda
@ -22,6 +22,7 @@ import com.google.android.material.appbar.AppBarLayout;
|
|||||||
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
import com.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import com.r0adkll.slidr.Slidr;
|
import com.r0adkll.slidr.Slidr;
|
||||||
|
import com.r0adkll.slidr.model.SlidrInterface;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@ -76,6 +77,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
private SectionsPagerAdapter sectionsPagerAdapter;
|
private SectionsPagerAdapter sectionsPagerAdapter;
|
||||||
|
private SlidrInterface mSlidrInterface;
|
||||||
private Menu mMenu;
|
private Menu mMenu;
|
||||||
private AppBarLayout.LayoutParams params;
|
private AppBarLayout.LayoutParams params;
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
@ -98,7 +100,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
applyCustomTheme();
|
applyCustomTheme();
|
||||||
|
|
||||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
|
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
|
||||||
Slidr.attach(this);
|
mSlidrInterface = Slidr.attach(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
@ -179,12 +181,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
viewPager.setOffscreenPageLimit(2);
|
viewPager.setOffscreenPageLimit(2);
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
|
|
||||||
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
|
||||||
@Override
|
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPageSelected(int position) {
|
public void onPageSelected(int position) {
|
||||||
if (isInLazyMode) {
|
if (isInLazyMode) {
|
||||||
@ -194,11 +191,12 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
sectionsPagerAdapter.pauseLazyMode();
|
sectionsPagerAdapter.pauseLazyMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPageScrollStateChanged(int state) {
|
|
||||||
|
|
||||||
|
if (position == 0) {
|
||||||
|
unlockSwipeRightToGoBack();
|
||||||
|
} else {
|
||||||
|
lockSwipeRightToGoBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -290,6 +288,18 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void lockSwipeRightToGoBack() {
|
||||||
|
if (mSlidrInterface != null) {
|
||||||
|
mSlidrInterface.lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unlockSwipeRightToGoBack() {
|
||||||
|
if (mSlidrInterface != null) {
|
||||||
|
mSlidrInterface.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
private PostFragment postFragment;
|
private PostFragment postFragment;
|
||||||
private CommentsListingFragment commentsListingFragment;
|
private CommentsListingFragment commentsListingFragment;
|
||||||
|
@ -21,6 +21,7 @@ import com.google.android.material.appbar.AppBarLayout;
|
|||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import com.r0adkll.slidr.Slidr;
|
import com.r0adkll.slidr.Slidr;
|
||||||
|
import com.r0adkll.slidr.model.SlidrInterface;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@ -86,6 +87,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
private SlidrInterface mSlidrInterface;
|
||||||
private boolean mNullAccessToken = false;
|
private boolean mNullAccessToken = false;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
@ -109,7 +111,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
applyCustomTheme();
|
applyCustomTheme();
|
||||||
|
|
||||||
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
|
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
|
||||||
Slidr.attach(this);
|
mSlidrInterface = Slidr.attach(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
@ -179,6 +181,16 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
|
||||||
viewPager.setAdapter(sectionsPagerAdapter);
|
viewPager.setAdapter(sectionsPagerAdapter);
|
||||||
viewPager.setOffscreenPageLimit(3);
|
viewPager.setOffscreenPageLimit(3);
|
||||||
|
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onPageSelected(int position) {
|
||||||
|
if (position == 0) {
|
||||||
|
unlockSwipeRightToGoBack();
|
||||||
|
} else {
|
||||||
|
lockSwipeRightToGoBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
tabLayout.setupWithViewPager(viewPager);
|
tabLayout.setupWithViewPager(viewPager);
|
||||||
|
|
||||||
if (showMultiReddits) {
|
if (showMultiReddits) {
|
||||||
@ -316,6 +328,18 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void lockSwipeRightToGoBack() {
|
||||||
|
if (mSlidrInterface != null) {
|
||||||
|
mSlidrInterface.lock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unlockSwipeRightToGoBack() {
|
||||||
|
if (mSlidrInterface != null) {
|
||||||
|
mSlidrInterface.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
private class SectionsPagerAdapter extends FragmentPagerAdapter {
|
||||||
|
|
||||||
private SubscribedSubredditsListingFragment subscribedSubredditsListingFragment;
|
private SubscribedSubredditsListingFragment subscribedSubredditsListingFragment;
|
||||||
|
Loading…
Reference in New Issue
Block a user