This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<dimen name="appbar_title_height">125dp</dimen> | |
<dimen name="appbar_header_height">200dp</dimen> | |
</resources> |
This file contains 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
import android.util.Log | |
import com.dangerfield.triviaapp.model.Question | |
import com.google.firebase.firestore.FirebaseFirestore | |
class QuestionsRepositoryImp(): QuestionsRepository { | |
private val db = FirebaseFirestore.getInstance() | |
override fun getQuestions(): List<Question> { | |
var result = listOf<Question>() | |
db.collection("questions").get().addOnSuccessListener { |
This file contains 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
import android.os.Bundle | |
import android.util.Log | |
import androidx.fragment.app.Fragment | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.fragment.app.viewModels | |
import com.dangerfield.triviaapp.R | |
import com.dangerfield.triviaapp.api.QuestionsRepositoryImp |
This file contains 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
import android.util.Log | |
import androidx.lifecycle.LiveData | |
import com.dangerfield.triviaapp.model.Question | |
import com.google.firebase.firestore.FirebaseFirestore | |
class QuestionsRepositoryImp(): QuestionsRepository { | |
private val db = FirebaseFirestore.getInstance() | |
override fun getQuestions(): MutableLiveData<List<Question>> { |
This file contains 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
import android.util.Log | |
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.MutableLiveData | |
import com.dangerfield.triviaapp.model.Question | |
import com.google.firebase.firestore.FirebaseFirestore | |
class QuestionsRepositoryImp(): QuestionsRepository { | |
private val db = FirebaseFirestore.getInstance() | |
override fun getQuestions(): MutableLiveData<List<Question>> { |
This file contains 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
import android.os.Bundle | |
import androidx.fragment.app.Fragment | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup | |
import androidx.fragment.app.viewModels | |
import androidx.lifecycle.Observer | |
import com.dangerfield.triviaapp.R | |
import com.dangerfield.triviaapp.api.QuestionsRepositoryImp |
This file contains 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 QuestionsViewModel : ViewModel() { | |
private val repository: QuestionsRepository = QuestionsRepositoryImp() | |
private val questions = MutableLiveData<List<Question>>() | |
} |
This file contains 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 QuestionsViewModel : ViewModel() { | |
private val repository: QuestionsRepository = QuestionsRepositoryImp() | |
private val questions = MutableLiveData<List<Question>>() | |
fun getQuestions(): LiveData<List<Question>> { | |
return questions | |
} | |
} |
This file contains 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 QuestionsFragment : Fragment() { | |
val questionsViewModel: QuestionsViewModel by viewModels() | |
override fun onCreateView( | |
inflater: LayoutInflater, container: ViewGroup?, | |
savedInstanceState: Bundle? | |
): View? { | |
// Inflate the layout for this fragment | |
return inflater.inflate(R.layout.fragment_questions, container, false) |
This file contains 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 QuestionsViewModel : ViewModel() { | |
private val repository: QuestionsRepository = QuestionsRepositoryImp() | |
private var questions = MutableLiveData<List<Question>>() | |
fun getQuestions(): LiveData<List<Question>> { | |
questions = repository.getQuestions() | |
return questions | |
} | |
} |
OlderNewer