-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: LabelInputElement is only one line
- Loading branch information
balakz
committed
Aug 27, 2021
1 parent
f69b8ee
commit e9bb2f7
Showing
2 changed files
with
24 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,9 @@ class MainActivity : AppCompatActivity() { | |
|
||
private lateinit var form: Form | ||
|
||
private lateinit var toast: Toast | ||
|
||
|
||
private val charPool: List<Char> = ('a'..'z') + ('A'..'Z') | ||
private val INPUTS_ID = "INPUTS_ID" | ||
private val stringValues = arrayOf( | ||
|
@@ -64,58 +67,52 @@ class MainActivity : AppCompatActivity() { | |
|
||
private val validateActionCallback = object : ActionCallback, Form.Callback { | ||
override fun successCallback() { | ||
Toast.makeText(this@MainActivity, "Validate OK", Toast.LENGTH_SHORT).show() | ||
showMessage("Validate OK") | ||
} | ||
|
||
override fun errorCallback(message: String?) { | ||
Toast.makeText(this@MainActivity, "Validate not ok $message", Toast.LENGTH_SHORT).show() | ||
showMessage("Validate not ok $message") | ||
} | ||
|
||
override fun callback() { | ||
form.sendForm(this) | ||
} | ||
} | ||
|
||
private fun showMessage(message: String) { | ||
toast.setText(message) | ||
toast.show() | ||
} | ||
|
||
private val showToastActionCallback = object : ActionCallback { | ||
override fun callback() { | ||
Toast.makeText(this@MainActivity, "Action performed", Toast.LENGTH_SHORT).show() | ||
showMessage("Action performed") | ||
} | ||
} | ||
|
||
private val showToastCheckboxCallback = object : CheckboxCallback { | ||
private var toast: Toast? = null | ||
override fun callback(checked: Boolean) { | ||
toast?.cancel() | ||
toast = Toast.makeText(this@MainActivity, "Selected: $checked", Toast.LENGTH_SHORT) | ||
toast?.show() | ||
showMessage("Selected: $checked") | ||
} | ||
} | ||
|
||
private val showToastStringValueCallback = object : ValueCallback<String> { | ||
private var toast: Toast? = null | ||
override fun callback(value: String) { | ||
toast?.cancel() | ||
toast = Toast.makeText(this@MainActivity, value, Toast.LENGTH_SHORT) | ||
toast?.show() | ||
showMessage(value) | ||
} | ||
} | ||
private val showToastDateTimeValueCallback = object : ValueCallback<Date> { | ||
private var toast: Toast? = null | ||
override fun callback(value: Date) { | ||
toast?.cancel() | ||
toast = Toast.makeText( | ||
this@MainActivity, | ||
SimpleDateFormat("dd.MM.yyyy - HH:mm", Locale.getDefault()).format(value), | ||
Toast.LENGTH_SHORT | ||
) | ||
toast?.show() | ||
showMessage(SimpleDateFormat("dd.MM.yyyy - HH:mm", Locale.getDefault()).format(value)) | ||
|
||
} | ||
} | ||
|
||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
toast = Toast.makeText(this, "Toast", Toast.LENGTH_SHORT) | ||
form = buildForm() | ||
form.draw() | ||
//how to get inout data?? | ||
|
@@ -217,7 +214,7 @@ class MainActivity : AppCompatActivity() { | |
"Edit text element text", | ||
valueChangeListener = object : ValueCallback<String> { | ||
override fun callback(value: String) { | ||
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show() | ||
showMessage(value) | ||
} | ||
}, | ||
password = false, | ||
|
@@ -232,7 +229,7 @@ class MainActivity : AppCompatActivity() { | |
fewStringValues, | ||
valueCallback = object : ValueCallback<String> { | ||
override fun callback(value: String) { | ||
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show() | ||
showMessage(value) | ||
} | ||
} | ||
), true, | ||
|
@@ -250,7 +247,7 @@ class MainActivity : AppCompatActivity() { | |
"Edit text element text", | ||
valueChangeListener = object : ValueCallback<String> { | ||
override fun callback(value: String) { | ||
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show() | ||
showMessage(value) | ||
} | ||
}, | ||
password = false, | ||
|
@@ -262,15 +259,15 @@ class MainActivity : AppCompatActivity() { | |
"Password", "password", | ||
valueChangeListener = object : ValueCallback<String> { | ||
override fun callback(value: String) { | ||
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show() | ||
showMessage(value) | ||
} | ||
}, password = true, formValidators = arrayListOf(notEmptyValidator) | ||
), true | ||
) | ||
|
||
addElement(LabelInputElement("Email", "[email protected]", "", object : ValueCallback<String> { | ||
override fun callback(value: String) { | ||
Toast.makeText(applicationContext, value, Toast.LENGTH_SHORT).show() | ||
showMessage(value) | ||
} | ||
}, arrayListOf(emailValidator)), true) | ||
addElement( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters