more README info; pictures; DB closure for ShareActivity

This commit is contained in:
Sean 2024-12-19 14:21:56 -05:00
parent 6efc014ce5
commit acdfe4c306
4 changed files with 26 additions and 2 deletions

View file

@ -35,6 +35,7 @@ class ShareActivity : AppCompatActivity() {
// Get the shared text
val sharedText = intent.getStringExtra(Intent.EXTRA_TEXT)
// pull variables from our app's SQLite DB
val url = dbHelper.getUrl()
val token = dbHelper.getToken()
@ -46,6 +47,12 @@ class ShareActivity : AppCompatActivity() {
}
}
// Closes DB when process closes
override fun onDestroy() {
super.onDestroy()
dbHelper.close()
}
private fun sendPostRequest(url: String, token: String, sharedText: String) {
isRequestRunning = true
val fullUrl = "$url/api/recipes/create/url"
@ -84,6 +91,7 @@ class ShareActivity : AppCompatActivity() {
override fun onResponse(call: Call, response: Response) {
isRequestRunning = false
if (response.isSuccessful) {
// Send a Toast notification to the running UI (if successfully POSTed)
runOnUiThread {
Toast.makeText(this@ShareActivity, "URL sent to your Mealie API", Toast.LENGTH_SHORT).show()
}