Start search implementation

This commit is contained in:
Kirill Kamakin
2022-11-12 15:26:57 +01:00
parent effd4934a5
commit 21abf38282
15 changed files with 104 additions and 23 deletions

View File

@@ -1,6 +1,5 @@
package gq.kirmanak.mealient.extensions
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
@@ -18,10 +17,7 @@ fun <T> Fragment.collectWhenViewResumed(flow: Flow<T>, collector: FlowCollector<
}
}
fun Fragment.showLongToast(@StringRes text: Int) = showLongToast(getString(text))
fun Fragment.showLongToast(@StringRes text: Int) = context?.showLongToast(text) != null
fun Fragment.showLongToast(text: String) = showToast(text, Toast.LENGTH_LONG)
fun Fragment.showLongToast(text: String) = context?.showLongToast(text) != null
private fun Fragment.showToast(text: String, length: Int): Boolean {
return context?.let { Toast.makeText(it, text, length).show() } != null
}

View File

@@ -1,8 +1,10 @@
package gq.kirmanak.mealient.extensions
import android.content.Context
import android.content.SharedPreferences
import android.widget.EditText
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.core.widget.doAfterTextChanged
import androidx.lifecycle.LifecycleOwner
@@ -95,4 +97,13 @@ fun <T> LiveData<T>.observeOnce(lifecycleOwner: LifecycleOwner, observer: Observ
observer.onChanged(value)
}
})
}
}
fun Context.showLongToast(text: String) = showToast(text, Toast.LENGTH_LONG)
fun Context.showLongToast(@StringRes text: Int) = showLongToast(getString(text))
private fun Context.showToast(text: String, length: Int) {
Toast.makeText(this, text, length).show()
}