0Pricing
Jetpack Compose Academy · Ders

Yükleme, Başarı ve Hata Kullanıcı Arayüzü

Her ağ sonucunu temiz biçimde oluşturun.

Yükleme, Başarı ve Hata Kullanıcı Arayüzü, CoddyKit'te ücretsiz bir Jetpack Compose Academy dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Jetpack Compose Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Every Request Has Three Outcomes

A network call is either still loading, finished with data, or failed. Great screens show something honest for all three.

Model State With a Sealed Class

A sealed class captures those outcomes as distinct types, so the compiler forces you to handle each case in the UI.

sealed class UiState {
    object Loading : UiState()
    data class Success(val users: List<User>) : UiState()
    data class Error(val message: String) : UiState()
}

Start in the Loading State

Initialize your state as Loading so the screen shows a spinner the instant it appears, before any data arrives.

var state by mutableStateOf<UiState>(UiState.Loading)

Update on Success

When the call returns, swap the state to Success with the fetched list. Compose recomposes and reveals the content.

state = UiState.Success(api.getUsers())

Update on Error

In your catch block, move to the Error state with a friendly message instead of leaving the user stuck on a spinner.

catch (e: Exception) {
    state = UiState.Error("Couldn't load users")
}

Branch With when

In the Composable, use a when over the state. Each branch renders exactly the right UI for that outcome.

when (val s = state) {
    is UiState.Loading -> { }
    is UiState.Success -> { }
    is UiState.Error -> { }
}

Show a Spinner While Loading

For the loading branch, a centered CircularProgressIndicator reassures users that something is happening. ⏳

is UiState.Loading -> CircularProgressIndicator()

Render the Data on Success

The success branch reads the list and draws it, usually in a LazyColumn so long results scroll smoothly.

is UiState.Success -> UserList(s.users)

Offer a Retry on Error

The error branch should show the message plus a Retry button that re-runs your load function. Failures shouldn't be dead ends.

is UiState.Error -> RetryView(s.message, ::loadUsers)

Handle the Empty Case

Success doesn't always mean items. When the list is empty, show a calm empty state rather than a blank screen.

One State Drives the Whole Screen

Because a single state object decides everything, your UI can never show a spinner and data at once. It stays predictable.

Quick Check

Why model loading, success, and error as a sealed class?

Recap: Rendering Every Outcome

You modeled state as a sealed class, branched with when, and showed loading, data, errors, and empties. You can now ship a robust networked screen.

Sıkça Sorulan Sorular

“Yükleme, Başarı ve Hata Kullanıcı Arayüzü” dersi ücretsiz mi?

Evet — “Yükleme, Başarı ve Hata Kullanıcı Arayüzü” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Jetpack Compose Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Jetpack Compose Academy kursu toplamda 4 dersten oluşur.

“Yükleme, Başarı ve Hata Kullanıcı Arayüzü” dersinde ne öğreneceğim?

Her ağ sonucunu temiz biçimde oluşturun. Jetpack Compose Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Jetpack Compose Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Jetpack Compose Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Yükleme, Başarı ve Hata Kullanıcı Arayüzü” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Jetpack Compose Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Jetpack Compose Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Retrofit API Interface Tanımlama
  2. Moshi ile JSON Çözümleme
  3. ViewModel'de suspend Çağrıları
  4. Yükleme, Başarı ve Hata Kullanıcı Arayüzü
← Jetpack Compose Academy Sayfasına Dön