OG
10/11/2022, 11:58 PMrtsketo
10/12/2022, 10:59 AMRadoslaw Juszczyk
10/13/2022, 6:16 AMval isTooLate: Boolean
get() = System.currentTimeMillis() > someTimestamp
I find it confusing that hovering over it in the IDE gives:
public final val isTooLate: Boolean
which gives an impression that this value is going to be always the same - but it's not.Abdul Moeed
10/13/2022, 7:17 AMoverride suspend fun getBusStopModel(): Flow<Resource<SmartBusStop>> {
return flow {
while(currentCoroutineContext().isActive){
try{
val data = api.getBusService(STOPID).toSmartBusStop()
emit(Resource.Success<SmartBusStop>(data))
} catch (e: HttpException){
emit(Resource.Error(e.localizedMessage ?: "An unexpected error occurred"))
} catch (e: IOException){
emit(Resource.Error("Couldn't reach server. Check your internet connection"))
} catch (e: Exception){
emit(Resource.Error(e.stackTraceToString()))
}
delay(10000)
}
}
}
This is called and collected in the view model.
I want to ask, is there any better way to achieve a periodic API call. I have looked into work manager a little bitPabitra Ranjan Sahu
10/14/2022, 5:03 AMKMM (Kotlin Multiplatform Mobile)
in Android Studio.
I followed the steps to create this, But I am facing some issues while compiling the code.
Here it is:
'pod install' command failed with code 1.
Full command: pod install
Error message:
[33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8
[0m
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/unicode_normalize/normalize.rb:141:in `normalize': Unicode Normalization not appropriate for ASCII-8BIT (Encoding::CompatibilityError)
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/config.rb:166:in `unicode_normalize'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/config.rb:166:in `installation_root'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/config.rb:226:in `podfile_path'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface/error_report.rb:105:in `markdown_podfile'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/user_interface/error_report.rb:30:in `report'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:66:in `report_error'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:396:in `handle_exception'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:337:in `rescue in run'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:324:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/unicode_normalize/normalize.rb:141:in `normalize': Unicode Normalization not appropriate for ASCII-8BIT (Encoding::CompatibilityError)
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/config.rb:166:in `unicode_normalize'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/config.rb:166:in `installation_root'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/config.rb:226:in `podfile_path'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/config.rb:205:in `podfile'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:160:in `verify_podfile_exists!'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command/install.rb:46:in `run'
from /Library/Ruby/Gems/2.6.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
from /usr/local/bin/pod:23:in `load'
from /usr/local/bin/pod:23:in `<main>'
Please, check that podfile contains following lines in header:
source '<https://cdn.cocoapods.org>'
Please, check that each target depended on sharedKMM contains following dependencies:
Thanks in advance.khiari youssef
10/14/2022, 9:56 AMJhonatan Sabadi
10/14/2022, 10:57 AMlint-baseline
files ?
I already have generated files, but with changes in code, i would like to regenerate it, or update.Ben Edwards
10/14/2022, 11:04 PMBen Edwards
10/15/2022, 12:28 AMAaron Waller
10/16/2022, 9:16 AMFlow<List<Favorite>>
and I collect it in my ViewModel.
Whenever the user adds a Favorite I execute this function in my VM:
fun addToFavorite(favorite: Favorite, alreadyFavorite: () -> Unit, addedToFavorite: () -> Unit) {
viewModelScope.launch {
favoriteRepository.getFavorites().collect(){ favoriteList ->
if(favoriteList.contains(favorite)){
alreadyFavorite()
}else{
addedToFavorite()
favoriteRepository.insertFavorite(favorite)
}
}
}
}
Now the problem here is that favoriteRepostitory.insertFavorite() adds the item to the room database and triggers the getFavorites().collect. So an endless loop gets created and the item is added to the room database indefinitely.
How can I get the result of my getFavorites Flow without using collect? Or is there any other way?Milo
10/16/2022, 9:55 PMKulwinder Singh
10/17/2022, 5:06 AMElio Maroun
10/17/2022, 6:06 AMBharath Kandula
10/17/2022, 11:12 AMbrian
10/17/2022, 12:52 PMpublic class E2EEService {
Context context;
public EThree eThree = null;
ApiService apiService;
public E2EEService(@NotNull ApiService apiService, Context context) {
this.apiService = apiService;
this.context = context;
}
public void initE2EE(Callback<Void> initCallback) {
Callback<User> requestCallback = new Callback<User>() {
@Override
public void onSuccess(User user) {
Function0<String> getToken = () -> user.virgilJwt;
EThreeParams eThreeParams = new EThreeParams(
user.uuid,
getToken,
context
);
E2EEService.this.eThree = new EThree(eThreeParams);
initCallback.onSuccess(null);
}
@Override
public void onError(Throwable throwable) {
initCallback.onError(throwable);
}
};
apiService.getUser(requestCallback);
}
Christian Würthenr
10/17/2022, 2:03 PM-Xobjc-generics
to pass generic information to Objective-C code, but all examples seem to be outdated on how to set this flag. Does anyone have a recent example?Javier
10/17/2022, 7:39 PMSarthak Gupta
10/18/2022, 7:45 AMGreg Rynkowski
10/18/2022, 4:19 PMikechukwu Wami
10/18/2022, 6:25 PMDaniele Segato
10/19/2022, 8:00 AMlintPublish()
to be ignored in multi-module projects?
:myLib
<--- module with a library (using lintPublish(project(":myLib-lint")
)
:myLib-lint
<--- lint checks module for my library
:featureX
<--- some library including :myLib
as dependency
lint checks are not performed in :featureX
module unless I manually lintChecks(":myLib-lint")
in addition to the dependency on :myLib
Daniele Segato
10/19/2022, 8:39 AMexecution = "ANDROIDX_TEST_ORCHESTRATOR"
all test run but they fail (on both devices) because I need
testInstrumentationRunnerArguments += "clearPackageData" to "true"
I'd appreciate any suggestion.
Thanks
EDIT: nevermind, apparently I had to use a newer / non stable version of orchestrator (and/or) runnerVikas Rathod
10/19/2022, 1:16 PMKayacan Kaya
10/19/2022, 8:54 PMWorkManager
nowadays. I was just wondering if you have any recommended design patterns/code samples that you have used in your projects for injecting/using class instances into your Worker
classes without the use of any dependency injection frameworks. Those classes can be repositories, data sources, etc, that may have executions of IO operations. Worth to mention: what I see, in general, is either the use of Hilt
to inject the instances of classes to the constructors of `Worker`s or using singletons (kotlin objects) to make function calls. I am asking for other alternatives to use.
Note: it is important to note that I am asking this question for Periodic Worker which complicates the usecase as I am imagining.Christy K
10/19/2022, 9:33 PMChristy K
10/19/2022, 9:39 PMJung Danny
10/20/2022, 4:15 AMStateFlow
with stateIn
, and you want the flow producer to be active all the time (even when the app is in the background), what coroutine scope should be used?
2. When observing to the above StateFlow
, even though the flow producer would live forever, can you still use repeatOnLifecycle
in the UI to safely unregister?Greg Rynkowski
10/20/2022, 10:28 AMapply from
, eg.
apply from: "$rootDir/gradle/getversion.gradle"
I still keep my app config in Groovy's build.gradle, but I would like to write my utils in kotlin. Can I import kts files from build.gradle?Sky
10/20/2022, 11:08 AMprivate fun deleteFavourite(
favourite: GetFavourite?,
viewModel: WallpapersSharedViewModel
) {
//handling 404 error in case of subsequent Delete request
try {
if (favourite != null && !favourite.isEmpty()) {
val favouriteId = favourite.get(0).id
viewModel.deleteFavourite(favouriteId)
Log.i("hiiiiyaa", "deleted${favouriteId}")
}
}
catch (e: HttpException){
Log.i("hiiiiyaa", "cannot find item to delete in the Api")
}
}
Error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.catexplorer, PID: 28492
retrofit2.HttpException: HTTP 400
at retrofit2.KotlinExtensions$await$2$2.onResponse(KotlinExtensions.kt:53)
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:161)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
............
Slackbot
10/20/2022, 2:18 PMSlackbot
10/20/2022, 2:18 PM