forked from tukcomCD2024/ISP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat : Add new function that opens skyscanner website when user click…
…s likeItem tukcomCD2024#74
- Loading branch information
Showing
29 changed files
with
591 additions
and
126 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
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
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
64 changes: 56 additions & 8 deletions
64
...boutTrip/app/src/main/java/com/project/how/adapter/recyclerview/record/BillListAdapter.kt
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,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<Bill>, | ||
private val context : Context, | ||
private val onItemClickListener: OnItemClickListener | ||
) : RecyclerView.Adapter<BillListAdapter.ViewHolder>(){ | ||
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<Bill>){ | ||
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) | ||
} | ||
} |
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
20 changes: 19 additions & 1 deletion
20
...pp/src/main/java/com/project/how/data_class/dto/booking/airplane/GetLikeFlightResponse.kt
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,18 +1,36 @@ | ||
package com.project.how.data_class.dto.booking.airplane | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
typealias GetLikeFlightResponse = List<GetLikeFlightResponseElement> | ||
|
||
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 | ||
) |
20 changes: 19 additions & 1 deletion
20
...AboutTrip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeFlight.kt
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,18 +1,36 @@ | ||
package com.project.how.data_class.dto.booking.airplane | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
typealias LikeFlight = List<LikeFlightElement> | ||
|
||
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 | ||
) |
17 changes: 16 additions & 1 deletion
17
...rip/app/src/main/java/com/project/how/data_class/dto/booking/airplane/LikeOneWayFlight.kt
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,15 +1,30 @@ | ||
package com.project.how.data_class.dto.booking.airplane | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
typealias LikeOneWayFlight = List<LikeOneWayFlightElement> | ||
|
||
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 | ||
) |
10 changes: 10 additions & 0 deletions
10
...oid/HowAboutTrip/app/src/main/java/com/project/how/data_class/recyclerview/record/Bill.kt
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,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 | ||
) |
2 changes: 1 addition & 1 deletion
2
...a_class/recyclerview/RecentAddedRecord.kt → .../recyclerview/record/RecentAddedRecord.kt
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
6 changes: 6 additions & 0 deletions
6
...boutTrip/app/src/main/java/com/project/how/data_class/recyclerview/ticket/FlightMember.kt
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,6 @@ | ||
package com.project.how.data_class.recyclerview.ticket | ||
|
||
data class FlightMember( | ||
val adult : Long, | ||
val children : Long | ||
) |
2 changes: 1 addition & 1 deletion
2
...data_class/recyclerview/RecentAirplane.kt → ...ass/recyclerview/ticket/RecentAirplane.kt
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
2 changes: 1 addition & 1 deletion
2
...ow/data_class/recyclerview/RecentHotel.kt → ..._class/recyclerview/ticket/RecentHotel.kt
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
21 changes: 21 additions & 0 deletions
21
android/HowAboutTrip/app/src/main/java/com/project/how/view/activity/record/BillActivity.kt
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,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 | ||
} | ||
} | ||
} |
Oops, something went wrong.