mirror of
https://github.com/afollestad/nock-nock.git
synced 2025-08-07 00:18:38 +00:00
Fix crash when mremoving headers, resolves #48
This commit is contained in:
parent
a6670e2bea
commit
82c1a17c68
3 changed files with 21 additions and 11 deletions
|
@ -8,7 +8,7 @@ android:
|
||||||
- build-tools-28.0.3
|
- build-tools-28.0.3
|
||||||
- android-24
|
- android-24
|
||||||
- android-28
|
- android-28
|
||||||
- sys-img-arm64-v8a-android-24
|
- sys-img-armeabi-v7a-android-24
|
||||||
|
|
||||||
licenses:
|
licenses:
|
||||||
- '.+'
|
- '.+'
|
||||||
|
@ -21,7 +21,7 @@ env:
|
||||||
# Emulator Management: Create, Start and Wait
|
# Emulator Management: Create, Start and Wait
|
||||||
before_script:
|
before_script:
|
||||||
- android list target
|
- android list target
|
||||||
- echo no | android create avd --force -n test -t android-24 --abi default/arm64-v8a
|
- echo no | android create avd --force -n test -t android-24 --abi default/armeabi-v7a
|
||||||
- emulator -avd test -no-audio -no-window &
|
- emulator -avd test -no-audio -no-window &
|
||||||
- android-wait-for-emulator
|
- android-wait-for-emulator
|
||||||
- adb shell input keyevent 82 &
|
- adb shell input keyevent 82 &
|
||||||
|
|
|
@ -55,8 +55,7 @@ abstract class DarkModeSwitchActivity : AppCompatActivity() {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||||
return UNKNOWN
|
return UNKNOWN
|
||||||
}
|
}
|
||||||
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
return when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
|
||||||
return when (currentNightMode) {
|
|
||||||
Configuration.UI_MODE_NIGHT_YES -> return ENABLED
|
Configuration.UI_MODE_NIGHT_YES -> return ENABLED
|
||||||
Configuration.UI_MODE_NIGHT_NO -> return DISABLED
|
Configuration.UI_MODE_NIGHT_NO -> return DISABLED
|
||||||
else -> UNKNOWN
|
else -> UNKNOWN
|
||||||
|
|
|
@ -56,9 +56,22 @@ class HeaderStackLayout(
|
||||||
|
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
val index = v.tag as Int
|
val index = v.tag as Int
|
||||||
list.removeViewAt(index)
|
check(index >= 0 || index < list.childCount) {
|
||||||
headers.removeAt(index)
|
"Index $index is out of bounds in the header stack (size ${list.childCount})."
|
||||||
postLiveData()
|
}
|
||||||
|
list.post {
|
||||||
|
list.removeViewAt(index)
|
||||||
|
headers.removeAt(index)
|
||||||
|
invalidateTags()
|
||||||
|
postLiveData()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun invalidateTags() {
|
||||||
|
for (i in 0 until list.childCount) {
|
||||||
|
val entry = list.getChildAt(i) as HeaderItemLayout
|
||||||
|
entry.btnRemove.tag = i
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addEntry(forHeader: Header) {
|
private fun addEntry(forHeader: Header) {
|
||||||
|
@ -67,9 +80,7 @@ class HeaderStackLayout(
|
||||||
|
|
||||||
val li = LayoutInflater.from(context)
|
val li = LayoutInflater.from(context)
|
||||||
val entry = li.inflate(R.layout.header_stack_item, list, false) as HeaderItemLayout
|
val entry = li.inflate(R.layout.header_stack_item, list, false) as HeaderItemLayout
|
||||||
list.addView(entry)
|
list.addView(entry.apply {
|
||||||
|
|
||||||
entry.run {
|
|
||||||
inputKey.setText(forHeader.key)
|
inputKey.setText(forHeader.key)
|
||||||
inputKey.post { entry.inputKey.requestFocus() }
|
inputKey.post { entry.inputKey.requestFocus() }
|
||||||
attachHeader(forHeader, this@HeaderStackLayout)
|
attachHeader(forHeader, this@HeaderStackLayout)
|
||||||
|
@ -77,6 +88,6 @@ class HeaderStackLayout(
|
||||||
|
|
||||||
btnRemove.tag = headers.size - 1
|
btnRemove.tag = headers.size - 1
|
||||||
btnRemove.setOnClickListener(this@HeaderStackLayout)
|
btnRemove.setOnClickListener(this@HeaderStackLayout)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue