11package org.wordpress.android.ui.reader
22
33import android.os.Bundle
4+ import android.view.View
5+ import androidx.recyclerview.widget.RecyclerView
46import dagger.hilt.android.AndroidEntryPoint
57import org.wordpress.android.R
68import org.wordpress.android.WordPress
79import org.wordpress.android.ui.LocaleAwareActivity
10+ import org.wordpress.android.ui.ScrollableViewInitializedListener
811import org.wordpress.android.ui.reader.tracker.ReaderTracker
912import org.wordpress.android.ui.reader.tracker.ReaderTrackerType.MAIN_READER
13+ import org.wordpress.android.util.JetpackBrandingUtils
1014import javax.inject.Inject
1115
1216/* *
@@ -15,8 +19,10 @@ import javax.inject.Inject
1519 * into new tested classes without requiring us to change the search behavior.
1620 */
1721@AndroidEntryPoint
18- class ReaderSearchActivity : LocaleAwareActivity () {
22+ class ReaderSearchActivity : LocaleAwareActivity (),
23+ ScrollableViewInitializedListener {
1924 @Inject lateinit var readerTracker: ReaderTracker
25+ @Inject lateinit var jetpackBrandingUtils: JetpackBrandingUtils
2026
2127 override fun onCreate (savedInstanceState : Bundle ? ) {
2228 super .onCreate(savedInstanceState)
@@ -41,4 +47,24 @@ class ReaderSearchActivity : LocaleAwareActivity() {
4147 super .onPause()
4248 readerTracker.stop(MAIN_READER )
4349 }
50+
51+ override fun onScrollableViewInitialized (containerId : Int ) {
52+ val fragmentContainer = supportFragmentManager.findFragmentById(R .id.fragment_container)
53+
54+ if (fragmentContainer is ReaderPostListFragment ) {
55+ val fragmentView = fragmentContainer.view ? : return
56+
57+ fragmentView.post {
58+ // post is used to create a minimal delay here. containerId changes just before
59+ // onScrollableViewInitialized is called, and findViewById can't find the new id before the delay.
60+ val jetpackBannerView = fragmentView.findViewById<View >(R .id.jetpack_banner)
61+ val scrollableView = fragmentView.findViewById<View >(containerId) as RecyclerView
62+
63+ if (jetpackBrandingUtils.shouldShowJetpackBranding()) {
64+ jetpackBrandingUtils.showJetpackBannerIfScrolledToTop(jetpackBannerView, scrollableView)
65+ jetpackBrandingUtils.initJetpackBannerAnimation(jetpackBannerView, scrollableView)
66+ }
67+ }
68+ }
69+ }
4470}
0 commit comments