Barebone swiping left or right to go to previous or next post in ViewPostDetailActivity.

This commit is contained in:
Alex Ning 2021-01-27 21:50:09 +08:00
parent b6c00df82f
commit 968519b2eb
14 changed files with 2007 additions and 1653 deletions

View File

@ -37,7 +37,7 @@ android {
dependencies { dependencies {
/** AndroidX **/ /** AndroidX **/
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.biometric:biometric:1.1.0-rc01' implementation 'androidx.biometric:biometric:1.2.0-alpha01'
implementation 'androidx.browser:browser:1.3.0' implementation 'androidx.browser:browser:1.3.0'
implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
@ -52,7 +52,8 @@ dependencies {
implementation "androidx.room:room-runtime:$roomVersion" implementation "androidx.room:room-runtime:$roomVersion"
annotationProcessor "androidx.room:room-compiler:$roomVersion" annotationProcessor "androidx.room:room-compiler:$roomVersion"
implementation 'androidx.work:work-runtime:2.4.0' implementation 'androidx.work:work-runtime:2.4.0'
implementation 'com.google.android.material:material:1.3.0-alpha04' implementation 'com.google.android.material:material:1.3.0-rc01'
implementation "androidx.viewpager2:viewpager2:1.1.0-alpha01"
/** ExoPlayer **/ /** ExoPlayer **/
def exoplayerVersion = "2.10.8" def exoplayerVersion = "2.10.8"

View File

@ -64,6 +64,7 @@ import ml.docilealligator.infinityforreddit.fragments.SubscribedSubredditsListin
import ml.docilealligator.infinityforreddit.fragments.UserListingFragment; import ml.docilealligator.infinityforreddit.fragments.UserListingFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewImgurImageFragment; import ml.docilealligator.infinityforreddit.fragments.ViewImgurImageFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewImgurVideoFragment; import ml.docilealligator.infinityforreddit.fragments.ViewImgurVideoFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryImageOrGifFragment; import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryImageOrGifFragment;
import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment; import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment;
import ml.docilealligator.infinityforreddit.services.DownloadMediaService; import ml.docilealligator.infinityforreddit.services.DownloadMediaService;
@ -248,4 +249,6 @@ public interface AppComponent {
void inject(ViewImgurImageFragment viewImgurImageFragment); void inject(ViewImgurImageFragment viewImgurImageFragment);
void inject(ViewRedditGalleryImageOrGifFragment viewRedditGalleryImageOrGifFragment); void inject(ViewRedditGalleryImageOrGifFragment viewRedditGalleryImageOrGifFragment);
void inject(ViewPostDetailFragment viewPostDetailFragment);
} }

View File

@ -52,8 +52,8 @@ public class EditCommentActivity extends BaseActivity {
public static final String EXTRA_FULLNAME = "EF"; public static final String EXTRA_FULLNAME = "EF";
public static final String EXTRA_POSITION = "EP"; public static final String EXTRA_POSITION = "EP";
static final String EXTRA_EDITED_COMMENT_CONTENT = "EECC"; public static final String EXTRA_EDITED_COMMENT_CONTENT = "EECC";
static final String EXTRA_EDITED_COMMENT_POSITION = "EECP"; public static final String EXTRA_EDITED_COMMENT_POSITION = "EECP";
@BindView(R.id.coordinator_layout_edit_comment_activity) @BindView(R.id.coordinator_layout_edit_comment_activity)
CoordinatorLayout coordinatorLayout; CoordinatorLayout coordinatorLayout;

View File

@ -50,9 +50,9 @@ import retrofit2.Retrofit;
public class EditPostActivity extends BaseActivity { public class EditPostActivity extends BaseActivity {
static final String EXTRA_TITLE = "ET"; public static final String EXTRA_TITLE = "ET";
static final String EXTRA_CONTENT = "EC"; public static final String EXTRA_CONTENT = "EC";
static final String EXTRA_FULLNAME = "EF"; public static final String EXTRA_FULLNAME = "EF";
@BindView(R.id.coordinator_layout_edit_post_activity) @BindView(R.id.coordinator_layout_edit_post_activity)
CoordinatorLayout coordinatorLayout; CoordinatorLayout coordinatorLayout;

View File

@ -968,11 +968,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
private void changeSortType() { private void changeSortType() {
int currentPostType = sectionsPagerAdapter.getCurrentPostType(); int currentPostType = sectionsPagerAdapter.getCurrentPostType();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
if (currentPostType != PostDataSource.TYPE_FRONT_PAGE) { bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, currentPostType != PostDataSource.TYPE_FRONT_PAGE);
bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
} else {
bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false);
}
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment(); SortTypeBottomSheetFragment sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
sortTypeBottomSheetFragment.setArguments(bundle); sortTypeBottomSheetFragment.setArguments(bundle);
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag()); sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
@ -980,43 +976,43 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override @Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) { public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) { int itemId = item.getItemId();
case R.id.action_search_main_activity: if (itemId == R.id.action_search_main_activity) {
Intent intent = new Intent(this, SearchActivity.class); Intent intent = new Intent(this, SearchActivity.class);
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.action_sort_main_activity: } else if (itemId == R.id.action_sort_main_activity) {
changeSortType(); changeSortType();
return true; return true;
case R.id.action_refresh_main_activity: } else if (itemId == R.id.action_refresh_main_activity) {
if (mMenu != null) { if (mMenu != null) {
mMenu.findItem(R.id.action_lazy_mode_main_activity).setTitle(R.string.action_start_lazy_mode); mMenu.findItem(R.id.action_lazy_mode_main_activity).setTitle(R.string.action_start_lazy_mode);
} }
sectionsPagerAdapter.refresh(); sectionsPagerAdapter.refresh();
mFetchUserInfoSuccess = false; mFetchUserInfoSuccess = false;
loadUserData(); loadUserData();
return true; return true;
case R.id.action_lazy_mode_main_activity: } else if (itemId == R.id.action_lazy_mode_main_activity) {
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity); MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_main_activity);
if (isInLazyMode) { if (isInLazyMode) {
sectionsPagerAdapter.stopLazyMode(); sectionsPagerAdapter.stopLazyMode();
isInLazyMode = false; isInLazyMode = false;
lazyModeItem.setTitle(R.string.action_start_lazy_mode); lazyModeItem.setTitle(R.string.action_start_lazy_mode);
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS); params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
collapsingToolbarLayout.setLayoutParams(params);
} else {
if (sectionsPagerAdapter.startLazyMode()) {
isInLazyMode = true;
lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
collapsingToolbarLayout.setLayoutParams(params); collapsingToolbarLayout.setLayoutParams(params);
} else {
if (sectionsPagerAdapter.startLazyMode()) {
isInLazyMode = true;
lazyModeItem.setTitle(R.string.action_stop_lazy_mode);
params.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
collapsingToolbarLayout.setLayoutParams(params);
}
} }
return true; }
case R.id.action_change_post_layout_main_activity: return true;
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment(); } else if (itemId == R.id.action_change_post_layout_main_activity) {
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
return true; postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true;
} }
return false; return false;
} }

View File

@ -113,6 +113,7 @@ import ml.docilealligator.infinityforreddit.comment.FetchComment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager; import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager;
import ml.docilealligator.infinityforreddit.fragments.ViewPostDetailFragment;
import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.post.PostDataSource; import ml.docilealligator.infinityforreddit.post.PostDataSource;
import ml.docilealligator.infinityforreddit.utils.APIUtils; import ml.docilealligator.infinityforreddit.utils.APIUtils;
@ -143,6 +144,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 17; private static final int VIEW_TYPE_VIEW_ALL_COMMENTS = 17;
private AppCompatActivity mActivity; private AppCompatActivity mActivity;
private ViewPostDetailFragment mFragment;
private Executor mExecutor; private Executor mExecutor;
private Retrofit mRetrofit; private Retrofit mRetrofit;
private Retrofit mOauthRetrofit; private Retrofit mOauthRetrofit;
@ -238,7 +240,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private float mScale; private float mScale;
private ExoCreator mExoCreator; private ExoCreator mExoCreator;
public CommentAndPostRecyclerViewAdapter(AppCompatActivity activity, Executor executor, CustomThemeWrapper customThemeWrapper, public CommentAndPostRecyclerViewAdapter(AppCompatActivity activity, ViewPostDetailFragment fragment, Executor executor, CustomThemeWrapper customThemeWrapper,
Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit, Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit,
Retrofit redgifsRetrofit, Retrofit redgifsRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide, RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
@ -249,6 +251,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
SharedPreferences nsfwAndSpoilerSharedPreferences, ExoCreator exoCreator, SharedPreferences nsfwAndSpoilerSharedPreferences, ExoCreator exoCreator,
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) { CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
mActivity = activity; mActivity = activity;
mFragment = fragment;
mExecutor = executor; mExecutor = executor;
mRetrofit = retrofit; mRetrofit = retrofit;
mOauthRetrofit = oauthRetrofit; mOauthRetrofit = oauthRetrofit;
@ -3765,9 +3768,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (bottomConstraintLayout.getLayoutParams().height == 0) { if (bottomConstraintLayout.getLayoutParams().height == 0) {
bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT; bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
topScoreTextView.setVisibility(View.GONE); topScoreTextView.setVisibility(View.GONE);
((ViewPostDetailActivity) mActivity).delayTransition(); mFragment.delayTransition();
} else { } else {
((ViewPostDetailActivity) mActivity).delayTransition(); mFragment.delayTransition();
bottomConstraintLayout.getLayoutParams().height = 0; bottomConstraintLayout.getLayoutParams().height = 0;
topScoreTextView.setVisibility(View.VISIBLE); topScoreTextView.setVisibility(View.VISIBLE);
} }
@ -3944,7 +3947,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (mActivity != null && mActivity instanceof ViewPostDetailActivity) { if (mActivity != null && mActivity instanceof ViewPostDetailActivity) {
mIsSingleCommentThreadMode = false; mIsSingleCommentThreadMode = false;
mSingleCommentId = null; mSingleCommentId = null;
((ViewPostDetailActivity) mActivity).changeToNomalThreadMode(); mFragment.changeToNomalThreadMode();
} }
}); });

View File

@ -92,6 +92,7 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.ShareLinkBottom
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView; import ml.docilealligator.infinityforreddit.customviews.AspectRatioGifImageView;
import ml.docilealligator.infinityforreddit.events.PostUpdateEventToDetailActivity; import ml.docilealligator.infinityforreddit.events.PostUpdateEventToDetailActivity;
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.post.Post;
import ml.docilealligator.infinityforreddit.post.PostDataSource; import ml.docilealligator.infinityforreddit.post.PostDataSource;
import ml.docilealligator.infinityforreddit.user.UserDao; import ml.docilealligator.infinityforreddit.user.UserDao;
@ -128,6 +129,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
} }
}; };
private AppCompatActivity mActivity; private AppCompatActivity mActivity;
private PostFragment mFragment;
private Executor mExecutor; private Executor mExecutor;
private Retrofit mOauthRetrofit; private Retrofit mOauthRetrofit;
private Retrofit mRetrofit; private Retrofit mRetrofit;
@ -207,7 +209,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private ExoCreator mExoCreator; private ExoCreator mExoCreator;
private Callback mCallback; private Callback mCallback;
public PostRecyclerViewAdapter(AppCompatActivity activity, Executor executor, Retrofit oauthRetrofit, Retrofit retrofit, public PostRecyclerViewAdapter(AppCompatActivity activity, PostFragment fragment, Executor executor, Retrofit oauthRetrofit, Retrofit retrofit,
Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, Retrofit gfycatRetrofit, Retrofit redgifsRetrofit,
RedditDataRoomDatabase redditDataRoomDatabase, RedditDataRoomDatabase redditDataRoomDatabase,
CustomThemeWrapper customThemeWrapper, Locale locale, int imageViewWidth, CustomThemeWrapper customThemeWrapper, Locale locale, int imageViewWidth,
@ -218,6 +220,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
super(DIFF_CALLBACK); super(DIFF_CALLBACK);
if (activity != null) { if (activity != null) {
mActivity = activity; mActivity = activity;
mFragment = fragment;
mExecutor = executor; mExecutor = executor;
mOauthRetrofit = oauthRetrofit; mOauthRetrofit = oauthRetrofit;
mRetrofit = retrofit; mRetrofit = retrofit;
@ -1629,7 +1632,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
canStartActivity = false; canStartActivity = false;
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class); Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post); intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST, mFragment.getPostList());
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, getAdapterPosition()); intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, getAdapterPosition());
mActivity.startActivity(intent); mActivity.startActivity(intent);
} }
@ -2645,7 +2648,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
canStartActivity = false; canStartActivity = false;
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class); Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post); intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST, mFragment.getPostList());
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, getAdapterPosition()); intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, getAdapterPosition());
mActivity.startActivity(intent); mActivity.startActivity(intent);
} }

View File

@ -437,7 +437,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime)); sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout); postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
windowWidth, accessToken, accountName, postType, postLayout, true, windowWidth, accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@ -503,7 +503,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortType = new SortType(SortType.Type.valueOf(sort)); sortType = new SortType(SortType.Type.valueOf(sort));
} }
mAdapter = new PostRecyclerViewAdapter(activity, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
windowWidth, accessToken, accountName, postType, postLayout, displaySubredditName, windowWidth, accessToken, accountName, postType, postLayout, displaySubredditName,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@ -567,7 +567,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortType = new SortType(SortType.Type.valueOf(sort)); sortType = new SortType(SortType.Type.valueOf(sort));
} }
mAdapter = new PostRecyclerViewAdapter(activity, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
windowWidth, accessToken, accountName, postType, postLayout, true, windowWidth, accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@ -631,7 +631,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} }
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout); postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
windowWidth, accessToken, accountName, postType, postLayout, true, windowWidth, accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@ -686,7 +686,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} }
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout); postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
mAdapter = new PostRecyclerViewAdapter(activity, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit, mAdapter = new PostRecyclerViewAdapter(activity, this, mExecutor, mOauthRetrofit, mRetrofit, mGfycatRetrofit,
mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale, mRedgifsRetrofit, mRedditDataRoomDatabase, mCustomThemeWrapper, locale,
windowWidth, accessToken, accountName, postType, postLayout, true, windowWidth, accessToken, accountName, postType, postLayout, true,
mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences, mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostHistorySharedPreferences,
@ -1061,6 +1061,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} }
} }
public ArrayList<Post> getPostList() {
return new ArrayList<>(mPostViewModel.getPosts().getValue());
}
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);

View File

@ -32,44 +32,11 @@
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.viewpager2.widget.ViewPager2
android:id="@+id/swipe_refresh_layout_view_post_detail_activity" android:id="@+id/view_pager_2_view_post_detail_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<ml.docilealligator.infinityforreddit.customviews.CustomToroContainer
android:id="@+id/recycler_view_view_post_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="144dp"
android:clipToPadding="false" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/fetch_post_info_linear_layout_view_post_detail_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:id="@+id/fetch_post_info_image_view_view_post_detail_activity"
android:layout_width="150dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/fetch_post_info_text_view_view_post_detail_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</LinearLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_view_post_detail_activity" android:id="@+id/fab_view_post_detail_activity"

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".fragments.ViewPostDetailFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout_view_post_detail_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<ml.docilealligator.infinityforreddit.customviews.CustomToroContainer
android:id="@+id/recycler_view_view_post_detail_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="144dp"
android:clipToPadding="false" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/fetch_post_info_linear_layout_view_post_detail_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<ImageView
android:id="@+id/fetch_post_info_image_view_view_post_detail_fragment"
android:layout_width="150dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/fetch_post_info_text_view_view_post_detail_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="center"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</LinearLayout>
</FrameLayout>

View File

@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<item <item
android:id="@+id/action_comment_view_post_detail_activity" android:id="@+id/action_comment_view_post_detail_fragment"
android:orderInCategory="1" android:orderInCategory="1"
android:title="@string/action_add_comment" android:title="@string/action_add_comment"
android:icon="@drawable/ic_comment_toolbar_24dp" android:icon="@drawable/ic_comment_toolbar_24dp"
@ -10,92 +10,92 @@
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_save_view_post_detail_activity" android:id="@+id/action_save_view_post_detail_fragment"
android:orderInCategory="2" android:orderInCategory="2"
android:title="@string/action_save_post" android:title="@string/action_save_post"
app:showAsAction="ifRoom" app:showAsAction="ifRoom"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_sort_view_post_detail_activity" android:id="@+id/action_sort_view_post_detail_fragment"
android:orderInCategory="3" android:orderInCategory="3"
android:title="@string/action_sort" android:title="@string/action_sort"
app:showAsAction="never" app:showAsAction="never"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_refresh_view_post_detail_activity" android:id="@+id/action_refresh_view_post_detail_fragment"
android:orderInCategory="4" android:orderInCategory="4"
android:title="@string/action_refresh" android:title="@string/action_refresh"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/action_view_crosspost_parent_view_post_detail_activity" android:id="@+id/action_view_crosspost_parent_view_post_detail_fragment"
android:orderInCategory="5" android:orderInCategory="5"
android:title="@string/action_view_crosspost_parent" android:title="@string/action_view_crosspost_parent"
app:showAsAction="never" app:showAsAction="never"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_hide_view_post_detail_activity" android:id="@+id/action_hide_view_post_detail_fragment"
android:orderInCategory="6" android:orderInCategory="6"
app:showAsAction="never" app:showAsAction="never"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_edit_view_post_detail_activity" android:id="@+id/action_edit_view_post_detail_fragment"
android:orderInCategory="7" android:orderInCategory="7"
android:title="@string/action_edit_post" android:title="@string/action_edit_post"
app:showAsAction="never" app:showAsAction="never"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_delete_view_post_detail_activity" android:id="@+id/action_delete_view_post_detail_fragment"
android:orderInCategory="8" android:orderInCategory="8"
android:title="@string/action_delete_post" android:title="@string/action_delete_post"
app:showAsAction="never" app:showAsAction="never"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_nsfw_view_post_detail_activity" android:id="@+id/action_nsfw_view_post_detail_fragment"
android:orderInCategory="9" android:orderInCategory="9"
app:showAsAction="never" app:showAsAction="never"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_spoiler_view_post_detail_activity" android:id="@+id/action_spoiler_view_post_detail_fragment"
android:orderInCategory="10" android:orderInCategory="10"
app:showAsAction="never" app:showAsAction="never"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_edit_flair_view_post_detail_activity" android:id="@+id/action_edit_flair_view_post_detail_fragment"
android:orderInCategory="11" android:orderInCategory="11"
android:title="@string/action_edit_flair" android:title="@string/action_edit_flair"
app:showAsAction="never" app:showAsAction="never"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_give_award_view_post_detail_activity" android:id="@+id/action_give_award_view_post_detail_fragment"
android:orderInCategory="12" android:orderInCategory="12"
android:title="@string/action_give_award" android:title="@string/action_give_award"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/action_report_view_post_detail_activity" android:id="@+id/action_report_view_post_detail_fragment"
android:orderInCategory="13" android:orderInCategory="13"
android:title="@string/action_report" android:title="@string/action_report"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/action_see_removed_view_post_detail_activity" android:id="@+id/action_see_removed_view_post_detail_fragment"
android:orderInCategory="14" android:orderInCategory="14"
android:title="@string/action_see_removed" android:title="@string/action_see_removed"
app:showAsAction="never" app:showAsAction="never"
android:visible="false" /> android:visible="false" />
<item <item
android:id="@+id/action_crosspost_view_post_detail_activity" android:id="@+id/action_crosspost_view_post_detail_fragment"
android:orderInCategory="15" android:orderInCategory="15"
android:title="@string/action_crosspost" android:title="@string/action_crosspost"
app:showAsAction="never" /> app:showAsAction="never" />

View File

@ -1016,7 +1016,5 @@
<string name="add_subreddit_or_user_to_multireddit_failed">Unable to add %1$s to multireddit %2$s</string> <string name="add_subreddit_or_user_to_multireddit_failed">Unable to add %1$s to multireddit %2$s</string>
<string name="choose_a_user">Choose a user</string> <string name="choose_a_user">Choose a user</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources> </resources>