razeware / emitron-Android

Android version of emitron
Apache License 2.0
55 stars 30 forks source link

EMA #263 - Fixed a bug where the Data binding for the Pro course badge wasn't set up #271

Closed filbabic closed 4 years ago

filbabic commented 4 years ago

This issue caused all courses to have the Pro course badge. This PR fixes Issue #263.

There was only one simple change, where the Data binding for the Pro course badge wasn't set up, and in turn, the view was always visible.

Because we're using Data binding, it's important to add all the attributes in the XML, as all UI logic is handled there.

To fix the issue, we had to add the missing attribute for visibility, which depends on the professional flag within Data attributes.

<androidx.appcompat.widget.AppCompatTextView
  android:id="@+id/text_collection_label_pro"
  android:visibility="@{data.professional ? View.VISIBLE : View.GONE}"
/>

We also updated the documentation, as it seems to have been wrongly explaining what the isProfessional() function returns:

  /**
   *  @return true if content requires a professional subscription, else false
   */
  fun isProfessional(): Boolean = attributes?.professional == true
filbabic commented 4 years ago

@orionthewake Yeah the description in the professional property of the class was completely opposite of what it actually did (at least in this case), so it's good to get some historic knowledge as to why that was the case!

Thanks!