Nikola Milovic
05/05/2020, 2:40 PMrobstoll
05/05/2020, 6:29 PMDavid Winer [G]
05/05/2020, 10:11 PMZac Sweers
05/06/2020, 5:35 AMApex
05/06/2020, 7:31 AMNikola Milovic
05/06/2020, 5:56 PMiex
05/06/2020, 8:19 PMval
?Marcin Wisniowski
05/07/2020, 5:04 PMLiveData
with the loading state and toggle the loading screen based on that. But if the loading screen is in the Activity, I have no access to the Fragment's ViewModel
. What am I missing?Vishvendu
05/07/2020, 5:37 PMNikola Milovic
05/07/2020, 5:42 PMlawlorslaw
05/07/2020, 8:05 PMfile.sink()
because it throws a FileNotFoundException
.adams2
05/07/2020, 11:01 PMandroidx.lifecycle.observe
ktx extension. When I do viewModel.observe(this, ::myOnChanged)
, I get this error: Type mismatch: inferred type is KFunction1<Action, Unit?> but Observer<in Action!> was expected
. However, when I do viewModel.observe(this) { myOnChanged(it) }
, the extension functions as expected. Is there some precedence rule preventing me from using a method reference?lawlorslaw
05/08/2020, 4:22 AMJoao Birk
05/08/2020, 4:28 PMPenguinDan
05/08/2020, 7:13 PMoverride fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? = EnsureDialogUi(requireContext()).apply {
yesButton.setOnClickListener {
ensureListener?.onYes()
dismissSafely()
}
noButton.setOnClickListener {
cancelSafely()
}
}.root
// My Ui code
...
override val root: View = constraintLayout {
// Set the parameters of our ConstraintLayout container
layoutParams = ConstraintLayout.LayoutParams(
DeviceUtil.calcDiagRatioInt(0.33f), wrapContent
)
...
Any ideas how I would go about doing this?dewildte
05/09/2020, 12:54 AMJoshua
05/09/2020, 1:59 PMval navController = findNavController(R.id.nav_host_fragment)
val appBarConfiguration = AppBarConfiguration(navController.graph)
findViewById<androidx.appcompat.widget.Toolbar>(R.id.toolbar).setupWithNavController(navController,appBarConfiguration)
setSupportActionBar(findViewById(R.id.toolbar))
This code is from my activity
What I'm trying to do is, set this default back-arrow autogenerated button to a hamburger icon instead.sathawale27
05/10/2020, 1:44 PMkrtko
05/11/2020, 1:54 AMplugins
system and for some reason the Android plugin needs me to add
pluginManagement {
repositories {
gradlePluginPortal()
jcenter()
google()
}
resolutionStrategy {
eachPlugin {
if (requested.id.id.startsWith("com.android")) {
useModule("com.android.tools.build:gradle:${requested.version}")
}
}
}
}
to my settings.gradle
fileJoao Birk
05/11/2020, 2:25 AMShortcutInfo.Builder
with navigation components? It needs an intent, there is no pendingIntent method that I can pass to the Builder, so cant really use NavDeepLinkBuilder.createPendingIntent().
Leon johnson
05/12/2020, 11:33 AMjean
05/12/2020, 2:32 PMFlowCollector
or anything build through the builder helpers function like flow { }, callbackFlow { }, etc...
.
What I want is to be able to do something like that from my fragment (or activity) but in a “correct” way
private lateinit var collector: FlowCollector<MainFragmentEvent>
private val events = flow<MainFragmentEvent> {
collector = this
}
override onResume() {
lifecycleScope.launch {
collector.emit(MainFragmentEvent.ResumeEvent(requireContext()))
}
}
Can I do that only by using Channel, SendChannel, etc...
and then convert it some how to a Flow
?Remon Shehata
05/12/2020, 4:37 PM//build the geofence
val fence = Geofence.Builder()
.setRequestId("123")
.setCircularRegion(latitude, longitude, radiusInMeters)
.setExpirationDuration(Geofence.NEVER_EXPIRE)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER)
.build()
geofencingRequest = GeofencingRequest.Builder().apply {
setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER)
addGeofence(fence)
}.build()
//build pending intent
val geofencePendingIntent: PendingIntent by lazy {
val intent = Intent(activity, GeofenceReceiver::class.java)
PendingIntent.getBroadcast(activity, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
//request
geofencingClient.addGeofences(geofencingRequest, geofencePendingIntent).run {
addOnFailureListener {
// display error
}
addOnSuccessListener {
// move on
}
}
Remon Shehata
05/12/2020, 9:55 PMSomesh
05/13/2020, 6:48 AMLeon johnson
05/13/2020, 7:48 PMGaurav K Tyagi 1
05/14/2020, 7:49 AMantoniomarin
05/14/2020, 8:37 AMViewPager2
and I cannot make any sense of it, I’ve got separate Activity
that holds ViewPager2
which contains fragments. That means destroying that activity with finish()
closes ViewPager2
as well.
Now what I’ve got is beyond me, everything works fine when I start it for the first time, but if I close it and reopen my observables in the fragments won’t emit any changes, tho everything is created fine?. I’ve pinpointed issue to the createFragment
method where commented part works but non commented doesn’t?
class PagerAdapter(
fragmentActivity: FragmentActivity,
private val items: List<PagerAdapterFragment>
//private val items: List<Int>
) : FragmentStateAdapter(fragmentActivity) {
override fun createFragment(position: Int): Fragment {
return items[position].fragment
// return when (position) {
// 0 -> Fragment1.newInstance()
// 1 -> Fragment2.newInstance()
// 2 -> PlaceholderFragment.newInstance("Retention information screen")
// else -> PlaceholderFragment.newInstance("Else")
// }
}
data class PagerAdapterFragment(val id: Long, val fragment: Fragment)
louiscad
05/14/2020, 7:39 PMstdlib-jdk8
in Android, but @mbonnin research came to the conclusion that stdlib
(not stdlib-jdk7
) is often the best.
I think I disagree since Autocloseable.use { ... }
is quite useful for some Android APIs exposing it, and is part of stdlib-jdk7
, but I've yet to see content stdlib-jdk8
being used in actual Android apps, and it seems the best it has to offer is not used by Android apps because of ineffective way to determine runtime capabilities as ART isn't technically a JRE-8.
If you can confirm what this article says, who can/should make the stdlib-jdk8
content work on Android as it should? The D8/R8 team? The Kotlin team? The platform team, meaning only Android several years from now will get it?
https://medium.com/@mbonnin/the-different-kotlin-stdlibs-explained-83d7c6bf293Remon Shehata
05/15/2020, 1:25 AMoverride fun checkOrganization(organizationId: String): Boolean {
var isFound = false
db.collection(FirebaseConstants.ORGANIZATION)
.get()
.addOnSuccessListener { querySnapshot ->
for (document in querySnapshot) {
Log.d(TAG, document.id)
if (organizationId == document.id) {
isFound = true
}
}
}
.addOnFailureListener { exception ->
Log.w(TAG, "Error getting documents.", exception)
}
return isFound
}
I want to return from the method after the loop is completed. how to achieve that?Remon Shehata
05/15/2020, 1:25 AMoverride fun checkOrganization(organizationId: String): Boolean {
var isFound = false
db.collection(FirebaseConstants.ORGANIZATION)
.get()
.addOnSuccessListener { querySnapshot ->
for (document in querySnapshot) {
Log.d(TAG, document.id)
if (organizationId == document.id) {
isFound = true
}
}
}
.addOnFailureListener { exception ->
Log.w(TAG, "Error getting documents.", exception)
}
return isFound
}
I want to return from the method after the loop is completed. how to achieve that?OG
05/17/2020, 7:56 PMcheckOrganization
and invoking the callback in the addOnSuccessListener
. Another alternative would be changing this interface (if it's internal) and using coroutines so you can return the result asynchronously.checkOrganization
a suspend function so you can return the result asynchronously.
b.) Use traditional callbacks to pass the result at a later time (the end of the for loop in addOnSuccessListener