Skip to content

Commit

Permalink
update booked and reserved list
Browse files Browse the repository at this point in the history
  • Loading branch information
JahidHasanCO committed Aug 24, 2022
1 parent afb9b8e commit edc0da3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ constructor(context: Context, attrs: AttributeSet? = null) :
private var title = listOf<String>()

private var selectedIdList: ArrayList<Int> = arrayListOf()
private var bookedIdList: ArrayList<Int> = arrayListOf()
private var reservedIdList: ArrayList<Int> = arrayListOf()

private var selectSeatLimit = Int.MAX_VALUE
private var selectedSeats = 0


private var isCustomTitle = false
private var count = 0

Expand Down Expand Up @@ -223,6 +227,27 @@ constructor(context: Context, attrs: AttributeSet? = null) :
return selectedIdList
}

fun getBookedIdList(): List<Int> {
return bookedIdList
}

fun getReservedIdList(): List<Int> {
return reservedIdList
}

fun setBookedIdList(list: List<Int>) {
for (id in list) {
markAsBooked(seatViewList[id - 1])
}
}

fun setReservedIdList(list: List<Int>) {
for (id in list) {
markAsReserved(seatViewList[id - 1])
}
}


fun setAvailableSeatsBackground(drawable: Int): SeatBookView {
bookDrawable = drawable
return this
Expand Down
30 changes: 9 additions & 21 deletions app/src/main/java/dev/jahidhasanco/demo_app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.setPadding
import dev.jahidhasanco.seatbookview.SeatBookView
Expand All @@ -29,8 +28,9 @@ class MainActivity : AppCompatActivity() {

)


private var title = listOf(
"/", "E1", "", "", "", "E5",
"/", "I1", "", "", "", "E5",
"/", "", "", "", "", "",
"/", "A1", "A2", "", "A3", "A4",
"/", "B1", "B2", "", "B2", "B4",
Expand All @@ -39,11 +39,10 @@ class MainActivity : AppCompatActivity() {
"/", "E1", "E2", "", "E3", "E4",
"/", "F1", "F2", "", "F3", "F4",
"/", "G1", "G2", "", "G3", "G4",
"/", "H1", "H2", "H3", "H4", "H5")
"/", "H1", "H2", "H3", "H4", "H5"
)


private val STATUS_AVAILABLE = 1
private val STATUS_BOOKED = 2
private val STATUS_RESERVED = 3

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand All @@ -67,6 +66,7 @@ class MainActivity : AppCompatActivity() {
seatBookView.setSeatViewLayout(viewGroupLayout)
seatBookView.show()


seatBookView.getSeatView(2).apply {
seatBookView.markAsTransparentSeat(this as TextView)
this.setBackgroundResource(R.drawable.ic_steering)
Expand All @@ -76,27 +76,15 @@ class MainActivity : AppCompatActivity() {
seatBookView.setSeatClickListener(object : SeatBookView.SeatClickListener {

override fun onAvailableSeatClick(selectedIdList: List<Int>, view: View) {
Toast.makeText(
this@MainActivity,
"Seat " + view.id.toString() + " is Selected",
Toast.LENGTH_SHORT
).show()

}

override fun onBookedSeatClick(view: View) {
Toast.makeText(
this@MainActivity,
"Seat " + view.id.toString() + " is Booked",
Toast.LENGTH_SHORT
).show()

}

override fun onReservedSeatClick(view: View) {
Toast.makeText(
this@MainActivity,
"Seat " + view.id.toString() + " is Reserved",
Toast.LENGTH_SHORT
).show()

}


Expand Down

0 comments on commit edc0da3

Please sign in to comment.