+Поля
This commit is contained in:
@ -22,6 +22,7 @@ import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
@ -382,37 +383,36 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
}
|
||||
cursor.close();
|
||||
dboh.close();
|
||||
|
||||
// Чтоб при изменении страны обновлялся список регионов
|
||||
((selectDB)spiCountry).setOnChangeValueListener(new OnClickListener()
|
||||
{
|
||||
spiCountry.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
((selectDB)spiRegion).clearFields();
|
||||
((selectDB)spiRegion).addField("", "");
|
||||
|
||||
if(((selectDB)spiCountry).getValue() != null && !((selectDB)spiCountry).getValue().equals(""))
|
||||
{
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustHealthActivity.this);
|
||||
Cursor cursor = dboh.getReadableDatabase().rawQuery(
|
||||
"select id, name from countriesregions where del=0 and country_id=" + ((selectDB)spiCountry).getValue() + " order by name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
{
|
||||
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")),
|
||||
cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
dboh.close();
|
||||
}
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
return true; // Перехватываем все события касания
|
||||
}
|
||||
});
|
||||
|
||||
//Область
|
||||
spiRegion = findViewById(R.id.spiRegion); // Регион
|
||||
guiTableDel.add(spiRegion, "region_id");
|
||||
((selectDB)spiRegion).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select id, name from countriesregions where del=0 order by name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
{
|
||||
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")),
|
||||
cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
dboh.close();
|
||||
|
||||
spiRegion.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
return true; // Перехватываем все события касания
|
||||
}
|
||||
});
|
||||
//Район
|
||||
edtArea = (EditText) findViewById(R.id.edtArea); // Район
|
||||
guiTableDel.add(edtArea, "area");
|
||||
@ -3450,26 +3450,6 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
{
|
||||
_lat = location.getLatitude(); // от устройства
|
||||
_lon = location.getLongitude(); // от устройства
|
||||
|
||||
if(_lat!=0 && _lon!=0){
|
||||
if((((selectDB)spiCountry).getValue() == null || ((selectDB)spiCountry).getValue().equals("")) && (((selectDB)spiRegion).getValue()==null || ((selectDB)spiRegion).getValue().equals(""))){
|
||||
String prefName = "Identify";
|
||||
SharedPreferences prefs = getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
||||
String checked = prefs.getString(prefName, "");
|
||||
if(checked.equals("") || checked.equals("1")) {
|
||||
//Пытаюсь найти какому региону принадлежит точка
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
Integer i1 = new Integer(0);
|
||||
int[] ids = dboh.inPerimeter((float) _lon, (float) _lat);
|
||||
if (ids[0] != 0 && ids[1] != 0) {
|
||||
((selectDB)spiCountry).setValue(String.valueOf(ids[0]));
|
||||
((selectDB)spiRegion).setValue(String.valueOf(ids[1]));
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -660,7 +660,7 @@ public class LocustHealthListActivity extends AppCompatActivity
|
||||
from
|
||||
frmlocustdel ld
|
||||
left join frmlocusthealth lh on lh.frmlocustdel_uid=ld.uid
|
||||
where ld.del=0
|
||||
where ld.del=0 and ld.filled=true
|
||||
""", null); //Все
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user