вся лаб 5
This commit is contained in:
parent
7af968a96a
commit
bdebaee485
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="true"
|
||||
|
@ -19,7 +19,7 @@ import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
// TODO
|
||||
@Database(entities = [Hotel::class, User::class, Order::class, RemoteKeys::class], version = 5)
|
||||
@Database(entities = [Hotel::class, User::class, Order::class, RemoteKeys::class], version = 6)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun hotelDao(): HotelDao
|
||||
abstract fun userDao(): UserDao
|
||||
@ -43,7 +43,7 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
userDao.createUser(user1)
|
||||
userDao.createUser(user2)
|
||||
userDao.createUser(user3)
|
||||
// Sneaker
|
||||
// Hotel
|
||||
val hotelDao = database.hotelDao()
|
||||
val hotel1 = Hotel(null, "Hotel1", 1000.0, R.drawable.img, 1, "location1", "info1")
|
||||
val hotel2 = Hotel(null, "Hotel2", 2000.0, R.drawable.img_2, 2, "location2", "info2")
|
||||
|
@ -43,7 +43,7 @@ interface BackendService {
|
||||
@Body hotel: HotelRemote
|
||||
): HotelRemote
|
||||
|
||||
@DELETE("sneaker/delete/{id}")
|
||||
@DELETE("hotel/delete/{id}")
|
||||
suspend fun deleteHotel(
|
||||
@Path("id") id: Int
|
||||
)
|
||||
@ -80,7 +80,7 @@ interface BackendService {
|
||||
)
|
||||
|
||||
companion object {
|
||||
private const val BASE_URL = "https://59k4pfj3-8080.euw.devtunnels.ms/api/"
|
||||
private const val BASE_URL = "https://7w06qshk-8080.euw.devtunnels.ms/api/"
|
||||
|
||||
@Volatile
|
||||
private var INSTANCE: BackendService? = null
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.example.androidlabs.api.model
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.PrimaryKey
|
||||
import com.example.androidlabs.DB.models.Hotel
|
||||
import com.example.androidlabs.DB.models.Order
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
@ -15,7 +12,7 @@ data class OrderRemote(
|
||||
val rooms: Int = 0,
|
||||
val total: Double = 0.0,
|
||||
val userId: Int = 0,
|
||||
val bookedHotelId: Int = 0
|
||||
val hotelId: Int = 0
|
||||
)
|
||||
|
||||
fun OrderRemote.toOrder(): Order = Order(
|
||||
@ -25,7 +22,7 @@ fun OrderRemote.toOrder(): Order = Order(
|
||||
rooms,
|
||||
total,
|
||||
userId,
|
||||
bookedHotelId,
|
||||
hotelId,
|
||||
)
|
||||
|
||||
fun Order.toOrderRemote():OrderRemote = OrderRemote(
|
||||
|
@ -37,7 +37,6 @@ import com.example.androidlabs.homeScreen.SearchField.SearchField
|
||||
@Composable
|
||||
fun HomeScreen(navController: NavHostController, hotelViewModel: HotelViewModel = viewModel(factory = AppViewModelProvider.Factory)) {
|
||||
val list = hotelViewModel.HotelList.collectAsLazyPagingItems()
|
||||
//Log.d("MyLog", list.toString())
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
|
@ -84,7 +84,7 @@ fun HotelInfo(hotel: Hotel, navController: NavHostController) {
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
){
|
||||
Text(text = "1 room | 1 Night")
|
||||
Text(text = "Rs. 4000")
|
||||
Text(text = "Rs. " + hotel.price)
|
||||
}
|
||||
}
|
||||
Divider(color = Color.Black, thickness = 1.dp)
|
||||
@ -133,7 +133,7 @@ fun HotelInfo(hotel: Hotel, navController: NavHostController) {
|
||||
verticalArrangement = Arrangement.SpaceEvenly
|
||||
){
|
||||
Text(text = "Info")
|
||||
Text(text = "inf")
|
||||
Text(text = hotel.info)
|
||||
}
|
||||
}
|
||||
Row(
|
||||
|
Loading…
Reference in New Issue
Block a user