-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[둘리] 3, 4 단계 영화 티켓 예매 제출합니다. #47
Merged
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
afc8cca
test: PriceCalculatorTest 생성
hyemdooly 4ca2988
test: TicketTest 수정
hyemdooly aaace58
refactor: fold를 사용하여 코드 단축
hyemdooly 067af6b
refactor: PlayingDateTimes로 클래스명과 코드 수정
hyemdooly f5c4730
refactor: package 이동으로 인한 수정
hyemdooly eeaeb22
refactor: 필요없는 주석 삭제
hyemdooly d8f91d8
refactor: TicketResultActivity View 세팅 코드 분리
hyemdooly 417aca7
feat: SeatSelectActivity xml 작성
hyemdooly d9672f2
refactor: DateSpinnerListener 삭제, findViewById 한번만 하도록 수정
hyemdooly e174e3d
refactor: MovieListItemListener 분리
hyemdooly debeaca
fix: onItemClickListener -> SelectedListener 수정
hyemdooly 76c0a90
feat: SeatView 구현
hyemdooly 3738630
refactor: Ticket Model 구조 변경
hyemdooly e892f4b
feat: 좌석 선택 페이지로 넘어가도록 수정
hyemdooly 2c8cc14
feat: 좌석 Grade 클래스 추가
hyemdooly 21c892b
feat: TheaterInfo 생성
hyemdooly 61f7022
feat: SeatSelectSystem 생성
hyemdooly 09e0766
feat: SelectResult Success sead class 생성
hyemdooly cf52062
refactor: PriceCalculator 리팩토링
hyemdooly 8291de2
feat: PriceSystem 생성
hyemdooly f4d6e7c
refactor: JUnit4 버전 수정
hyemdooly cd9c49e
feat: Seat 클래스 생성, seats custom getter 생성
hyemdooly e351227
refactor: 패키지명 수정
hyemdooly 7ff59f2
feat: 좌석 선택 액티비티 구현
hyemdooly 55df55c
feat: Listener 수정, 자리 선택 액티비티 구현 완료
hyemdooly 025733a
refactor: Ticket 액티비티에서 자리 순서대로 출력하도록 수정
hyemdooly 61c6a5f
refactor: count max값 추가
hyemdooly 29d7245
refactor: PriceModel 구현 및 수정
hyemdooly a410609
feat: Dialog 구현
hyemdooly 1e294bc
feat: Dialog NegativeButton Listener 추가
hyemdooly 371ec72
refactor: UI 변경 사항 수정
hyemdooly 9c41ac5
test: MovieDetailActivity, SeatSelectActivity UI Test 추가
hyemdooly 21c60b1
test: TicketResultActivity UI Test 추가
hyemdooly 04b076e
feat: ListView -> RecyclerView로 변경
hyemdooly 74fbd10
feat: RecyclerView Ad View 추가
hyemdooly cc1abcc
refactor: ViewHolder property private 수정
hyemdooly 3b89b78
test: MovieListActivityTest 추가
hyemdooly ea36840
docs: Update README.md
hyemdooly aa5050c
refactor: MovieDetailActivityTest 수정
hyemdooly 8a3b1df
refactor: MovieDetailActivityTest 수정
hyemdooly 55c309b
refactor: Listener interface 삭제
hyemdooly 27c24b4
refactor: layoutManager xml에서 지정, View에서 Bundle이 아닌 Data 주입
hyemdooly 03d294e
refactor: ReserveInfoModel 추가 및 수정
hyemdooly bb03b6a
refactor: sealed class view holder, view type enum class 생성, item들 xm…
hyemdooly 0522cc9
Merge remote-tracking branch 'origin/step4' into step4
hyemdooly 8f35ee7
refactor: 코드 변경에 따른 테스트 수정, 패키지 변경
hyemdooly 9f09fcd
refactor: Log 삭제
hyemdooly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
refactor: sealed class view holder, view type enum class 생성, item들 xm…
…l 수정
- Loading branch information
commit bb03b6a3a08078a2fa418a3686bcfd53fb711be9
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
43 changes: 43 additions & 0 deletions
43
app/src/main/java/woowacourse/movie/activity/movielist/CustomViewHolder.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,43 @@ | ||
package woowacourse.movie.activity.movielist | ||
|
||
import android.view.View | ||
import android.widget.Button | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.annotation.DrawableRes | ||
import androidx.recyclerview.widget.RecyclerView | ||
import woowacourse.movie.R | ||
import woowacourse.movie.model.MovieModel | ||
import java.time.format.DateTimeFormatter | ||
|
||
sealed class CustomViewHolder(view: View) : RecyclerView.ViewHolder(view) { | ||
class MovieItemViewHolder(view: View) : CustomViewHolder(view) { | ||
private val image: ImageView = view.findViewById(R.id.img_movie) | ||
private val title: TextView = view.findViewById(R.id.text_title) | ||
private val playingDate: TextView = view.findViewById(R.id.text_playing_date) | ||
private val runningTime: TextView = view.findViewById(R.id.text_running_time) | ||
private val reserveButton: Button = view.findViewById(R.id.btn_reserve) | ||
|
||
fun set(movie: MovieModel, clickListener: View.OnClickListener) { | ||
val context = title.context | ||
image.setImageResource(movie.image) | ||
title.text = movie.title | ||
playingDate.text = context.getString( | ||
R.string.playing_date_range, | ||
DateTimeFormatter.ofPattern(context.getString(R.string.date_format)) | ||
.format(movie.startDate), | ||
DateTimeFormatter.ofPattern(context.getString(R.string.date_format)) | ||
.format(movie.endDate), | ||
) | ||
runningTime.text = context.getString(R.string.running_time, movie.runningTime) | ||
reserveButton.setOnClickListener(clickListener) | ||
} | ||
} | ||
|
||
class AdItemViewHolder(view: View) : CustomViewHolder(view) { | ||
private val image: ImageView = view.findViewById(R.id.img_ad) | ||
fun set(@DrawableRes resId: Int) { | ||
image.setImageResource(resId) | ||
} | ||
} | ||
} |
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
78 changes: 25 additions & 53 deletions
78
app/src/main/java/woowacourse/movie/activity/movielist/MovieListAdapter.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,81 +1,53 @@ | ||
package woowacourse.movie.activity.movielist | ||
|
||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.View.OnClickListener | ||
import android.view.ViewGroup | ||
import android.widget.Button | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import woowacourse.movie.R | ||
import woowacourse.movie.model.ListViewType | ||
import woowacourse.movie.model.MovieModel | ||
import java.time.format.DateTimeFormatter | ||
|
||
class MovieListAdapter( | ||
private val adInterval: Int, | ||
private val movies: List<MovieModel>, | ||
private val onClick: (MovieModel) -> Unit, | ||
) : | ||
RecyclerView.Adapter<MovieListAdapter.ViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
return when (viewType) { | ||
AD_VIEWTYPE -> { | ||
val view = LayoutInflater.from(parent.context) | ||
.inflate(R.layout.ad_item, parent, false) | ||
ViewHolder(view) | ||
RecyclerView.Adapter<CustomViewHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomViewHolder { | ||
return when (ListViewType.values()[viewType]) { | ||
ListViewType.AD_VIEWTYPE -> { | ||
Log.d("Type", "AD") | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.ad_item, parent, false) | ||
CustomViewHolder.AdItemViewHolder(view) | ||
} | ||
else -> { | ||
val view = LayoutInflater.from(parent.context) | ||
.inflate(R.layout.movie_item, parent, false) | ||
ViewHolder(view) | ||
Log.d("Type", "MOVIE") | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.movie_item, parent, false) | ||
CustomViewHolder.MovieItemViewHolder(view) | ||
} | ||
} | ||
} | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
holder.set(movies[position]) { | ||
onClick(movies[position]) | ||
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) { | ||
when (holder) { | ||
is CustomViewHolder.AdItemViewHolder -> { // ad item | ||
holder.set(R.drawable.ad) | ||
} | ||
is CustomViewHolder.MovieItemViewHolder -> { // movie item | ||
holder.set(movies[position - ((position + 1) / (adInterval + 1))]) { | ||
onClick(movies[position - ((position + 1) / (adInterval + 1))]) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun getItemViewType(position: Int): Int { | ||
if (position != 0 && position % 3 == 0) { | ||
return AD_VIEWTYPE | ||
} | ||
return NORMAL_VIEWTYPE | ||
return ListViewType.getViewType(adInterval, position).ordinal | ||
} | ||
|
||
override fun getItemId(position: Int): Long = position.toLong() | ||
|
||
override fun getItemCount(): Int = movies.size | ||
|
||
class ViewHolder(view: View) : | ||
RecyclerView.ViewHolder(view) { | ||
private val image: ImageView = view.findViewById(R.id.img_movie) | ||
private val title: TextView = view.findViewById(R.id.text_title) | ||
private val playingDate: TextView = view.findViewById(R.id.text_playing_date) | ||
private val runningTime: TextView = view.findViewById(R.id.text_running_time) | ||
private val reserveButton: Button = view.findViewById(R.id.btn_reserve) | ||
|
||
fun set(movie: MovieModel, clickListener: OnClickListener) { | ||
val context = title.context | ||
image.setImageResource(movie.image) | ||
title.text = movie.title | ||
playingDate.text = context.getString( | ||
R.string.playing_date_range, | ||
DateTimeFormatter.ofPattern(context.getString(R.string.date_format)) | ||
.format(movie.startDate), | ||
DateTimeFormatter.ofPattern(context.getString(R.string.date_format)) | ||
.format(movie.endDate), | ||
) | ||
runningTime.text = context.getString(R.string.running_time, movie.runningTime) | ||
reserveButton.setOnClickListener(clickListener) | ||
} | ||
} | ||
|
||
companion object { | ||
private const val AD_VIEWTYPE = 1 | ||
private const val NORMAL_VIEWTYPE = 0 | ||
} | ||
} |
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,12 @@ | ||
package woowacourse.movie.model | ||
|
||
enum class ListViewType { | ||
AD_VIEWTYPE, NORMAL_VIEWTYPE; | ||
|
||
companion object { | ||
fun getViewType(adInterval: Int, position: Int): ListViewType { | ||
if ((position + 1) % (adInterval + 1) == 0) return AD_VIEWTYPE | ||
return NORMAL_VIEWTYPE | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ViewHolder에 sealed class를 활용하셨네요 👍
CustomViewHolder란 이름은 좀 더 고민해보면 좋겠네요 :)