Posts by Max Fratane • 1,535 points
51 posts
-
1
votes0
answers20
viewsQ: Access to this in different types of Anonimas functions
The question is simple, because when I do it: function reducer(accumulator, current) { return accumulator.concat(current); } Array.prototype.flatMap = () => { return this.reduce(reducer, []); };…
javascriptasked Max Fratane 1,535 -
1
votes1
answer246
viewsA: Classes with private Javascript properties
Today, what exists is a proposal so that there are, in fact, private members of a class. An example is the implementation on V8. And once approved, members will start with #, for example: class…
-
1
votes1
answer42
viewsA: Search in Index on Mongodb returning non-existent words, 'Bed' do you think 'Camera'?
From what I understand of what you want to do, the operator $search the way it is being used is not ideal for this case. O $search will break the string passed into several pieces and make a or with…
-
2
votes1
answer58
viewsA: How does an annonymous innerclass arrow a private instance variable?
After talking with some friends and a deeper research, I found out what is the appearance that happens in this case. It’s kind of obscure and relatively hard to find, so I’ll try to explain. The…
-
6
votes1
answer58
viewsQ: How does an annonymous innerclass arrow a private instance variable?
Since Java does not actually have closures, but emulates behavior with a technique using Inner classes, the following code: class Test{ private int myField; private void doSomething(){…
-
7
votes2
answers7309
viewsA: How to concatenate items from a python list?
You can use the join and then turn its return into a single element array. separator = ' ' array = ['_', '_', '_', '_', '_', '_', '_'] result = [separator.join(array)] print(result) The print will…
-
1
votes1
answer63
viewsA: Asynctask Android generating Nullpointerexception
Probably Activity, in which the download is taking place, is being destroyed by the system but the task continues running. And anywhere you access the variable activity(or any variable that belongs…
-
2
votes1
answer66
viewsA: importing a file containing a function I wrote: no global variable
The function def matriz(m, n) is declared within the function main(), so you can’t access def matriz(m, n) from nowhere but within main(). To solve it just take def matriz(m, n) from within the…
-
0
votes1
answer325
viewsA: Function running without clicking the Python button
You’re not passing a function the way you’re doing. Instead, you are running the function callbackInsereCritico and passing the return value to the attribute command. That’s why it’s running without…
pythonanswered Max Fratane 1,535 -
4
votes2
answers116
viewsA: Sorting algorithm not working!
Apparently you want to implement Bubblesort. A possible implementation of Bubblesort: def bubblesort(list): not_sorted = True while not_sorted: not_sorted = False for i in range(0, len(list)-1): if…
-
3
votes2
answers594
viewsA: Error instantiating python OO objects
You are thinking very "javamente". This code there can be pythonizado. In python, what defines the scope is indentation. For example: def function(a): if a is None: b = 100 return b if a > 300: c…
python-3.xanswered Max Fratane 1,535 -
2
votes2
answers16086
viewsA: unboundlocalerror problem: local variable 'num' referenced before assignment
The problem is the variable scope num. It is declared within the if scope: if semente != None: num=semente And you’re trying to access it in the scope of the function: num_aleatorio = (num*a+b)%m…
-
1
votes2
answers56
viewsA: SQL sub-consultations with counter
This consultation should work: SELECT ESTADO, COUNT(CASE WHEN CARGO = "ESTAGIARIO" THEN 1 END) estag, COUNT(CASE WHEN CARGO = "ANALISTA" THEN 1 END) analista, COUNT(CASE WHEN CARGO = "GERENTE" THEN…
-
3
votes2
answers340
viewsA: Difference between Java Arrays
String[] array1 = new String[99]; By doing this you are initiating an array of 99 positions in which all these positions have the value null. The {} are invalid in that case. In that case,…
-
1
votes1
answer30
viewsA: Toolbar hiding a piece of textview
This layout has the behavior you need: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"…
-
6
votes1
answer250
viewsA: What is the applicability of the eight queens problem?
The n-queen problem can be reduced to the SAT(satisfiability) problem, which is an NP-complete problem. And the most famous problem of SAT is to find a configuration of variables to satisfy a…
computer-scienceanswered Max Fratane 1,535 -
0
votes1
answer407
viewsA: Android - Activity destroyed when rotating the tablet
To understand what is happening, it is necessary to remember some points: You can have different xmls depending on the screen configuration. For example, you can have an xml for when Activity is in…
androidanswered Max Fratane 1,535 -
1
votes2
answers650
viewsA: Problem with Mysql Inner Join
The way you are applying the junction is wrong. viagens A inner join b.entregadores, doesn’t make sense. You have to put the name of the two tables involved in JOIN. The right thing would be viagens…
-
3
votes1
answer1120
viewsA: How to put the 3 buttons at the bottom of the screen?
I would do so: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"…
-
1
votes1
answer925
viewsA: How to convert a Json file to a list of objects in Java?
I would do something like: FileInputStream fstream = new FileInputStream("C:\\Users\\casa\\Desktop\\sales.jsonl"); BufferedReader br = new BufferedReader(new InputStreamReader(fstream)); Gson gson =…
-
4
votes1
answer182
viewsA: Create a comparison string in Java
In java, the operators == and != compare the instance reference and not their value. When using == to compare instances in java you will be asking if the variables have the same reference. If you…
-
1
votes1
answer320
viewsQ: Why pass arguments to a Fragment using Bundle instead of a set method
I recently asked myself a question, seemingly simple, that I could not answer and I did not find any concise answer. The question is simple: Why use Bundle instead of a set method to pass parameters…
-
22
votes4
answers1171
viewsA: What is the difference between -= and =-?
saldo -= 100 is the same thing as saldo = saldo - 100. saldo =- 100 is assigning -100 to the variable saldo. It’s clearer to visualize like this: saldo = -100…
-
1
votes3
answers46
viewsA: Group separate table records
Just use COUNT() together with GROUP BY Select nome, count(nome) as qtd from fornecedores where ativo = 1 group by nome; Union all Select nome, count(nome) as qtd from clientes where ativo = 1 group…
sqlanswered Max Fratane 1,535 -
0
votes1
answer668
viewsA: Mysql - Sort before grouping
There’s a way to fix it this way: SELECT usuario FROM tab_logins GROUP BY usuario ORDER BY MAX(data_login) desc; The only difference is the application of the function MAX()…
-
1
votes3
answers842
viewsA: Save state when returning to an Activity
You can solve this problem in many ways. I would do using the startActivityForResult. When you give the startActivity from Activity confirmation, you pass a Bundle pro Intent containing all the…
-
2
votes2
answers88
viewsA: Run Service with a Broadcastreceiver
According to the documentation: Attention: A service runs on the main chain in your hosting process - the service does not create its own chaining and is not executed in a separate process (unless…
-
0
votes1
answer30
viewsA: Doubt with Intents
It’s not very good for you to show all the bank records. Very hardly the user will want to see everything, the most important in the context of the app are the ones you should prioritize. Ideally…
androidanswered Max Fratane 1,535 -
0
votes1
answer608
viewsA: Pass Activity variable to javascript function in Android webview
First define a class with the annotation @JavascriptInterface in the methods. public class JsHelper { private int attr1; private int attr2; @JavascriptInterface public int getAttr1() { return attr1;…
-
1
votes2
answers974
viewsA: How to capture date value with Datepicker
One way to do this is by using the Android Datepicker: Create a class that extends DialogFragment and implement the interface DatePickerDialog.OnDateSetListener. public class DatePickerFragment…
-
2
votes1
answer173
viewsA: Enable and disable Android alarms via code
There’s no way to do that. There’s no way you can even get a list of all the active alarms in the system, for example. Unless the app that triggered the alarm provides services for this, using…
-
1
votes2
answers125
viewsA: Google Maps returning Latitude and Longitude as zero and problems when placing the Marker
The problem you have there is that both the method onSuccess(Location location) and the onMapReady(GoogleMap googleMap) are asynchronous, i.e., onSuccess can be executed before the onMapReady or the…
-
0
votes2
answers2097
viewsA: Read java txt file data and perform Java operations
That’s pretty quiet to do, what should be getting in the way is the way you’re looking at the problem. First I used a class to represent the die, called Data. This class has nothing else. Just some…
-
-1
votes1
answer1050
viewsA: Adjust image inside button
Use the attribute padding should solve your problem. <Button android:id="@+id/funcionario" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="30dp"…
-
1
votes1
answer87
viewsA: Edittext losing focus on Listview header
What is probably happening is that when you click on Listview (whether it’s the scroll click or the actual click), its observable, which is under the covers, will do that whole process to warn all…
-
1
votes1
answer174
viewsA: I cannot register data using JAVA Rest webservice
The http error 415 is when the service provider, in the case of its webservice, does not support the format of the data sent, in the case of json. On the line: con.setRequestProperty("User-Agent",…
-
0
votes1
answer89
viewsA: How are websites and web applications converted into mobile applications?
Typically, large companies develop native apps. The back-end of the app is the same as the site, so when you post a video on the youtube site, it also appears in the app. That’s what the…
-
1
votes1
answer299
viewsA: How to select multiple data from related tables
This consultation should work: SELECT livro.Titulo_livro, aluno.Nome_aluno FROM emprestimo JOIN livro ON emprestimo.Id_livro = livro.Id_livro JOIN aluno ON emprestimo.Id_aluno = aluno.Id_aluno The…
-
0
votes1
answer53
viewsA: problem to reset Countdowntimer
I think you’re forgetting to set the TIMER to null when you call the TIMER.cancel();. Since you’re wearing the suit of TIMER was null or not as a flag. After the first run, according to your code,…
-
0
votes4
answers304
viewsA: Leave part of the APP in library
It’s pretty quiet to do that.. First you’ll need to open the build.gradle of the module you want to behave like a library, and then change apply plugin: com.android.application for apply plugin:…
-
0
votes2
answers74
viewsA: Skip file when entering an Exception
It will crash because the for is inside the Try-catch, as soon as the exception is launched(FileNotFoundException or NoSuchElementException ), he will come out of the go and enter the catch. Try to…
-
2
votes2
answers775
viewsA: What is the real difference between these three ways of changing from one Activity to another?
Form 2 and 3 are the same thing. Onclick is a callback interface method. Doing it from here: new View.OnClickListener() { @Override public void onClick(View v) { Intent it = new…
-
3
votes2
answers871
viewsA: How to put notifications in an Android app?
Nothing better than Google’s own documentation. https://developer.android.com/guide/topics/ui/notifiers/notifications.html https://developer.android.com/reference/android/app/Notification.html You…
-
1
votes3
answers1005
viewsA: Recognition of sound patterns
Dude, I would recommend you use the AudioInputStream. Using it, you can take the amplitude of the wave and thus find a pattern in the input sound and compare, this pattern, with the patterns you…
-
1
votes1
answer670
viewsA: JDBC connection on AZURE server with SSL encryption
If the Encrypt property is set to true, the trustServerCertificate property is set to false and the name of the server in the connection chain does not match the server name on SSL certificate of…
-
1
votes3
answers616
viewsA: How to hide the title bar? Crash when changing android:Theme="@style/Apptheme"
Just do this in Styles. <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/SuaCor1</item>…
-
5
votes2
answers1003
viewsA: Can Sqlite work fully offline?
You can create the database(sqlite), put it in the Assets folder of your project and use the offline database quietly. For example, you can use DB Browser http://sqlitebrowser.org to create and fill…
-
1
votes1
answer425
viewsA: Java help with the concept of how to relate classes
I would solve this problem there another way. Door-class: public class Porta { boolean aberta; String cor; double dimensaoX, dimensaoY, dimensaoZ; public void Porta(boolean aberta, String cor,…
javaanswered Max Fratane 1,535 -
0
votes3
answers583
viewsA: How to recover a product id by clicking on listview opening another Activity
I didn’t quite understand the question, but first of all I strongly advise you to use a Recyclerview instead of a Listview. https://developer.android.com/training/material/lists-cards.html?hl=fr You…
-
1
votes1
answer374
viewsA: problems while running android usb in android studio
The emulator will not run because you have set the minimum API version to be larger than the version that will run on the emulator. Put your build.Radle on, please. Your phone is not showing up…