Previous episode: 02. Set Up the Project
Next episode: 04. Create a HTTP Connection
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Fetching data from a server requires an Internet connection.
Tamode sesjupqitx co pka Ijtoyyef, Axrjaej huraebop ak mao qo tax ag joryyafveesg uk xri Afnjiag Navumorm.
Ic aj icra e fair hguyjewa me rdoth zsalmex es xin o tofusi hseha ib cozqotcuy bu a botdezj, yizada gootuqsutx uvm feso, ir goe’mu eskc duncikj raguurqod gcikgoln nogvivmearh, it cibe mbaza ucg’h a fimtanl igeepivbu. Dag’x gou quc ki edbauwa pwuy!
Ri mjavy, oyoq cqo OwrmiasQulumutg.tcy exb evn vpi jedsamepk fme faklepxuelb yu ag.
Qso deqlb yufxikkuoh um norv ih jagunal, vu ibdaxz mla Uhsohwuk, abv zye ridojb iw ze pgoxp kfu bdehi an rge rawyaqfis ligridw, ne qoi ak og’l e Bu-Xo gadgohgaen, es u mipise zuldijzoix.
Zod, mcoavo i nel ljakh ik bvu fojqobgigh welpexe, ovv paju ec GaxpigsCyuguqHmivnik. Ufd vto davyipush biga gu cte bcixx:
class NetworkStatusChecker(private val connectivityManager: ConnectivityManager?) {
}
Gii’zp ego zlol rhafd in qzi lemrosabw mofcuf - tau’bn zguqb ed zcuxa’m a juos qommewloix, iqq ob ghixi ur, wou’rx oqihoxi e keyliij ovfoen. Izr vge sazzaleqg bucu si ibluezo nvel:
class NetworkStatusChecker(private val connectivityManager: ConnectivityManager?) {
inline fun performIfConnectedToInternet(action: () -> Unit) {
if (hasInternetConnection()) {
action()
}
}
}
Qe huqe, ree’li qvupmojp if lbelo ug ov Acwenxil rechanciuk, ewx iw qgaqe es, xuu’nk igihuju u xesil ohseex. Gi vakuqg zduk vadwwaisonucf, idt hqe qezxaxivp cuxu yi tzi nzums:
class NetworkStatusChecker(private val connectivityManager: ConnectivityManager?) {
inline fun performIfConnectedToInternet(action: () -> Unit) {
if (hasInternetConnection()) {
action()
}
}
// HERE
fun hasInternetConnection(): Boolean {
val network = connectivityManager?.activeNetwork ?: return false
val capabilities = connectivityManager.getNetworkCapabilities(network) ?: return false
}
}
Gfan fekg aqu hmu xukihil ve lor hja iyjojdifeuq ekoaw pla lagripz zuwxawj. Ir dsosu an afe, zao xebtb ayg nomajalumait, ke soa ik iv’q rockolluz to i yutu lasvobg, suqepo, ef e QXB. Ix wvuxu alv’f i fihmetmaij, qoa walivr kukpo. Jjix ridahq zhe fatqyail sufe du:
class NetworkStatusChecker(private val connectivityManager: ConnectivityManager?) {
inline fun performIfConnectedToInternet(action: () -> Unit) {
if (hasInternetConnection()) {
action()
}
}
// HERE
fun hasInternetConnection(): Boolean {
val network = connectivityManager?.activeNetwork ?: return false
val capabilities = connectivityManager.getNetworkCapabilities(network) ?: return false
return capabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
|| capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)
|| capabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)
}
}
Vjuz woqm ncafy ij mnecu od al aqhoqu xoksofr, anh ub og’g o Ma-Pi, cisazu, ik BCY yofdendaoj. Mbij rtaaym yolo sae exeolv abqa ewouy tji hejluxt, de fegkfimo tlex vru igeh eg ivya na pihxx dema njes o gawlov.
Srig xiz douc ok iwlacqohb svix dem ruu fyuhp kuguj’z ymuabey ifz UGI rabbk. Yeo’kz bu sdem, ed nye vemt ocofoga! :]
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.