Finished dialog and fixed hard coded strings

This commit is contained in:
Bnyro 2022-05-15 10:24:19 +02:00
parent c619056b67
commit 0665ecb622
2 changed files with 16 additions and 6 deletions

View File

@ -61,15 +61,21 @@ class SearchFragment : Fragment() {
val historyRecycler = view.findViewById<RecyclerView>(R.id.history_recycler) val historyRecycler = view.findViewById<RecyclerView>(R.id.history_recycler)
val filterImageView = view.findViewById<ImageView>(R.id.filterMenu_imageView) val filterImageView = view.findViewById<ImageView>(R.id.filterMenu_imageView)
var checkedItem = 0
var tempSelectedItem = 0
filterImageView.setOnClickListener { filterImageView.setOnClickListener {
val options = arrayOf("Alle", "Videos") val options = arrayOf(getString(R.string.all), getString(R.string.videos), getString(R.string.channels), getString(R.string.playlists))
var checkItem = 1
AlertDialog.Builder(view.context) AlertDialog.Builder(view.context)
.setTitle("Choose an Option") .setTitle(getString(R.string.choose_filter))
.setSingleChoiceItems(options, checkItem, DialogInterface.OnClickListener { .setSingleChoiceItems(options, checkedItem, DialogInterface.OnClickListener {
dialog, id -> Toast.makeText(view.context,id.toString(),Toast.LENGTH_LONG).show() dialog, id -> tempSelectedItem = id
}) })
.setPositiveButton("Ok", DialogInterface.OnClickListener {
dialog, id -> checkedItem = tempSelectedItem
})
.setNegativeButton("Cancel", null)
.create() .create()
.show() .show()
} }

View File

@ -72,4 +72,8 @@
<string name="noInternet">No Internet Connection</string> <string name="noInternet">No Internet Connection</string>
<string name="retry">Retry</string> <string name="retry">Retry</string>
<string name="comments">Comments</string> <string name="comments">Comments</string>
<string name="choose_filter">Choose search filter</string>
<string name="channels">Channels</string>
<string name="all">All</string>
<string name="playlists">Playlists</string>
</resources> </resources>