‫Hello, my friends.
‫In this video I'm going to create a new Kotlin class and I will name it as journal user.
‫So this journal user will act as a subclass to allow the application to run it before and to prepare
‫the instance of this application and passing the context of this application.
‫So we need to create two fields here, the name, the user name in order to get the current user name
‫and the ID string.
‫Equal to null and var user id string.
‫Equal to none.
‫And we've talked about the Singletons and the companion objects in Kotlin before.
‫So we said that whenever you have a database and connectivity and like a user to get like in this case,
‫the authentication, we need to prepare a subclass to be running in the background and the first launching
‫of the application to be preparing the current user, the connection and return only one singleton of
‫this class.
‫So because it's a singleton and following the Singleton design pattern, I'm going to use the companion
‫object and create an instance of this class.
‫So instance of journal user from this class, I'm making an instance only I need only in this application
‫and anytime, anywhere and any application in order to get only one instance, one object of this class
‫so equal.
‫To null.
‫Now get.
‫If.
‫The field isn't equal or equal to null, then we need to create a new instance.
‫So create a new instance.
‫From Journal.
‫User.
‫How to create.
‫I will put field equal to journal user.
‫Then I will return the field itself.
‫And here I will put private set.
‫This is the getters and setters for the the the fields here that we have inside this instance.