Skip to content

Commit 07ca1f3

Browse files
committed
add for sale images
1 parent 5e57df9 commit 07ca1f3

File tree

6 files changed

+44
-13
lines changed

6 files changed

+44
-13
lines changed

10-mars-photos/.idea/misc.xml

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

10-mars-photos/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ An app to learn how to get data from an API, using Retrofit to make REST request
1616
- adding a loading animation and error icon.
1717
- displaying a grid of images with a RecyclerView.
1818
- handling potential errors.
19+
- adding "for sale" images to the overview.
20+
- filtering the results.
21+
- creating a detail page and setting up navigation.
1922

20-
Based on 2 tutorials by Google Codelabs (2022):
23+
Based on 3 tutorials by Google Codelabs (2022):
2124

2225
- [Get data from the internet](https://developer.android.com/codelabs/basic-android-kotlin-training-getting-data-internet)
2326
- [Loading and displaying images from the internet](https://codelabs.developers.google.com/codelabs/kotlin-android-training-internet-images/index.html?index=..%2F..android-kotlin-fundamentals#0)
27+
- [Filtering and detail views with internet data](https://developer.android.com/codelabs/kotlin-android-training-internet-filtering?index=..%2F..android-kotlin-fundamentals#0)

10-mars-photos/app/src/main/java/com/example/android/marsphotos/network/MarsApiService.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private val retrofit = Retrofit.Builder()
1919
.build()
2020

2121
interface MarsApiService {
22-
@GET("photos")
22+
@GET("realestate")
2323
suspend fun getPhotos(): List<MarsPhoto>
2424
}
2525

10-mars-photos/app/src/main/java/com/example/android/marsphotos/network/MarsPhoto.kt

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ import com.squareup.moshi.Json
44

55
data class MarsPhoto(
66
val id: String,
7-
@Json(name = "img_src") val imgSrcUrl: String
8-
)
7+
@Json(name = "img_src") val imgSrcUrl: String,
8+
val type: String,
9+
val price: Double
10+
) {
11+
val isRental
12+
get() = type == "rent"
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="22dp" android:viewportHeight="21.8"
2+
android:viewportWidth="14" android:width="14dp" xmlns:android="http://schemas.android.com/apk/res/android">
3+
<path android:fillColor="#FF000000" android:pathData="M5.1,20.5v-2.3c-2.2,-0.6 -3.6,-2.1 -3.7,-4.2l0,-0.5h3.2l0,0.5c0.1,1.1 0.9,1.6 2.5,1.6c2,0 2.2,-1 2.2,-1.3c0,-0.4 0,-1.3 -2.6,-1.9c-2.2,-0.5 -5.1,-1.6 -5.1,-4.6c0,-1.9 1.3,-3.4 3.5,-4V1.5h4v2.3C11,4.5 12.2,6 12.3,8l0,0.5H9.1l0,-0.5c0,-0.8 -0.3,-1.6 -2,-1.6C5.7,6.4 4.9,7 4.9,7.8c0,0.5 0.2,1 2.6,1.7c1.5,0.4 5.1,1.3 5.1,4.9c0,2 -1.3,3.4 -3.5,4v2.2H5.1z"/>
4+
<path android:fillColor="#FFFFFF" android:pathData="M8.6,2v2.2c2.1,0.5 3.1,2.1 3.2,3.8H9.6C9.5,6.8 8.8,5.9 7.1,5.9c-1.7,0 -2.7,0.8 -2.7,1.9c0,0.9 0.7,1.6 3,2.1c2.3,0.6 4.7,1.6 4.7,4.4c0,2.1 -1.6,3.2 -3.5,3.6V20h-3v-2.2C3.6,17.5 2,16.2 1.9,14h2.2c0.1,1.2 0.9,2.1 3,2.1c2.2,0 2.7,-1.1 2.7,-1.8c0,-0.9 -0.5,-1.8 -3,-2.4C4,11.3 2.1,10.1 2.1,7.8c0,-1.9 1.6,-3.2 3.5,-3.6V2H8.6M9.6,1h-1h-3h-1v1v1.4C2.4,4.2 1.1,5.8 1.1,7.8c0,3.8 4.1,4.8 5.5,5.1c2.2,0.5 2.2,1.2 2.2,1.4c0,0.5 -0.6,0.8 -1.7,0.8c-1.9,0 -2,-0.8 -2,-1.2L5,13H4.1H1.9H0.8l0.1,1.1c0.1,2.2 1.5,3.8 3.7,4.5V20v1h1h3h1v-1v-1.4c2.2,-0.7 3.5,-2.3 3.5,-4.3c0,-4 -3.8,-4.9 -5.4,-5.4c-2.3,-0.6 -2.3,-1 -2.3,-1.2c0,-0.6 0.9,-0.9 1.7,-0.9c1.3,0 1.5,0.5 1.5,1.1l0,1h1h2.2h1l0,-1c-0.1,-2.1 -1.3,-3.8 -3.2,-4.5V2V1L9.6,1z"/>
5+
</vector>

10-mars-photos/app/src/main/res/layout/grid_view_item.xml

+25-9
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,30 @@
2323
<variable
2424
name="property"
2525
type="com.example.android.marsphotos.network.MarsPhoto" />
26+
<import type="android.view.View" />
2627
</data>
27-
<ImageView
28-
android:id="@+id/mars_image"
29-
android:layout_width="wrap_content"
30-
android:layout_height="170dp"
31-
android:scaleType="fitXY"
32-
android:adjustViewBounds="true"
33-
android:padding="2dp"
34-
tools:src="@tools:sample/backgrounds/scenic"
35-
app:imageUrl="@{property.imgSrcUrl}"/>
28+
<FrameLayout
29+
android:layout_width="match_parent"
30+
android:layout_height="170dp">
31+
<ImageView
32+
android:id="@+id/mars_image"
33+
android:layout_width="match_parent"
34+
android:layout_height="match_parent"
35+
android:scaleType="centerCrop"
36+
android:adjustViewBounds="true"
37+
android:padding="2dp"
38+
tools:src="@tools:sample/backgrounds/scenic"
39+
app:imageUrl="@{property.imgSrcUrl}" />
40+
<ImageView
41+
android:id="@+id/mars_property_type"
42+
android:layout_width="wrap_content"
43+
android:layout_height="45dp"
44+
android:layout_gravity="bottom|end"
45+
android:adjustViewBounds="true"
46+
android:padding="5dp"
47+
android:scaleType="fitCenter"
48+
android:src="@drawable/ic_for_sale_outline"
49+
tools:src="@drawable/ic_for_sale_outline"
50+
android:visibility="@{property.rental ? View.GONE : View.VISIBLE}"/>
51+
</FrameLayout>
3652
</layout>

0 commit comments

Comments
 (0)