Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.

Commit 1f7de07

Browse files
committed
Add learn screen.
Change-Id: I01bd0fd816304e8c85f00ec6bbee0e0bc917083d
1 parent c964817 commit 1f7de07

38 files changed

+1398
-106
lines changed

app/src/main/java/com/materialstudies/owl/model/Course.kt

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ data class Course(
2222
val id: Long,
2323
val name: String,
2424
val subject: String,
25-
val thumb: String,
25+
val thumbUrl: String,
2626
val thumbContentDesc: String,
27+
val description: String = "",
2728
val steps: Int,
2829
val step: Int,
29-
val instructor: String
30+
val instructor: String = "https://i.pravatar.cc/112?$id"
3031
)
3132

3233
object CourseDiff : DiffUtil.ItemCallback<Course>() {
@@ -39,120 +40,119 @@ val courses = listOf(
3940
id = 0,
4041
name = "Basic Blocks and Woodturning",
4142
subject = "Arts & Crafts",
42-
thumb = "",
43+
thumbUrl = "https://source.unsplash.com/oJ7SV6vQfBA",
4344
thumbContentDesc = "",
4445
steps = 7,
45-
step = 1,
46-
instructor = ""
46+
step = 1
4747
),
4848
Course(
4949
id = 1,
5050
name = "An Introduction To Oil Painting On Canvas",
5151
subject = "Painting",
52-
thumb = "",
52+
thumbUrl = "https://source.unsplash.com/W9_sznrBmoA",
5353
thumbContentDesc = "",
5454
steps = 12,
55-
step = 1,
56-
instructor = ""
55+
step = 1
5756
),
5857
Course(
5958
id = 2,
6059
name = "Understanding the Composition of Modern Cities",
6160
subject = "Architecture",
62-
thumb = "",
61+
thumbUrl = "https://source.unsplash.com/s4I1xpX_ny8",
6362
thumbContentDesc = "",
6463
steps = 18,
65-
step = 1,
66-
instructor = ""
64+
step = 1
6765
),
6866
Course(
69-
id = 2,
67+
id = 3,
7068
name = "Learning The Basics of Brand Identity",
7169
subject = "Design",
72-
thumb = "",
70+
thumbUrl = "https://source.unsplash.com/G9_Euqxpu4k",
7371
thumbContentDesc = "",
7472
steps = 22,
75-
step = 1,
76-
instructor = ""
73+
step = 1
7774
),
7875
Course(
79-
id = 2,
76+
id = 4,
8077
name = "Wooden Materials and Sculpting Machinery",
8178
subject = "Arts & Crafts",
82-
thumb = "",
79+
thumbUrl = "https://source.unsplash.com/o54RjF-C7xo",
8380
thumbContentDesc = "",
8481
steps = 19,
85-
step = 1,
86-
instructor = ""
82+
step = 1
8783
),
8884
Course(
89-
id = 2,
85+
id = 5,
9086
name = "Advanced Potter's Wheel",
9187
subject = "Arts & Crafts",
92-
thumb = "",
88+
thumbUrl = "https://source.unsplash.com/-LHvba-FgAo",
9389
thumbContentDesc = "",
9490
steps = 14,
95-
step = 1,
96-
instructor = ""
91+
step = 1
9792
),
9893
Course(
99-
id = 2,
100-
name = "Advanced Abstract Shapes & 3D",
94+
id = 6,
95+
name = "Advanced Abstract Shapes & 3D Printing",
10196
subject = "Arts & Crafts",
102-
thumb = "",
97+
thumbUrl = "https://source.unsplash.com/HQkz_lWT_lY",
10398
thumbContentDesc = "",
10499
steps = 17,
105-
step = 1,
106-
instructor = ""
100+
step = 1
107101
),
108102
Course(
109-
id = 2,
103+
id = 7,
110104
name = "Beginning Portraiture",
111105
subject = "Photography",
112-
thumb = "",
106+
thumbUrl = "https://source.unsplash.com/LE0Hp8l9gvs",
113107
thumbContentDesc = "",
114108
steps = 22,
115-
step = 1,
116-
instructor = ""
109+
step = 1
117110
),
118111
Course(
119-
id = 2,
112+
id = 8,
120113
name = "Intermediate Knife Skills",
121114
subject = "Culinary",
122-
thumb = "",
115+
thumbUrl = "https://source.unsplash.com/f1xj_KeZ5RM",
123116
thumbContentDesc = "",
124117
steps = 14,
125-
step = 1,
126-
instructor = ""
118+
step = 1
127119
),
128120
Course(
129-
id = 2,
130-
name = "Pattern Making for Begginers",
121+
id = 9,
122+
name = "Pattern Making for Beginners",
131123
subject = "Fashion",
132-
thumb = "",
124+
thumbUrl = "https://source.unsplash.com/hew8-OoUriU",
133125
thumbContentDesc = "",
134126
steps = 7,
135-
step = 1,
136-
instructor = ""
127+
step = 1
137128
),
138129
Course(
139-
id = 2,
130+
id = 10,
140131
name = "Location Lighting for Beginners",
141132
subject = "Photography",
142-
thumb = "",
133+
thumbUrl = "https://source.unsplash.com/pPxJTtxfV1A",
143134
thumbContentDesc = "",
144135
steps = 6,
145-
step = 1,
146-
instructor = ""
136+
step = 1
147137
),
148138
Course(
149-
id = 2,
139+
id = 11,
150140
name = "Cinematography & Lighting",
151141
subject = "Film",
152-
thumb = "",
142+
thumbUrl = "https://source.unsplash.com/oIf4VCDztZY",
143+
thumbContentDesc = "",
144+
steps = 4,
145+
step = 1
146+
),
147+
Course(
148+
id = 12,
149+
name = "Monuments, Buildings & Other Structures",
150+
subject = "Photography",
151+
thumbUrl = "https://source.unsplash.com/KxCJXXGsv9I",
153152
thumbContentDesc = "",
153+
description = "This video course introduces the photography of structures, including " +
154+
"urban and rural buildings, monuments, and less traditional structures. Instruction includes the handling of equipment and methods used to capture building interiors and exteriors. The discussion will be about the handling of distortion, varied light sources, and perspective.",
154155
steps = 4,
155-
step = 1,
156-
instructor = ""
156+
step = 1
157157
)
158158
)
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright 2019 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.materialstudies.owl.model
18+
19+
import androidx.recyclerview.widget.DiffUtil
20+
21+
data class Lesson(
22+
val title: String,
23+
val formattedSteps: String,
24+
val length: String,
25+
val thumbUrl: String,
26+
val thumbContentDescription: String = ""
27+
)
28+
29+
object LessonDiff : DiffUtil.ItemCallback<Lesson>() {
30+
override fun areItemsTheSame(oldItem: Lesson, newItem: Lesson) = oldItem.title == newItem.title
31+
override fun areContentsTheSame(oldItem: Lesson, newItem: Lesson) = oldItem == newItem
32+
}
33+
34+
val lessons = listOf(
35+
Lesson(
36+
title = "An introduction to the Landscape",
37+
formattedSteps = "01",
38+
length = "4:14",
39+
thumbUrl = "https://source.unsplash.com/NRQV-hBF10M"
40+
),
41+
Lesson(
42+
title = "Movement and Expression",
43+
formattedSteps = "02",
44+
length = "7:28",
45+
thumbUrl = "https://source.unsplash.com/JhqhGfX_Wd8"
46+
),
47+
Lesson(
48+
title = "Composition and the Urban Canvas",
49+
formattedSteps = "03",
50+
length = "3:43",
51+
thumbUrl = "https://source.unsplash.com/0OjzOqlJyoU"
52+
),
53+
Lesson(
54+
title = "Lighting Techniques and Aesthetics",
55+
formattedSteps = "04",
56+
length = "4:45",
57+
thumbUrl = "https://source.unsplash.com/J5-Kqu_fxyo"
58+
),
59+
Lesson(
60+
title = "Special Effects",
61+
formattedSteps = "05",
62+
length = "6:19",
63+
thumbUrl = "https://source.unsplash.com/9ZCZoH69dZQ"
64+
),
65+
Lesson(
66+
title = "Techniques with Structures",
67+
formattedSteps = "06",
68+
length = "9:41",
69+
thumbUrl = "https://source.unsplash.com/RFDP7_80v5A"
70+
),
71+
Lesson(
72+
title = "Deep Focus Using a Camera Dolly",
73+
formattedSteps = "07",
74+
length = "4:43",
75+
thumbUrl = "https://source.unsplash.com/0rZ2-QWtkwY"
76+
),
77+
Lesson(
78+
title = "Point of View Shots with Structures",
79+
formattedSteps = "08",
80+
length = "9:41",
81+
thumbUrl = "https://source.unsplash.com/iQnR_xEsBj0"
82+
),
83+
Lesson(
84+
title = "Photojournalism: Street Art",
85+
formattedSteps = "09",
86+
length = "9:41",
87+
thumbUrl = "https://source.unsplash.com/qX9Ie7ieb1E"
88+
)
89+
)

app/src/main/java/com/materialstudies/owl/ui/featured/FeaturedAdapter.kt

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ package com.materialstudies.owl.ui.featured
1818

1919
import android.view.LayoutInflater
2020
import android.view.ViewGroup
21+
import androidx.navigation.Navigation.findNavController
22+
import androidx.navigation.fragment.findNavController
2123
import androidx.recyclerview.widget.ListAdapter
2224
import androidx.recyclerview.widget.RecyclerView
2325
import com.bumptech.glide.Glide
@@ -33,12 +35,16 @@ class FeaturedAdapter : ListAdapter<Course, FeaturedViewHolder>(CourseDiff) {
3335
LayoutInflater.from(parent.context),
3436
parent,
3537
false
36-
)
38+
).apply {
39+
root.setOnClickListener {
40+
findNavController(it).navigate(R.id.learn)
41+
}
42+
}
3743
return FeaturedViewHolder(binding)
3844
}
3945

4046
override fun onBindViewHolder(holder: FeaturedViewHolder, position: Int) {
41-
holder.bind(getItem(position), position)
47+
holder.bind(getItem(position))
4248
}
4349

4450
}
@@ -47,17 +53,9 @@ class FeaturedViewHolder(
4753
private val binding: FeaturedItemBinding
4854
) : RecyclerView.ViewHolder(binding.root) {
4955

50-
fun bind(course: Course, position: Int) {
56+
fun bind(course: Course) {
5157
binding.run {
5258
this.course = course
53-
Glide.with(courseImage)
54-
.load("https://source.unsplash.com/collection/369966/?$position")
55-
.placeholder(R.drawable.course_image_placeholder)
56-
.into(courseImage)
57-
Glide.with(courseInstructor)
58-
.load("https://i.pravatar.cc/56?$position")
59-
.circleCrop()
60-
.into(courseInstructor)
6159
executePendingBindings()
6260
}
6361
}

0 commit comments

Comments
 (0)