Multi select eff impect (ubuntu)

This commit is contained in:
2025-09-02 07:31:51 +05:00
parent 8a67c49668
commit 1da522d469
12 changed files with 266 additions and 89 deletions

View File

@ -167,7 +167,7 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
public CheckBox cbEffectiveness = null; // Галочка чтоб сделать поля не обязательными
public View spiTypeImpact = null; // Тип оцениваемого биологического воздействия
//public View spiTypeImpact = null; // Тип оцениваемого биологического воздействия
public GridLayout glBiologicalImpact = null; // Тип оцениваемого биологического воздействия (grid)
public EditText edtBiologicalImpact = null; // Тип оцениваемого биологического воздействия (список значений)
@ -1055,7 +1055,6 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
}
dboh.close();*/
//Type of biological impact being assessed (I build a table of checkboxes)
edtBiologicalImpact = findViewById(R.id.edtBiologicalImpact);
guiTable.add(edtBiologicalImpact, "efficacy_impact");
@ -1083,6 +1082,32 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
}
};
edtBiologicalImpact.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s)
{
}
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
public void onTextChanged(CharSequence s, int start, int before, int count)
{
String str = LocustDelActivity.this.edtBiologicalImpact.getText().toString();
for (int i = 0; i < glBiologicalImpact.getChildCount(); i++) {
View child = glBiologicalImpact.getChildAt(i);
if (child instanceof CheckBox) {
CheckBox cb = (CheckBox) child;
String val = cb.getTag().toString();
if(str.contains(val) && !cb.isChecked()) {
cb.setChecked(true);
}
}
}
}
});
glBiologicalImpact = findViewById(R.id.glBiologicalImpact);
dboh = new DbOpenHelper(this);
rdb = null;
@ -1126,31 +1151,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
}
dboh.close();
edtBiologicalImpact.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s)
{
}
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
public void onTextChanged(CharSequence s, int start, int before, int count)
{
String str = LocustDelActivity.this.edtBiologicalImpact.getText().toString();
for (int i = 0; i < glBiologicalImpact.getChildCount(); i++) {
View child = glBiologicalImpact.getChildAt(i);
if (child instanceof CheckBox) {
CheckBox cb = (CheckBox) child;
String val = cb.getTag().toString();
if(str.contains(val) && !cb.isChecked()) {
cb.setChecked(true);
}
}
}
}
});
edtEffMortality = (EditText) findViewById(R.id.edtEffMortality); // смертность саранчи(%)
guiTable.add(edtEffMortality, "efficacy_mortality");

View File

@ -31,6 +31,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.GridLayout;
import android.widget.LinearLayout;
@ -158,18 +159,20 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
public EditText edtCalibrDropletCoating = null; //H Ширина дорожки с хорошим покрытием капель (м)
public EditText edtCalibrPassesInterval = null; //H Рекомендуемый интервал между проходами (м)
public View spiEffControl = null; // Контроль эфективности
public View spiEffTypeImpact = null; // Тип оцениваемого биологического воздействия
public GridLayout glEffTypeImpact = null; // Тип оцениваемого биологического воздействия (grid)
public EditText edtEffTypeImpact = null; // Тип оцениваемого биологического воздействия (список значений)
public View spiEffControl = null; // Контроль эфективности (Контроль эффективности проведен (бригада по обработке)?)
//public View spiEffTypeImpact = null; // Тип оцениваемого биологического воздействия (теперь множественный выбор, не используется)
public GridLayout glBiologicalImpact = null; // Тип оцениваемого биологического воздействия (grid)
public EditText edtBiologicalImpact = null; // Тип оцениваемого биологического воздействия (список значений)
//glBiologicalImpact
public EditText edtEffMortality = null; // смертность саранчи(%)
public EditText edtEffPassedTime = null; // Прошло времени после обработки в часах
public View spiEffMethod = null; // метод подсчета смертности
public View spiEffControl2 = null; //H Проведен ли контроль эффективности (бригада мониторинга)?
public View spiEffTypeImpact2 = null; //H Тип оцениваемого биологического воздействия
//public View spiEffTypeImpact2 = null; //H Тип оцениваемого биологического воздействия
public GridLayout glEffTypeImpact = null; //H Тип оцениваемого биологического воздействия(grid)
public EditText edtEffTypeImpact = null; //H Тип оцениваемого биологического воздействия (список значений)
public EditText edtEffMortality2 = null; //H Наблюдаемая эффективность обработки (%)
public EditText edtEffPassedTime2 = null; //H Прошло времени после обработки
public View spiEffMethod2 = null; //H Метод оценки эффективности обработки (выбор: подсчет квадратов; подсчет по разрезам; подсчет кулиг личинок; другое)
@ -1304,10 +1307,60 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
}
dboh.close();*/
//public GridLayout glEffTypeImpact = null; // Тип оцениваемого биологического воздействия (grid)
//public EditText edtEffTypeImpact = null; // Тип оцениваемого биологического воздействия (список значений)
//Type of biological impact being assessed (I build a table of checkboxes)
edtBiologicalImpact = findViewById(R.id.edtBiologicalImpact);
guiTableHealth.add(edtBiologicalImpact, "efficacy_impact");
CompoundButton.OnCheckedChangeListener occlBiologicalImpact = new CompoundButton.OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
StringBuilder val = new StringBuilder();
// loop through all elements inside the GridLayout
for (int i = 0; i < glBiologicalImpact.getChildCount(); i++) {
View child = glBiologicalImpact.getChildAt(i);
if (child instanceof CheckBox) {
CheckBox cb = (CheckBox) child;
if (cb.isChecked()) {
val.append(cb.getTag().toString()).append(",");
}
}
}
// remove the last comma if there is one
if (val.length() > 0 && val.charAt(val.length() - 1) == ',') {
val.deleteCharAt(val.length() - 1);
}
// save in editText
LocustHealthActivity.this.edtBiologicalImpact.setText(val.toString());
}
};
glEffTypeImpact = findViewById(R.id.glEffTypeImpact);
edtBiologicalImpact.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s)
{
}
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
public void onTextChanged(CharSequence s, int start, int before, int count)
{
String str = LocustHealthActivity.this.edtBiologicalImpact.getText().toString();
for (int i = 0; i < glBiologicalImpact.getChildCount(); i++) {
View child = glBiologicalImpact.getChildAt(i);
if (child instanceof CheckBox) {
CheckBox cb = (CheckBox) child;
String val = cb.getTag().toString();
if(str.contains(val) && !cb.isChecked()) {
cb.setChecked(true);
}
}
}
}
});
glBiologicalImpact = findViewById(R.id.glBiologicalImpact);
dboh = new DbOpenHelper(this);
rdb = null;
cursor = null;
@ -1319,24 +1372,22 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
{
int row = 0;
int col = 0;
int colCount = glEffTypeImpact.getColumnCount(); // например 2
int colCount = glBiologicalImpact.getColumnCount(); // например 2
do
{
String name = cursor.getString(cursor.getColumnIndexOrThrow("name"));
String id = cursor.getString(cursor.getColumnIndexOrThrow("id"));
CheckBox cb = new CheckBox(this);
cb.setEnabled(false);
cb.setText(name);
cb.setTag(id);
cb.setEnabled(false);
cb.setFocusable(false);
cb.setClickable(false);
cb.setLayoutParams(new GridLayout.LayoutParams(
GridLayout.spec(row, 1f), // row index
GridLayout.spec(col, 1f) // column index
));
//cb.setOnCheckedChangeListener(occlBiologicalImpact);
glEffTypeImpact.addView(cb);
cb.setOnCheckedChangeListener(occlBiologicalImpact);
glBiologicalImpact.addView(cb);
col++;
if (col >= colCount) {
@ -1353,9 +1404,7 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
}
dboh.close();
//+++++++++++++++++++++++++++++++
@ -1425,7 +1474,7 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
llEffPassedTime2.setVisibility(View.VISIBLE);
llEffMethod2.setVisibility(View.VISIBLE);
}else{
((selectDB)spiEffTypeImpact2).setValue(null);
//((selectDB)spiEffTypeImpact2).setValue(null);
edtEffMortality2.setText("");
edtEffPassedTime2.setText("");
((selectDB)spiEffMethod2).setValue(null);
@ -1437,7 +1486,7 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
}
});
//H Тип оцениваемого биологического воздействия
spiEffTypeImpact2 = findViewById(R.id.spiEffTypeImpact2);
/*spiEffTypeImpact2 = findViewById(R.id.spiEffTypeImpact2);
guiTableHealth.add(spiEffTypeImpact2, "efficacy_impact_type_id");
((selectDB)spiEffTypeImpact2).addField("", "");
dboh = new DbOpenHelper(this);
@ -1459,8 +1508,103 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
if(cursor!=null){ cursor.close(); }
if(rdb!=null){ rdb.close(); }
}
dboh.close();*/
//Type of biological impact being assessed (I build a table of checkboxes)
edtEffTypeImpact = findViewById(R.id.edtEffTypeImpact);
guiTableDel.add(edtEffTypeImpact, "efficacy_impact_type");
CompoundButton.OnCheckedChangeListener occlEffTypeImpact = new CompoundButton.OnCheckedChangeListener()
{
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
StringBuilder val = new StringBuilder();
// loop through all elements inside the GridLayout
for (int i = 0; i < glEffTypeImpact.getChildCount(); i++) {
View child = glEffTypeImpact.getChildAt(i);
if (child instanceof CheckBox) {
CheckBox cb = (CheckBox) child;
if (cb.isChecked()) {
val.append(cb.getTag().toString()).append(",");
}
}
}
// remove the last comma if there is one
if (val.length() > 0 && val.charAt(val.length() - 1) == ',') {
val.deleteCharAt(val.length() - 1);
}
// save in editText
LocustHealthActivity.this.edtEffTypeImpact.setText(val.toString());
}
};
edtEffTypeImpact.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged(Editable s){}
public void beforeTextChanged(CharSequence s, int start, int count, int after){}
public void onTextChanged(CharSequence s, int start, int before, int count)
{
String str = LocustHealthActivity.this.edtEffTypeImpact.getText().toString();
for (int i = 0; i < glEffTypeImpact.getChildCount(); i++) {
View child = glEffTypeImpact.getChildAt(i);
if (child instanceof CheckBox) {
CheckBox cb = (CheckBox) child;
String val = cb.getTag().toString();
if(str.contains(val) && !cb.isChecked()) {
cb.setChecked(true);
}
}
}
}
});
glEffTypeImpact = findViewById(R.id.glEffTypeImpact);
dboh = new DbOpenHelper(this);
rdb = null;
cursor = null;
try {
rdb = dboh.getReadableDatabase();
cursor = rdb.rawQuery("select d.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = d.name AND l.short_name='"
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_impact d where d.del=0 order by d.sort,d.name", null);
if (cursor.moveToFirst())
{
int row = 0;
int col = 0;
int colCount = glEffTypeImpact.getColumnCount(); // например 2
do
{
String name = cursor.getString(cursor.getColumnIndexOrThrow("name"));
String id = cursor.getString(cursor.getColumnIndexOrThrow("id"));
CheckBox cb = new CheckBox(this);
cb.setText(name);
cb.setTag(id);
cb.setLayoutParams(new GridLayout.LayoutParams(
GridLayout.spec(row, 1f), // row index
GridLayout.spec(col, 1f) // column index
));
cb.setOnCheckedChangeListener(occlEffTypeImpact);
glEffTypeImpact.addView(cb);
col++;
if (col >= colCount) {
col = 0;
row++;
}
} while (cursor.moveToNext());
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(cursor!=null){ cursor.close(); }
if(rdb!=null){ rdb.close(); }
}
dboh.close();
//H Наблюдаемая эффективность обработки (%)
edtEffMortality2 = (EditText) findViewById(R.id.edtEffMortality2);
guiTableHealth.add(edtEffMortality2, "efficacy_mortality");
@ -2396,10 +2540,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
if(spiCalibrConsumptionCheck.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiCalibrConsumptionCheck).updateAdapter(this);
if(spiCalibrPrecipitation.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiCalibrPrecipitation).updateAdapter(this);
if(spiEffControl.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiEffControl).updateAdapter(this);
if(spiEffTypeImpact.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiEffTypeImpact).updateAdapter(this);
//if(spiEffTypeImpact.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiEffTypeImpact).updateAdapter(this);
if(spiEffMethod.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiEffMethod).updateAdapter(this);
if(spiEffControl2.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiEffControl2).updateAdapter(this);
if(spiEffTypeImpact2.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiEffTypeImpact2).updateAdapter(this);
//if(spiEffTypeImpact2.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiEffTypeImpact2).updateAdapter(this);
if(spiEffMethod2.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiEffMethod2).updateAdapter(this);
if(spiHlthProtectiveClothingClean.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiHlthProtectiveClothingClean).updateAdapter(this);
if(spiHlthClothingReserve.getClass().toString().indexOf("dbfields.AutoCompleteTextViewDB")!=-1) ((AutoCompleteTextViewDB)spiHlthClothingReserve).updateAdapter(this);
@ -2614,7 +2758,7 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
llEffPassedTime2.setVisibility(View.VISIBLE);
llEffMethod2.setVisibility(View.VISIBLE);
}else{
((selectDB)spiEffTypeImpact2).setValue(null);
//((selectDB)spiEffTypeImpact2).setValue(null);
edtEffMortality2.setText("");
edtEffPassedTime2.setText("");
((selectDB)spiEffMethod2).setValue(null);

View File

@ -391,7 +391,7 @@ public class MainActivity extends Activity {
}
return true;
}
/** СМ. http://developer.android.com/reference/android/app/Activity.html
* Происходит при старте и при возврате на этот Activity
* */

View File

@ -1017,11 +1017,12 @@ class MyThread extends Thread
mSemaphore.release(); //Отдаем семафор
}
//Выполняем задание на отправку/приём данных
if(tsk != null)
{
Log.i("CCALM", "download task = "+tsk.name);
if(tsk.name.equals("frmlocustdel_locations")){
Log.i("CCALM", "download task = "+tsk.name + " time = " + tsk.t);
if(tsk.name.equals("frmlocustdel")){
Log.i("CCALM", "download task = "+tsk.name);
}
boolean bError=false;
@ -1152,6 +1153,7 @@ class MyThread extends Thread
bundle.putString("type", tsk.type); //Тип файла
msg.setData(bundle);
myHandle.sendMessage(msg);
}else{
Log.e("CCALM", "ERROR URL = "+tsk.url+" responseCode"+String.valueOf(responseCode));
}