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" />