Saving Data on Android


model  package and name it  QuizState



Download 19,28 Mb.
Pdf ko'rish
bet172/292
Sana24.01.2022
Hajmi19,28 Mb.
#407089
1   ...   168   169   170   171   172   173   174   175   ...   292
Bog'liq
Bailey J., Dominguez A., Djermanovic D. - Saving Data on Android (1st Edition) - 2019

model
 package and name it 
QuizState
. Modify 
your class like below:
sealed
 
class
 
QuizState
 { 
  
object
 LoadingState : QuizState() 
  
data
 
class
 
DataState
(
val
 
data
: QuestionAndAllAnswers) : 
QuizState() 
  
object
 EmptyState : QuizState() 
  
data
 
class
 
FinishState
(
val
 numberOfQuestions: 
Int

val
 score: 
Int
) : QuizState() 
}
Saving Data on Android Chapter 9: Using Room with Google's Architecture Components
raywenderlich.com
158


As you can see each of the aforementioned states is represented here. The 
Data
 has a 
contains the question that you will display to your users, within 
data
. The 
Finish
 
holds the number of questions in the quiz, within 
numberOfQuestions
 and the 
number of correct answers from the user within 
score
. The other two states - 
Loading
 and 
Empty
 are simple 
object
s, which represent events for the two cases.
Now, it is time to create your 
ViewModel
.
Create a new class under the 

Download 19,28 Mb.

Do'stlaringiz bilan baham:
1   ...   168   169   170   171   172   173   174   175   ...   292




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish