Last active
June 20, 2019 12:33
-
-
Save nirav-tukadiya/7d127ea26a06a140786165584bc1e2cc to your computer and use it in GitHub Desktop.
Main Activity for AFE_Android module
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
package `in`.androidgeek.afe | |
import android.os.Bundle | |
import android.support.v7.app.AppCompatActivity | |
import android.widget.Toast | |
import kotlinx.android.synthetic.main.activity_input_numbers.* | |
class InputNumbersActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_input_numbers) | |
send.setOnClickListener { | |
val pair = isInputValid() | |
if (pair != null) { | |
sendDataToFlutterModule(pair.first, pair.second) | |
} | |
} | |
} | |
private fun sendDataToFlutterModule(first: Int, second: Int) { | |
//TODO will be implemented later | |
} | |
private fun isInputValid(): Pair<Int, Int>? { | |
val number1 = et_number_1.text.toString() | |
val number2 = et_number_2.text.toString() | |
when { | |
number1.isBlank() -> showToast("Please enter first number") | |
number2.isBlank() -> showToast("Please enter second number") | |
else -> return Pair(number1.toInt(), number2.toInt()) | |
} | |
return null | |
} | |
private fun showToast(msg: String) { | |
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment