ZariApps
08/11/2020, 5:41 PMoverride fun onCreateOptionsMenu(menu: Menu?): Boolean {
val inflater = menuInflater
super.onCreateOptionsMenu(menu)
inflater.inflate(R.menu.main_menu, menu)
val manager = getSystemService(Context.SEARCH_SERVICE) as SearchManager
val searchItem = menu?.findItem(R.id.search)
val searchView = searchItem?.actionView as SearchView
searchView.setSearchableInfo(manager.getSearchableInfo(componentName))
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
searchView.clearFocus()
searchView.setQuery("", false)
searchItem.collapseActionView()
Toast.makeText(this@MainActivity, "looking for $query", Toast.LENGTH_LONG).show()
return true
}
i have this in the main activity. if I want to reuse this(it's a search bar on the actionbar) in another activity, do i have to copy and paste the code every time? or is there an easier/efficient way to do this?Brendan Weinstein
08/11/2020, 8:02 PMJonny
08/12/2020, 5:51 PM@Singleton
@Component(
dependencies = [AppComponent::class],
modules = [
ViewModelModule::class,
FragmentModule::class
]
)
interface StartupComponent : AndroidInjector<BaseApplication> {
fun inject(activity: MainActivity)
}
But I have nowhere to initialize this component from.
This is the error that I get: No injector factory bound for Class<ferm.jonny.startup.presentation.fragments.ExtendedSplashScreenFragment>
Olajide Awoyinka
08/13/2020, 1:39 AMJoey
08/13/2020, 2:20 AMChristopher Elías
08/13/2020, 7:27 AMWalletDao.java:11: error: Not sure how to convert a Cursor to this method's return type
Has someone experienced something like this?myanmarking
08/13/2020, 9:21 AMSam
08/13/2020, 1:52 PMgabrielfv
08/13/2020, 6:41 PMbuildSrc
. Using Kotlin along with the kotlin-dsl
for gradle i’ve been able to move pretty much everything except for the following excerpt:
android {
kotlinOptions {
jvmTarget = "1.8"
}
}
The kotlinOptions
isn’t visible from the extensions within buildSrc
sourceset, probably because I don’t implement the dsl? I’ve tried doing the following, but it didn’t work
target.tasks.withType(KotlinCompile::class.java).forEach { task ->
task.kotlinOptions.jvmTarget = "1.8"
}
samuel
08/14/2020, 12:50 AMdialog?.window?.decorView?.setOnTouchListener { view, motionEvent ->
activity?.dispatchTouchEvent(motionEvent)
false
}
to try to dispatch the touch event to the activity but it doesn’t work as i expected. Does anyone have an idea of how to approach this?Isaac
08/14/2020, 3:10 PMVincent Williams
08/14/2020, 5:42 PMcolintheshots
08/14/2020, 6:05 PMkotlin.explicitApi()
manlan
08/14/2020, 7:41 PMitnoles
08/14/2020, 8:51 PMjnyakush
08/15/2020, 9:48 AMNikola Milovic
08/15/2020, 6:05 PMemit
says it has to be ran from a coroutine body ( I am well aware it is a suspend function)?
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
class FirebaseDataSource (private val firebaseFirestore: FirebaseFirestore) : NetworkDataSource{
fun fetchMenuItems(): Flow<Food> = flow{
firebaseFirestore.collection("menu_items")
.get()
.addOnSuccessListener { documents ->
try {
for (document in documents) {
val doc =...
emit(doc) //error here
}
}
}
}
In every example I've seen online they have it just inside the flow {}
Eg.
fun simple(): Flow<Int> = flow {
for (i in 1..3) {
delay(100)
println("Emitting $i")
emit(i)
}
}
Mohamed Elfiky
08/16/2020, 8:52 AMNikola Milovic
08/17/2020, 12:15 PMEugene
08/17/2020, 2:27 PMDaniele B
08/17/2020, 8:58 PMclass AppViewModel : ViewModel(), LifecycleObserver {
val myCoreModel = MyCoreViewModel()
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onStart() {
myCoreModel.appEnteredForeground()
}
override fun onCleared() {
super.onCleared()
myCoreModel.appWillClose()
}
}
How can I capture, from within the Android’s ViewModel, the event of the app entering the foreground? I tried this way, but my function appEnteredForeground
doesn’t get fired.Aditya
08/17/2020, 11:12 PMPaul Woitaschek
08/18/2020, 7:07 AMEugen Martynov
08/18/2020, 7:28 AMCaused by: java.lang.IllegalStateException: Unexpected non-class file: META-INF/versions/9/kotlin/reflect/jvm/internal/impl/serialization/deserialization/builtins/BuiltInsResourceLoader.class
Any ideas people what could be the cause?siz
08/18/2020, 10:24 AMMohamed Elfiky
08/19/2020, 1:17 AMmanlan
08/19/2020, 9:22 AMtseisel
08/19/2020, 4:34 PMJu
08/19/2020, 4:34 PMSlackbot
08/19/2020, 6:06 PM