Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Team-16] [Android] [PR-5] 구글맵 연동, 숙소 상세 및 예약 화면, 위시리스트 화면, 예약 내역 화면 구현 #275

Open
wants to merge 19 commits into
base: team-16
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'

id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'kotlinx-serialization'
}

android {
Expand Down Expand Up @@ -75,6 +75,11 @@ dependencies {
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.2'
implementation("com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.8.0")

//serialization
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

//Hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
Expand All @@ -98,4 +103,6 @@ dependencies {

// for price chart
implementation "com.github.stfalcon-studio:StfalconPriceRangeBar-android:v1.5"


}
4 changes: 4 additions & 0 deletions Android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.search.roomdetail.RoomDetailActivity"
android:theme="@style/Theme.Airbnb.FullScreen" >
</activity>
</application>

</manifest>
20 changes: 17 additions & 3 deletions Android/app/src/main/java/com/team16/airbnb/MoneyRangeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import androidx.databinding.DataBindingUtil
import com.stfalcon.pricerangebar.model.BarEntry
import com.team16.airbnb.databinding.FragmentHomeBinding
import com.team16.airbnb.databinding.FragmentMoneyRangeBinding
import java.text.DecimalFormat
import java.util.ArrayList


Expand All @@ -34,7 +35,7 @@ class MoneyRangeFragment : Fragment() {

val chartList = ArrayList<BarEntry>()

for(i in 1..20){
for (i in 1..20) {
val end = i * 50000f - 3000f
val start = end - 44000f

Expand All @@ -49,13 +50,26 @@ class MoneyRangeFragment : Fragment() {

binding.rangeBarWithChart.setEntries(chartList)


var start = "0"
var end = "1,000,000"

val decimalFormat = DecimalFormat("#,###")
binding.rangeBarWithChart.onLeftPinChanged = { index, leftPinValue ->
Log.d("AppTest", "leftpin / index : ${index}, value : ${leftPinValue}")
binding.tietLeftpin.setText(leftPinValue.toString())

start = decimalFormat.format(leftPinValue?.substring(0, leftPinValue.length - 2)?.toInt())
binding.tietLeftpin.setText(start)

binding.tvMoneyRange.text = getString(R.string.money_label_string, start, end)
}
binding.rangeBarWithChart.onRightPinChanged = { index, rightPinValue ->
Log.d("AppTest", "rightpin / index : ${index}, value : ${rightPinValue}")
binding.tietRightpin.setText(rightPinValue.toString())

end = decimalFormat.format(rightPinValue?.substring(0, rightPinValue.length - 2)?.toInt())
binding.tietRightpin.setText(end)

binding.tvMoneyRange.text = getString(R.string.money_label_string, start, end)
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.core.content.ContextCompat
import androidx.databinding.BindingAdapter
import com.team16.airbnb.R
import com.team16.airbnb.data.model.DayInfo
import java.text.DecimalFormat

@SuppressLint("UseCompatLoadingForDrawables")
@BindingAdapter("dayCheck")
Expand Down Expand Up @@ -65,4 +66,23 @@ fun setCheckInCheckOutRange(dayView: TextView, item: DayInfo) {

}

@BindingAdapter("reviewCount")
fun setReviewCount(textView: TextView, count: Int) {
"(후기 ${count}개)".also { textView.text = it }
}

@BindingAdapter("moneyFormat")
fun setMoneyFormat(textView: TextView, money: Int) {
val format = DecimalFormat("₩#,###")
val money = format.format(money.toLong())
textView.text = "$money / 박"
}

@BindingAdapter("totalMoneyFormat")
fun setTotalMoneyFormat(textView: TextView, money: Int) {
val format = DecimalFormat("₩#,###")
val money = format.format(money.toLong())
textView.text = "총액 $money"
}


56 changes: 56 additions & 0 deletions Android/app/src/main/java/com/team16/airbnb/data/dto/MyBookDTO.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.team16.airbnb.data.dto


import com.team16.airbnb.data.model.MyBookData
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class MyBookDTO(
@SerialName("result")
val result: List<Result>?
) {

@Serializable
data class Result(
@SerialName("address")
val address: List<Address>?,
@SerialName("checkIn")
val checkIn: String?,
@SerialName("checkOut")
val checkOut: String?,
@SerialName("imageThumnail")
val imageThumnail: String?,
@SerialName("roomId")
val roomId: Int?,
@SerialName("roomName")
val roomName: String?
) {

@Serializable
data class Address(
@SerialName("city")
val city: String?,
@SerialName("detail")
val detail: String?,
@SerialName("district")
val district: String?,
@SerialName("region")
val region: String?
)

}
}

fun MyBookDTO.toMyBookData(): MyBookData {
val list = mutableListOf<MyBookData.Result>()
this.result?.forEach {
val address: List<MyBookDTO.Result.Address>? = it.address
val checkIn: String? = it.checkIn
val checkOut: String? = it.checkOut
val imageThumnail: String? = it.imageThumnail
val roomId: Int? = it.roomId
val roomName: String? = it.roomName
}
return MyBookData(list)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.team16.airbnb.data.dto


import com.team16.airbnb.data.model.SearchResult
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class SearchResultDTO(
@SerialName("imageUrl")
val imageUrl: List<String>?,
@SerialName("price")
val price: Int?,
@SerialName("rating")
val rating: Double?,
@SerialName("reviewCount")
val reviewCount: Int?,
@SerialName("roomId")
val roomId: Int?,
@SerialName("roomName")
val roomName: String?,
@SerialName("totalPrice")
val totalPrice: Int?
)

fun SearchResultDTO.toSearchResult(): SearchResult {
val imageUrl: String = this.imageUrl?.get(0) ?: ""
val price: Int = this.price ?: 0
val rating: Double = this.rating ?: 0.0
val reviewCount: Int = this.reviewCount ?: 0
val roomId: Int = requireNotNull(this.roomId)
val roomName: String = requireNotNull(this.roomName)
val totalPrice: Int = requireNotNull(this.totalPrice)

return SearchResult(imageUrl, price, rating, reviewCount, roomId, roomName, totalPrice)
}
43 changes: 43 additions & 0 deletions Android/app/src/main/java/com/team16/airbnb/data/dto/WishDTO.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.team16.airbnb.data.dto


import com.team16.airbnb.data.model.WishData
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class WishDTO(
@SerialName("result")
val result: List<Result>?
) {
@Serializable
data class Result(
@SerialName("imageThumnail")
val imageThumnail: String?,
@SerialName("price")
val price: Int?,
@SerialName("review")
val review: Int?,
@SerialName("roomId")
val roomId: Int?,
@SerialName("roomName")
val roomName: String?,
@SerialName("star")
val star: Double?
)
}

fun WishDTO.toWishData(): WishData {
val list = mutableListOf<WishData.ResultData>()
this.result?.forEach {
val imageThumnail = it.imageThumnail.orEmpty()
val price = requireNotNull(it.price)
val review = it.review ?: 0
val roomId = requireNotNull(it.roomId)
val roomName = requireNotNull(it.roomName)
val star = it.star ?: 0.0

list.add(WishData.ResultData(imageThumnail, price, review, roomId, roomName, star))
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map, toList() 오퍼레이터를 잘 이용하면 list.add(WishData.ResultData(imageThumnail, price, review, roomId, roomName, star) 하지 않아도 됩니다 ㅎㅎ

return WishData(list)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.team16.airbnb.data.model

data class MyBookData(
val result: List<Result>
) {

data class Result(
val address: List<Address>,
val checkIn: String,
val checkOut: String,
val imageThumnail: String,
val roomId: Int,
val roomName: String
) {

data class Address(
val city: String,
val detail: String,
val district: String,
val region: String
)

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.team16.airbnb.data.model

data class SearchResult(
val imageUrl: String,
val price: Int,
val rating: Double,
val reviewCount: Int,
val roomId: Int,
val roomName: String,
val totalPrice: Int
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.team16.airbnb.data.model


data class WishData(
val result: List<WishData.ResultData>
) {

data class ResultData(
val imageThumnail: String,
val price: Int,
val review: Int,
val roomId: Int,
val roomName: String,
val star: Double
)
}

val wishList = listOf(
WishData.ResultData(
"https://cloudfront-ap-northeast-1.images.arcpublishing.com/chosun/T7Y4P736SLLCA6FU2HAHOQIISA.jpg",
3000,
100,
1,
"스터디룸",
400.0
),
WishData.ResultData(
"https://cloudfront-ap-northeast-1.images.arcpublishing.com/chosun/T7Y4P736SLLCA6FU2HAHOQIISA.jpg",
3000,
200,
2,
"스터디룸",
400.0
),
WishData.ResultData(
"https://cloudfront-ap-northeast-1.images.arcpublishing.com/chosun/T7Y4P736SLLCA6FU2HAHOQIISA.jpg",
3000,
300,
3,
"스터디룸",
400.0
),
WishData.ResultData(
"https://cloudfront-ap-northeast-1.images.arcpublishing.com/chosun/T7Y4P736SLLCA6FU2HAHOQIISA.jpg",
3000,
400,
4,
"스터디룸",
400.0
),
WishData.ResultData(
"https://cloudfront-ap-northeast-1.images.arcpublishing.com/chosun/T7Y4P736SLLCA6FU2HAHOQIISA.jpg",
3000,
500,
5,
"스터디룸",
400.0
),
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team16.airbnb.ui
package com.team16.airbnb.ui.home

import android.os.Bundle
import android.util.Log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.team16.airbnb.ui
package com.team16.airbnb.ui.mybook

import android.os.Bundle
import androidx.fragment.app.Fragment
Expand Down
Loading