@@ -410,7 +410,7 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
410410 if (dy > 0 && !m_isLazyLoading && !model .isLoading () && model .isLazyLoadEnabled () &&
411411 lastVisibleItem >= Application .getArticles ().size () - 5 ) {
412412
413- Log .d (TAG , "attempting to lazy load more articles..." );
413+ Log .d (TAG , "attempting to lazy load more articles (onScrolled) ..." );
414414
415415 m_isLazyLoading = true ;
416416
@@ -441,6 +441,24 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
441441 Log .d (TAG , "observed active article=" + activeArticle );
442442
443443 if (activeArticle != null ) {
444+
445+ // we can't be sure scrollToArticle() below actually does anything in DetailView because our fragment might be invisible in some layouts
446+ // so we also trigger lazy load on active article change
447+ if (m_activity instanceof DetailActivity ) {
448+ int position = Application .getArticles ().indexOf (activeArticle );
449+
450+ if (!m_isLazyLoading && !model .isLoading () && model .isLazyLoadEnabled () &&
451+ position >= Application .getArticles ().size () - 5 ) {
452+
453+ Log .d (TAG , "attempting to lazy load more articles (observed active article change)..." );
454+
455+ m_isLazyLoading = true ;
456+
457+ // this has to be dispatched delayed, consequent adapter updates are forbidden in scroll handler
458+ new Handler ().postDelayed (() -> refresh (true ), 250 );
459+ }
460+ }
461+
444462 scrollToArticle (activeArticle );
445463 }
446464 });
0 commit comments