-
Notifications
You must be signed in to change notification settings - Fork 0
MOB-5193 HP4U Data API #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@sanjacurcic-taboola - When adding UI, please add screenshots of the relevant UI. |
app/build.gradle
Outdated
| applicationId "com.taboola.hp4udemoapplication" | ||
| minSdk 21 | ||
| targetSdk 32 | ||
| targetSdk 34 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - The latest SDK level is 36, so at the very least you can upgrade to it or to 35.
| implementation 'androidx.core:core-splashscreen:1.0.0-rc01' | ||
| implementation 'com.squareup.picasso:picasso:2.8' | ||
| //Taboola SDK | ||
| implementation 'com.taboola:android-sdk:3.8.13' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Notice that you changed the major version (from three to four). I would make sure nothing was impacted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already checked the entire app, everything seems fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Remember you can only merge this once 4.0.17 has been released officially.
8348835 to
2e01bc4
Compare
|
|
||
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
| super.onViewCreated(view, savedInstanceState) | ||
| if (homePage == null) createHomePage() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Is there a reason where homePage wouldn't be null in this situation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we click on some Article, a new screen will open. After returning from that screen to the HomePage screen, the onViewCreated will be called again and the HomePage fetchContent will be triggered again. To avoid this, I added this check. If the HomePage has already been initialized, it should not be initialized again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the example project initializing homepage in a fragment? Wouldn't it be more relevant in an activity that holds fragments? Do you feel this simulates a publisher scenario?
| override fun onHomePageStatusChanged(active: Boolean) { | ||
| super.onHomePageStatusChanged(active) | ||
|
|
||
| if (active) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Maybe add a log/toast if home page isn't active?
| } | ||
|
|
||
| private fun swapItems(recommendationItems: HashMap<String, MutableList<TBLRecommendationHomePageDataApiItem>>) { | ||
| if (homePage == null) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - I see there are many places where you are guarding the scenario where homePage is null. What could lead to this behavior? Also, do you want to log something for these scenarios?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed if (homePage == null) return from here and responded in another comment.
|
|
||
| for (position in listWithSwappedItems.indices) { | ||
| val currentItem = listWithSwappedItems[position] | ||
| if (currentItem is Article) sectionName = currentItem.sectionName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Could you refactor this into a when statement?
| if (currentItem is Article) sectionName = currentItem.sectionName | ||
| if (currentItem is Header) sectionStartPositionIndex = position + 1 | ||
|
|
||
| if (homePage!!.shouldSwapItemInSectionDataApi(sectionName, position, sectionStartPositionIndex)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Force unwrapping is not something we should always do. Is there a way to re-write this?
| } | ||
| } | ||
|
|
||
| private fun getRecommendation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - If a publisher goes over this code, do you believe they will understand what is going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments that will help publisher understand the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Thanks, that helps, but according to your comments, I believe the name of the method can be changed to provide better clarity.
tomer-br-taboola
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Please go over the comments.
| } | ||
| DEFAULT_ARTICLE -> { | ||
| val viewHolder = HomePageItemViewHolder(view) | ||
| val viewHolder = if (isHomePageDataApiMode) HomePageDataApiItemViewHolder(view) else HomePageItemViewHolder(view) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val viewHolder = when(isHomePageApiMode) { true -> ... false -> ... }
| } | ||
| DEFAULT_ARTICLE -> { | ||
| val viewHolder = if (isHomePageDataApiMode) HomePageDataApiItemViewHolder(view) else HomePageItemViewHolder(view) | ||
| val viewHolder = when (isHomePageDataApiMode) { true -> HomePageDataApiItemViewHolder(view) false -> HomePageItemViewHolder(view) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Please apply formatting here.
|
|
||
| private val TAG = HomePageDataApiScreenFragment::class.java.simpleName | ||
| private var homePage: TBLHomePage? = null | ||
| private lateinit var homePage: TBLHomePage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - Since you changed it to lateinit, just make sure that any flow in your logic doesn't reference this variable before it is actually initialized. Because otherwise, there will be a crash.
tomer-br-taboola
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sanjacurcic-taboola - I am approving, but please go over the last remaining comments.
Added new screen for HP4U Data API.