Skip to content
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

HW-4 DataBinding 적용 #543

Merged
merged 13 commits into from Mar 28, 2020
Merged

HW-4 DataBinding 적용 #543

merged 13 commits into from Mar 28, 2020

Conversation

mtjin
Copy link
Contributor

@mtjin mtjin commented Mar 23, 2020

No description provided.

@mtjin mtjin added the Review Needed 리뷰어의 리뷰가 필요한 경우 label Mar 23, 2020
@mtjin mtjin self-assigned this Mar 23, 2020
val linearLayoutManager = LinearLayoutManager(this)
rvMovies.layoutManager = linearLayoutManager
binding.rvMovies.layoutManager = linearLayoutManager
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LayoutManager는 xml에서 설정 할 수 있어요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5d6aff2
수정했습니다.

Comment on lines 26 to 48
android:id="@+id/et_input"
android:layout_width="0dp"
android:layout_height="0dp"
android:hint="입력"
android:inputType="text"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintEnd_toStartOf="@+id/btn_search"
app:layout_constraintHorizontal_weight="8"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/btn_search"
android:layout_width="0dp"
android:layout_height="0dp"
android:onClick="@{()->search.onSearchClick()}"
android:text="검색"
app:layout_constraintBottom_toTopOf="@id/guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_weight="2"
app:layout_constraintStart_toEndOf="@+id/et_input"
app:layout_constraintTop_toTopOf="parent" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xml에서도 텍스트는 string.xml에서 관리해주는 습관이 좋아요

string.xml에서 텍스트를 관리하면, 기기의 언어가 바뀔 때 바뀐 언어의 string.xml에서 id에 해당하는 텍스트값을 가져와 자연스럽게 다국어 지원이 가능하기도 해요

ex)
values-ko/string.xml
로그인

values-en/string.xml
login

그리고 의 text가 android:text="@string/login_btn"이면, 기기의 설정이 영어일땐 login을, 한글일 땐 로그인을 가져오게 되요

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

android studio 에서
Analyze - Run Inspection by Name 에서
hard coded string / hard coded text를 검색하면 내 프로젝트에 하드 코딩된 텍스트나 스트링 값을 쉽게 검색할 수 있기도 합니다 ㅎㅎ

@kangraemin kangraemin added Answer Needed PR담당자의 응답이 필요한 경우 and removed Review Needed 리뷰어의 리뷰가 필요한 경우 labels Mar 23, 2020
@mtjin mtjin added Review Needed 리뷰어의 리뷰가 필요한 경우 and removed Answer Needed PR담당자의 응답이 필요한 경우 labels Mar 24, 2020
Comment on lines +51 to +52
scrollListener = object :
EndlessRecyclerViewScrollListener(binding.rvMovies.layoutManager as LinearLayoutManager) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

커밋에 xml에 linearlayoutManager 추가하는 코드가 빠진것같아요 ~~

Copy link
Contributor Author

@mtjin mtjin Mar 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존에 xml에 linearlayoutManager 추가 되있었습니다~
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗그렇군요 ... 제가못봤었네요 @sooakim approve하였습니다 ~~

@kangraemin kangraemin self-requested a review March 24, 2020 13:24
@kangraemin kangraemin added Answer Needed PR담당자의 응답이 필요한 경우 and removed Review Needed 리뷰어의 리뷰가 필요한 경우 labels Mar 24, 2020
@mtjin mtjin added Review Needed 리뷰어의 리뷰가 필요한 경우 and removed Answer Needed PR담당자의 응답이 필요한 경우 labels Mar 24, 2020
@sjjeong
Copy link
Collaborator

sjjeong commented Mar 25, 2020

@kangraemin
approve 하시면 mentor needed 라벨도 추가해주셔야 합니다.


@BindingAdapter("bind:urlImage")
fun setUrlImage(imageView: ImageView, url: String) {
Glide.with(imageView.context).load(url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glide.with를 쓸 때 imageView.context대신 imageView를 넣어주세요.
with를 통해 넘어오는 파라미터의 생명주기에 따라 RequestManager 인스턴스를 자동으로 관리 해주는데 imageView.context를 쓰면 View가 어디에 위치하던지 activity의 생명주기를 따르게 돼요.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1aef5d3
수정했습니다.

Comment on lines 15 to 19
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
textView.text = Html.fromHtml(html, Html.FROM_HTML_MODE_COMPACT)
} else {
textView.text = Html.fromHtml(html)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이부분은 HtmlCompat을 써서 버전 분기 없이 한줄로 줄 일 수 있어요.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

af549d9
수정했습니다.

import com.mtjin.androidarchitecturestudy.R


@BindingAdapter("bind:htmlText")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

android:text와 같이 기본 attr에 대한 어댑터를 사용할 때는 prefix가 필요하지만 그 경우가 아니라면 bind prefix를 붙일 필요가 없어요.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

88f5031
수정했습니다.

}
}

@BindingAdapter("bind:urlImage")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind: 제거

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.into(imageView)
}

@BindingAdapter("bind:movieRating")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind: 제거

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtjin xml에서는 유지해주세요.
BindingAdapter에서 bind를 붙이지 않았더라도, xml에서는 bind를 붙일 수 있어요.
사실 xml에서는 아무거나 같다붙여도 동작하고, prefix가 없어도 동작해요. bind는 아무의미가 없기때문이죠. xml에서 bind를 붙여주는건 단순히 다른 attr과의 구분을 줘서 가독성을 높이기위해서에요.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

af06d28
수정했습니다.

@sooakim sooakim added Answer Needed PR담당자의 응답이 필요한 경우 and removed Review Needed 리뷰어의 리뷰가 필요한 경우 labels Mar 25, 2020
@mtjin mtjin added Review Needed 리뷰어의 리뷰가 필요한 경우 and removed Answer Needed PR담당자의 응답이 필요한 경우 labels Mar 25, 2020
@sooakim sooakim added Answer Needed PR담당자의 응답이 필요한 경우 and removed Review Needed 리뷰어의 리뷰가 필요한 경우 labels Mar 25, 2020
@mtjin mtjin added Review Needed 리뷰어의 리뷰가 필요한 경우 and removed Answer Needed PR담당자의 응답이 필요한 경우 labels Mar 25, 2020
@sooakim sooakim added Answer Needed PR담당자의 응답이 필요한 경우 Mentor Needed 멘토가 필요한 경우 Review Needed 리뷰어의 리뷰가 필요한 경우 and removed Review Needed 리뷰어의 리뷰가 필요한 경우 Answer Needed PR담당자의 응답이 필요한 경우 labels Mar 26, 2020
@sooakim sooakim self-requested a review March 26, 2020 06:07
Copy link
Collaborator

@sjjeong sjjeong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ✊ ✌️ 👋

@sjjeong sjjeong added Merge Needed 모든 리뷰어가 Approve를 한 경우 and removed Review Needed 리뷰어의 리뷰가 필요한 경우 labels Mar 27, 2020
@mtjin mtjin merged commit 22e31a2 into StudyFork:2003/mtjin Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mentor Needed 멘토가 필요한 경우 Merge Needed 모든 리뷰어가 Approve를 한 경우
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants