@@ -250,24 +250,10 @@ protected void onCreate(Bundle savedInstanceState) {
250
250
mVolumeKeysNavigateComments = mSharedPreferences .getBoolean (SharedPreferencesUtils .VOLUME_KEYS_NAVIGATE_COMMENTS , false );
251
251
252
252
binding .fabViewPostDetailActivity .setOnClickListener (view -> {
253
- if (mSectionsPagerAdapter != null ) {
254
- ViewPostDetailFragment fragment = mSectionsPagerAdapter .getCurrentFragment ();
255
- if (fragment != null ) {
256
- fragment .scrollToNextParentComment ();
257
- }
258
- }
253
+ scrollToNextParentComment ();
259
254
});
260
255
261
- binding .fabViewPostDetailActivity .setOnLongClickListener (view -> {
262
- if (mSectionsPagerAdapter != null ) {
263
- ViewPostDetailFragment fragment = mSectionsPagerAdapter .getCurrentFragment ();
264
- if (fragment != null ) {
265
- fragment .scrollToPreviousParentComment ();
266
- return true ;
267
- }
268
- }
269
- return false ;
270
- });
256
+ binding .fabViewPostDetailActivity .setOnLongClickListener (view -> scrollToPreviousParentComment ());
271
257
272
258
if (accountName .equals (Account .ANONYMOUS_ACCOUNT ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
273
259
binding .searchTextInputEditTextViewPostDetailActivity .setImeOptions (binding .searchTextInputEditTextViewPostDetailActivity .getImeOptions () | EditorInfoCompat .IME_FLAG_NO_PERSONALIZED_LEARNING );
@@ -318,6 +304,27 @@ public void showSnackBar(int resId) {
318
304
Snackbar .make (binding .getRoot (), resId , Snackbar .LENGTH_SHORT ).show ();
319
305
}
320
306
307
+ public void scrollToNextParentComment () {
308
+ if (mSectionsPagerAdapter != null ) {
309
+ ViewPostDetailFragment fragment = mSectionsPagerAdapter .getCurrentFragment ();
310
+ if (fragment != null ) {
311
+ fragment .scrollToNextParentComment ();
312
+ }
313
+ }
314
+ }
315
+
316
+ public boolean scrollToPreviousParentComment () {
317
+ if (mSectionsPagerAdapter != null ) {
318
+ ViewPostDetailFragment fragment = mSectionsPagerAdapter .getCurrentFragment ();
319
+ if (fragment != null ) {
320
+ fragment .scrollToPreviousParentComment ();
321
+ return true ;
322
+ }
323
+ }
324
+
325
+ return false ;
326
+ }
327
+
321
328
@ Override
322
329
public SharedPreferences getDefaultSharedPreferences () {
323
330
return mSharedPreferences ;
@@ -792,6 +799,12 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
792
799
} else if (item .getItemId () == R .id .action_reset_fab_position_view_post_detail_activity ) {
793
800
binding .fabViewPostDetailActivity .resetCoordinates ();
794
801
return true ;
802
+ } else if (item .getItemId () == R .id .action_next_parent_comment_view_post_detail_activity ) {
803
+ scrollToNextParentComment ();
804
+ return true ;
805
+ } else if (item .getItemId () == R .id .action_previous_parent_comment_view_post_detail_activity ) {
806
+ scrollToPreviousParentComment ();
807
+ return true ;
795
808
}
796
809
return false ;
797
810
}
@@ -858,16 +871,13 @@ protected void onDestroy() {
858
871
@ Override
859
872
public boolean onKeyDown (int keyCode , KeyEvent event ) {
860
873
if (mVolumeKeysNavigateComments ) {
861
- ViewPostDetailFragment fragment = mSectionsPagerAdapter .getCurrentFragment ();
862
- if (fragment != null ) {
863
- switch (keyCode ) {
864
- case KeyEvent .KEYCODE_VOLUME_UP :
865
- fragment .scrollToPreviousParentComment ();
866
- return true ;
867
- case KeyEvent .KEYCODE_VOLUME_DOWN :
868
- fragment .scrollToNextParentComment ();
869
- return true ;
870
- }
874
+ switch (keyCode ) {
875
+ case KeyEvent .KEYCODE_VOLUME_UP :
876
+ scrollToPreviousParentComment ();
877
+ return true ;
878
+ case KeyEvent .KEYCODE_VOLUME_DOWN :
879
+ scrollToNextParentComment ();
880
+ return true ;
871
881
}
872
882
}
873
883
return super .onKeyDown (keyCode , event );
0 commit comments