change the way video limit is stored

This commit is contained in:
tibbi
2016-11-06 13:09:42 +01:00
parent f634df285b
commit 52190cf797
3 changed files with 46 additions and 9 deletions

View File

@ -154,22 +154,41 @@ class SettingsActivity : SimpleActivity() {
0 -> Constants.TWO_MPX
1 -> Constants.FIVE_MPX
2 -> Constants.EIGHT_MPX
else -> 0
else -> -1
}
}
private fun setupMaxVideoResolution() {
settings_max_video_resolution.setSelection(mConfig.maxVideoResolution)
settings_max_video_resolution.setSelection(getMaxVideoSelection())
settings_max_video_resolution.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onNothingSelected(parent: AdapterView<*>?) {
}
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
mConfig.maxVideoResolution = settings_max_video_resolution.selectedItemPosition
mConfig.maxVideoResolution = getMaxVideoPx(settings_max_video_resolution.selectedItemPosition)
}
}
}
private fun getMaxVideoSelection(): Int {
val maxRes = mConfig.maxVideoResolution
return when (maxRes) {
Constants.P480 -> 0
Constants.P720 -> 1
Constants.P1080 -> 2
else -> 3
}
}
private fun getMaxVideoPx(index: Int): Int {
return when (index) {
0 -> Constants.P480
1 -> Constants.P720
2 -> Constants.P1080
else -> -1
}
}
private fun restartActivity() {
TaskStackBuilder.create(applicationContext).addNextIntentWithParentStack(intent).startActivities()
}