Skip to content

Commit de19686

Browse files
Improve adapter constructors
1 parent de4acbb commit de19686

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

app/src/main/java/guide/graphql/toc/ui/chapters/ChaptersAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import guide.graphql.toc.R
1010
import guide.graphql.toc.databinding.ChapterBinding
1111

1212
class ChaptersAdapter(
13-
private var chapters: List<ChaptersQuery.Chapter>,
1413
private val context: Context,
14+
private var chapters: List<ChaptersQuery.Chapter> = listOf(),
1515
private val onItemClicked: ((ChaptersQuery.Chapter) -> Unit)
1616
) :
1717
RecyclerView.Adapter<ChaptersAdapter.ViewHolder>() {

app/src/main/java/guide/graphql/toc/ui/chapters/ChaptersFragment.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class ChaptersFragment : Fragment() {
4545
requireActivity()
4646
val adapter =
4747
ChaptersAdapter(
48-
listOf(),
4948
requireContext()
5049
) { chapter ->
5150
findNavController().navigate(

app/src/main/java/guide/graphql/toc/ui/sections/SectionsAdapter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import guide.graphql.toc.SectionsQuery
99
import guide.graphql.toc.databinding.SectionBinding
1010

1111
class SectionsAdapter(
12-
private val chapterNumber: Int?,
13-
private var sections: List<SectionsQuery.Section?>,
14-
private val context: Context
12+
private val context: Context,
13+
private val chapterNumber: Int,
14+
private var sections: List<SectionsQuery.Section?> = listOf()
1515
) :
1616
RecyclerView.Adapter<SectionsAdapter.ViewHolder>() {
1717

app/src/main/java/guide/graphql/toc/ui/sections/SectionsFragment.kt

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,11 @@ class SectionsFragment : Fragment() {
4646

4747
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
4848
super.onViewCreated(view, savedInstanceState)
49-
// val activity = (requireActivity() as AppCompatActivity)
50-
// activity.setSupportActionBar(binding.chapterHeader)
51-
// activity.supportActionBar?.setDisplayHomeAsUpEnabled(true)
52-
//
53-
// binding.chapterHeader.setNavigationOnClickListener {
54-
// findNavController().navigateUp()
55-
// }
56-
//
57-
// binding.chapterHeader.setNavigationIcon(R.drawable.ic_baseline_arrow_back_24)
58-
// activity.title =
59-
// if (args.chapterNumber == -1) args.chapterTitle else getString(
60-
// R.string.chapter_title,
61-
// args.chapterNumber.toString(),
62-
// args.chapterTitle
63-
// )
6449

6550
val adapter =
6651
SectionsAdapter(
67-
args.chapterNumber,
68-
listOf(),
69-
requireContext()
52+
requireContext(),
53+
args.chapterNumber
7054
)
7155
val layoutManager = LinearLayoutManager(requireContext())
7256
binding.sections.layoutManager = layoutManager

0 commit comments

Comments
 (0)