Hi,
The TaifunTextbox1.AfterTextChanged block is running more and more frequently in my app, even though I'm performing the same actions.
After a few of these repeated actions, my app slows down so much that my phone's Android system tells me to either wait a bit longer or close my app.
The task of my application is simple: it calculates the unknown fourth factor of a paired proportion from the values of the other three known factors.
In the case of direct proportion, the formula is a:b=c:d.
In the case of inverse proportion, the formula is a×b=c×d.
Where in my application code does this happen?
I described this process for myself, see below!
The appropriate calculation is called when the content of one of the four input fields changes.
This is done in the TaifunTextbox1.AfterTextChanged block.
In this block, we can check whether the content entered into the input field is a number when one of the four factors (a,b,c,d) changes in the input field?
If it is a number, then we call the create_a_target_field_if_possible_calculate_multiplier_divisor - celmezot_letrehoz_ha_lehet_szorz_hanydost_kiszamol procedure.
If this succeeds in creating a target field, then we call the TextChangeMonitoring_is_disabled_only_in_TargetField - CsakCelmezobenTilosSzovValtozasFigyelese block. In this block, we disable TaifunTextbox1 from monitoring changes in the target field's input field.
Finally, we call the calculates_TargetField_values kiszamolja_CelMezo_Erteket procedure, which changes the content of the target field.
Implementation of calculation
In the celmezot_letrehoz_ha_lehet_szorz_hanydost_kiszamol block, we create the target field – if it does not exist yet, and the corresponding product and quotient.
These two are necessary for the calculation.
When creating these two, we check whether the content of the input fields of their two factors is a number, and we create them only if the factors are numbers.
The variables of this block are: global there_is_target_field - van_celmezo, global there_are_so_many_empty_input_field - ennyi_ures_beviteli_mezo_van, global a_target_fields_serial_number - a_celmezo_sorszama, global quotient - hanyados, global product - szorzat.
In the procedure calculate_TargetField_Values block - kiszamolja_CelMezo_Erteket, we call the block corresponding to the proportionality and the serial number of the target field, which calculates the value of the unknown fourth factor.:
procedure calculates_a_in_direct_proportionality - a_t_kiszamlja_egynes_aranyossag_eseten
procedure calculates_a_in_reverse_proportionality - a_t_kiszamlja_forditott_aranyossag_eseten
procedure calculates_b_in_direct_proportionality - b_t_kiszamlja_egynes_aranyossag_eseten
procedure calculates_b_in_reverse_proportionality - b_t_kiszamlja_forditott_aranyossag_eseten
procedure calculates_c_in_direct_proportionality - c_t_kiszamlja_egynes_aranyossag_eseten
procedure calculates_c_in_reverse_proportionality - c_t_kiszamlja_forditott_aranyossag_eseten
procedure calculates_d_in_direct_proportionality - d_t_kiszamlja_egynes_aranyossag_eseten
procedure calculates_d_in_reverse_proportionality - d_t_kiszamlja_forditott_aranyossag_eseten
In the calculates_a_in_direct_proportionality - a_t_kiszamlja_egynes_aranyossag_eseten block, if b, c, d are numbers, and d is not zero, then we display the calculation formula and calculate the value of the factor, which we put in the text of the input field bevMezo_a. Then we display the values of the four factors involved in the calculation in four labels. Finally, we draw the function of linear or inverse proportionality on the canvas.
The drawing block is disabled for now, while debugging.
Here are pictures of the blocks mentioned above:
I am debugging my application by downloading the apk file from MIT App Inventor 2, installing it on my phone, and connecting the phone to my computer's USB port.
Then I started my app on the phone.
My computer is running Debian 12. In a Mate-Terminal window (command line), I issue the following command:
adb logcat -b main -v color --pid=`adb shell pidof -s appinventor.ai_csanyipal.Proportion_Solver` > logcat.txt
I am attaching the logcat.txt file:
logcat.txt (183.5 KB)
I am also attaching a link to the short video:
The short video.
Looking at the logcat.txt file, it appears that the line TaifunTextbox: AfterTextChanged. is repeated more and more when I change the content of an input field. What could be causing this?
I appreciate all advice!