diff --git a/android/HowAboutTrip/app/build.gradle.kts b/android/HowAboutTrip/app/build.gradle.kts index 15647ff9..ecf26734 100644 --- a/android/HowAboutTrip/app/build.gradle.kts +++ b/android/HowAboutTrip/app/build.gradle.kts @@ -87,6 +87,7 @@ dependencies { implementation("com.google.dagger:hilt-android:2.46") implementation("androidx.activity:activity-ktx:1.9.1") + implementation("androidx.activity:activity:1.9.1") kapt("com.google.dagger:hilt-android-compiler:2.46") implementation("com.squareup.retrofit:retrofit:2.0.0-beta2") diff --git a/android/HowAboutTrip/app/src/main/AndroidManifest.xml b/android/HowAboutTrip/app/src/main/AndroidManifest.xml index 73bb0af5..9d1d1d8f 100644 --- a/android/HowAboutTrip/app/src/main/AndroidManifest.xml +++ b/android/HowAboutTrip/app/src/main/AndroidManifest.xml @@ -18,6 +18,9 @@ android:supportsRtl="true" android:theme="@style/Base.Theme.HowAboutTrip" tools:targetApi="31"> + diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/airplane/OneWayAirplaneListAdapter.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/airplane/OneWayAirplaneListAdapter.kt index 8ea503c7..367da999 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/airplane/OneWayAirplaneListAdapter.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/airplane/OneWayAirplaneListAdapter.kt @@ -7,13 +7,20 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.project.how.R import com.project.how.data_class.dto.booking.airplane.GetOneWayFlightOffersResponseElement +import com.project.how.data_class.recyclerview.ticket.FlightMember import com.project.how.databinding.OneWayAirplaneListItemBinding import java.text.NumberFormat import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.util.Locale -class OneWayAirplaneListAdapter(private val context: Context, private val data : ArrayList, lid : MutableList, private val onItemClickListener : OnItemClickListener) : RecyclerView.Adapter(){ +class OneWayAirplaneListAdapter( + private val context: Context, + private val data: ArrayList, + lid: MutableList, + private val onItemClickListener: OnItemClickListener, + private var flightMember: List? +) : RecyclerView.Adapter(){ private val hearts = lid.map { it > 0 }.toMutableList() private var likeId = lid private var heartClickable = false @@ -91,7 +98,7 @@ class OneWayAirplaneListAdapter(private val context: Context, private val data : val d = data[position] holder.bind(d, position) holder.itemView.setOnClickListener { - onItemClickListener.onItemClickerListener(d) + onItemClickListener.onItemClickerListener(d, if(flightMember.isNullOrEmpty()) null else flightMember!![position]) } } @@ -141,7 +148,10 @@ class OneWayAirplaneListAdapter(private val context: Context, private val data : private fun getFormattedNumber(price : Long) : String = NumberFormat.getNumberInstance(Locale.US).format(price) interface OnItemClickListener{ - fun onItemClickerListener(data : GetOneWayFlightOffersResponseElement) + fun onItemClickerListener( + data: GetOneWayFlightOffersResponseElement, + flightMember: FlightMember? + ) fun onHeartClickerListener( check: Boolean, data: GetOneWayFlightOffersResponseElement, diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/airplane/RoundTripAirplaneListAdapter.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/airplane/RoundTripAirplaneListAdapter.kt index fe3ebfa6..cb077d48 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/airplane/RoundTripAirplaneListAdapter.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/airplane/RoundTripAirplaneListAdapter.kt @@ -7,13 +7,20 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.project.how.R import com.project.how.data_class.dto.booking.airplane.GetFlightOffersResponseElement +import com.project.how.data_class.recyclerview.ticket.FlightMember import com.project.how.databinding.RoundTripAirplaneListItemBinding import java.text.NumberFormat import java.time.LocalDateTime import java.time.format.DateTimeFormatter import java.util.Locale -class RoundTripAirplaneListAdapter(private val context: Context, private val data : ArrayList, lid : MutableList, private val onItemClickListener : OnItemClickListener) : RecyclerView.Adapter(){ +class RoundTripAirplaneListAdapter( + private val context: Context, + private val data: ArrayList, + lid: MutableList, + private val onItemClickListener: OnItemClickListener, + private val flightMember: List? +) : RecyclerView.Adapter(){ private val hearts = lid.map { it > 0 }.toMutableList() private var likeId = lid private var heartClickable = false @@ -108,7 +115,7 @@ class RoundTripAirplaneListAdapter(private val context: Context, private val dat val d = data[position] holder.bind(d, position) holder.itemView.setOnClickListener { - onItemClickListener.onItemClickerListener(d) + onItemClickListener.onItemClickerListener(d, if (flightMember.isNullOrEmpty()) null else flightMember!![position]) } } @@ -158,7 +165,10 @@ class RoundTripAirplaneListAdapter(private val context: Context, private val dat private fun getFormattedNumber(price : Long) : String = NumberFormat.getNumberInstance(Locale.US).format(price) interface OnItemClickListener{ - fun onItemClickerListener(data : GetFlightOffersResponseElement) + fun onItemClickerListener( + data: GetFlightOffersResponseElement, + flightMember: FlightMember? + ) fun onHeartClickerListener( check: Boolean, data: GetFlightOffersResponseElement, diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/hotel/RecentHotelAdapter.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/hotel/RecentHotelAdapter.kt index 1a31ebcc..a21590a2 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/hotel/RecentHotelAdapter.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/booking/hotel/RecentHotelAdapter.kt @@ -5,7 +5,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.project.how.BuildConfig -import com.project.how.data_class.recyclerview.RecentHotel +import com.project.how.data_class.recyclerview.ticket.RecentHotel import com.project.how.databinding.RecentHotelItemBinding class RecentHotelAdapter(recentHotel : List, private val onItemClickListener: OnItemClickListener) diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/record/BillListAdapter.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/record/BillListAdapter.kt index 4628a965..5ea07593 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/record/BillListAdapter.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/record/BillListAdapter.kt @@ -1,27 +1,75 @@ package com.project.how.adapter.recyclerview.record +import android.content.Context +import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView +import com.bumptech.glide.Glide +import com.project.how.BuildConfig +import com.project.how.R +import com.project.how.data_class.recyclerview.record.Bill import com.project.how.databinding.BillListItemBinding class BillListAdapter ( - + data : List, + private val context : Context, + private val onItemClickListener: OnItemClickListener ) : RecyclerView.Adapter(){ + private var bills = data.toMutableList() inner class ViewHolder(val binding: BillListItemBinding) : RecyclerView.ViewHolder(binding.root){ - fun bind(){ + fun bind(data: Bill, position: Int){ + binding.title.text = data.title + binding.date.text = data.date + binding.cost.text = context.getString(R.string.cost, data.cost.toString()) + binding.count.text = context.getString(R.string.bill_count, data.count.toString()) + Glide.with(binding.root) + .load(data.image ?: BuildConfig.TEMPORARY_IMAGE_URL) + .error(BuildConfig.ERROR_IMAGE_URL) + .into(binding.image) + binding.delete.setOnClickListener { + onItemClickListener.onDeleteButtonClickListener(data.id, position) + } + itemView.setOnClickListener { + onItemClickListener.onItemClickListener(data.id) + } } } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - TODO("Not yet implemented") + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = ViewHolder( + BillListItemBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false + ) + ) + + override fun getItemCount(): Int = bills.size + + override fun getItemViewType(position: Int): Int = position + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val data = bills[position] + holder.bind(data, position) + } + + fun update(newData : List){ + bills = newData.toMutableList() + notifyDataSetChanged() } - override fun getItemCount(): Int { - TODO("Not yet implemented") + fun delete(position: Int){ + bills.removeAt(position) + notifyItemRangeChanged(position, bills.lastIndex) } - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - TODO("Not yet implemented") + fun add(newData : Bill){ + bills.add(newData) + notifyItemInserted(bills.lastIndex) + } + + interface OnItemClickListener{ + fun onItemClickListener(id: Long) + fun onDeleteButtonClickListener(id: Long, position: Int) } } \ No newline at end of file diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/viewpager/RecentAddedRecordsAdapter.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/viewpager/RecentAddedRecordsAdapter.kt index 6b53bb34..32657313 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/viewpager/RecentAddedRecordsAdapter.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/adapter/recyclerview/viewpager/RecentAddedRecordsAdapter.kt @@ -5,7 +5,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.project.how.BuildConfig -import com.project.how.data_class.recyclerview.RecentAddedRecord +import com.project.how.data_class.recyclerview.record.RecentAddedRecord import com.project.how.databinding.ViewpagerRecentRecordItemBinding class RecentAddedRecordsAdapter( diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/GenerateSkyscannerUrlRequest.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/GenerateSkyscannerUrlRequest.kt index 12bba4de..ea342f21 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/GenerateSkyscannerUrlRequest.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/GenerateSkyscannerUrlRequest.kt @@ -11,8 +11,8 @@ data class GenerateSkyscannerUrlRequest( val departureDate : String, @SerializedName("returnDate") val returnDate : String, - @SerializedName("adults") - val adults : Long, + @SerializedName("adult") + val adult : Long, @SerializedName("children") val children : Long, @SerializedName("departureTime") @@ -28,8 +28,8 @@ data class GenerateOneWaySkyscannerUrlRequest( val arrivalIataCode : String, @SerializedName("departureDate") val departureDate : String, - @SerializedName("adults") - val adults : Long, + @SerializedName("adult") + val adult : Long, @SerializedName("children") val children : Long, @SerializedName("departureTime") diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/GetLikeFlightResponse.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/GetLikeFlightResponse.kt index 0162a412..b549ca0b 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/GetLikeFlightResponse.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/GetLikeFlightResponse.kt @@ -1,18 +1,36 @@ package com.project.how.data_class.dto.booking.airplane +import com.google.gson.annotations.SerializedName + typealias GetLikeFlightResponse = List data class GetLikeFlightResponseElement( + @SerializedName("id") val id: Long, + @SerializedName("carrierCode") val carrierCode: String, + @SerializedName("totalPrice") val totalPrice: Long, + @SerializedName("abroadDuration") val abroadDuration: String, + @SerializedName("abroadDepartureTime") val abroadDepartureTime: String, + @SerializedName("abroadArrivalTime") val abroadArrivalTime: String, + @SerializedName("homeDuration") val homeDuration: String? = null, + @SerializedName("homeDepartureTime") val homeDepartureTime: String? = null, + @SerializedName("homeArrivalTime") val homeArrivalTime: String? = null, + @SerializedName("departureIataCode") val departureIataCode: String, + @SerializedName("arrivalIataCode") val arrivalIataCode: String, - val transferCount: String + @SerializedName("transferCount") + val transferCount: String, + @SerializedName("adult") + val adult : Long, + @SerializedName("children") + val children : Long ) diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeFlight.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeFlight.kt index 297dcba0..d1ed16ab 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeFlight.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeFlight.kt @@ -1,18 +1,36 @@ package com.project.how.data_class.dto.booking.airplane +import com.google.gson.annotations.SerializedName + typealias LikeFlight = List data class LikeFlightElement ( + @SerializedName("carrierCode") val carrierCode: String, + @SerializedName("totalPrice") val totalPrice: Long, + @SerializedName("abroadDuration") val abroadDuration: String, + @SerializedName("abroadDepartureTime") val abroadDepartureTime: String, + @SerializedName("abroadArrivalTime") val abroadArrivalTime: String, + @SerializedName("homeDuration") val homeDuration: String, + @SerializedName("homeDepartureTime") val homeDepartureTime: String, + @SerializedName("homeArrivalTime") val homeArrivalTime: String, + @SerializedName("departureIataCode") val departureIataCode: String, + @SerializedName("arrivalIataCode") val arrivalIataCode: String, + @SerializedName("nonstop") val nonstop: Boolean, - val transferCount: Long + @SerializedName("transferCount") + val transferCount: Long, + @SerializedName("adult") + val adult : Long, + @SerializedName("children") + val children : Long ) diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeOneWayFlight.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeOneWayFlight.kt index 9a92417c..5cda442d 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeOneWayFlight.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeOneWayFlight.kt @@ -1,15 +1,30 @@ package com.project.how.data_class.dto.booking.airplane +import com.google.gson.annotations.SerializedName + typealias LikeOneWayFlight = List data class LikeOneWayFlightElement ( + @SerializedName("carrierCode") val carrierCode: String, + @SerializedName("totalPrice") val totalPrice: Long, + @SerializedName("departureIataCode") val departureIataCode: String, + @SerializedName("arrivalIataCode") val arrivalIataCode: String, + @SerializedName("abroadDuration") val abroadDuration: String, + @SerializedName("abroadDepartureTime") val abroadDepartureTime: String, + @SerializedName("abroadArrivalTime") val abroadArrivalTime: String, + @SerializedName("nonstop") val nonstop: Boolean, - val transferCount: Long + @SerializedName("transferCount") + val transferCount: Long, + @SerializedName("adult") + val adult : Long, + @SerializedName("children") + val children : Long ) diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/record/Bill.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/record/Bill.kt new file mode 100644 index 00000000..a837791d --- /dev/null +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/record/Bill.kt @@ -0,0 +1,10 @@ +package com.project.how.data_class.recyclerview.record + +data class Bill( + val id : Long, + val image : String?, + val title : String, + val date : String, + val cost : Long, + val count : Long +) diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/RecentAddedRecord.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/record/RecentAddedRecord.kt similarity index 77% rename from android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/RecentAddedRecord.kt rename to android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/record/RecentAddedRecord.kt index 74ead559..8264feaa 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/RecentAddedRecord.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/record/RecentAddedRecord.kt @@ -1,4 +1,4 @@ -package com.project.how.data_class.recyclerview +package com.project.how.data_class.recyclerview.record data class RecentAddedRecord( val id : Long, diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/FlightMember.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/FlightMember.kt new file mode 100644 index 00000000..dc9110da --- /dev/null +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/FlightMember.kt @@ -0,0 +1,6 @@ +package com.project.how.data_class.recyclerview.ticket + +data class FlightMember( + val adult : Long, + val children : Long +) diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/RecentAirplane.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/RecentAirplane.kt similarity index 76% rename from android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/RecentAirplane.kt rename to android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/RecentAirplane.kt index fd52867a..fa4bdea4 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/RecentAirplane.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/RecentAirplane.kt @@ -1,4 +1,4 @@ -package com.project.how.data_class.recyclerview +package com.project.how.data_class.recyclerview.ticket data class RecentAirplane( val id : Long, diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/RecentHotel.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/RecentHotel.kt similarity index 72% rename from android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/RecentHotel.kt rename to android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/RecentHotel.kt index 52df11cb..cb8d5e1a 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/RecentHotel.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/RecentHotel.kt @@ -1,4 +1,4 @@ -package com.project.how.data_class.recyclerview +package com.project.how.data_class.recyclerview.ticket data class RecentHotel( val id : Long, diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/record/BillActivity.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/record/BillActivity.kt new file mode 100644 index 00000000..9ee2dd4e --- /dev/null +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/record/BillActivity.kt @@ -0,0 +1,21 @@ +package com.project.how.view.activity.record + +import android.os.Bundle +import androidx.activity.enableEdgeToEdge +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import com.project.how.R + +class BillActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContentView(R.layout.activity_bill) + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> + val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) + insets + } + } +} \ No newline at end of file diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/record/BillListActivity.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/record/BillListActivity.kt index 947b8212..cb5f1e6b 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/record/BillListActivity.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/record/BillListActivity.kt @@ -5,17 +5,37 @@ import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity import androidx.core.view.ViewCompat import androidx.core.view.WindowInsetsCompat +import androidx.databinding.DataBindingUtil +import com.project.how.BuildConfig import com.project.how.R +import com.project.how.adapter.recyclerview.record.BillListAdapter +import com.project.how.data_class.recyclerview.record.Bill +import com.project.how.databinding.ActivityBillListBinding -class BillListActivity : AppCompatActivity() { +class BillListActivity : AppCompatActivity(), BillListAdapter.OnItemClickListener { + private lateinit var binding : ActivityBillListBinding + private lateinit var adapter : BillListAdapter override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - enableEdgeToEdge() - setContentView(R.layout.activity_bill_list) - ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> - val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) - v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) - insets - } + binding = DataBindingUtil.setContentView(this, R.layout.activity_bill_list) + binding.bill = this + binding.lifecycleOwner = this + adapter = BillListAdapter(listOf( + Bill(1, BuildConfig.TEMPORARY_IMAGE_URL, "Temporary1", "2024.01.20 - 2024.01.24", 0, 3 ) + ), + this, this) + binding.billList.adapter = adapter + } + + fun add(){ + + } + + override fun onItemClickListener(id: Long) { + + } + + override fun onDeleteButtonClickListener(id: Long, position: Int) { + adapter.delete(position) } } \ No newline at end of file diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/ticket/OneWayAirplaneListActivity.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/ticket/OneWayAirplaneListActivity.kt index 99b00bcc..44d45f68 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/ticket/OneWayAirplaneListActivity.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/ticket/OneWayAirplaneListActivity.kt @@ -17,12 +17,11 @@ import com.project.how.data_class.dto.booking.airplane.GetOneWayFlightOffersRequ import com.project.how.data_class.dto.booking.airplane.GetOneWayFlightOffersResponseElement import com.project.how.data_class.dto.booking.airplane.LikeOneWayFlightElement import com.project.how.data_class.dto.booking.airplane.OneWayFlightOffers +import com.project.how.data_class.recyclerview.ticket.FlightMember import com.project.how.data_class.roomdb.RecentAirplane import com.project.how.databinding.ActivityOneWayAirplaneListBinding import com.project.how.view.activity.calendar.CalendarEditActivity -import com.project.how.view.dialog.bottom_sheet_dialog.WebViewBottomSheetDialog import com.project.how.view_model.BookingViewModel -import com.project.how.view_model.MemberViewModel import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch @@ -46,7 +45,7 @@ class OneWayAirplaneListActivity : AppCompatActivity(), OneWayAirplaneListAdapte getString(R.string.one_way_flight_offers), OneWayFlightOffers::class.java).data lid = MutableList(data.size) { -1L } bookingViewModel.getLikeFlightList(lid) - adapter = OneWayAirplaneListAdapter(this, data, lid,this) + adapter = OneWayAirplaneListAdapter(this, data, lid, this, null) input = CalendarEditActivity.getSerializable(this, getString(R.string.get_one_way_flight_offers_request), GetOneWayFlightOffersRequest::class.java) @@ -83,7 +82,10 @@ class OneWayAirplaneListActivity : AppCompatActivity(), OneWayAirplaneListAdapte } - override fun onItemClickerListener(data: GetOneWayFlightOffersResponseElement) { + override fun onItemClickerListener( + data: GetOneWayFlightOffersResponseElement, + flightMember: FlightMember? + ) { lifecycleScope.launch { clicked = data val request = GenerateOneWaySkyscannerUrlRequest( @@ -95,7 +97,7 @@ class OneWayAirplaneListActivity : AppCompatActivity(), OneWayAirplaneListAdapte data.abroadDuration, data.transferCount ) - bookingViewModel.generateOneWaySkyscannerUrl(this@OneWayAirplaneListActivity, MemberViewModel.tokensLiveData.value!!.accessToken, request).collect{check-> + bookingViewModel.generateOneWaySkyscannerUrl(request).collect{ check-> when(check){ BookingViewModel.NOT_EXIST->{ Toast.makeText(this@OneWayAirplaneListActivity, getString(R.string.not_exist_flight_offers), Toast.LENGTH_SHORT).show() @@ -116,7 +118,7 @@ class OneWayAirplaneListActivity : AppCompatActivity(), OneWayAirplaneListAdapte ){ lifecycleScope.launch{ if (check){ - bookingViewModel.unlike(this@OneWayAirplaneListActivity, MemberViewModel.tokensLiveData.value!!.accessToken, id, position).collect{c-> + bookingViewModel.unlike(id, position).collect{ c-> when(c){ BookingViewModel.NOT_EXIST->{ Toast.makeText(this@OneWayAirplaneListActivity, @@ -141,9 +143,11 @@ class OneWayAirplaneListActivity : AppCompatActivity(), OneWayAirplaneListAdapte data.abroadDepartureTime, data.abroadArrivalTime, data.nonstop, - data.transferCount + data.transferCount, + input.adults, + input.children ) - bookingViewModel.like(this@OneWayAirplaneListActivity, MemberViewModel.tokensLiveData.value!!.accessToken, lowf, position).collect{c-> + bookingViewModel.like(lowf, position).collect{ c-> if (c != BookingViewModel.SUCCESS){ Toast.makeText(this@OneWayAirplaneListActivity, getString(R.string.server_network_error), Toast.LENGTH_SHORT).show() } diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/ticket/RoundTripAirplaneListActivity.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/ticket/RoundTripAirplaneListActivity.kt index b6b9c072..f7aeb7ce 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/ticket/RoundTripAirplaneListActivity.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/ticket/RoundTripAirplaneListActivity.kt @@ -18,12 +18,11 @@ import com.project.how.data_class.dto.booking.airplane.GetFlightOffersRequest import com.project.how.data_class.dto.booking.airplane.GetFlightOffersResponseElement import com.project.how.data_class.dto.booking.airplane.LikeFlightElement import com.project.how.data_class.dto.booking.airplane.RoundTripFlightOffers +import com.project.how.data_class.recyclerview.ticket.FlightMember import com.project.how.data_class.roomdb.RecentAirplane import com.project.how.databinding.ActivityRoundTripAirplaneListBinding import com.project.how.view.activity.calendar.CalendarEditActivity -import com.project.how.view.dialog.bottom_sheet_dialog.WebViewBottomSheetDialog import com.project.how.view_model.BookingViewModel -import com.project.how.view_model.MemberViewModel import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch @@ -48,7 +47,7 @@ class RoundTripAirplaneListActivity : AppCompatActivity(), RoundTripAirplaneList bookingViewModel.getLikeFlightList(lid) Log.d("RoundTripAirplaneListActivity", "data.size = ${data.size}\ndata[0] : ${data[0].id}") - adapter = RoundTripAirplaneListAdapter(this, data, lid,this) + adapter = RoundTripAirplaneListAdapter(this, data, lid, this, null) binding.airplaneList.adapter = adapter input = CalendarEditActivity.getSerializable(this, @@ -84,7 +83,10 @@ class RoundTripAirplaneListActivity : AppCompatActivity(), RoundTripAirplaneList } } - override fun onItemClickerListener(data: GetFlightOffersResponseElement) { + override fun onItemClickerListener( + data: GetFlightOffersResponseElement, + flightMember: FlightMember? + ) { lifecycleScope.launch { clicked = data val request = GenerateSkyscannerUrlRequest( @@ -97,7 +99,7 @@ class RoundTripAirplaneListActivity : AppCompatActivity(), RoundTripAirplaneList data.abroadDuration, data.transferCount ) - bookingViewModel.generateSkyscannerUrl(this@RoundTripAirplaneListActivity, MemberViewModel.tokensLiveData.value!!.accessToken, request).collect{ check-> + bookingViewModel.generateSkyscannerUrl(request).collect{ check-> when(check){ BookingViewModel.NOT_EXIST->{ Toast.makeText(this@RoundTripAirplaneListActivity, getString(R.string.not_exist_flight_offers), Toast.LENGTH_SHORT).show() @@ -118,7 +120,7 @@ class RoundTripAirplaneListActivity : AppCompatActivity(), RoundTripAirplaneList ) { lifecycleScope.launch{ if (check){ - bookingViewModel.unlike(this@RoundTripAirplaneListActivity, MemberViewModel.tokensLiveData.value!!.accessToken, id, position).collect{c-> + bookingViewModel.unlike(id, position).collect{ c-> when(c){ BookingViewModel.NOT_EXIST->{ Toast.makeText(this@RoundTripAirplaneListActivity, @@ -146,9 +148,11 @@ class RoundTripAirplaneListActivity : AppCompatActivity(), RoundTripAirplaneList data.departureIataCode, data.arrivalIataCode, data.nonstop, - data.transferCount + data.transferCount, + input.adults, + input.children ) - bookingViewModel.like(this@RoundTripAirplaneListActivity, MemberViewModel.tokensLiveData.value!!.accessToken, lowf, position).collect{c-> + bookingViewModel.like(lowf, position).collect{ c-> if (c != BookingViewModel.SUCCESS){ Toast.makeText(this@RoundTripAirplaneListActivity, getString(R.string.server_network_error), Toast.LENGTH_SHORT).show() } diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/main/RecordFragment.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/main/RecordFragment.kt index e6af21f0..78f5e9bc 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/main/RecordFragment.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/main/RecordFragment.kt @@ -11,7 +11,7 @@ import androidx.lifecycle.lifecycleScope import com.google.android.material.tabs.TabLayoutMediator import com.project.how.R import com.project.how.adapter.recyclerview.viewpager.RecentAddedRecordsAdapter -import com.project.how.data_class.recyclerview.RecentAddedRecord +import com.project.how.data_class.recyclerview.record.RecentAddedRecord import com.project.how.databinding.FragmentRecordBinding import com.project.how.view.activity.record.BillListActivity import com.project.how.view.activity.record.LocationMapActivity diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/main/TicketFragment.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/main/TicketFragment.kt index a81a609d..3266b518 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/main/TicketFragment.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/main/TicketFragment.kt @@ -15,7 +15,7 @@ import com.project.how.adapter.recyclerview.booking.airplane.RecentAirplaneAdapt import com.project.how.adapter.recyclerview.booking.hotel.RecentHotelAdapter import com.project.how.adapter.recyclerview.viewpager.EventTicketViewPagerAdapter import com.project.how.data_class.recyclerview.schedule.EventViewPager -import com.project.how.data_class.recyclerview.RecentHotel +import com.project.how.data_class.recyclerview.ticket.RecentHotel import com.project.how.data_class.roomdb.RecentAirplane import com.project.how.databinding.FragmentTicketBinding import com.project.how.view.activity.mypage.LikeActivity diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/mypage/OneWayLikeFragment.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/mypage/OneWayLikeFragment.kt index a6bc4b01..be424438 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/mypage/OneWayLikeFragment.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/mypage/OneWayLikeFragment.kt @@ -1,5 +1,7 @@ package com.project.how.view.fragment.mypage +import android.content.Intent +import android.net.Uri import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -11,12 +13,15 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import com.project.how.R import com.project.how.adapter.recyclerview.booking.airplane.OneWayAirplaneListAdapter +import com.project.how.data_class.dto.booking.airplane.GenerateOneWaySkyscannerUrlRequest +import com.project.how.data_class.dto.booking.airplane.GenerateSkyscannerUrlRequest import com.project.how.data_class.dto.booking.airplane.GetOneWayFlightOffersResponseElement -import com.project.how.data_class.dto.booking.airplane.LikeOneWayFlightElement +import com.project.how.data_class.recyclerview.ticket.FlightMember +import com.project.how.data_class.roomdb.RecentAirplane import com.project.how.databinding.FragmentOneWayLikeBinding import com.project.how.view_model.BookingViewModel -import com.project.how.view_model.MemberViewModel import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @AndroidEntryPoint @@ -28,6 +33,8 @@ class OneWayLikeFragment : Fragment(), OneWayAirplaneListAdapter.OnItemClickList private val data = arrayListOf() private lateinit var adapter : OneWayAirplaneListAdapter private lateinit var lid : MutableList + private lateinit var member : MutableList + private var clicked = false override fun onCreateView( inflater: LayoutInflater, @@ -39,11 +46,13 @@ class OneWayLikeFragment : Fragment(), OneWayAirplaneListAdapter.OnItemClickList binding.lifecycleOwner = viewLifecycleOwner bookingViewModel.likeFlightLiveData.observe(viewLifecycleOwner){likes-> lid = mutableListOf() + member = mutableListOf() data.clear() likes.forEachIndexed { index, d -> if (d.homeDuration == null){ lid.add(d.id) + member.add(FlightMember(d.adult, d.children)) data.add( GetOneWayFlightOffersResponseElement( d.id.toString(), @@ -60,13 +69,20 @@ class OneWayLikeFragment : Fragment(), OneWayAirplaneListAdapter.OnItemClickList ) } } - adapter = OneWayAirplaneListAdapter(requireContext(), data, lid,this) + adapter = OneWayAirplaneListAdapter(requireContext(), data, lid, this, member) binding.airplaneList.adapter = adapter adapter.unlock() } bookingViewModel.likeFlightListLiveData.observe(viewLifecycleOwner){ lid = it } + bookingViewModel.skyscannerUrlLiveData.observe(viewLifecycleOwner){url-> + if (clicked){ + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + startActivity(intent) + clicked = false + } + } return binding.root } @@ -78,7 +94,7 @@ class OneWayLikeFragment : Fragment(), OneWayAirplaneListAdapter.OnItemClickList override fun onResume() { super.onResume() lifecycleScope.launch { - bookingViewModel.getLikeFlight(requireContext(), MemberViewModel.tokensLiveData.value!!.accessToken).collect{ check-> + bookingViewModel.getLikeFlight().collect{ check-> if (check != BookingViewModel.SUCCESS){ Toast.makeText(requireContext(), getString(R.string.server_network_error), Toast.LENGTH_SHORT).show() } @@ -87,8 +103,27 @@ class OneWayLikeFragment : Fragment(), OneWayAirplaneListAdapter.OnItemClickList } - override fun onItemClickerListener(data: GetOneWayFlightOffersResponseElement) { - + override fun onItemClickerListener( + data: GetOneWayFlightOffersResponseElement, + flightMember: FlightMember? + ) { + lifecycleScope.launch(Dispatchers.IO) { + clicked = true + bookingViewModel.generateOneWaySkyscannerUrl( + GenerateOneWaySkyscannerUrlRequest( + data.departureIataCode, + data.arrivalIataCode, + data.abroadDepartureTime.split(" ")[0], + flightMember?.adult ?: 1L, + flightMember?.children ?: 0L, + data.abroadDuration, + data.transferCount + ) + ).collect{ + if (it != BookingViewModel.SUCCESS) + clicked = false + } + } } override fun onHeartClickerListener( @@ -99,7 +134,7 @@ class OneWayLikeFragment : Fragment(), OneWayAirplaneListAdapter.OnItemClickList ) { lifecycleScope.launch{ if (check){ - bookingViewModel.unlike(requireContext(), MemberViewModel.tokensLiveData.value!!.accessToken, id, position).collect{c-> + bookingViewModel.unlike(id, position).collect{ c-> when(c){ BookingViewModel.SUCCESS->{ adapter.remove(position) @@ -117,24 +152,6 @@ class OneWayLikeFragment : Fragment(), OneWayAirplaneListAdapter.OnItemClickList } } } - }else{ - val lowf = LikeOneWayFlightElement( - data.carrierCode, - data.totalPrice, - data.departureIataCode, - data.arrivalIataCode, - data.abroadDuration, - data.abroadDepartureTime, - data.abroadArrivalTime, - data.nonstop, - data.transferCount - ) - bookingViewModel.like(requireContext(), MemberViewModel.tokensLiveData.value!!.accessToken, lowf, position).collect{c-> - if (c != BookingViewModel.SUCCESS){ - Toast.makeText(requireContext(), getString(R.string.server_network_error), Toast.LENGTH_SHORT).show() - } - - } } } diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/mypage/RoundTripLikeFragment.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/mypage/RoundTripLikeFragment.kt index 09cbea4f..73638d3d 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/mypage/RoundTripLikeFragment.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/mypage/RoundTripLikeFragment.kt @@ -1,5 +1,7 @@ package com.project.how.view.fragment.mypage +import android.content.Intent +import android.net.Uri import android.os.Bundle import android.view.LayoutInflater import android.view.View @@ -11,12 +13,13 @@ import androidx.fragment.app.viewModels import androidx.lifecycle.lifecycleScope import com.project.how.R import com.project.how.adapter.recyclerview.booking.airplane.RoundTripAirplaneListAdapter +import com.project.how.data_class.dto.booking.airplane.GenerateSkyscannerUrlRequest import com.project.how.data_class.dto.booking.airplane.GetFlightOffersResponseElement -import com.project.how.data_class.dto.booking.airplane.LikeFlightElement +import com.project.how.data_class.recyclerview.ticket.FlightMember import com.project.how.databinding.FragmentRoundTripLikeBinding import com.project.how.view_model.BookingViewModel -import com.project.how.view_model.MemberViewModel import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @AndroidEntryPoint @@ -28,6 +31,8 @@ class RoundTripLikeFragment : Fragment(), RoundTripAirplaneListAdapter.OnItemCli private val data = arrayListOf() private lateinit var adapter: RoundTripAirplaneListAdapter private lateinit var lid : MutableList + private lateinit var member : MutableList + private var clicked = false override fun onCreateView( inflater: LayoutInflater, @@ -37,11 +42,13 @@ class RoundTripLikeFragment : Fragment(), RoundTripAirplaneListAdapter.OnItemCli _binding = DataBindingUtil.inflate(inflater, R.layout.fragment_round_trip_like, container, false) bookingViewModel.likeFlightLiveData.observe(viewLifecycleOwner){likes-> lid = mutableListOf() + member = mutableListOf() data.clear() likes.forEachIndexed { index, d -> if (d.homeDuration != null){ lid.add(d.id) + member.add(FlightMember(d.adult, d.children)) data.add( GetFlightOffersResponseElement( d.id.toString(), @@ -61,13 +68,21 @@ class RoundTripLikeFragment : Fragment(), RoundTripAirplaneListAdapter.OnItemCli ) } } - adapter = RoundTripAirplaneListAdapter(requireContext(), data, lid,this) + adapter = RoundTripAirplaneListAdapter(requireContext(), data, lid, this, member) binding.airplaneList.adapter = adapter adapter.unlock() } bookingViewModel.likeFlightListLiveData.observe(viewLifecycleOwner){ lid = it } + bookingViewModel.skyscannerUrlLiveData.observe(viewLifecycleOwner){url-> + if (clicked){ + val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + startActivity(intent) + clicked = false + } + } + return binding.root } @@ -80,7 +95,7 @@ class RoundTripLikeFragment : Fragment(), RoundTripAirplaneListAdapter.OnItemCli override fun onResume() { super.onResume() lifecycleScope.launch { - bookingViewModel.getLikeFlight(requireContext(), MemberViewModel.tokensLiveData.value!!.accessToken).collect{ check-> + bookingViewModel.getLikeFlight().collect{ check-> if (check != BookingViewModel.SUCCESS){ Toast.makeText(requireContext(), getString(R.string.server_network_error), Toast.LENGTH_SHORT).show() } @@ -89,8 +104,28 @@ class RoundTripLikeFragment : Fragment(), RoundTripAirplaneListAdapter.OnItemCli } - override fun onItemClickerListener(data: GetFlightOffersResponseElement) { - + override fun onItemClickerListener( + data: GetFlightOffersResponseElement, + flightMember: FlightMember? + ) { + lifecycleScope.launch(Dispatchers.IO) { + clicked = true + bookingViewModel.generateSkyscannerUrl( + GenerateSkyscannerUrlRequest( + data.departureIataCode, + data.arrivalIataCode, + data.abroadDepartureTime.split(" ")[0], + data.homeArrivalTime.split(" ")[0], + flightMember?.adult ?: 1L, + flightMember?.children ?: 0L, + data.abroadDuration, + data.transferCount + ) + ).collect{ + if (it != BookingViewModel.SUCCESS) + clicked = false + } + } } override fun onHeartClickerListener( @@ -101,7 +136,7 @@ class RoundTripLikeFragment : Fragment(), RoundTripAirplaneListAdapter.OnItemCli ) { lifecycleScope.launch { if (check){ - bookingViewModel.unlike(requireContext(), MemberViewModel.tokensLiveData.value!!.accessToken, id, position).collect{c-> + bookingViewModel.unlike(id, position).collect{ c-> when(c){ BookingViewModel.SUCCESS->{ adapter.remove(position) @@ -119,26 +154,6 @@ class RoundTripLikeFragment : Fragment(), RoundTripAirplaneListAdapter.OnItemCli } } } - }else{ - val lf = LikeFlightElement( - data.carrierCode, - data.totalPrice, - data.abroadDuration, - data.abroadDepartureTime, - data.abroadArrivalTime, - data.homeDuration, - data.homeDepartureTime, - data.homeArrivalTime, - data.departureIataCode, - data.arrivalIataCode, - data.nonstop, - data.transferCount - ) - bookingViewModel.like(requireContext(), MemberViewModel.tokensLiveData.value!!.accessToken, lf, position).collect{c-> - if (c != BookingViewModel.SUCCESS){ - Toast.makeText(requireContext(), getString(R.string.server_network_error), Toast.LENGTH_SHORT).show() - } - } } } } diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/ticket/OneWaySearchFragment.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/ticket/OneWaySearchFragment.kt index 7ecfa72c..4941d718 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/ticket/OneWaySearchFragment.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/ticket/OneWaySearchFragment.kt @@ -24,7 +24,6 @@ import com.project.how.view.activity.ticket.OneWayAirplaneListActivity import com.project.how.view.dialog.ConfirmDialog import com.project.how.view.dialog.bottom_sheet_dialog.AirportBottomSheetDialog import com.project.how.view_model.BookingViewModel -import com.project.how.view_model.MemberViewModel import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch import java.text.SimpleDateFormat @@ -119,7 +118,7 @@ class OneWaySearchFragment(private val onLoadListener: OnLoadListener) : Fragmen 50, nonStop ) - bookingViewModel.getFlightOffers(requireContext(), MemberViewModel.tokensLiveData.value!!.accessToken, input).collect{check-> + bookingViewModel.getFlightOffers(input).collect{ check-> setEnabled() onLoadListener.onLoadFinishListener() when(check){ diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/ticket/RoundTripSearchFragment.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/ticket/RoundTripSearchFragment.kt index bf954955..56d27070 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/ticket/RoundTripSearchFragment.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view/fragment/ticket/RoundTripSearchFragment.kt @@ -24,7 +24,6 @@ import com.project.how.view.activity.ticket.RoundTripAirplaneListActivity import com.project.how.view.dialog.ConfirmDialog import com.project.how.view.dialog.bottom_sheet_dialog.AirportBottomSheetDialog import com.project.how.view_model.BookingViewModel -import com.project.how.view_model.MemberViewModel import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.launch import java.text.SimpleDateFormat @@ -111,7 +110,7 @@ class RoundTripSearchFragment(private val onLoadListener: OnLoadListener) : Frag 50, nonStop ) - bookingViewModel.getFlightOffers(requireContext(), MemberViewModel.tokensLiveData.value!!.accessToken, input).collect{check-> + bookingViewModel.getFlightOffers(input).collect{ check-> setEnabled() onLoadListener.onLoadFinishListener() when(check){ diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view_model/BookingViewModel.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view_model/BookingViewModel.kt index 04c6c226..6e31f3fb 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view_model/BookingViewModel.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view_model/BookingViewModel.kt @@ -1,6 +1,5 @@ package com.project.how.view_model -import android.content.Context import android.util.Log import androidx.lifecycle.LiveData import androidx.lifecycle.ViewModel @@ -24,6 +23,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.launch import retrofit2.Call import retrofit2.Callback @@ -73,7 +73,7 @@ class BookingViewModel @Inject constructor( } } - fun getFlightOffers(context : Context, accessToken : String, getFlightOffersRequest: GetFlightOffersRequest) : Flow = callbackFlow{ + fun getFlightOffers(getFlightOffersRequest: GetFlightOffersRequest) : Flow = callbackFlow{ BookingRetrofit.getApiService()?.let {apiService -> apiService.getFlightOffers(getFlightOffersRequest) .enqueue(object : Callback{ @@ -111,9 +111,9 @@ class BookingViewModel @Inject constructor( } ?: close() awaitClose() - } + }.flowOn(Dispatchers.IO) - fun getFlightOffers(context : Context, accessToken : String, getOneWayFlightOffersRequest: GetOneWayFlightOffersRequest) : Flow = callbackFlow{ + fun getFlightOffers(getOneWayFlightOffersRequest: GetOneWayFlightOffersRequest) : Flow = callbackFlow { BookingRetrofit.getApiService()?.let {apiService -> apiService.getOneWayFligthOffers(getOneWayFlightOffersRequest) .enqueue(object : Callback{ @@ -151,9 +151,9 @@ class BookingViewModel @Inject constructor( } ?: close() awaitClose() - } + }.flowOn(Dispatchers.IO) - fun generateSkyscannerUrl(context : Context, accessToken : String, generateSkyscannerUrlRequest: GenerateSkyscannerUrlRequest) : Flow = callbackFlow { + fun generateSkyscannerUrl(generateSkyscannerUrlRequest: GenerateSkyscannerUrlRequest) : Flow = callbackFlow { BookingRetrofit.getApiService()?.let {apiService-> apiService.generateSkyscannerUrl(generateSkyscannerUrlRequest) .enqueue(object : Callback{ @@ -186,9 +186,9 @@ class BookingViewModel @Inject constructor( } ?: close() awaitClose() - } + }.flowOn(Dispatchers.IO) - fun generateOneWaySkyscannerUrl(context : Context, accessToken : String, generateOneWaySkyscannerUrlRequest: GenerateOneWaySkyscannerUrlRequest) : Flow = callbackFlow { + fun generateOneWaySkyscannerUrl(generateOneWaySkyscannerUrlRequest: GenerateOneWaySkyscannerUrlRequest) : Flow = callbackFlow { BookingRetrofit.getApiService()?.let {apiService-> apiService.generateOneWaySkyscannerUrl(generateOneWaySkyscannerUrlRequest) .enqueue(object : Callback{ @@ -221,9 +221,9 @@ class BookingViewModel @Inject constructor( } ?: close() awaitClose() - } + }.flowOn(Dispatchers.IO) - fun like(context: Context, accessToken: String, likeFlightElement: LikeFlightElement, position: Int) : Flow = callbackFlow{ + fun like(likeFlightElement: LikeFlightElement, position: Int) : Flow = callbackFlow { BookingRetrofit.getApiService()?.let { apiService-> apiService.addLikeFlight(likeFlightElement) .enqueue(object : Callback{ @@ -254,9 +254,9 @@ class BookingViewModel @Inject constructor( } ?: close() awaitClose() - } + }.flowOn(Dispatchers.IO) - fun like(context: Context, accessToken: String, likeOneWayFlightElement: LikeOneWayFlightElement, position: Int) : Flow = callbackFlow { + fun like(likeOneWayFlightElement: LikeOneWayFlightElement, position: Int) : Flow = callbackFlow { BookingRetrofit.getApiService()?.let { apiService-> apiService.addLikeOneWayFlight(likeOneWayFlightElement) .enqueue(object : Callback{ @@ -287,9 +287,9 @@ class BookingViewModel @Inject constructor( } ?: close() awaitClose() - } + }.flowOn(Dispatchers.IO) - fun getLikeFlight(context: Context, accessToken: String) : Flow = callbackFlow { + fun getLikeFlight(): Flow = callbackFlow { BookingRetrofit.getApiService()?.let { apiService-> apiService.getLikeFlight() .enqueue(object : Callback{ @@ -322,9 +322,9 @@ class BookingViewModel @Inject constructor( } ?: close() awaitClose() - } + }.flowOn(Dispatchers.IO) - fun unlike(context: Context, accessToken: String, id: Long, position: Int) : Flow = callbackFlow{ + fun unlike(id: Long, position: Int) : Flow = callbackFlow { BookingRetrofit.getApiService()?.let {apiService-> apiService.deleteLikeFlight(id) .enqueue(object : Callback{ @@ -354,7 +354,7 @@ class BookingViewModel @Inject constructor( } ?: close() awaitClose() - } + }.flowOn(Dispatchers.IO) fun getLikeFlightList(data : MutableList){ bookingRepository.getLikeFlightList(data) diff --git a/android/HowAboutTrip/app/src/main/java/com/project/how/view_model/RecordViewModel.kt b/android/HowAboutTrip/app/src/main/java/com/project/how/view_model/RecordViewModel.kt index a355e7ea..b6fd8514 100644 --- a/android/HowAboutTrip/app/src/main/java/com/project/how/view_model/RecordViewModel.kt +++ b/android/HowAboutTrip/app/src/main/java/com/project/how/view_model/RecordViewModel.kt @@ -1,4 +1,8 @@ package com.project.how.view_model -class RecordViewModel { +import androidx.lifecycle.ViewModel +import com.project.how.model.RecordRepository + +class RecordViewModel : ViewModel() { + val recordRepository : RecordRepository = RecordRepository() } \ No newline at end of file diff --git a/android/HowAboutTrip/app/src/main/res/layout/activity_bill.xml b/android/HowAboutTrip/app/src/main/res/layout/activity_bill.xml new file mode 100644 index 00000000..2b90d8fa --- /dev/null +++ b/android/HowAboutTrip/app/src/main/res/layout/activity_bill.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file