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

세션 리스트 아이템에 onair 표시하기 #103 완료 #115

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.droidknights.app2020.binding

import android.view.View
import android.webkit.WebView
import android.widget.ImageView
import androidx.databinding.BindingAdapter
Expand All @@ -19,3 +20,12 @@ fun SwipeRefreshLayout.bindRefreshListener(onRefreshListener: SwipeRefreshLayout

@BindingAdapter("webUrl")
fun WebView.bindUrl(value: String?) = value?.let(::loadUrl)

@BindingAdapter(value = ["onAir"])
fun ImageView.setVisibility(onAir: Boolean) {
Copy link
Member

Choose a reason for hiding this comment

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

@takedawon
현재 BindingAdapter는 ImageView의 Extension 기능으로도 정의되어 있습니다.
그래서 모든 ImageView가 이 함수를 호출할 수 있습니다.
일반적으로 setVisibility에서 true/false는 VISIBLE/GONE에 해당되기 때문에, 이 경우 onAir라는 표현이 맞지 않아보이네요.

isInvisible 라는 KTX도 존재하므로 BindingAdapter의 네이밍을 더 일반화할 필요가 있어보이네요.

if (onAir) {
this.visibility = View.VISIBLE
} else {
this.visibility = View.INVISIBLE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ data class Session(
var contents: String? = "",
var speakerName: String? = "",
var speakerDesc: String? = "",
var speakerProfile: String? = ""
var speakerProfile: String? = "",
var isLive:Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ fun Session.asUiModel() =
title = title,
time = time,
tag = tag?.map { Tag(it, true) },
speakerName = speakerName ?: ""
speakerName = speakerName ?: "",
isLive = isLive
)

fun Sponsor.asUiModel() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ data class UiSessionModel(
val title: String,
val time: String,
val tag: List<Tag>?,
val speakerName: String
val speakerName: String,
val isLive:Boolean
)
20 changes: 15 additions & 5 deletions androidapp/app/src/main/res/layout/item_session.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="15dp"
android:paddingTop="15dp"
android:paddingEnd="15dp"
tools:background="@android:color/white">

Expand All @@ -28,7 +26,7 @@
android:textStyle="bold"
app:layout_constraintEnd_toStartOf="@id/cb_alarm"
app:layout_constraintStart_toEndOf="@+id/tvDate"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toTopOf="@+id/tvDate"
tools:text="1년간 토스 앱의 '홈' 탭을 개발하며 쌓은 Learning Share" />

<CheckBox
Expand All @@ -45,19 +43,31 @@
android:id="@+id/tvDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:text="@{item.time}"
android:textColor="#00d0a8"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView"
tools:text="10:45" />

<ImageView
android:id="@+id/imageView"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginTop="2dp"
app:onAir="@{item.isLive}"
app:layout_constraintEnd_toEndOf="@+id/tvDate"
app:layout_constraintStart_toStartOf="@+id/tvDate"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_onair" />

<TextView
android:id="@+id/tvSessionSpeakerName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="12sp"
android:text="@{@string/session_speaker_name_format(item.speakerName)}"
android:textSize="12sp"
app:layout_constraintEnd_toEndOf="@id/tvMemoTitle"
app:layout_constraintStart_toStartOf="@id/tvMemoTitle"
app:layout_constraintTop_toBottomOf="@id/tvMemoTitle"
Expand Down