Systers, an AnitaB.org community

Use Kotlin Lazy Delegated Properties to initialise ViewModels (Mentorship - Android)

Prerequisite:

  1. Fork and clone the project from the github repository
  2. Follow the documentation for successfully setting up the project
  3. Open Project in Android Studio

Steps:

  1. We are using the Kotlin lateinit keyword to initialize ViewModels eg here
  2. Instead, we should use Lazy initialization here private val sendRequestViewModel by lazy { ViewModelProviders.of(this).get(SendRequestViewModel::class.java) }
  3. Find all such instances where we are using lateinit keyword to initialize ViewModels and replace it with lazy initializer.

Resources:

Work Submission:

After successfully fixing this issue, commit and make a Pull Request. Title of PR should contain "Program:GCI"

  1. Commit Message Style Guide
  2. Sample PR structure
  3. Make sure to attach either screenshot or GIF of the fixed issue

Task tags

  • kotlin
  • android

Students who completed this task

_daksha_, BartekPacia, i_maier

Task type

  • code Code
  • done_all Quality Assurance
close

2019