Salimov Azimjon 316-18 guruh Mavzu: Android dasturlarida xabarlarni yuborish va almashtirish uchun foydalanuvchi interfeysini yaratish


Mavzu: Serverga ulanish. HTTP GET va POST usullaridan foydalanish



Download 24,18 Kb.
bet2/5
Sana31.12.2021
Hajmi24,18 Kb.
#238279
1   2   3   4   5
Bog'liq
3-TOPSHIRIQ MI

Mavzu: Serverga ulanish. HTTP GET va POST usullaridan foydalanish

Laboratoriya ishining maqsadi:

Server ko'nikmalarini olish va HTTP GET va POST usullaridan foydalanish
Laboratoriya vazifalari:

ilova yaratish;

• serverga ulanish;

• HTTP GET va POST usullaridan foydalaning


import retrofit2.http.GET


import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Query
import uz.azim.stocks.model.StocksResponse
import uz.azim.stocks.util.Resource

interface StocksService {

@GET("co/collections")
suspend fun getStocks(
@Query("start") start: Int,
@Query("list") listType: String
): Resource

@POST("v1.0/auth/basic/request_token")


fun getBasicToken(@Header("Authorization") basicAuth: String?): Observable?

}

package uz.azim.stocks.data.repo.stock



import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flow
import uz.azim.stocks.data.local.db.StockDao
import uz.azim.stocks.data.remote.SearchService
import uz.azim.stocks.data.remote.StocksService
import uz.azim.stocks.model.Quote
import uz.azim.stocks.model.SearchResult
import uz.azim.stocks.util.Resource
import javax.inject.Inject

class StocksRepositoryImpl


@Inject constructor(
private val stocksService: StocksService,
private val searchService: SearchService,
private val stockDao: StockDao,
) : StocksRepository {
override fun getAllFavs() = stockDao.getAllFavoriteStocks()

override suspend fun saveStock(quote: Quote) {


stockDao.saveStock(quote)
}

override suspend fun deleteStock(quote: Quote) {


stockDao.deleteStock(quote)
}

//Didn't add caching due to data update


override suspend fun getStocks(listType: String): Flow
> {
val favs = stockDao.getAllFavoriteStocks().first()
return Pager(
config = PagingConfig(pageSize = 25, enablePlaceholders = false)
) {
StockPagingSource(stocksService, stockDao, listType, favs)

Download 24,18 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5




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