From 538827f11e2dd20dd8076544f8fbb3b85eb83df8 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 16 Feb 2021 11:41:38 +0800 Subject: Continue adding Gallery Layout. --- .../adapters/PostRecyclerViewAdapter.java | 18 ++++ .../infinityforreddit/fragments/PostFragment.java | 4 +- app/src/main/res/layout/item_post_gallery.xml | 119 ++++++++++++--------- app/src/main/res/layout/item_post_text.xml | 1 - .../res/layout/item_post_video_type_autoplay.xml | 1 - app/src/main/res/layout/item_post_with_preview.xml | 1 - 6 files changed, 86 insertions(+), 58 deletions(-) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index ca3ebb2b..47db2b6d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -3424,11 +3424,29 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { + int position = getBindingAdapterPosition(); + if (position >= 0 && canStartActivity) { + Post post = getItem(position); + if (post != null) { + //markPostRead(post, true); + canStartActivity = false; + + Intent intent = new Intent(mActivity, ViewPostDetailActivity.class); + intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, post); + intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, getBindingAdapterPosition()); + intent.putExtra(ViewPostDetailActivity.EXTRA_POST_FRAGMENT_ID, mFragment.getPostFragmentId()); + mActivity.startActivity(intent); + } + } + }); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index 140a36a8..c2be273a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -1711,9 +1711,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator { int halfOffset = mItemOffset / 2; if (spanIndex == 0) { - outRect.set(0, 0, halfOffset, 0); + outRect.set(halfOffset, 0, halfOffset, 0); } else { - outRect.set(halfOffset, 0, 0, 0); + outRect.set(halfOffset, 0, halfOffset, 0); } } } diff --git a/app/src/main/res/layout/item_post_gallery.xml b/app/src/main/res/layout/item_post_gallery.xml index 82e4ec60..dd1c7c1d 100644 --- a/app/src/main/res/layout/item_post_gallery.xml +++ b/app/src/main/res/layout/item_post_gallery.xml @@ -1,67 +1,80 @@ - + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + app:cardElevation="2dp" + app:cardCornerRadius="8dp"> - + - + - + - + android:visibility="gone"> - + - + - + - + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_post_text.xml b/app/src/main/res/layout/item_post_text.xml index 1d1dbce0..9bffa573 100644 --- a/app/src/main/res/layout/item_post_text.xml +++ b/app/src/main/res/layout/item_post_text.xml @@ -7,7 +7,6 @@ android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:id="@+id/card_view_item_post_text_type" - app:cardBackgroundColor="?attr/cardViewBackgroundColor" app:cardElevation="2dp" app:cardCornerRadius="16dp"> diff --git a/app/src/main/res/layout/item_post_video_type_autoplay.xml b/app/src/main/res/layout/item_post_video_type_autoplay.xml index b4fcb314..9573d808 100644 --- a/app/src/main/res/layout/item_post_video_type_autoplay.xml +++ b/app/src/main/res/layout/item_post_video_type_autoplay.xml @@ -7,7 +7,6 @@ android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:id="@+id/card_view_item_post_video_type_autoplay" - app:cardBackgroundColor="?attr/cardViewBackgroundColor" app:cardElevation="2dp" app:cardCornerRadius="16dp"> diff --git a/app/src/main/res/layout/item_post_with_preview.xml b/app/src/main/res/layout/item_post_with_preview.xml index 0e7b65b3..5cec4cfa 100644 --- a/app/src/main/res/layout/item_post_with_preview.xml +++ b/app/src/main/res/layout/item_post_with_preview.xml @@ -7,7 +7,6 @@ android:layout_marginTop="8dp" android:layout_marginBottom="8dp" android:id="@+id/card_view_item_post_with_preview" - app:cardBackgroundColor="?attr/cardViewBackgroundColor" app:cardElevation="2dp" app:cardCornerRadius="16dp"> -- cgit v1.2.3