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