diff --git a/.idea/misc.xml b/.idea/misc.xml index 0076403..4e369b6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -11,7 +11,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 0076403..4e369b6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -11,7 +11,7 @@ - + diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt index 8dc2310..bb402f8 100644 --- a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt @@ -11,44 +11,15 @@ package com.lukas.music.ui.adapters import android.view.LayoutInflater -import android.view.View import android.view.ViewGroup -import android.widget.AdapterView -import android.widget.ArrayAdapter import androidx.recyclerview.widget.RecyclerView import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument -import com.lukas.music.instruments.Waveform import com.lukas.music.ui.fragments.InstrumentListFragment class InstrumentAdapter(val parent: InstrumentListFragment) : - RecyclerView.Adapter() { - class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : - RecyclerView.ViewHolder(binding.root), AdapterView.OnItemSelectedListener { - lateinit var instrument: Instrument - - init { - val adapter = ArrayAdapter( - binding.root.context, - android.R.layout.simple_spinner_dropdown_item, Waveform.VALUES - ) - binding.waveformSelection.adapter = adapter - binding.waveformSelection.onItemSelectedListener = this - } - - override fun onItemSelected( - adapterView: AdapterView<*>?, - view: View?, - position: Int, - id: Long - ) { - instrument.waveform = Waveform.VALUES[position] - } - - override fun onNothingSelected(adapterView: AdapterView<*>?) { - } - } + RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): InstrumentViewHolder { val context = parent.context diff --git a/.idea/misc.xml b/.idea/misc.xml index 0076403..4e369b6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -11,7 +11,7 @@ - + diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt index 8dc2310..bb402f8 100644 --- a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt @@ -11,44 +11,15 @@ package com.lukas.music.ui.adapters import android.view.LayoutInflater -import android.view.View import android.view.ViewGroup -import android.widget.AdapterView -import android.widget.ArrayAdapter import androidx.recyclerview.widget.RecyclerView import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument -import com.lukas.music.instruments.Waveform import com.lukas.music.ui.fragments.InstrumentListFragment class InstrumentAdapter(val parent: InstrumentListFragment) : - RecyclerView.Adapter() { - class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : - RecyclerView.ViewHolder(binding.root), AdapterView.OnItemSelectedListener { - lateinit var instrument: Instrument - - init { - val adapter = ArrayAdapter( - binding.root.context, - android.R.layout.simple_spinner_dropdown_item, Waveform.VALUES - ) - binding.waveformSelection.adapter = adapter - binding.waveformSelection.onItemSelectedListener = this - } - - override fun onItemSelected( - adapterView: AdapterView<*>?, - view: View?, - position: Int, - id: Long - ) { - instrument.waveform = Waveform.VALUES[position] - } - - override fun onNothingSelected(adapterView: AdapterView<*>?) { - } - } + RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): InstrumentViewHolder { val context = parent.context diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt new file mode 100644 index 0000000..aeb1078 --- /dev/null +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2022 Lukas Eisenhauer + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + */ + +package com.lukas.music.ui.adapters + +import androidx.recyclerview.widget.RecyclerView +import com.lukas.music.databinding.FragmentInstrumentBinding +import com.lukas.music.instruments.Instrument + +class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : + RecyclerView.ViewHolder(binding.root) { + lateinit var instrument: Instrument +} \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0076403..4e369b6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -11,7 +11,7 @@ - + diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt index 8dc2310..bb402f8 100644 --- a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt @@ -11,44 +11,15 @@ package com.lukas.music.ui.adapters import android.view.LayoutInflater -import android.view.View import android.view.ViewGroup -import android.widget.AdapterView -import android.widget.ArrayAdapter import androidx.recyclerview.widget.RecyclerView import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument -import com.lukas.music.instruments.Waveform import com.lukas.music.ui.fragments.InstrumentListFragment class InstrumentAdapter(val parent: InstrumentListFragment) : - RecyclerView.Adapter() { - class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : - RecyclerView.ViewHolder(binding.root), AdapterView.OnItemSelectedListener { - lateinit var instrument: Instrument - - init { - val adapter = ArrayAdapter( - binding.root.context, - android.R.layout.simple_spinner_dropdown_item, Waveform.VALUES - ) - binding.waveformSelection.adapter = adapter - binding.waveformSelection.onItemSelectedListener = this - } - - override fun onItemSelected( - adapterView: AdapterView<*>?, - view: View?, - position: Int, - id: Long - ) { - instrument.waveform = Waveform.VALUES[position] - } - - override fun onNothingSelected(adapterView: AdapterView<*>?) { - } - } + RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): InstrumentViewHolder { val context = parent.context diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt new file mode 100644 index 0000000..aeb1078 --- /dev/null +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2022 Lukas Eisenhauer + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + */ + +package com.lukas.music.ui.adapters + +import androidx.recyclerview.widget.RecyclerView +import com.lukas.music.databinding.FragmentInstrumentBinding +import com.lukas.music.instruments.Instrument + +class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : + RecyclerView.ViewHolder(binding.root) { + lateinit var instrument: Instrument +} \ No newline at end of file diff --git a/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt index d933194..05b471f 100644 --- a/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt +++ b/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt @@ -10,17 +10,21 @@ package com.lukas.music.ui.fragments +import android.R import android.os.Bundle import android.text.Editable import android.text.TextWatcher import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.AdapterView +import android.widget.ArrayAdapter import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager import com.lukas.music.databinding.FragmentEditInstrumentBinding import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument +import com.lukas.music.instruments.Waveform class EditInstrumentFragment( private val instrument: Instrument, @@ -45,6 +49,24 @@ instrument.applyToView(parent, manager) } }) + val adapter = ArrayAdapter( + binding.root.context, + R.layout.simple_spinner_dropdown_item, Waveform.VALUES + ) + binding.waveformSelection.adapter = adapter + binding.waveformSelection.onItemSelectedListener = + object : AdapterView.OnItemSelectedListener { + override fun onItemSelected( + parent: AdapterView<*>?, + view: View?, + position: Int, + id: Long + ) { + instrument.waveform = Waveform.VALUES[position] + } + + override fun onNothingSelected(parent: AdapterView<*>?) {} + } binding.closeButton.setOnClickListener { dismiss() } diff --git a/.idea/misc.xml b/.idea/misc.xml index 0076403..4e369b6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -11,7 +11,7 @@ - + diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt index 8dc2310..bb402f8 100644 --- a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt @@ -11,44 +11,15 @@ package com.lukas.music.ui.adapters import android.view.LayoutInflater -import android.view.View import android.view.ViewGroup -import android.widget.AdapterView -import android.widget.ArrayAdapter import androidx.recyclerview.widget.RecyclerView import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument -import com.lukas.music.instruments.Waveform import com.lukas.music.ui.fragments.InstrumentListFragment class InstrumentAdapter(val parent: InstrumentListFragment) : - RecyclerView.Adapter() { - class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : - RecyclerView.ViewHolder(binding.root), AdapterView.OnItemSelectedListener { - lateinit var instrument: Instrument - - init { - val adapter = ArrayAdapter( - binding.root.context, - android.R.layout.simple_spinner_dropdown_item, Waveform.VALUES - ) - binding.waveformSelection.adapter = adapter - binding.waveformSelection.onItemSelectedListener = this - } - - override fun onItemSelected( - adapterView: AdapterView<*>?, - view: View?, - position: Int, - id: Long - ) { - instrument.waveform = Waveform.VALUES[position] - } - - override fun onNothingSelected(adapterView: AdapterView<*>?) { - } - } + RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): InstrumentViewHolder { val context = parent.context diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt new file mode 100644 index 0000000..aeb1078 --- /dev/null +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2022 Lukas Eisenhauer + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + */ + +package com.lukas.music.ui.adapters + +import androidx.recyclerview.widget.RecyclerView +import com.lukas.music.databinding.FragmentInstrumentBinding +import com.lukas.music.instruments.Instrument + +class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : + RecyclerView.ViewHolder(binding.root) { + lateinit var instrument: Instrument +} \ No newline at end of file diff --git a/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt index d933194..05b471f 100644 --- a/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt +++ b/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt @@ -10,17 +10,21 @@ package com.lukas.music.ui.fragments +import android.R import android.os.Bundle import android.text.Editable import android.text.TextWatcher import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.AdapterView +import android.widget.ArrayAdapter import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager import com.lukas.music.databinding.FragmentEditInstrumentBinding import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument +import com.lukas.music.instruments.Waveform class EditInstrumentFragment( private val instrument: Instrument, @@ -45,6 +49,24 @@ instrument.applyToView(parent, manager) } }) + val adapter = ArrayAdapter( + binding.root.context, + R.layout.simple_spinner_dropdown_item, Waveform.VALUES + ) + binding.waveformSelection.adapter = adapter + binding.waveformSelection.onItemSelectedListener = + object : AdapterView.OnItemSelectedListener { + override fun onItemSelected( + parent: AdapterView<*>?, + view: View?, + position: Int, + id: Long + ) { + instrument.waveform = Waveform.VALUES[position] + } + + override fun onNothingSelected(parent: AdapterView<*>?) {} + } binding.closeButton.setOnClickListener { dismiss() } diff --git a/app/src/main/res/layout/fragment_edit_instrument.xml b/app/src/main/res/layout/fragment_edit_instrument.xml index d398b23..e984e4b 100644 --- a/app/src/main/res/layout/fragment_edit_instrument.xml +++ b/app/src/main/res/layout/fragment_edit_instrument.xml @@ -68,6 +68,27 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/waveformSelection" /> + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0076403..4e369b6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -11,7 +11,7 @@ - + diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt index 8dc2310..bb402f8 100644 --- a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt @@ -11,44 +11,15 @@ package com.lukas.music.ui.adapters import android.view.LayoutInflater -import android.view.View import android.view.ViewGroup -import android.widget.AdapterView -import android.widget.ArrayAdapter import androidx.recyclerview.widget.RecyclerView import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument -import com.lukas.music.instruments.Waveform import com.lukas.music.ui.fragments.InstrumentListFragment class InstrumentAdapter(val parent: InstrumentListFragment) : - RecyclerView.Adapter() { - class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : - RecyclerView.ViewHolder(binding.root), AdapterView.OnItemSelectedListener { - lateinit var instrument: Instrument - - init { - val adapter = ArrayAdapter( - binding.root.context, - android.R.layout.simple_spinner_dropdown_item, Waveform.VALUES - ) - binding.waveformSelection.adapter = adapter - binding.waveformSelection.onItemSelectedListener = this - } - - override fun onItemSelected( - adapterView: AdapterView<*>?, - view: View?, - position: Int, - id: Long - ) { - instrument.waveform = Waveform.VALUES[position] - } - - override fun onNothingSelected(adapterView: AdapterView<*>?) { - } - } + RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): InstrumentViewHolder { val context = parent.context diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt new file mode 100644 index 0000000..aeb1078 --- /dev/null +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2022 Lukas Eisenhauer + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + */ + +package com.lukas.music.ui.adapters + +import androidx.recyclerview.widget.RecyclerView +import com.lukas.music.databinding.FragmentInstrumentBinding +import com.lukas.music.instruments.Instrument + +class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : + RecyclerView.ViewHolder(binding.root) { + lateinit var instrument: Instrument +} \ No newline at end of file diff --git a/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt index d933194..05b471f 100644 --- a/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt +++ b/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt @@ -10,17 +10,21 @@ package com.lukas.music.ui.fragments +import android.R import android.os.Bundle import android.text.Editable import android.text.TextWatcher import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.AdapterView +import android.widget.ArrayAdapter import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager import com.lukas.music.databinding.FragmentEditInstrumentBinding import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument +import com.lukas.music.instruments.Waveform class EditInstrumentFragment( private val instrument: Instrument, @@ -45,6 +49,24 @@ instrument.applyToView(parent, manager) } }) + val adapter = ArrayAdapter( + binding.root.context, + R.layout.simple_spinner_dropdown_item, Waveform.VALUES + ) + binding.waveformSelection.adapter = adapter + binding.waveformSelection.onItemSelectedListener = + object : AdapterView.OnItemSelectedListener { + override fun onItemSelected( + parent: AdapterView<*>?, + view: View?, + position: Int, + id: Long + ) { + instrument.waveform = Waveform.VALUES[position] + } + + override fun onNothingSelected(parent: AdapterView<*>?) {} + } binding.closeButton.setOnClickListener { dismiss() } diff --git a/app/src/main/res/layout/fragment_edit_instrument.xml b/app/src/main/res/layout/fragment_edit_instrument.xml index d398b23..e984e4b 100644 --- a/app/src/main/res/layout/fragment_edit_instrument.xml +++ b/app/src/main/res/layout/fragment_edit_instrument.xml @@ -68,6 +68,27 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/waveformSelection" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_instrument.xml b/app/src/main/res/layout/fragment_instrument.xml index 5377212..e37f479 100644 --- a/app/src/main/res/layout/fragment_instrument.xml +++ b/app/src/main/res/layout/fragment_instrument.xml @@ -60,19 +60,6 @@ app:layout_constraintStart_toEndOf="@+id/editInstrumentButton" app:layout_constraintTop_toBottomOf="@+id/instrumentNameText" /> - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0076403..4e369b6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -11,7 +11,7 @@ - + diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt index 8dc2310..bb402f8 100644 --- a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentAdapter.kt @@ -11,44 +11,15 @@ package com.lukas.music.ui.adapters import android.view.LayoutInflater -import android.view.View import android.view.ViewGroup -import android.widget.AdapterView -import android.widget.ArrayAdapter import androidx.recyclerview.widget.RecyclerView import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument -import com.lukas.music.instruments.Waveform import com.lukas.music.ui.fragments.InstrumentListFragment class InstrumentAdapter(val parent: InstrumentListFragment) : - RecyclerView.Adapter() { - class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : - RecyclerView.ViewHolder(binding.root), AdapterView.OnItemSelectedListener { - lateinit var instrument: Instrument - - init { - val adapter = ArrayAdapter( - binding.root.context, - android.R.layout.simple_spinner_dropdown_item, Waveform.VALUES - ) - binding.waveformSelection.adapter = adapter - binding.waveformSelection.onItemSelectedListener = this - } - - override fun onItemSelected( - adapterView: AdapterView<*>?, - view: View?, - position: Int, - id: Long - ) { - instrument.waveform = Waveform.VALUES[position] - } - - override fun onNothingSelected(adapterView: AdapterView<*>?) { - } - } + RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): InstrumentViewHolder { val context = parent.context diff --git a/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt new file mode 100644 index 0000000..aeb1078 --- /dev/null +++ b/app/src/main/java/com/lukas/music/ui/adapters/InstrumentViewHolder.kt @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2022 Lukas Eisenhauer + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or(at your option) any later version. + * + * This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + */ + +package com.lukas.music.ui.adapters + +import androidx.recyclerview.widget.RecyclerView +import com.lukas.music.databinding.FragmentInstrumentBinding +import com.lukas.music.instruments.Instrument + +class InstrumentViewHolder(val binding: FragmentInstrumentBinding) : + RecyclerView.ViewHolder(binding.root) { + lateinit var instrument: Instrument +} \ No newline at end of file diff --git a/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt b/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt index d933194..05b471f 100644 --- a/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt +++ b/app/src/main/java/com/lukas/music/ui/fragments/EditInstrumentFragment.kt @@ -10,17 +10,21 @@ package com.lukas.music.ui.fragments +import android.R import android.os.Bundle import android.text.Editable import android.text.TextWatcher import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.AdapterView +import android.widget.ArrayAdapter import androidx.fragment.app.DialogFragment import androidx.fragment.app.FragmentManager import com.lukas.music.databinding.FragmentEditInstrumentBinding import com.lukas.music.databinding.FragmentInstrumentBinding import com.lukas.music.instruments.Instrument +import com.lukas.music.instruments.Waveform class EditInstrumentFragment( private val instrument: Instrument, @@ -45,6 +49,24 @@ instrument.applyToView(parent, manager) } }) + val adapter = ArrayAdapter( + binding.root.context, + R.layout.simple_spinner_dropdown_item, Waveform.VALUES + ) + binding.waveformSelection.adapter = adapter + binding.waveformSelection.onItemSelectedListener = + object : AdapterView.OnItemSelectedListener { + override fun onItemSelected( + parent: AdapterView<*>?, + view: View?, + position: Int, + id: Long + ) { + instrument.waveform = Waveform.VALUES[position] + } + + override fun onNothingSelected(parent: AdapterView<*>?) {} + } binding.closeButton.setOnClickListener { dismiss() } diff --git a/app/src/main/res/layout/fragment_edit_instrument.xml b/app/src/main/res/layout/fragment_edit_instrument.xml index d398b23..e984e4b 100644 --- a/app/src/main/res/layout/fragment_edit_instrument.xml +++ b/app/src/main/res/layout/fragment_edit_instrument.xml @@ -68,6 +68,27 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/waveformSelection" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_instrument.xml b/app/src/main/res/layout/fragment_instrument.xml index 5377212..e37f479 100644 --- a/app/src/main/res/layout/fragment_instrument.xml +++ b/app/src/main/res/layout/fragment_instrument.xml @@ -60,19 +60,6 @@ app:layout_constraintStart_toEndOf="@+id/editInstrumentButton" app:layout_constraintTop_toBottomOf="@+id/instrumentNameText" /> - \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 197d2c5..13d3b8a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -37,4 +37,5 @@ Edit instrument Instrument name: close this menu + Waveform: \ No newline at end of file