Posts by Leonardo Lima • 3,541 points
120 posts
-
0
votes1
answer11
viewsA: Reactor - After filter false, call another method
I believe what you’re looking for is the operator doOnDiscard, designed for scenarios like this: return gateway1.getPerson(id) .filter { isPersonValid(it) } .doOnDiscard(Person.class, person -> {…
-
0
votes1
answer25
viewsA: How to perform Flatten with reactor?
You can turn a List<String> in a Flux<String> with: flatMap + fromIterable: values .toFlux() .flatMap { Flux.fromIterable(findMoreValues()) } .collectList() .map { /* List<String>…
-
0
votes1
answer80
viewsA: Variable grab the ID of a button clicked on Activity
If I understand your problem correctly, you can declare in the layout: <Button android:text="Botao 1" onClick="buttonClicked"/> <Button android:text="Botao 2" onClick="buttonClicked"/>…
kotlinanswered Leonardo Lima 3,541 -
0
votes1
answer38
viewsA: Check if there is already value inside the Array and listview?
In the following section of your code, you do not only add the variable codigo to the list, but rather a concatenation of it: listaCodigos.add("Codigo: " + codigo); Therefore, for her condition to…
-
0
votes1
answer374
viewsA: Real-time component update at Angular
If your backend still doesn’t offer Websockets or SSE, you can do it through Polling: public ngOnInit(): void { interval(20000).pipe( mergeMap(() => this.eventsService.getEvents()),…
-
2
votes2
answers215
viewsA: How to map class fields with names other than database columns?
The behavior you expect can be implemented through a ImplicitNamingStrategy or PhysicalNamingStrategy. That’s the mechanism that determines how class and field names will be translated into tables…
-
0
votes1
answer395
viewsA: NODE.js with socket and Mysql
Study asynchrony on Ode and its relationship with callbacks. The code is not running in the sequence you are thinking of. let msg =[]; io.on('connection', socket => { con.connect(function(err) {…
node.jsanswered Leonardo Lima 3,541 -
2
votes2
answers422
viewsA: Error installing nodemon globally
Avoid running commands npm sudo. It may seem the easiest solution, but it opens the door for malicious scripts to run on your machine. This article talks a little about the subject. Recommended…
-
0
votes1
answer28
viewsA: Response Em Restfull
Simply declare a Java method that takes the parameters of the request you will use and returns what you want: @GetMapping("/botao/{id}") public Botao getButtonById(@PathVariable Long id) { Botao…
-
0
votes1
answer32
viewsA: Mutablelist<Int> cannot be Invoked as a Function. What do I do?
You must use square brackets to access an element of a list (as if it were an array): val priorityId = mlstPrioritiesId[SpinnerPriority.selectedItemPosition] This is the Indexed access Operator, a…
-
11
votes1
answer252
viewsA: Access to object properties in a list (KOTLIN). Why is it so complicated?
The way you declared the class Student, the variables name, age and course are only parameters passed to the constructor. If you want them to become class properties, you should add the keyword val…
kotlinanswered Leonardo Lima 3,541 -
2
votes1
answer139
viewsA: Access a property of a saved object in localstorage
Error hints: the variable USUARIO is a string. You must convert it before: var USUARIO = JSON.parse(localStorage.getItem('currentUser')); const TOKEN = USUARIO.id; const CLIENT_ID = USUARIO.token;…
-
0
votes1
answer9
viewsA: When running the application on the mobile phone the imageView is not visible
You are using the attribute tools to place the image. How is it explained in the documentation, when using this attribute, you are setting a placeholder to be shown only in the preview. Substitute…
-
2
votes2
answers19
viewsA: button opening a new problem Activity in a class
The class you set as Listener should implement the View.OnClickListener. In this case, it is the very Activity(this): public class MainActivity extends AppCompatActivity implements…
-
1
votes1
answer143
viewsA: Treat Nodejs application for when crash, the server restart alone
Ideally, while your project is being developed, you detect all the relevant exceptions to your system and treat them to prevent the process from dying from silly errors. But, unexpected mistakes can…
-
1
votes1
answer747
viewsA: Break line after a number of characters without cutting the word
The problem is that you are only counting the letters, disregarding the concept of words. In this case, an option is to divide the input text by spaces, generating an array of words. Then iterate…
javaanswered Leonardo Lima 3,541 -
1
votes1
answer311
viewsA: Error implementing Room Persistence Library + Kotlin
The Room generates at compile time some classes for its operation: A class that will extend the abstract class you wrote down with @Database Classes that implement / extend the interfaces / classes…
-
3
votes2
answers894
viewsA: How to return a "not found" feature in Spring?
Your code can become more declarative using the methods of Optional, without the need for a if: @RequestMapping(value = "/{id}", method = RequestMethod.GET) public ResponseEntity<?>…
-
2
votes1
answer70
viewsA: Application rejected in Apple Store due to language difference with IOS messages
You should add in the file config.xml, in the Platform section, the permissions that you use along with the appropriate messages. An example: <platform name="ios"> ... <config-file…
-
3
votes2
answers1055
viewsA: If, Elseif and Else with Java 8
A for simple solve your problem: class Main { public static void main(String[] args) { String result = findMatchingRegex(Arrays.asList( () -> testRegex(null), () -> testRegex(" A "), () ->…
-
3
votes2
answers196
viewsA: Python 3 - Unexpected Flow Control when running IF/IF NOT or IF/ELSE
The codes are not equivalent. if not is not the same as else. In Java, the equivalent of what you wrote in Python is: private boolean luz_ligada; private void interruptor(){ if(luz_ligada){…
-
1
votes1
answer396
viewsA: Create variable with an object property - Angular
To create a new array with the names of the original array, just use the map method straight into the array: this.name = res.map(it => it.name)…
-
1
votes1
answer134
viewsA: How to take a JSON String and display in recyclerview without repeating?
You can group the records according to one of the fields. If you have 24+ minimum api, you can use streams: List<Story> stories = Arrays.asList( new Story(1L, "pedroGC", "url1.jpg"), new…
-
2
votes1
answer126
viewsA: put Thread.Leep in the Retrofit Call method without locking the Thread UI (main)
You can use the postDelayed: Handler handler = new Handler(); handler.postDelayed(() -> salvar(contato, callback), 2000);…
-
1
votes1
answer50
viewsA: Java spring: error removing model listing object
The remove is returning false because he could not find an object in the collection that met the equals. According to the Javadoc: Removes the specified element from this set if it is present…
-
1
votes1
answer35
viewsA: Ionic loop reading sensor and sending to api
In fact, making multiple requests per second can impair app and backend performance. You can use the watchAcceleration and the operators of rxjs to limit and / or group the accelerometer data. Some…
-
2
votes1
answer628
viewsA: Filter *ngFor async data
You are using your pipe before async, meaning it is receiving an Observable and not an array. You must change the order of the Pipes: (lotes$ | async) | lancamentosFilter:searchText…
-
1
votes1
answer90
viewsA: Retain a request after 5 seconds in case of error
From rxjs 5.5, the recommended way to chain operators is by using the pipe. To documentation explains the why. Instead of doing: $observable.map(...) .filter(...) .mergeMap(...) .subscribe(...) You…
-
1
votes2
answers416
viewsA: How to make multiple http requests at angular?
The solution will depend a lot on the context of your problem and the outcome you expect. Answering your headline question: what you want will probably involve the operator mergeMap. With it, your…
-
0
votes1
answer40
viewsA: I have an error trying to consume an API, via js fExpected BEGIN_OBJECT but was BEGIN_ARRAY
Your class does not correctly represent the API response. The correct statement would be: public class Data { private String date; private String name; private String link; private String type;…
-
1
votes1
answer559
viewsA: Retrofit = Manipulating the Sponse
Class returned in your service method must match the JSON representation the API returns. Create a class that represents JSON: import java.util.List; class ClientesResponse { private…
-
1
votes1
answer199
viewsA: problems with Strictmode.Threadpolicy
What happens is that your JsonClass tries to access the network (a blocking operation) in the main thread of Android, which is not allowed. You can read a little more on the subject at this link,…
-
2
votes1
answer128
viewsA: Failed to add Class objects to the Array List
First you’re initiating a ArrayList with nil: ArrayList<Clientes> aCli = null; And then trying to manipulate it on line 94, which is not allowed in Java: aCli.add(cliente); In this case, the…
-
3
votes2
answers129
viewsA: Kotlin for Creation and Apis: Only for Android?
Yes, it is perfectly possible to build your backend with Kotlin. One of Kotlin’s top priorities is to offer interoperability with Java. So virtually every library / frameworks you would use to build…
-
1
votes1
answer71
viewsA: Referencing components of Activity
As the error itself says, another thread, besides main, is trying to change views - which is not allowed. The solution is to always execute the code that changes the views in the main thread. If…
-
0
votes1
answer139
viewsA: Remove Branded in Android Studio editor
The yellow in question is in fact a lint brand indicating a possible problem or improvement that can be applied in your code. You can read more about how lint works on documentation, as well as ways…
-
5
votes3
answers681
viewsA: Extract date with Regex
The character ^ means beginning of string, that is, your string would have to start with the specified pattern. Only (\\d{2}\\/\\d{2}\\/\\d{4}) is enough. To get the first one, just do not advance…
-
3
votes2
answers753
viewsA: What does the exclamation mark mean after a guy’s name?
It means you’re dealing with a platform type: a type from Java that may or may not be null. The Kotlin compiler always tries to search for invalidity annotations and infer whether a type can be null…
-
0
votes1
answer29
viewsA: Log activity for synchronization capturing task data running in background
The Asynctasks, by default, work as a shared queue. All tasks are executed serial, one at a time, by a thread in the background. Does that mean that if you have a task that takes too long to…
-
1
votes1
answer51
viewsA: Problems with Thread (Koltin)
The problem is that you are trying to change the view from another thread that is not the main. Run the code changes the view in a block runOnUiThread: runOnUiThread { down_bar.text = "Última…
-
0
votes1
answer1059
viewsA: Error: Unable to locate or load Olamundo main class.java
You must first compile with the command javac: javac OlaMundo.java And then run with the command java: java OlaMundo
-
1
votes1
answer27
viewsA: Error: Mismatch "${body.toString()}" in Kotlin
When you use properties access syntax (using .), you must pass a Editable to the EditText. To pass a String, use the Setter: editTextRespostaAviario?.setText("${body.toString()}" Note that the above…
-
3
votes2
answers428
viewsA: Load log by id in Angular
Your method restaurantById is ignoring the parameter id, and using a variable that does not exist (name). This way he will make the requisition on /restaurants/ and list all restaurants. This is…
angularanswered Leonardo Lima 3,541 -
3
votes1
answer522
viewsA: React Native and hybrid?
With React Native, you program in Javascript and your code will be "translated" into native components of each platform. When you declare a Text, for example, it will be translated to a UIView on…
-
1
votes1
answer99
viewsA: Error database.Cursorindexoutofboundsexception: Index 0 requested, with a size of 0
What happens is that in implementing your method GetUsuario, you assume that there is always a user with the informed id, which is not true by the error. First you should check if the cursor really…
-
4
votes2
answers1499
viewsA: Java DTO with Spring Boot 2
What happens is that the serialization library looks at the type declared in the method signature (which in your case is ClienteDTO) and tries to convert for him. An alternative is to give a "hint"…
-
0
votes1
answer74
viewsA: Is there a correct way to write this code?
The method getDefault() is static and will always return to JVM default Locale. I believe what you really want is: Locale locale = new Locale("portuguese", "pt"); System.out.println("Linguagem: " +…
javaanswered Leonardo Lima 3,541 -
2
votes1
answer179
viewsA: Access list from inside a Viewholder in Kotlin
In Kotlin, a nested class, by default, cannot access members of the class from outside. To achieve this, use the modifier inner in the statement of nested class: class SearchFilterAdapter(private…
-
0
votes2
answers1351
viewsA: Instant Run works but file . apk does not install
The safest way to generate an APK that will be installed manually (outside of Android Studio) is by using Gradle. With a terminal open in your project folder, run the following command to generate a…
-
-1
votes1
answer118
viewsA: Help with Java Pointer Error
The problem is that you have two builders in the Fila class: public Fila() { } public Fila(Pessoa[] fila, int ponteiroInicio, int ponteiroPercorrer, int ponteiroFim, int total) { this.fila = new…