This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.coroutinelearning.viewModels.learning | |
| import android.app.Application | |
| import androidx.lifecycle.ViewModel | |
| import androidx.lifecycle.ViewModelProvider | |
| import com.example.coroutinelearning.repositories.MyRepositoryTwo | |
| import java.lang.IllegalArgumentException | |
| class MyAndroidViewModelFactoryFour( | |
| private val application: Application, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.coroutinelearning.fragments | |
| import android.os.Bundle | |
| import android.util.Log | |
| import android.view.LayoutInflater | |
| import android.view.View | |
| import android.view.ViewGroup | |
| import androidx.fragment.app.Fragment | |
| import com.example.coroutinelearning.databinding.ByDelegateLearningBinding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.coroutinelearning.fragments | |
| import android.os.Bundle | |
| import android.view.LayoutInflater | |
| import android.view.View | |
| import android.view.ViewGroup | |
| import androidx.fragment.app.Fragment | |
| import androidx.fragment.app.activityViewModels | |
| import androidx.lifecycle.Observer | |
| import com.example.coroutinelearning.databinding.NewUserEntryBinding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SealedLearningFrag: Fragment(), View.OnClickListener{ | |
| override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
| super.onViewCreated(view, savedInstanceState) | |
| binding.btnEmployee.setOnClickListener(this) | |
| binding.btnManager.setOnClickListener(this) | |
| binding.btnJuniorDev.setOnClickListener(this) | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.coroutinelearning.entity | |
| sealed class Employee //there is no need of {}, its optional | |
| //if you use {}, u have to call class with use of Employee class, like Employee.Manager from fragment/activity. else u will be | |
| //able to directly call it. | |
| data class Manager(val name: String, val age: Int, val team: List<String>) : Employee() | |
| class SeniorDev(val name: String, val age: Int, val project: String) : Employee() | |
| object JuniorDev : Employee() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun saveUserDetailToDB() { | |
| val name = binding.txtName.text.toString() | |
| var mobNo = binding.txtMobNo.text.toString() | |
| mobNo = mobNo.addMobileExtension() //extension function | |
| var user = User(name = name, mobileNumber = mobNo) | |
| user = user.firstLetterCapital() //extension function | |
| userViewModel.saveUserDetail(user) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <uses-permission android:name="android.permission.INTERNET" /> | |
| <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.coroutinelearning.retrofits | |
| import com.example.coroutinelearning.entity.Root | |
| import retrofit2.Response | |
| import retrofit2.http.GET | |
| import retrofit2.http.Query | |
| interface ApiInterface { | |
| @GET("/api/users") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.coroutinelearning.retrofits | |
| import com.example.coroutinelearning.entity.Root | |
| import retrofit2.Response | |
| import retrofit2.http.GET | |
| import retrofit2.http.Query | |
| interface ApiInterface { | |
| @GET("/api/users") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.coroutinelearning.retrofits | |
| import com.example.coroutinelearning.entity.Root | |
| import retrofit2.Response | |
| import retrofit2.http.GET | |
| import retrofit2.http.Query | |
| interface ApiInterface { | |
| @GET("/api/users") |