diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f320cb64..fb659b23 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -406,7 +406,8 @@
+ android:theme="@style/AppTheme.Slidable"
+ android:windowSoftInputMode="adjustPan" />
{
+ ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
+ if (fragment != null) {
+ searchComment(fragment, true);
+ }
+ });
+
+ previousResultImageView.setOnClickListener(view -> {
+ ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
+ if (fragment != null) {
+ searchComment(fragment, false);
+ }
+ });
+
+ closeSearchPanelImageView.setOnClickListener(view -> {
+ ViewPostDetailFragment fragment = sectionsPagerAdapter.getCurrentFragment();
+ if (fragment != null) {
+ fragment.resetSearchCommentIndex();
+ }
+
+ searchPanelMaterialCardView.setVisibility(View.GONE);
+ });
}
public boolean isNsfwSubreddit() {
@@ -396,6 +418,10 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}
}
+ public void searchComment(ViewPostDetailFragment fragment, boolean searchNextComment) {
+ fragment.searchComment(searchTextInputEditText.getText().toString(), searchNextComment);
+ }
+
@Subscribe
public void onAccountSwitchEvent(SwitchAccountEvent event) {
if (!getClass().getName().equals(event.excludeActivityClassName)) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
index f88012b9..7e00a97f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java
@@ -139,6 +139,8 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter visibleComments = mCommentsAdapter.getVisibleComments();
+ int currentSearchIndex = mCommentsAdapter.getSearchCommentIndex();
+ if (visibleComments != null) {
+ if (searchNextComment) {
+ for (int i = currentSearchIndex + 1; i < visibleComments.size(); i++) {
+ if (visibleComments.get(i).getCommentRawText() != null && visibleComments.get(i).getCommentRawText().contains(query)) {
+ if (mCommentsAdapter != null) {
+ if (mCommentsRecyclerView == null) {
+ mRecyclerView.smoothScrollToPosition(i + 1);
+ } else {
+ mCommentsRecyclerView.smoothScrollToPosition(i);
+ }
+ mCommentsAdapter.highlightSearchResult(i);
+ mCommentsAdapter.notifyItemChanged(i);
+ }
+ return;
+ }
+ }
+
+ return;
+ } else {
+ for (int i = currentSearchIndex - 1; i >= 0; i--) {
+ if (visibleComments.get(i).getCommentRawText() !=null && visibleComments.get(i).getCommentRawText().contains(query)) {
+ if (mCommentsAdapter != null) {
+ if (mCommentsRecyclerView == null) {
+ mRecyclerView.smoothScrollToPosition(i + 1);
+ } else {
+ mCommentsRecyclerView.smoothScrollToPosition(i);
+ }
+ mCommentsAdapter.highlightSearchResult(i);
+ mCommentsAdapter.notifyItemChanged(i);
+ }
+ return;
+ }
+ }
+
+ return;
+ }
+ }
+ }
+ }
+
+ public void resetSearchCommentIndex() {
+ if (mCommentsAdapter != null) {
+ mCommentsAdapter.resetCommentSearchIndex();
+ }
+ }
+
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.view_post_detail_fragment, menu);