Skip to content

Commit

Permalink
Swipe between gallery images in PostFragment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Docile-Alligator committed Nov 12, 2022
1 parent 0f1c4d1 commit 03a2784
Show file tree
Hide file tree
Showing 29 changed files with 832 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import androidx.fragment.app.Fragment;

import com.r0adkll.slidr.Slidr;
import com.r0adkll.slidr.model.SlidrInterface;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
Expand Down Expand Up @@ -53,6 +54,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
SharedPreferences mCurrentAccountSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
private SlidrInterface mSlidrInterface;
private String mAccessToken;
private String mAccountName;
private String mUserWhere;
Expand All @@ -74,7 +76,7 @@ protected void onCreate(Bundle savedInstanceState) {
applyCustomTheme();

if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK, true)) {
Slidr.attach(this);
mSlidrInterface = Slidr.attach(this);
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Expand Down Expand Up @@ -239,4 +241,18 @@ public void onLongPress() {
((PostFragment) mFragment).goBackToTop();
}
}

@Override
public void lockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.lock();
}
}

@Override
public void unlockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.unlock();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,14 @@ public void onLongPress() {
}
}

@Override
public void lockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.lock();
}
}

@Override
public void unlockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,4 +391,13 @@ public void setCustomFont(Typeface typeface, Typeface titleTypeface, Typeface co
this.titleTypeface = titleTypeface;
this.contentTypeface = contentTypeface;
}


public void lockSwipeRightToGoBack() {

}

public void unlockSwipeRightToGoBack() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockScrollView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;

public class FullMarkdownActivity extends BaseActivity {

Expand Down Expand Up @@ -145,7 +144,7 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
miscPlugin, markdownColor, spoilerBackgroundColor, null);

MarkwonAdapter markwonAdapter = MarkdownUtils.createTablesAdapter();
LinearLayoutManagerBugFixed linearLayoutManager = new MarkwonLinearLayoutManager(this, new SwipeLockScrollView.SwipeLockInterface() {
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
@Override
public void lockSwipe() {
if (mSlidrInterface != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,14 @@ public void onLongPress() {
}
}

@Override
public void lockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.lock();
}
}

@Override
public void unlockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,15 @@ public void onLongPress() {
}
}

private void lockSwipeRightToGoBack() {
@Override
public void lockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.lock();
}
}

private void unlockSwipeRightToGoBack() {
@Override
public void unlockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,13 +913,15 @@ public int getItemCount() {
}
}

private void lockSwipeRightToGoBack() {
@Override
public void lockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.lock();
}
}

private void unlockSwipeRightToGoBack() {
@Override
public void unlockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,15 @@ public void onLongPress() {
}
}

private void lockSwipeRightToGoBack() {
@Override
public void lockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.lock();
}
}

private void unlockSwipeRightToGoBack() {
@Override
public void unlockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,12 +916,14 @@ public void sortTypeSelected(SortType sortType) {
}
}

@Override
public void lockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.lock();
}
}

@Override
public void unlockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public class ViewRedditGalleryActivity extends AppCompatActivity implements SetA
public static final String EXTRA_REDDIT_GALLERY = "ERG";
public static final String EXTRA_SUBREDDIT_NAME = "ESN";
public static final String EXTRA_IS_NSFW = "EIN";
public static final String EXTRA_GALLERY_ITEM_INDEX = "EGII";

@BindView(R.id.hauler_view_view_reddit_gallery_activity)
HaulerView haulerView;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1547,13 +1547,15 @@ public void markPostAsRead(Post post) {
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
}

private void lockSwipeRightToGoBack() {
@Override
public void lockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.lock();
}
}

private void unlockSwipeRightToGoBack() {
@Override
public void unlockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1748,12 +1748,14 @@ void filterPosts() {
}
}

@Override
public void lockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.lock();
}
}

@Override
public void unlockSwipeRightToGoBack() {
if (mSlidrInterface != null) {
mSlidrInterface.unlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockScrollView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
import ml.docilealligator.infinityforreddit.utils.JSONUtils;
Expand Down Expand Up @@ -178,7 +178,7 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
miscPlugin, markdownColor, spoilerBackgroundColor, onLinkLongClickListener);

markwonAdapter = MarkdownUtils.createTablesAdapter();
LinearLayoutManagerBugFixed linearLayoutManager = new MarkwonLinearLayoutManager(this, new SwipeLockScrollView.SwipeLockInterface() {
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(this, new SwipeLockInterface() {
@Override
public void lockSwipe() {
if (mSlidrInterface != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
import ml.docilealligator.infinityforreddit.customviews.CustomMarkwonAdapter;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockScrollView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
import ml.docilealligator.infinityforreddit.utils.APIUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
Expand Down Expand Up @@ -502,7 +502,7 @@ public class CommentViewHolder extends RecyclerView.ViewHolder {
});

commentMarkdownView.setRecycledViewPool(recycledViewPool);
LinearLayoutManagerBugFixed linearLayoutManager = new MarkwonLinearLayoutManager(mActivity, new SwipeLockScrollView.SwipeLockInterface() {
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
if (mActivity instanceof AccountSavedThingActivity) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
import ml.docilealligator.infinityforreddit.customviews.CommentIndentationView;
import ml.docilealligator.infinityforreddit.customviews.CustomMarkwonAdapter;
import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.customviews.SpoilerOnClickTextView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockScrollView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
import ml.docilealligator.infinityforreddit.post.Post;
Expand Down Expand Up @@ -1268,7 +1268,7 @@ public class CommentViewHolder extends RecyclerView.ViewHolder {
}

commentMarkdownView.setRecycledViewPool(recycledViewPool);
LinearLayoutManagerBugFixed linearLayoutManager = new MarkwonLinearLayoutManager(mActivity, new SwipeLockScrollView.SwipeLockInterface() {
LinearLayoutManagerBugFixed linearLayoutManager = new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
((ViewPostDetailActivity) mActivity).lockSwipeRightToGoBack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockScrollView;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockInterface;
import ml.docilealligator.infinityforreddit.customviews.SwipeLockLinearLayoutManager;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
import ml.docilealligator.infinityforreddit.markdown.MarkdownUtils;
import ml.docilealligator.infinityforreddit.post.Post;
Expand Down Expand Up @@ -1191,7 +1191,7 @@ void setBaseView(AspectRatioGifImageView mIconGifImageView,
mActivity.startActivity(intent);
});

mContentMarkdownView.setLayoutManager(new MarkwonLinearLayoutManager(mActivity, new SwipeLockScrollView.SwipeLockInterface() {
mContentMarkdownView.setLayoutManager(new SwipeLockLinearLayoutManager(mActivity, new SwipeLockInterface() {
@Override
public void lockSwipe() {
((ViewPostDetailActivity) mActivity).lockSwipeRightToGoBack();
Expand Down
Loading

0 comments on commit 03a2784

Please sign in to comment.