Refactoring.
This commit is contained in:
parent
d5d6aeb9c7
commit
777fb1ad65
2 changed files with 13 additions and 21 deletions
|
@ -226,8 +226,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
setOnEditorActionListener { _, id, _ ->
|
||||||
setOnEditorActionListener { v, id, event ->
|
|
||||||
if (id == EditorInfo.IME_ACTION_DONE) {
|
if (id == EditorInfo.IME_ACTION_DONE) {
|
||||||
clearFocus()
|
clearFocus()
|
||||||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
@ -260,8 +259,7 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
adapter = ArrayAdapter<String>(this@MainActivity, android.R.layout.simple_list_item_1, titles)
|
adapter = ArrayAdapter<String>(this@MainActivity, android.R.layout.simple_list_item_1, titles)
|
||||||
isTextFilterEnabled = true
|
isTextFilterEnabled = true
|
||||||
isScrollbarFadingEnabled = false
|
isScrollbarFadingEnabled = false
|
||||||
@Suppress("UNUSED_PARAMETER")
|
onItemClickListener = AdapterView.OnItemClickListener { _, _, position, _ ->
|
||||||
onItemClickListener = AdapterView.OnItemClickListener { parent, v, position, id ->
|
|
||||||
if (validateFields(fields)) {
|
if (validateFields(fields)) {
|
||||||
saveConfig()
|
saveConfig()
|
||||||
startActivity<ProgrammingActivity>(
|
startActivity<ProgrammingActivity>(
|
||||||
|
@ -320,15 +318,13 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
dialogInterface.dismiss()
|
dialogInterface.dismiss()
|
||||||
})
|
})
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
|
||||||
alert.setNegativeButton(android.R.string.cancel,
|
alert.setNegativeButton(android.R.string.cancel,
|
||||||
{ dialogInterface, i ->
|
{ dialogInterface, _ ->
|
||||||
dialogInterface.dismiss()
|
dialogInterface.dismiss()
|
||||||
})
|
})
|
||||||
|
|
||||||
@Suppress("UNUSED_PARAMETER")
|
|
||||||
alert.setNeutralButton(R.string.dialog_import,
|
alert.setNeutralButton(R.string.dialog_import,
|
||||||
{ dialogInterface, i ->
|
{ dialogInterface, _ ->
|
||||||
dialogInterface.dismiss()
|
dialogInterface.dismiss()
|
||||||
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
||||||
intent.addCategory(Intent.CATEGORY_OPENABLE)
|
intent.addCategory(Intent.CATEGORY_OPENABLE)
|
||||||
|
@ -360,11 +356,10 @@ class MainActivity : AppCompatActivity(), AnkoLogger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveConfigurations(confs: Configurations) {
|
fun saveConfigurations(confs: Configurations) =
|
||||||
ObjectOutputStream(openFileOutput(configurationsData, Context.MODE_PRIVATE)).use {
|
ObjectOutputStream(openFileOutput(configurationsData, Context.MODE_PRIVATE)).use {
|
||||||
it.writeObject(confs)
|
it.writeObject(confs)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fun saveConfig(backup: Boolean = true) {
|
fun saveConfig(backup: Boolean = true) {
|
||||||
if (backup) {
|
if (backup) {
|
||||||
|
|
|
@ -143,8 +143,7 @@ class ProgrammingActivity : AppCompatActivity(), AnkoLogger {
|
||||||
|
|
||||||
if (!it.hasNext()) {
|
if (!it.hasNext()) {
|
||||||
imeOptions = EditorInfo.IME_ACTION_DONE
|
imeOptions = EditorInfo.IME_ACTION_DONE
|
||||||
@Suppress("UNUSED_PARAMETER")
|
setOnEditorActionListener { _, id, _ ->
|
||||||
setOnEditorActionListener { v, id, event ->
|
|
||||||
if (id == EditorInfo.IME_ACTION_DONE) {
|
if (id == EditorInfo.IME_ACTION_DONE) {
|
||||||
clearFocus()
|
clearFocus()
|
||||||
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
@ -305,11 +304,9 @@ class ProgrammingActivity : AppCompatActivity(), AnkoLogger {
|
||||||
return isValid
|
return isValid
|
||||||
}
|
}
|
||||||
|
|
||||||
fun validateSize(size: Int, min: Int, max: Int): Boolean {
|
fun validateSize(size: Int, min: Int, max: Int): Boolean = if (min > 0) {
|
||||||
if (min > 0) {
|
size in IntRange(min, max)
|
||||||
return size in IntRange(min, max)
|
} else {
|
||||||
} else {
|
size == max
|
||||||
return size == max
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue