Skip to content
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

ViewBinding Migration #629

Merged
merged 35 commits into from
Oct 7, 2024
Merged

ViewBinding Migration #629

merged 35 commits into from
Oct 7, 2024

Conversation

baronhsieh2005
Copy link
Contributor

@baronhsieh2005 baronhsieh2005 commented Oct 6, 2024

Changes:

  1. Changed fragments/adapters that still use synthetics by either implementing viewbinding or creating instances to avoid direct global view referencing (as it is no longer a thing without synthetics). These are some of the implementations:
  • Access toolbar from mActivity.findViewById as it is a component of the include_main layout

  • Since all views that require loadingPanel already has access to the reuseable layout through include, I mostly just referenced it through view.findViewById or through the binding

  • As no_results is also a reusable layout, I gave all views that require the layout access through include

  • For most adapters, I rewrote them such that their viewholders would take in bindings so they can access and reference the view objects directly through the binding and bind the views inside the viewholders OR functions in the adapter can take in these viewholders as arguments and bind the view (The case of HomeAdapter)

  • Also additionally added viewbinding for some fragments that don't use it.

  1. Changed the Parcelize package used in SavedState to the non-deprecated version (enabled by the kotlin-parcelize gradle plugin)

  2. Removed abundant "not connected to internet" banner/toolbar in DiningHolderFragment since DiningFragment and DiningInsightsFragment already handle these logics themselves (and there would be two toolbars that pops up when there is no internet)

  3. Some other lifecycle tweaks (so that we won't do any view work during onCreate and crash the app)

Now, after this, we can start upgrading basically everything without too much issues. I have successfully implemented compose currently on a branch with kotlin ver. 1.8.0, but I think it's best to review the migration and we can finalize all the upgrades/implementation in a meeting in person

…homeAdapter to viewBinding) and GsrBuildingAdapter viewBinding implementation
…why does diningsettings use views from laundry lmao)
…o-refresh implmentation in onResume so we don't need to manually hide the no internet view on PottruckFragment
… the switches as the fragment has no access to the layout anymore (and also how do we even access PennCourseAlerts?)
@@ -164,39 +143,32 @@ class HomeAdapter(
}

else -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't the DiningCell, CalendarCell, and LaundryCell get their own ViewHolders? Although it's less code since they share the same views (for now), I don't think it's a good idea to blend all of these into one. Ultimately, they are different things and may have different needs in the future.

Maybe better is to make a base holder (e.g., HomeBaseHolder) that all of the other ViewHolders in the home page inherent from. Then, in this case you can basically have a "HomeDiningHolder" that just inherits from HomeBaseHolder without any fields of its own. IMO things are more natural this way.

@meiron03
Copy link
Member

meiron03 commented Oct 6, 2024

Everything else seems good to me though. Great job, this is huge!

Copy link
Member

@meiron03 meiron03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!!!

@baronhsieh2005
Copy link
Contributor Author

Yessirrrr

@baronhsieh2005 baronhsieh2005 merged commit 6efbbf9 into main Oct 7, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants