-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the caching issue using official APIs
- Loading branch information
1 parent
0aac0d2
commit 6398f5e
Showing
4 changed files
with
97 additions
and
11 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.hicham.flowlifecycle | ||
|
||
import kotlin.random.Random | ||
|
||
val FAKE_DATA = listOf( | ||
"Restaurant", | ||
"Clothing Store", | ||
"Coffee Shop", | ||
"Bookstore", | ||
"Pharmacy", | ||
"Electronics Store", | ||
"College", | ||
"Fast Food Restaurant", | ||
"Cupcake Shop", | ||
"Furniture Store", | ||
"Supermarket", | ||
"Gift Shop", | ||
"Kids Store" | ||
) | ||
|
||
class FakeApi { | ||
suspend fun fetchNearbyLocations(latitude: Double, longitude: Double): List<String> { | ||
val size = Random.nextInt(1, FAKE_DATA.size) | ||
return FAKE_DATA.shuffled().take(size) | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,38 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<androidx.appcompat.widget.AppCompatTextView | ||
android:id="@+id/location" | ||
<ProgressBar | ||
android:id="@+id/progressBar" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<androidx.appcompat.widget.AppCompatTextView | ||
android:id="@+id/location_text" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toTopOf="@id/nearby_locations" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintVertical_chainStyle="packed" /> | ||
|
||
<androidx.appcompat.widget.AppCompatTextView | ||
android:id="@+id/nearby_locations" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="16dp" | ||
android:textAlignment="center" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/location_text" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |