Alexander S
07/09/2023, 9:03 PMModifier#pointerInteropFilter
, but that method doesn't exist, which means I don't know how to get access to MotionEvent
. Any and all help will be greatly appreciated!Rahul Zala
07/10/2023, 10:32 AMGideon Oyediran
07/10/2023, 6:13 PMLukas Anda
07/10/2023, 10:02 PMCaused by: java.lang.IllegalStateException: Artifacts of dependency org.jetbrains.kotlinx:kotlinx-serialization-core-metadata:1.0.0 is built by old Kotlin Gradle Plugin and can't be consumed in this way
Did anyone encounter this already?İbrahim Ethem Şen
07/11/2023, 6:02 AMHariharasudhan D
07/11/2023, 9:25 AMLukas Anda
07/11/2023, 10:49 AMOmkar Amberkar
07/11/2023, 4:47 PMYasser AKBBACH
07/11/2023, 8:24 PMfun String.toLocalDate()
If not what's the recommended approach?
Let's say that the date is coming from the API in a specific format.Eugene Maksymenko
07/11/2023, 9:39 PMGioele Dev
07/12/2023, 3:27 AMNicolas Manurung
07/12/2023, 9:25 AMclass SampleViewModel : ViewModel() {
private val _listData = MutableStateFlow<List<PlaceholderContent.PlaceholderItem>>(emptyList())
val listData = _listData.asStateFlow()
fun getDataFirstTime() = viewModelScope.launch {
_listData.value = PlaceholderContent.ITEMS
}
fun addMoreData() = viewModelScope.launch {
PlaceholderContent.addMoreItems(15)
_listData.value = PlaceholderContent.ITEMS
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setupRecycerview()
setListenerForNestedScrollTransactions()
viewLifecycleOwner.lifecycleScope.launch {
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
launch {
vm.listData.collect {
adapterSample.setItems(it) // nothing happen here when i execute vm.addMoreData()
}
}
}
}
vm.getDataFirstTime()
}
private fun setListenerForNestedScrollTransactions() {
binding.nsvRecyclerview.setOnScrollChangeListener(NestedScrollView.OnScrollChangeListener { view, _, scrollY, _, oldScrollY ->
// This line triggered when nestedscrollview hit end of his bottom
if (shouldLoadMoreData(view, scrollY, oldScrollY)) {
vm.addMoreData()
}
})
}
private fun shouldLoadMoreData(view: NestedScrollView, scrollY: Int, oldScrollY: Int): Boolean {
return scrollY > oldScrollY && view.getChildAt(0).bottom <= binding.nsvRecyclerview.height + scrollY
}
Enes Cerrahoğlu
07/12/2023, 7:10 PMlnunezb6
07/13/2023, 3:05 AMBhumil
07/14/2023, 1:58 AM// ViewModel
fun doSome() {
repo.doSome().onSuccess { // handle success }.onFailure { // handle error }
}
// Repository
fun doSome(): Result<Some> {
return runCatching {
// do something that might fail
}
}
We're planning for a change where exceptions are directly thrown and caught in the ViewModel instead, removing the Result type.
What are your thoughts on this? How do you handle exceptions across layers in your projects?Hari Moradiya
07/14/2023, 9:42 AMmMediaRecorder.setMaxDuration(5000); // 5 seconds
mMediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() {
@Override
public void onInfo(MediaRecorder mediaRecorder, int i, int i1) {
if (i == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
}
}
});
Hello , i am trying to stop the media recorder every 5 seconds and start after 5 seconds until user stop the recording can anyone help me for that?Saleem
07/14/2023, 11:17 AMKev Thompson
07/17/2023, 7:58 AMMihai Potra
07/17/2023, 8:18 AMHandler
, and return a FutureTask
. (i.e. AccountManager.getAuthToken)
The gist of it is that these methods basically end up invoking something like this:
val handler = optionalHandler ?: Handler(context.getMainLooper()) // unless given, always use the main looper handler. Context is the main Activity context for example.
<http://handler.post|handler.post>{ callback(futuretask) }
Now, I want to wrap these with coroutines, so I ended up writing something like the below, which works fine:
suspend fun doMethod() = suspendCancellableCoroutine<Bundle?> { continuation->
callback= {result -> //do stuff with result }
invokeAndroidMethod(..., callback, /* Handler */ null)
}
But, because I'm not passing in a handler, the callback
always ends up running on the main thread (main looper)
How can I ensure that the callback
always runs in a different thread than main?
Any way I can get a Handler
out of some coroutine scope/context, to pass it to invokeAndroidMethod
? How about getting it for the current/parent coroutine?
Example: If I ever want to do launch(<http://Dispatchers.IO|Dispatchers.IO>) { doMethod() }
to basically ensure that callback
also runs in <http://Dispatchers.IO|Dispatchers.IO>
Marko Novaković
07/17/2023, 9:23 AMkotlinx.coroutines.MainScope()
is being called from my Hilt generated code.
90% of ANRs are on Android 11
coroutines version = 1.7.1Abhimanyu
07/18/2023, 5:39 AMval updateTitle: (updatedTitle: String) -> Unit,
and
val updateTitle: (String) -> Unit,
Both can be called in the same way and lambda can not have named arguments.
So curious if there is any difference I am missing out.J6ey
07/18/2023, 6:05 AMval index = fragmentList.indexOf(fragment)
fragmentList[index] = NoDataFragment.newInstance()
am I missing something?Travis Griggs
07/18/2023, 5:56 PMscope.launch {
val locationClient =
LocationServices.getFusedLocationProviderClient(context)
val location = await(locationClient.getCurrentLocation(PRIORITY_HIGH_ACCURACY, null))
val target = LatLng(location.latitude, location.longitude)
var update = CameraUpdateFactory.newLatLng(target)
cameraState.animate(update, 300)
}
But I get an error ( java.lang.IllegalStateException: Must not be called on the main application thread) when I run this. I guess I thought the scope.launch would take care of that. I'm missing a bit of the magic with tasks/coroutines I think. What do I need to add/change to make that work?Colton Idle
07/18/2023, 6:38 PMAmanpreet Kaur
07/18/2023, 6:54 PMAshiq
07/18/2023, 11:00 PMSanjayKarki
07/19/2023, 3:42 AMĐào Duy Anh
07/19/2023, 3:49 AMĐào Duy Anh
07/19/2023, 3:52 AMĐào Duy Anh
07/19/2023, 3:53 AMcmake_minimum_required(VERSION 3.22.1)
project("check-libs")
add_library(lib_track SHARED IMPORTED)
set_target_properties(
lib_track
PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libtrack.so
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
add_library(
check-libs SHARED
check_jni.cpp)
target_include_directories(check-libs PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include)
find_library(
log-lib
log)
target_link_libraries(
check-libs
android
lib_track
${log-lib})