From 007be817443b710fdbdea3c6fe24b7999ca93352 Mon Sep 17 00:00:00 2001 From: JUNGGWAN KIM Date: Fri, 4 Oct 2024 13:49:00 +0900 Subject: [PATCH] =?UTF-8?q?=EC=98=A4=EC=A0=84/=EC=98=A4=ED=9B=84=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C,=20=EB=82=A0=EC=A7=9C=20=EB=B3=80=ED=99=94?= =?UTF-8?q?=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/home/adapters/WeatherAdapter.kt | 55 +++++++++++++------ app/src/main/res/drawable/date_bg.xml | 15 +++++ .../main/res/layout/item_rec_hourly_dress.xml | 3 +- 3 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 app/src/main/res/drawable/date_bg.xml diff --git a/app/src/main/kotlin/rasel/lunar/launcher/home/adapters/WeatherAdapter.kt b/app/src/main/kotlin/rasel/lunar/launcher/home/adapters/WeatherAdapter.kt index a8059164..1d496f87 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/adapters/WeatherAdapter.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/adapters/WeatherAdapter.kt @@ -1,6 +1,8 @@ package rasel.lunar.launcher.home.adapters import android.annotation.SuppressLint +import android.graphics.Color +import android.support.annotation.ColorInt import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -18,7 +20,8 @@ import java.time.Instant import java.time.ZoneId class WeatherAdapter(private val dataSet: ArrayList): RecyclerView.Adapter(){ - var isShowAmOrPm: Boolean = true + var isChangedAmOrPm: Boolean = true + var day: Int = 0 class ViewHolder(view: View): RecyclerView.ViewHolder(view) { val viewItem: View @@ -51,34 +54,54 @@ class WeatherAdapter(private val dataSet: ArrayList): RecyclerView.Adapter return ViewHolder(view) } + @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: ViewHolder, position: Int) { val data = dataSet[position] as? Hour BLog.LOGE("saved weatherForcast >>> asFlow ${dataSet.size}") data?.let { holder.viewItem.findViewById(R.id.amOrPm) - .run { - this.text = Instant.ofEpochSecond(it.time_epoch.toLong()) + .apply { + Instant.ofEpochSecond(it.time_epoch.toLong()) .atZone(ZoneId.systemDefault()) .hour .run { - if (this < 12) "오전" else "오후" + this@apply.text = if (this < 12) "오전" else "오후" + isChangedAmOrPm = when (this) { + 12, 0 -> true + else -> false + } } + this.visibility = if (isChangedAmOrPm || position == 0) View.VISIBLE else View.INVISIBLE } holder.viewItem.findViewById(R.id.hour) - .run { - val hour = Instant.ofEpochSecond(it.time_epoch.toLong()) + .apply { + this.isSelected = (System.currentTimeMillis() % 3 == 0L) + Instant.ofEpochSecond(it.time_epoch.toLong()) .atZone(ZoneId.systemDefault()) - .hour - .toString() - this.text = "${hour}시" + .run { + if (this.hour == 0) { + this@apply.setTextColor(Color.BLACK) + this@apply.isSelected = true + this@apply.text = when (day++) { + 1 -> "내일" + 2 -> "모레" + 3 -> "글피" + else -> "${this.dayOfMonth}일" + } + } else { + this@apply.setTextColor(Color.WHITE) + this@apply.isSelected = false + this@apply.text = "${this.hour}시" + } + } + holder.viewItem.findViewById(R.id.imgDress) + .run { this.setImageResource(R.drawable.ico_time) } + holder.viewItem.findViewById(R.id.temperature) + .run { + this.text = "${it.temp_c}도" + } } - holder.viewItem.findViewById(R.id.imgDress) - .run { this.setImageResource(R.drawable.ico_time) } - holder.viewItem.findViewById(R.id.temperature) - .run { - this.text = "${it.temp_c}도" - } - } + } } override fun getItemCount(): Int = dataSet.size diff --git a/app/src/main/res/drawable/date_bg.xml b/app/src/main/res/drawable/date_bg.xml new file mode 100644 index 00000000..0a417cf5 --- /dev/null +++ b/app/src/main/res/drawable/date_bg.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_rec_hourly_dress.xml b/app/src/main/res/layout/item_rec_hourly_dress.xml index 0f796636..8a50a12a 100644 --- a/app/src/main/res/layout/item_rec_hourly_dress.xml +++ b/app/src/main/res/layout/item_rec_hourly_dress.xml @@ -16,10 +16,11 @@ android:fontFamily="sans-serif-medium" android:textSize="14sp" />