Skip to content

Commit b671acb

Browse files
Merge pull request #124 from muth0mi/issue-99
Issue 99
2 parents e32ce33 + 7d3ca94 commit b671acb

File tree

15 files changed

+207
-59
lines changed

15 files changed

+207
-59
lines changed

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<color name="colorBlack">#191d1d</color>
4848
<color name="colorWhite">#ffffff</color>
4949
<color name="colorYellow">#ffd858</color>
50+
<color name="colorYellowFaded">#8DFFD858</color>
5051
<color name="superLightPurple">#0D843D95</color>
5152
<color name="colorAquaMarineFaded">#1D68DEA4</color>
5253
<color name="colorRevolver">#241527</color>

buildSrc/local.properties

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
# Location of the SDK. This is only used by Gradle.
55
# For customization when using a Version Control System, please read the
66
# header note.
7-
<<<<<<< HEAD
8-
#Mon Apr 13 02:46:54 EAT 2020
9-
=======
10-
#Sat Apr 11 01:32:35 EAT 2020
11-
>>>>>>> 0e9f7f6... Refactor speaker module into the speakers module
12-
sdk.dir=/home/oly/Programs/Android/sdk
7+
#Sat May 02 22:10:28 EAT 2020
8+
>>>>>>>=0e9f7f6... Refactor speaker module into the speakers module
9+
sdk.dir=/home/oly/Programs/AndroidSdk
10+
=\=\=\=\=\=\=
11+
<<<<<<<=HEAD

features/home/src/main/java/com/android254/droidconKE2020/home/domain/Session.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package com.android254.droidconKE2020.home.domain
22

33
data class Session(
44
val id: Long,
5+
val title: String,
56
val description: String,
67
val time: String,
78
val room: String,
8-
val imageUrl: String
9+
val imageUrl: String,
10+
val speaker: Speaker
911
)

features/home/src/main/java/com/android254/droidconKE2020/home/domain/Speaker.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package com.android254.droidconKE2020.home.domain
22

33
data class Speaker(
4-
val id: Int,
4+
val id: Int = 0,
55
val name: String,
6-
val bio: String,
7-
val work: String,
8-
val company: String,
9-
val skills: List<String>,
10-
val imageUrl: String,
11-
val stars: List<Int>,
12-
val socialMedia: SocialMedia,
6+
val bio: String = "",
7+
val work: String = "",
8+
val company: String = "",
9+
val skills: List<String> = listOf(),
10+
val imageUrl: String = "",
11+
val stars: List<Int> = listOf(),
12+
val socialMedia: SocialMedia = SocialMedia(""),
1313
val isKeynoteSpeaker: Boolean = false
1414
)
1515

features/home/src/main/java/com/android254/droidconKE2020/home/ui/adapters/SessionAdapter.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package com.android254.droidconKE2020.home.ui.adapters
33
import android.view.LayoutInflater
44
import android.view.View
55
import android.view.ViewGroup
6+
import androidx.core.content.ContextCompat
67
import androidx.navigation.findNavController
78
import androidx.recyclerview.widget.RecyclerView
89
import coil.api.load
910
import com.android254.droidconKE2020.home.R
1011
import com.android254.droidconKE2020.home.domain.Session
1112
import com.android254.droidconKE2020.home.ui.views.HomeFragmentDirections
1213
import kotlinx.android.synthetic.main.home_item_session.view.*
14+
import com.android254.droidconKE2020.R as appR
1315

1416
class SessionAdapter : RecyclerView.Adapter<SessionAdapter.SessionViewHolder>() {
1517

@@ -24,7 +26,7 @@ class SessionAdapter : RecyclerView.Adapter<SessionAdapter.SessionViewHolder>()
2426

2527
override fun onBindViewHolder(holder: SessionViewHolder, position: Int) {
2628
val session = sessions[position]
27-
holder.bindSession(session)
29+
holder.bindSession(session, position)
2830
}
2931

3032
fun updateData(list: List<Session>) {
@@ -35,9 +37,21 @@ class SessionAdapter : RecyclerView.Adapter<SessionAdapter.SessionViewHolder>()
3537

3638
inner class SessionViewHolder(private val view: View) : RecyclerView.ViewHolder(view) {
3739

38-
fun bindSession(session: Session) {
40+
fun bindSession(session: Session, position: Int) {
41+
view.sessionImg.apply {
42+
val colorId = if (position % 2 == 0) appR.color.colorBermudaFaded
43+
else appR.color.colorYellowFaded
44+
45+
val bgColor = ContextCompat.getColor(context, colorId)
46+
setBackgroundColor(bgColor)
47+
}
3948
with(session) {
40-
view.sessionImg.load(imageUrl.toInt()) // ToDo: Remove the int cast upon introducing real data
49+
view.imgAvatar.load(speaker.imageUrl)
50+
view.tvSessionTitle.text = "$title:"
51+
view.tvSessionDescription.text = description
52+
view.tvSpeakerName.text = speaker.name
53+
view.tvSpeakerDelegation.text =
54+
"${speaker.work}${if (!speaker.company.isBlank()) ", " + speaker.company else ""}"
4155
view.time.text = time
4256
view.room.text = room
4357
view.description.text = description

features/home/src/main/java/com/android254/droidconKE2020/home/ui/views/HomeFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
153153

154154
val adapter = SessionAdapter()
155155
binding.sessionsList.adapter = adapter
156-
binding.sessionsList.addItemDecoration(HorizontalSpaceDecoration(20))
156+
binding.sessionsList.addItemDecoration(HorizontalSpaceDecoration(30))
157157

158158
homeViewModel.sessionList.observe(viewLifecycleOwner, Observer { sessions ->
159159
if (sessions == null) {

features/home/src/main/java/com/android254/droidconKE2020/home/viewmodel/HomeViewModel.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ package com.android254.droidconKE2020.home.viewmodel
33
import androidx.lifecycle.MutableLiveData
44
import androidx.lifecycle.ViewModel
55
import com.android254.droidconKE2020.home.R
6-
import com.android254.droidconKE2020.home.domain.Organizer
7-
import com.android254.droidconKE2020.home.domain.Promotion
8-
import com.android254.droidconKE2020.home.domain.Session
9-
import com.android254.droidconKE2020.home.domain.Sponsor
6+
import com.android254.droidconKE2020.home.domain.*
107
import com.android254.droidconKE2020.home.repositories.FakeSpeakerRepository
8+
import com.github.javafaker.Faker
119

1210
class HomeViewModel(
1311
private val promotionRepository: FakePromotionRepository,
@@ -99,10 +97,16 @@ class FakeSessionRepository {
9997
db.add(
10098
Session(
10199
id = i.toLong(),
100+
title = if (i == 0) "KeyNote" else if (i % 2 == 0) "Kotlin Garbage Collection" else "Yet Another Architecture",
102101
description = "Some short description",
103102
room = "Room $i",
104103
time = "10:5$i",
105-
imageUrl = "${R.drawable.dummy_session_image}"
104+
imageUrl = "${R.drawable.dummy_session_image}",
105+
speaker = Speaker(
106+
name = "Don Felker",
107+
work = "Software Developer / Podcast Host",
108+
imageUrl = Faker().avatar().image()
109+
)
106110
)
107111
)
108112
}
11.1 KB
Loading
6.41 KB
Loading
5.88 KB
Loading

0 commit comments

Comments
 (0)