Latest Added Tutorials
20-05-2020
PostsDataSource
class PostsDataSource(private val scope: CoroutineScope) :
PageKeyedDataSource<Int, Question>() {
private val repository = QuestionRepository()
override fun loadInitial(
params: LoadInitialParams<Int>,
callback: LoadInitialCallback<Int, Question>
) {
scope.launch {
try {
val response = repository.getQuestionsAsync(1)
when {
response.success -> {
val listing = response.data
val...Continue Reading
Fragment
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.codesenior.period.tracker.R
import com.codesenior.period.tracker.adapters.QuestionAdapter
import com.codesenior.period.tracker.factories.QuestionViewModelFactory
import com.codesenior.period.tracker.repositories.QuestionRepository
import kotlinx.andr...Continue Reading