Skip to content

Commit

Permalink
Merge pull request #6 from SOPT-29th-Joint-Seminar-10/subeen
Browse files Browse the repository at this point in the history
#3 [STYLE] : 차량 예약.xml 및 RecyclerView
  • Loading branch information
ub1n authored Nov 19, 2021
2 parents 0c1e83f + a1372a1 commit aba9146
Show file tree
Hide file tree
Showing 53 changed files with 426 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {

//viewpager2 추가
implementation "androidx.viewpager2:viewpager2:1.1.0-beta01"

implementation 'com.github.bumptech.glide:glide:4.12.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SoptSocar">
<activity android:name=".ReservationCar"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/kr/ac/smu/cs/soptsocar/CarInfoData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package kr.ac.smu.cs.soptsocar

data class CarInfoData(
val car : Int,
val heart: Int,
val name : String,
val price : String,
val sale : String,
val date : String,
val city : String,
)
41 changes: 41 additions & 0 deletions app/src/main/java/kr/ac/smu/cs/soptsocar/FilterCarAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package kr.ac.smu.cs.soptsocar

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import kr.ac.smu.cs.soptsocar.databinding.ItemFilterBinding
import kr.ac.smu.cs.soptsocar.databinding.ItemReserveCarListBinding

class FilterCarAdapter : RecyclerView.Adapter<FilterCarAdapter.FilterCarViewHolder>() {

val filterList = mutableListOf<FilterInfoData>()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FilterCarViewHolder {
val binding = ItemFilterBinding.inflate(
LayoutInflater.from(parent.context),
parent, false
)
return FilterCarViewHolder(binding)
}

override fun onBindViewHolder(holder: FilterCarViewHolder, position: Int) {
holder.onBind(filterList[position])
}

override fun getItemCount(): Int = filterList.size

class FilterCarViewHolder(private val binding: ItemFilterBinding) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(data: FilterInfoData) {
// 이미지버튼
Glide.with(binding.root)
.load(data.filterImage)
.into(binding.imgFilter)

}

}

}

6 changes: 6 additions & 0 deletions app/src/main/java/kr/ac/smu/cs/soptsocar/FilterInfoData.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package kr.ac.smu.cs.soptsocar

data class FilterInfoData(
val filterImage : Int

)
2 changes: 2 additions & 0 deletions app/src/main/java/kr/ac/smu/cs/soptsocar/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kr.ac.smu.cs.soptsocar

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.viewpager2.widget.ViewPager2
Expand All @@ -14,6 +15,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
binding= ActivityMainBinding.inflate(layoutInflater)


initViewPagerAdapter()
initBottomNavigation()
setContentView(binding.root)
Expand Down
74 changes: 74 additions & 0 deletions app/src/main/java/kr/ac/smu/cs/soptsocar/ReservationCar.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package kr.ac.smu.cs.soptsocar

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kr.ac.smu.cs.soptsocar.databinding.ActivityReservationCarBinding

class ReservationCar : AppCompatActivity() {

private lateinit var binding: ActivityReservationCarBinding
lateinit var reserveCarAdapter: ReserveCarAdapter
lateinit var filterCarAdapter: FilterCarAdapter

val data = mutableListOf<CarInfoData>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding= ActivityReservationCarBinding.inflate(layoutInflater)

setContentView(binding.root)

initAdapter()

//뒤로 가기 버튼 전 화면으로 이동
binding.back.setOnClickListener {
finish()
}
}



private fun initAdapter(){

reserveCarAdapter= ReserveCarAdapter()
filterCarAdapter = FilterCarAdapter()

binding.rvCar.adapter=reserveCarAdapter
binding.rvFilter.adapter=filterCarAdapter

val img1 = R.drawable.img_tosan
val img11 = R.drawable.ic_default_heart_ios


filterCarAdapter.filterList.addAll(
listOf(
FilterInfoData(R.drawable.ic_filter),
FilterInfoData(R.drawable.ic_rentalperiod),
FilterInfoData(R.drawable.ic_filterprice),
FilterInfoData(R.drawable.ic_model),
FilterInfoData(R.drawable.ic_popularity),
FilterInfoData(R.drawable.ic_region)

)
)
filterCarAdapter.notifyDataSetChanged()

reserveCarAdapter.carList.addAll(
listOf(
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천"),
CarInfoData(img1,img11,"투싼(경유)","월 503,000원~","26%","2016~2017", "서울/경기/인천")
)
)
reserveCarAdapter.notifyDataSetChanged()
}

}
47 changes: 47 additions & 0 deletions app/src/main/java/kr/ac/smu/cs/soptsocar/ReserveCarAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package kr.ac.smu.cs.soptsocar

import android.content.ClipData
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import kr.ac.smu.cs.soptsocar.databinding.ItemReserveCarListBinding

class ReserveCarAdapter : RecyclerView.Adapter<ReserveCarAdapter.ReserveCarViewHolder>() {

val carList = mutableListOf<CarInfoData>()

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ReserveCarViewHolder {
val binding = ItemReserveCarListBinding.inflate(
LayoutInflater.from(parent.context),
parent, false
)
return ReserveCarViewHolder(binding)
}

override fun onBindViewHolder(holder: ReserveCarViewHolder, position: Int) {
holder.onBind(carList[position])
}

override fun getItemCount(): Int = carList.size

class ReserveCarViewHolder(private val binding: ItemReserveCarListBinding) :
RecyclerView.ViewHolder(binding.root) {
fun onBind(data: CarInfoData) {
// 사진 불러오기 2개
Glide.with(binding.root)
.load(data.car)
.into(binding.imgCar)
Glide.with(binding.root)
.load(data.heart)
.into(binding.imgHeart)
binding.txtCarname.text = data.name
binding.txtPrice.text = data.price
binding.txtSale.text = data.sale
binding.txtDate.text = data.date
binding.txtCity.text = data.city
}

}

}
Binary file added app/src/main/res/drawable-hdpi/ic_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_filterprice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_popularity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_region.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_rentalperiod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_filterprice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_popularity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_region.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-mdpi/ic_rentalperiod.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_filterprice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_model.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_popularity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xhdpi/ic_region.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-xxhdpi/ic_filter.png
Binary file added app/src/main/res/drawable-xxhdpi/ic_model.png
Binary file added app/src/main/res/drawable-xxhdpi/ic_region.png
Binary file added app/src/main/res/drawable-xxxhdpi/ic_back.png
Binary file added app/src/main/res/drawable-xxxhdpi/ic_filter.png
Binary file added app/src/main/res/drawable-xxxhdpi/ic_model.png
Binary file added app/src/main/res/drawable-xxxhdpi/ic_region.png
6 changes: 6 additions & 0 deletions app/src/main/res/drawable/layout_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners android:radius="4dp" />
</shape>
9 changes: 9 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="차량예약액티비티"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:id="@+id/next"/>

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnv_main"
android:layout_width="match_parent"
Expand Down
95 changes: 95 additions & 0 deletions app/src/main/res/layout/activity_reservation_car.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ReservationCar">

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="144dp"
android:background="@color/whtie"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<TextView
android:id="@+id/txt_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:textColor="#28323c"
android:textSize="16sp"
android:includeFontPadding="false"
app:fontFamily="@font/spoqa_han_sans_neo_medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="차량 예약" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_filter"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txt_title"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:spanCount="1"
tools:listitem="@layout/item_filter">
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="vertical" />-->

</androidx.recyclerview.widget.RecyclerView>

<ImageButton
android:id="@+id/back"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginTop="40dp"
android:background="@color/white"
app:layout_constraintBottom_toTopOf="@+id/rv_filter"
app:layout_constraintEnd_toStartOf="@+id/txt_title"
app:layout_constraintHorizontal_bias="0.253"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/ic_back" />


</androidx.constraintlayout.widget.ConstraintLayout>



r<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_car"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/bnv_main"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:layout_marginTop="16dp"
app:layout_constraintTop_toBottomOf="@+id/constraintLayout"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="2"
tools:itemCount="10"
tools:listitem="@layout/item_reserve_car_list"/>



<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bnv_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
app:menu="@menu/menu"
app:itemIconTint="@color/selector_bottom_navi"
app:itemTextColor="@color/gray_070"
app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>
19 changes: 19 additions & 0 deletions app/src/main/res/layout/item_filter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageButton
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_marginLeft="24dp"
app:layout_constraintDimensionRatio="1:1"
android:background="@color/white"
app:srcCompat="@drawable/ic_filterprice"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:id="@+id/img_filter"/>

</androidx.constraintlayout.widget.ConstraintLayout>
Loading

0 comments on commit aba9146

Please sign in to comment.