Закрытие базы, освобождение ресурсов.
This commit is contained in:
@ -226,35 +226,35 @@ public class DBGUITable
|
||||
|
||||
validateField(cv);
|
||||
|
||||
SQLiteDatabase db=null;
|
||||
SQLiteDatabase wdb=null;
|
||||
try {
|
||||
db = dboh.getWritableDatabase();
|
||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
db.insert(m_table, null, cv);
|
||||
db.setTransactionSuccessful();
|
||||
wdb = dboh.getWritableDatabase();
|
||||
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
wdb.insert(m_table, null, cv);
|
||||
wdb.setTransactionSuccessful();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if(db!=null) db.endTransaction();
|
||||
if(db!=null) db.close();
|
||||
if(wdb!=null) wdb.endTransaction();
|
||||
if(wdb!=null) wdb.close();
|
||||
}
|
||||
|
||||
}else //Обновить запись
|
||||
{
|
||||
validateField(cv);
|
||||
|
||||
SQLiteDatabase db=null;
|
||||
SQLiteDatabase wdb=null;
|
||||
try {
|
||||
db = dboh.getWritableDatabase();
|
||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
wdb = dboh.getWritableDatabase();
|
||||
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
uid=cv.getAsString("uid");
|
||||
db.update(m_table, cv, "uid = ?", new String[] {uid});
|
||||
db.setTransactionSuccessful();
|
||||
wdb.update(m_table, cv, "uid = ?", new String[] {uid});
|
||||
wdb.setTransactionSuccessful();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if(db!=null) db.endTransaction();
|
||||
if(db!=null) db.close();
|
||||
if(wdb!=null) wdb.endTransaction();
|
||||
if(wdb!=null) wdb.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1603,8 +1603,11 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
||||
/**Функция для обновления или вставки табличных данных*/
|
||||
public Boolean updateTable(TCTable tbl)
|
||||
{
|
||||
SQLiteDatabase db;
|
||||
Cursor cursor;
|
||||
if(tbl.name.equals("countries"))
|
||||
Log.i("igor", "tbl0=" + tbl.name);
|
||||
if(tbl.name.equals("countriesregions"))
|
||||
Log.i("igor", "tbl0=" + tbl.name);
|
||||
|
||||
//Проверка на существование полей
|
||||
Boolean[] fb=new Boolean[tbl.fields.size()]; //Для проверки существования полей в локальной таблице
|
||||
@ -1621,7 +1624,9 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
||||
}
|
||||
}
|
||||
|
||||
db = this.getWritableDatabase();
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
wdb = this.getWritableDatabase();
|
||||
//Переписываем значения существующих полей и выполняем запросы
|
||||
while(tbl.ReadNextRecord())
|
||||
{
|
||||
@ -1659,29 +1664,32 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
||||
|
||||
if(!exists)
|
||||
{
|
||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
try {
|
||||
db.insert(tbl.name, null, cv);
|
||||
db.setTransactionSuccessful();
|
||||
wdb.insert(tbl.name, null, cv);
|
||||
wdb.setTransactionSuccessful();
|
||||
}catch(SQLException ex){
|
||||
ex.printStackTrace();
|
||||
}finally {
|
||||
db.endTransaction();
|
||||
wdb.endTransaction();
|
||||
}
|
||||
}else
|
||||
{
|
||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
try {
|
||||
db.update(tbl.name, cv, "id = ?", new String[] { tbl.getRowByName("id").getStrVal() });
|
||||
db.setTransactionSuccessful();
|
||||
wdb.update(tbl.name, cv, "id = ?", new String[] { tbl.getRowByName("id").getStrVal() });
|
||||
wdb.setTransactionSuccessful();
|
||||
}catch(SQLException ex){
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
wdb.endTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
db.close();
|
||||
}finally{
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
|
||||
|
||||
//Для дебага
|
||||
SQLiteDatabase rdb=null;
|
||||
@ -1720,10 +1728,13 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
||||
}
|
||||
}
|
||||
}
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
wdb = this.getWritableDatabase();
|
||||
//Переписываем значения существующих полей и выполняем запросы
|
||||
try {
|
||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
while(tbl.ReadNextRecord())
|
||||
{
|
||||
ContentValues cv = new ContentValues();
|
||||
@ -1737,15 +1748,17 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
||||
cv.put(tbl.fields.get(i).name, tbl.fields.get(i).getStrVal());
|
||||
}
|
||||
}
|
||||
db.insert(tbl.name, null, cv);
|
||||
wdb.insert(tbl.name, null, cv);
|
||||
}
|
||||
db.setTransactionSuccessful();
|
||||
wdb.setTransactionSuccessful();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
wdb.endTransaction();
|
||||
}
|
||||
}finally{
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
db.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1768,7 +1781,9 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
||||
|
||||
if(!b) //Новый
|
||||
{
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
wdb = this.getWritableDatabase();
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("id", id);
|
||||
cv.put("del", del);
|
||||
@ -1778,17 +1793,21 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
||||
cv.put("patronymic", patronymic);
|
||||
cv.put("login", login);
|
||||
cv.put("password", password);
|
||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
try {
|
||||
db.insert("_user", null, cv);
|
||||
db.setTransactionSuccessful();
|
||||
wdb.insert("_user", null, cv);
|
||||
wdb.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
wdb.endTransaction();
|
||||
}
|
||||
}finally{
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
db.close();
|
||||
}else //Обновить
|
||||
{
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
wdb = this.getWritableDatabase();
|
||||
ContentValues cv = new ContentValues();
|
||||
//cv.put("id", id);
|
||||
cv.put("del", del);
|
||||
@ -1798,16 +1817,16 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
||||
cv.put("patronymic", patronymic);
|
||||
cv.put("login", login);
|
||||
cv.put("password", password);
|
||||
|
||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
try {
|
||||
db.update("_user", cv, "id = ?", new String[] { String.valueOf(id) });
|
||||
db.setTransactionSuccessful();
|
||||
wdb.update("_user", cv, "id = ?", new String[] { String.valueOf(id) });
|
||||
wdb.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
wdb.endTransaction();
|
||||
}
|
||||
}finally{
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
|
||||
db.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -291,15 +291,21 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiRegion).addField("", "");
|
||||
|
||||
if (((selectDB)spiCountry).getValue() != null && !((selectDB)spiCountry).getValue().equals("")) {
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustActivity.this);
|
||||
String sql = "select id, name, lon_min from countriesregions where del=0 and country_id=" + ((selectDB)spiCountry).getValue() + " order by name";
|
||||
Cursor cursor = dboh.getReadableDatabase().rawQuery(sql, null);
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustActivity.this);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery(sql, null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
}
|
||||
@ -430,7 +436,7 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiBioBiotope).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
SQLiteDatabase rdb = null;
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select b.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = b.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),b.name) name from list_biotope b where b.del=0 order by b.name", null);
|
||||
@ -449,16 +455,21 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
guiTable.add(spiBioGreenery, "bio_greenery_id");
|
||||
((selectDB)spiBioGreenery).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
|
||||
sql = "select g.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = g.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),g.name) name from list_greenery g where g.del=0 order by g.sort";
|
||||
cursor = dboh.getReadableDatabase().rawQuery(sql, null);
|
||||
dboh = new DbOpenHelper(this);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery(sql, null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiBioGreenery).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiBioGreeneryCover = findViewById(R.id.spiBioGreeneryCover); // Растительный покров
|
||||
@ -466,14 +477,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiBioGreeneryCover).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select c.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = c.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),c.name) name from list_cover c where c.del=0 order by c.sort,c.name", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select c.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = c.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),c.name) name from list_cover c where c.del=0 order by c.sort,c.name", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiBioGreeneryCover).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtBioTemperature = (EditText) findViewById(R.id.edtBioTemperature); // Температура воздуха
|
||||
@ -496,14 +512,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiLocustType).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),lt.name) name from LocustsTypes lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),lt.name) name from LocustsTypes lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiLocustType).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtLocustPopulated = (EditText) findViewById(R.id.edtLocustPopulated);
|
||||
@ -527,13 +548,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiEggsEnemies).addField("", "");
|
||||
// Выбираем отрождение и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select b.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = b.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),b.name) name from list_enemies b where b.del=0 order by b.sort", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select b.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = b.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),b.name) name from list_enemies b where b.del=0 order by b.sort", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiEggsEnemies).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// Личинки
|
||||
@ -542,13 +569,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiLarvaBorn).addField("", "");
|
||||
// Выбираем отрождение и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select b.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = b.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),b.name) name from Borns b where b.del=0 order by b.sort", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select b.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = b.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),b.name) name from Borns b where b.del=0 order by b.sort", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiLarvaBorn).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiLarvaAge = findViewById(R.id.spiLarvaAge);
|
||||
@ -556,13 +589,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiLarvaAge).addField("", "");
|
||||
// Выбираем отрождение и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select a.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_age a where a.del=0 order by a.sort", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select a.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_age a where a.del=0 order by a.sort", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiLarvaAge).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiLarvaPainting = findViewById(R.id.spiLarvaPainting);
|
||||
@ -570,13 +609,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiLarvaPainting).addField("", "");
|
||||
// Выбираем отрождение и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select a.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_paintings a where a.del=0 order by a.sort", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select a.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_paintings a where a.del=0 order by a.sort", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiLarvaPainting).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//Поведение личинок
|
||||
@ -585,13 +630,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiLarvaBehavior).addField("", "");
|
||||
// Выбираем отрождение и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select a.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_behaviors a where a.del=0 order by a.sort", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select a.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_behaviors a where a.del=0 order by a.sort", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiLarvaBehavior).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtLarvaDensity = (EditText) findViewById(R.id.edtLarvaDensity); // Плотность
|
||||
@ -614,13 +665,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
guiTable.add(spiKuliguliAction, "kuliguli_action_id");
|
||||
((selectDB)spiKuliguliAction).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select a.id,COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_actions a where a.del=0 order by a.sort", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select a.id,COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_actions a where a.del=0 order by a.sort", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiKuliguliAction).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiKuliguliAge = findViewById(R.id.spiKuliguliAge);
|
||||
@ -628,13 +685,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
((selectDB)spiKuliguliAge).addField("", "");
|
||||
// Выбираем отрождение и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select a.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_age a where a.del=0 order by a.sort", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select a.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = a.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),a.name) name from list_age a where a.del=0 order by a.sort", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiKuliguliAge).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// Имаго
|
||||
@ -642,14 +705,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
guiTable.add(spiImagoWing, "imago_wing_id");
|
||||
((selectDB)spiImagoWing).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select f.id,COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = f.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),f.name) name from Fledgling f where f.del=0 order by f.sort", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select f.id,COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = f.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),f.name) name from Fledgling f where f.del=0 order by f.sort", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiImagoWing).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiImagoMaturity = findViewById(R.id.spiImagoMaturity);
|
||||
@ -662,13 +730,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
guiTable.add(spiImagoPhase, "imago_phase_id");
|
||||
((selectDB)spiImagoPhase).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().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_phase d where d.del=0 order by d.sort,d.name", null);
|
||||
rdb = 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_phase d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiImagoPhase).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//Поведение Имаго
|
||||
@ -676,14 +750,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
guiTable.add(spiImagoAction, "imago_action_id");
|
||||
((selectDB)spiImagoAction).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select f.id,COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = f.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),f.name) name from list_breeding f where f.del=0 order by f.sort", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select f.id,COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = f.name AND l.short_name='" + Tools.getLang() + "' LIMIT 1),f.name) name from list_breeding f where f.del=0 order by f.sort", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiImagoAction).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtImagoDensity = (EditText) findViewById(R.id.edtImagoDensity);
|
||||
@ -733,13 +812,19 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
guiTable.add(spiSwarmDensity, "swarm_density_id");
|
||||
((selectDB)spiSwarmDensity).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().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_density d where d.del=0 order by d.percent,d.name", null);
|
||||
rdb = 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_density d where d.del=0 order by d.percent,d.name", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiSwarmDensity).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtSwarmSize = (EditText) findViewById(R.id.edtSwarmSize);
|
||||
@ -752,27 +837,38 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
guiTable.add(spiSwarmFlying, "swarm_flying_direction_id");
|
||||
((selectDB)spiSwarmFlying).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
|
||||
cursor = dboh.getReadableDatabase().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, d.degree from list_directions d where d.del=0 order by d.degree", null);
|
||||
rdb = 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, d.degree from list_directions d where d.del=0 order by d.degree", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiSwarmFlying).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiSwarmHeight = findViewById(R.id.spiSwarmHeight);
|
||||
guiTable.add(spiSwarmHeight, "swarm_height_id");
|
||||
((selectDB)spiSwarmHeight).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().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_height d where d.del=0 order by d.sort,d.name", null);
|
||||
rdb = 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_height d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
do {
|
||||
((selectDB)spiSwarmHeight).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// public CheckBox cbBoxDescription = null;
|
||||
@ -1820,7 +1916,10 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
ArrayList<LatLon> list = adapter.latlonList;
|
||||
list.clear();
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
Cursor cursor = dboh.getReadableDatabase().rawQuery("select uid,lat,lon from frmlocust_locations where del=false and frmlocust_uid='" + uid + "' order by pos", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select uid,lat,lon from frmlocust_locations where del=false and frmlocust_uid='" + uid + "' order by pos", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
@ -1829,6 +1928,9 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||
}
|
||||
@ -2475,12 +2577,17 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
public void saveLocations(String uid){
|
||||
if(uid==null) return;
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustActivity.this);
|
||||
dboh.getReadableDatabase().execSQL("delete from frmlocust_locations where frmlocust_uid=\'" + uid+"\'");
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
rdb.execSQL("delete from frmlocust_locations where frmlocust_uid=\'" + uid+"\'");
|
||||
ArrayList<LatLon> list = ((LatLonAdapter)latlonList.getAdapter()).latlonList;
|
||||
for(int i=0;i<list.size();i++)
|
||||
{
|
||||
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
wdb = dboh.getWritableDatabase();
|
||||
SQLiteStatement stmt = wdb.compileStatement("insert into frmlocust_locations(uid,frmlocust_uid,pos,lat,lon)values(?,?,?,?,?)");
|
||||
stmt.bindString(1, UUID.randomUUID().toString());
|
||||
stmt.bindString(2, uid);
|
||||
@ -2488,8 +2595,14 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
stmt.bindDouble(4, list.get(i).lat);
|
||||
stmt.bindDouble(5, list.get(i).lon);
|
||||
stmt.executeInsert();
|
||||
}finally{
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
@ -2542,10 +2655,11 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
if(!cursor.moveToFirst())
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
@ -2553,6 +2667,9 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
||||
toast.show();
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
|
||||
@ -297,7 +297,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
((selectDB)spiCountry).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select id, name from countries where del=0 order by name", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select id, name from countries where del=0 order by name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
@ -306,6 +309,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// Чтоб при изменении страны обновлялся список регионов
|
||||
@ -320,8 +326,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
if(((selectDB)spiCountry).getValue() != null && !((selectDB)spiCountry).getValue().equals(""))
|
||||
{
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustDelActivity.this);
|
||||
Cursor cursor = dboh.getReadableDatabase().rawQuery(
|
||||
"select id, name from countriesregions where del=0 and country_id=" + ((selectDB)spiCountry).getValue() + " order by name", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select id, name from countriesregions where del=0 and country_id=" + ((selectDB)spiCountry).getValue() + " order by name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
@ -331,6 +339,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
}
|
||||
@ -386,10 +397,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiVegType, "vegetation_type_id");
|
||||
((selectDB)spiVegType).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.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='"
|
||||
rdb = 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_vegetation d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
@ -399,6 +410,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtVegHeight = (EditText) findViewById(R.id.edtVegHeight); // Высота (м)
|
||||
@ -408,9 +422,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiVegCover, "vegetation_cover_id");
|
||||
((selectDB)spiVegCover).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_cover d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -421,6 +436,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtVegCrop = (EditText) findViewById(R.id.edtVegCrop); // Перечисление культур
|
||||
@ -431,9 +449,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
((selectDB)spiVegDamage).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_damage d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -444,6 +463,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtVegDamageArea = (EditText) findViewById(R.id.edtVegDamageArea); // Площядь повреждения
|
||||
@ -461,9 +483,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiInsFormulation, "insecticide_formulation_id");
|
||||
((selectDB)spiInsFormulation).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_formulation d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -474,6 +497,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtInsDose = (EditText) findViewById(R.id.edtInsDose); // норма расхода(л/га)
|
||||
@ -482,9 +508,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiInsDiluted, "insecticide_diluted_id");
|
||||
((selectDB)spiInsDiluted).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_diluted d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -495,6 +522,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
edtInsProportion = (EditText) findViewById(R.id.edtInsProportion); // расход рабочей жидкости(л/га)
|
||||
guiTable.add(edtInsProportion, "insecticide_proportion");
|
||||
@ -531,10 +561,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiWindDirectionStart, "weather_direction_start");
|
||||
((selectDB)spiWindDirectionStart).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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, degree from list_directions d where d.del=0 order by d.degree", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -545,16 +575,19 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiWindDirectionEnd = findViewById(R.id.spiWindDirectionEnd); // направление ветра кон.
|
||||
guiTable.add(spiWindDirectionEnd, "weather_direction_end");
|
||||
((selectDB)spiWindDirectionEnd).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.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='"
|
||||
rdb = 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, degree from list_directions d where d.del=0 order by d.degree", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
@ -564,15 +597,19 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiSprayDirectionStart = findViewById(R.id.spiSprayDirectionStart); // направление опрыскивания нач.
|
||||
guiTable.add(spiSprayDirectionStart, "weather_spray_direction_start");
|
||||
((selectDB)spiSprayDirectionStart).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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, d.degree from list_directions d where d.del=0 and d.degree>=0 order by d.degree",
|
||||
null);
|
||||
@ -584,15 +621,19 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiSprayDirectionEnd = findViewById(R.id.spiSprayDirectionEnd); // направление опрыскивания кон.
|
||||
guiTable.add(spiSprayDirectionEnd, "weather_spray_direction_end");
|
||||
((selectDB)spiSprayDirectionEnd).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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, degree from list_directions d where d.del=0 and d.degree>=0 order by d.degree",
|
||||
null);
|
||||
@ -604,6 +645,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// locuststypes
|
||||
@ -611,9 +655,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiLocSpecies, "locust_type_id");
|
||||
((selectDB)spiLocSpecies).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery(
|
||||
"select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='"
|
||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from LocustsTypes lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -624,16 +669,19 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiLocHoppers = findViewById(R.id.spiLocHoppers); // Стадии личинок
|
||||
guiTable.add(spiLocHoppers, "locust_hoppers_id");
|
||||
((selectDB)spiLocHoppers).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
"select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='"
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='"
|
||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from list_age lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
@ -643,6 +691,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
/*
|
||||
@ -682,10 +733,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiMainPurpose, "locust_purpose_id");
|
||||
((selectDB)spiMainPurpose).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
"select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='"
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='"
|
||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from list_purpose lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
@ -695,6 +746,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
|
||||
@ -702,9 +756,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiLocustPhaseId, "locust_phase_id");
|
||||
((selectDB)spiLocustPhaseId).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_phase d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -715,16 +770,19 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiSprPlatform = findViewById(R.id.spiSprPlatform); // Вид опрыскивания
|
||||
guiTable.add(spiSprPlatform, "spray_platform");
|
||||
((selectDB)spiSprPlatform).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.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='"
|
||||
rdb = 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 sprayers_types d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
@ -734,15 +792,19 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiSprPlatformA = findViewById(R.id.spiSprPlatformA); // «Авиа» - выпадающий список:«Самолет», «Вертолет», «Дельтаплан».
|
||||
guiTable.add(spiSprPlatformA, "spray_platform_a");
|
||||
((selectDB)spiSprPlatformA).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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 sprayers d where d.del=0 and d.sprayer_type_id=1 order by d.sort,d.name",
|
||||
null);
|
||||
@ -754,15 +816,19 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiSprPlatformG = findViewById(R.id.spiSprPlatformG); // «Наземное» - выпадающий список:«Трактор», «Машина», «Аэроз.генераторG».
|
||||
guiTable.add(spiSprPlatformG, "spray_platform_g");
|
||||
((selectDB)spiSprPlatformG).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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 sprayers d where d.del=0 and d.sprayer_type_id=3 order by d.sort,d.name",
|
||||
null);
|
||||
@ -774,15 +840,19 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiSprPlatformH = findViewById(R.id.spiSprPlatformH); // «Ручное» - выпадающий список:«Ранцевый», «Моторный», «Батарейный».
|
||||
guiTable.add(spiSprPlatformH, "spray_platform_h");
|
||||
((selectDB)spiSprPlatformH).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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 sprayers d where d.del=0 and d.sprayer_type_id=5 order by d.sort,d.name",
|
||||
null);
|
||||
@ -794,6 +864,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
/*
|
||||
@ -836,9 +909,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiSprMarking, "spray_marking_id");
|
||||
((selectDB)spiSprMarking).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_markings d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -849,6 +923,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
cbEffectiveness = (CheckBox) findViewById(R.id.cbEffectiveness);
|
||||
@ -892,10 +969,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiTypeImpact, "efficacy_impact_id");
|
||||
((selectDB)spiTypeImpact).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.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='"
|
||||
rdb = 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())
|
||||
{
|
||||
@ -905,6 +982,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
edtEffMortality = (EditText) findViewById(R.id.edtEffMortality); // смертность саранчи(%)
|
||||
@ -918,9 +998,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
guiTable.add(spiEffMethod, "efficacy_mortality_method");
|
||||
((selectDB)spiEffMethod).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_mortality d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -931,6 +1012,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
OnCheckedChangeListener cclsl = new OnCheckedChangeListener()
|
||||
@ -1105,9 +1189,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
//guiTable.add(spiSafEmptyСontainers, "safety_container_id");
|
||||
//spiSafEmptyСontainers.addField(this, "", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_containers d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -1132,6 +1217,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
ccl = new OnCheckedChangeListener()
|
||||
@ -1747,13 +1835,18 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
public void saveLocations(String uid){
|
||||
if(uid==null) return;
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustDelActivity.this);
|
||||
dboh.getReadableDatabase().execSQL("update frmlocustdel_locations set del=true where frmlocustdel_uid=\'" + uid+"\'");
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
rdb.execSQL("update frmlocustdel_locations set del=true where frmlocustdel_uid=\'" + uid+"\'");
|
||||
ArrayList<LatLon> list = ((LatLonAdapter)latlonList.getAdapter()).latlonList;
|
||||
for(int i=0;i<list.size();i++)
|
||||
{
|
||||
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
||||
boolean exists=false;
|
||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
wdb = dboh.getWritableDatabase();
|
||||
SQLiteStatement stmt = wdb.compileStatement("select 1 from frmlocustdel_locations where uid=?");
|
||||
stmt.bindString(1, list.get(i).uid);
|
||||
try {
|
||||
@ -1778,8 +1871,14 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
stmt.bindString(5, list.get(i).uid);
|
||||
stmt.executeInsert();
|
||||
}
|
||||
}finally{
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
@ -1846,7 +1945,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
ArrayList<LatLon> list = adapter.latlonList;
|
||||
list.clear();
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
Cursor cursor = dboh.getReadableDatabase().rawQuery("select uid,lat,lon from frmlocustdel_locations where del=false and frmlocustdel_uid='" + uid + "' order by pos", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select uid,lat,lon from frmlocustdel_locations where del=false and frmlocustdel_uid='" + uid + "' order by pos", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
@ -1855,6 +1957,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||
}
|
||||
@ -2367,10 +2472,11 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
if(!cursor.moveToFirst())
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
@ -2378,6 +2484,9 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
||||
toast.show();
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -164,7 +165,13 @@ public class LocustDelListActivity extends AppCompatActivity
|
||||
public void onClick(DialogInterface dialog, int arg1)
|
||||
{
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustDelListActivity.this);
|
||||
dboh.getReadableDatabase().execSQL("delete from frmlocustdel where send=1");
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
wdb = dboh.getWritableDatabase();
|
||||
wdb.execSQL("delete from frmlocustdel where send=1");
|
||||
} finally {
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
LocustDelListActivity.this.onStart();
|
||||
}
|
||||
@ -599,20 +606,23 @@ public class LocustDelListActivity extends AppCompatActivity
|
||||
llList.removeAllViews();
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustDelListActivity.this);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = null;
|
||||
switch (spiList.getSelectedItemPosition())
|
||||
{
|
||||
case 0:
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and filled!=1 and device_id='"+android_id+"'", null); //Не отправленные
|
||||
cursor = rdb.rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and filled!=1 and device_id='" + android_id + "'", null); //Не отправленные
|
||||
break;
|
||||
case 1:
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and send=0 and filled=1 and device_id='"+android_id+"'", null); //Не отправленные
|
||||
cursor = rdb.rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and send=0 and filled=1 and device_id='"+android_id+"'", null); //Не отправленные
|
||||
break;
|
||||
case 2:
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and send=1 and device_id='"+android_id+"'", null); //Отправленные
|
||||
cursor = rdb.rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and send=1 and device_id='"+android_id+"'", null); //Отправленные
|
||||
break;
|
||||
default:
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and device_id='"+android_id+"'", null); //Все
|
||||
cursor = rdb.rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and device_id='"+android_id+"'", null); //Все
|
||||
break;
|
||||
}
|
||||
|
||||
@ -675,6 +685,9 @@ public class LocustDelListActivity extends AppCompatActivity
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
@ -687,8 +700,10 @@ public class LocustDelListActivity extends AppCompatActivity
|
||||
super.onStart();
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
if(!cursor.moveToFirst())
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
@ -696,6 +711,9 @@ public class LocustDelListActivity extends AppCompatActivity
|
||||
toast.show();
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
|
||||
@ -374,7 +374,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
((selectDB)spiCountry).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select id, uid, name from countries where del=0 order by name", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select id, uid, name from countries where del=0 order by name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
@ -383,6 +386,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
spiCountry.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
@ -396,7 +402,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
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);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select id, name from countriesregions where del=0 order by name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
@ -406,6 +415,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
spiRegion.setOnTouchListener(new View.OnTouchListener() {
|
||||
@ -479,9 +491,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiVegType, "vegetation_type_id");
|
||||
((selectDB)spiVegType).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_vegetation d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -492,6 +505,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//высота растительности
|
||||
@ -503,9 +519,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiVegCover, "vegetation_cover_id");
|
||||
((selectDB)spiVegCover).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_cover d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -516,6 +533,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//Наименование сельхоз культуры
|
||||
@ -550,9 +570,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
((selectDB)spiInsFormulation).addField("", "");
|
||||
// Выбираем страны и заполняем поля
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_formulation d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -563,6 +584,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// норма расхода(л/га)
|
||||
@ -574,10 +598,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiInsDiluted, "insecticide_diluted_id");
|
||||
((selectDB)spiInsDiluted).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.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='"
|
||||
rdb = 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_diluted d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
@ -587,6 +611,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// Если применимо: Коэффициент разбавления рабочего раствора (л или кг коммерческого препарата/л воды или дизельного топлива)
|
||||
@ -602,9 +629,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableHealth.add(spiInsContainerState, "insecticide_container_state_id");
|
||||
((selectDB)spiInsContainerState).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_containers_states d where d.del=0 order by d.sort, d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -615,6 +643,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//**********Погодные условия**********
|
||||
@ -644,10 +675,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiWindDirectionStart, "weather_direction_start");
|
||||
((selectDB)spiWindDirectionStart).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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, degree from list_directions d where d.del=0 order by d.degree", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -658,6 +689,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// направление ветра кон.
|
||||
@ -665,9 +699,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiWindDirectionEnd, "weather_direction_end");
|
||||
((selectDB)spiWindDirectionEnd).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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, degree from list_directions d where d.del=0 order by d.degree", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -678,6 +713,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// направление опрыскивания нач.
|
||||
@ -685,9 +723,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiSprayDirectionStart, "weather_spray_direction_start");
|
||||
((selectDB)spiSprayDirectionStart).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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, d.degree from list_directions d where d.del=0 and d.degree>=0 order by d.degree",
|
||||
null);
|
||||
@ -699,6 +738,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// направление опрыскивания кон.
|
||||
@ -706,9 +748,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiSprayDirectionEnd, "weather_spray_direction_end");
|
||||
((selectDB)spiSprayDirectionEnd).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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, degree from list_directions d where d.del=0 and d.degree>=0 order by d.degree",
|
||||
null);
|
||||
@ -720,6 +763,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//**********Информация о саранчовых**********
|
||||
@ -728,9 +774,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiLocSpecies, "locust_type_id");
|
||||
((selectDB)spiLocSpecies).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery(
|
||||
"select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='"
|
||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from LocustsTypes lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -741,15 +788,19 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
// Возраст личинок (Стадии личинок)
|
||||
spiLocHoppers = findViewById(R.id.spiLocHoppers);
|
||||
guiTableDel.add(spiLocHoppers, "locust_hoppers_id");
|
||||
((selectDB)spiLocHoppers).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery(
|
||||
"select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='"
|
||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from list_age lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -760,6 +811,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
// плотность на м2
|
||||
edtLocDensity = (EditText) findViewById(R.id.edtLocDensity);
|
||||
@ -770,9 +824,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiMainPurpose, "locust_purpose_id");
|
||||
((selectDB)spiMainPurpose).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery(
|
||||
"select lt.id, COALESCE((SELECT translation FROM _translations t JOIN _languages l ON t.language_id=l.id WHERE t.del = 0 AND identifier = lt.name AND l.short_name='"
|
||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from list_purpose lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -783,6 +838,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//**********Сведения по опрыскиванию**********
|
||||
@ -791,9 +849,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiSprPlatform, "spray_platform");
|
||||
((selectDB)spiSprPlatform).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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 sprayers_types d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -804,6 +863,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// «Авиа» - выпадающий список:«Самолет», «Вертолет», «Дельтаплан».
|
||||
@ -811,9 +873,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiSprPlatformA, "spray_platform_a");
|
||||
((selectDB)spiSprPlatformA).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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 sprayers d where d.del=0 and d.sprayer_type_id=1 order by d.sort,d.name",
|
||||
null);
|
||||
@ -825,6 +888,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// «Наземное» - выпадающий список:«Трактор», «Машина», «Аэроз.генераторG».
|
||||
@ -832,10 +898,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiSprPlatformG, "spray_platform_g");
|
||||
((selectDB)spiSprPlatformG).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.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='"
|
||||
rdb = 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 sprayers d where d.del=0 and d.sprayer_type_id=3 order by d.sort,d.name",
|
||||
null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -846,6 +912,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// «Ручное» - выпадающий список:«Ранцевый», «Моторный», «Батарейный».
|
||||
@ -853,9 +922,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiSprPlatformH, "spray_platform_h");
|
||||
((selectDB)spiSprPlatformH).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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 sprayers d where d.del=0 and d.sprayer_type_id=5 order by d.sort,d.name",
|
||||
null);
|
||||
@ -867,6 +937,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// Марка опрыскивателя
|
||||
@ -918,9 +991,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiSprMarking, "spray_marking_id");
|
||||
((selectDB)spiSprMarking).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_markings d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -931,6 +1005,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// обработанная площадь(га)
|
||||
@ -1016,9 +1093,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiEffTypeImpact, "efficacy_impact_id");
|
||||
((selectDB)spiEffTypeImpact).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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())
|
||||
@ -1029,6 +1107,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
// Наблюдаемая эфективность обработок (%)
|
||||
@ -1044,9 +1125,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableDel.add(spiEffMethod, "efficacy_mortality_method");
|
||||
((selectDB)spiEffMethod).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_mortality d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -1057,6 +1139,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//H Проведен ли контроль эффективности (бригада мониторинга)?
|
||||
@ -1078,9 +1163,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableHealth.add(spiEffTypeImpact2, "efficacy_impact_type_id");
|
||||
((selectDB)spiEffTypeImpact2).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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())
|
||||
@ -1091,6 +1177,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//H Наблюдаемая эффективность обработки (%)
|
||||
@ -1104,9 +1193,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
guiTableHealth.add(spiEffMethod2, "efficacy_mortality_method_id");
|
||||
((selectDB)spiEffMethod2).addField("", "");
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = 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_mortality d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -1117,6 +1207,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
|
||||
@ -1220,9 +1313,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
//**********Состояние окружающей среды**********
|
||||
// Пустые контейнеры (выборка локализованных названий)
|
||||
dboh = new DbOpenHelper(this);
|
||||
cursor = dboh
|
||||
.getReadableDatabase()
|
||||
.rawQuery(
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getWritableDatabase();
|
||||
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_containers d where d.del=0 order by d.sort,d.name", null);
|
||||
if (cursor.moveToFirst())
|
||||
@ -1244,6 +1338,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
//Тут сам выбор значений из базы
|
||||
edtSafEmptyContainers = (EditText) findViewById(R.id.edtSafEmptyContainers);
|
||||
@ -3348,18 +3445,29 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
public void saveLocations(String uid){
|
||||
if(uid==null) return;
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustHealthActivity.this);
|
||||
dboh.getReadableDatabase().execSQL("delete from frmlocusthealth_locations where frmlocusthealth_uid=\'" + uid+"\'");
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
wdb = dboh.getWritableDatabase();
|
||||
wdb.execSQL("delete from frmlocusthealth_locations where frmlocusthealth_uid=\'" + uid+"\'");
|
||||
}finally{
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
ArrayList<LatLon> list = ((LatLonAdapter)latlonList.getAdapter()).latlonList;
|
||||
for(int i=0;i<list.size();i++)
|
||||
{
|
||||
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
||||
wdb = null;
|
||||
try {
|
||||
wdb = dboh.getWritableDatabase();
|
||||
SQLiteStatement stmt = wdb.compileStatement("insert into frmlocusthealth_locations(frmlocusthealth_uid,pos,lat,lon)values(?,?,?,?)");
|
||||
stmt.bindString(1, uid);
|
||||
stmt.bindLong(2, i);
|
||||
stmt.bindDouble(3, list.get(i).lat);
|
||||
stmt.bindDouble(4, list.get(i).lon);
|
||||
stmt.executeInsert();
|
||||
}finally{
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
dboh.close();
|
||||
@ -3403,7 +3511,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
ArrayList<LatLon> list = adapter.latlonList;
|
||||
list.clear();
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
Cursor cursor = dboh.getReadableDatabase().rawQuery("select uid,lat,lon from frmlocustdel_locations where frmlocustdel_uid='" + uid + "' order by pos", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getWritableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select uid,lat,lon from frmlocustdel_locations where frmlocustdel_uid='" + uid + "' order by pos", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
@ -3412,6 +3523,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||
}
|
||||
@ -3970,8 +4084,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
super.onStart();
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery("select * from terminals where del=0 and serial='"+ Secure.getString(getContentResolver(), Secure.ANDROID_ID)+"';", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getWritableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Secure.getString(getContentResolver(), Secure.ANDROID_ID)+"';", null);
|
||||
if(!cursor.moveToFirst())
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
@ -3979,6 +4095,9 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
||||
toast.show();
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +161,13 @@ public class LocustHealthListActivity extends AppCompatActivity
|
||||
public void onClick(DialogInterface dialog, int arg1)
|
||||
{
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustHealthListActivity.this);
|
||||
dboh.getReadableDatabase().execSQL("delete from frmlocusthealth where send=1");
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
rdb.execSQL("delete from frmlocusthealth where send=1");
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
LocustHealthListActivity.this.onStart();
|
||||
}
|
||||
@ -596,12 +602,15 @@ public class LocustHealthListActivity extends AppCompatActivity
|
||||
llList.removeAllViews();
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustHealthListActivity.this);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
|
||||
Cursor cursor = null;
|
||||
switch (spiList.getSelectedItemPosition())
|
||||
{
|
||||
case 0:
|
||||
cursor = dboh.getReadableDatabase().rawQuery("""
|
||||
cursor = rdb.rawQuery("""
|
||||
select
|
||||
ld.uid as frmlocustdel_uid,
|
||||
lh.uid as frmlocusthealth_uid,
|
||||
@ -617,7 +626,7 @@ public class LocustHealthListActivity extends AppCompatActivity
|
||||
""", null); //Не отправленные
|
||||
break;
|
||||
case 1:
|
||||
cursor = dboh.getReadableDatabase().rawQuery("""
|
||||
cursor = rdb.rawQuery("""
|
||||
select
|
||||
ld.uid as frmlocustdel_uid,
|
||||
lh.uid as frmlocusthealth_uid,
|
||||
@ -634,7 +643,7 @@ public class LocustHealthListActivity extends AppCompatActivity
|
||||
""", null); //Не отправленные
|
||||
break;
|
||||
case 2:
|
||||
cursor = dboh.getReadableDatabase().rawQuery("""
|
||||
cursor = rdb.rawQuery("""
|
||||
select
|
||||
ld.uid as frmlocustdel_uid,
|
||||
lh.uid as frmlocusthealth_uid,
|
||||
@ -650,7 +659,7 @@ public class LocustHealthListActivity extends AppCompatActivity
|
||||
""", null); //Отправленные
|
||||
break;
|
||||
default:
|
||||
cursor = dboh.getReadableDatabase().rawQuery("""
|
||||
cursor = rdb.rawQuery("""
|
||||
select
|
||||
ld.uid as frmlocustdel_uid,
|
||||
lh.uid as frmlocusthealth_uid,
|
||||
@ -737,6 +746,9 @@ public class LocustHealthListActivity extends AppCompatActivity
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
@ -749,8 +761,10 @@ public class LocustHealthListActivity extends AppCompatActivity
|
||||
super.onStart();
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
if(!cursor.moveToFirst())
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
@ -758,6 +772,9 @@ public class LocustHealthListActivity extends AppCompatActivity
|
||||
toast.show();
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
|
||||
@ -159,7 +159,13 @@ public class LocustListActivity extends AppCompatActivity
|
||||
public void onClick(DialogInterface dialog, int arg1)
|
||||
{
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustListActivity.this);
|
||||
dboh.getReadableDatabase().execSQL("delete from frmlocust where send=1");
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
rdb.execSQL("delete from frmlocust where send=1");
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
LocustListActivity.this.onStart();
|
||||
}
|
||||
@ -573,26 +579,28 @@ public class LocustListActivity extends AppCompatActivity
|
||||
llList.removeAllViews();
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(LocustListActivity.this);
|
||||
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
String sql;
|
||||
Cursor cursor = null;
|
||||
switch (spiList.getSelectedItemPosition())
|
||||
{
|
||||
case 0:
|
||||
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0 and filled!=1";
|
||||
cursor = dboh.getReadableDatabase().rawQuery(sql, null); //Не заполненые
|
||||
cursor = rdb.rawQuery(sql, null); //Не заполненые
|
||||
break;
|
||||
case 1:
|
||||
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0 and send=0 and filled=1";
|
||||
cursor = dboh.getReadableDatabase().rawQuery(sql, null); //Не отправленные
|
||||
cursor = rdb.rawQuery(sql, null); //Не отправленные
|
||||
break;
|
||||
case 2:
|
||||
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0 and send=1";
|
||||
cursor = dboh.getReadableDatabase().rawQuery(sql, null); //Отправленные
|
||||
cursor = rdb.rawQuery(sql, null); //Отправленные
|
||||
break;
|
||||
default:
|
||||
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0";
|
||||
cursor = dboh.getReadableDatabase().rawQuery(sql, null); //Все
|
||||
cursor = rdb.rawQuery(sql, null); //Все
|
||||
break;
|
||||
}
|
||||
|
||||
@ -642,6 +650,9 @@ public class LocustListActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
/**
|
||||
@ -652,8 +663,10 @@ public class LocustListActivity extends AppCompatActivity
|
||||
super.onStart();
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||
if(!cursor.moveToFirst())
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(),
|
||||
@ -661,6 +674,9 @@ public class LocustListActivity extends AppCompatActivity
|
||||
toast.show();
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,8 +85,9 @@ public class MainActivity extends Activity {
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(MainActivity.this);;
|
||||
//Перебираем и удаляем фото файлы названия которых нет в базе данных!
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
|
||||
File directory = new File(Environment.getExternalStorageDirectory() + File.separator + "Pictures" + File.separator + "Locust");
|
||||
directory.mkdirs();
|
||||
@ -102,13 +103,13 @@ public class MainActivity extends Activity {
|
||||
|
||||
Cursor cursor;
|
||||
sql = "select 1 from frmlocust where image_name1='" + fileName + "' or image_name2='" + fileName + "' or image_name3='" + fileName + "';";
|
||||
cursor = db.rawQuery(sql, null);
|
||||
cursor = rdb.rawQuery(sql, null);
|
||||
if (cursor.moveToFirst())
|
||||
exest = exest | true;
|
||||
cursor.close();
|
||||
|
||||
sql = "select 1 from frmlocustdel where image_name1='" + fileName + "' or image_name2='" + fileName + "' or image_name3='" + fileName + "';";
|
||||
cursor = db.rawQuery(sql, null);
|
||||
cursor = rdb.rawQuery(sql, null);
|
||||
if (cursor.moveToFirst())
|
||||
exest = exest | true;
|
||||
cursor.close();
|
||||
@ -120,8 +121,6 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Проверяю есть ли в безе записи и вставляю только если их нет
|
||||
/* теперь в базу не переписываю так как всё храниться в файлах
|
||||
boolean exest = false;
|
||||
@ -146,7 +145,9 @@ public class MainActivity extends Activity {
|
||||
}
|
||||
}*/
|
||||
|
||||
db.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
tvCountTasks = (TextView) findViewById(R.id.tvCountTasks);
|
||||
@ -201,7 +202,10 @@ public class MainActivity extends Activity {
|
||||
DbOpenHelper dboh;
|
||||
Cursor cursor;
|
||||
dboh = new DbOpenHelper(MainActivity.this);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select c.id from borns c limit 1;", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select c.id from borns c limit 1;", null);
|
||||
if (cursor.moveToFirst())
|
||||
{
|
||||
do
|
||||
@ -210,6 +214,9 @@ public class MainActivity extends Activity {
|
||||
} while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
if(!exists) {
|
||||
|
||||
@ -9,6 +9,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@ -130,10 +131,12 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
|
||||
);
|
||||
marker.setVisible(false);
|
||||
|
||||
|
||||
//Геозоны обследования саранчи
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
Cursor cursor = dboh.getReadableDatabase().rawQuery("select frmlocust_uid,lat,lon from frmlocust_locations where frmlocust_uid!='"+uid+"' order by frmlocust_uid,pos;", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select frmlocust_uid,lat,lon from frmlocust_locations where frmlocust_uid!='"+uid+"' order by frmlocust_uid,pos;", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
String uid="";
|
||||
PolygonOptions pOptions2 = new PolygonOptions();
|
||||
@ -157,7 +160,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
|
||||
}
|
||||
cursor.close();
|
||||
//Геозоны противосаначовой обработки
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select frmlocustdel_uid,lat,lon from frmlocustdel_locations where frmlocustdel_uid!='"+uid+"' order by frmlocustdel_uid,pos;", null);
|
||||
cursor = rdb.rawQuery("select frmlocustdel_uid,lat,lon from frmlocustdel_locations where frmlocustdel_uid!='"+uid+"' order by frmlocustdel_uid,pos;", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
String uid="";
|
||||
PolygonOptions pOptions2 = new PolygonOptions();
|
||||
@ -180,6 +183,9 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
/**/
|
||||
//Сreating a polygon. (The main polygon at the end since they overlap each)
|
||||
|
||||
@ -194,7 +194,10 @@ public class MySynchronizationOld
|
||||
String xml="";
|
||||
DbOpenHelper dboh = new DbOpenHelper(_context);
|
||||
Cursor cursor = null;
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select * from frmlocust where uid=?", new String[] { String.valueOf(uid) });
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select * from frmlocust where uid=?", new String[] { String.valueOf(uid) });
|
||||
|
||||
if(cursor.moveToFirst())
|
||||
{
|
||||
@ -229,7 +232,7 @@ public class MySynchronizationOld
|
||||
}
|
||||
|
||||
String geom="";
|
||||
Cursor cursor2 = dboh.getReadableDatabase().rawQuery("select lat,lon from frmlocust_locations where frmlocust_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||
Cursor cursor2 = rdb.rawQuery("select lat,lon from frmlocust_locations where frmlocust_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||
if(cursor2.moveToFirst()) {
|
||||
String first="["+cursor2.getDouble(1)+","+cursor2.getDouble(0)+"]";
|
||||
do {
|
||||
@ -247,6 +250,9 @@ public class MySynchronizationOld
|
||||
}while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
@ -261,8 +267,11 @@ public class MySynchronizationOld
|
||||
String xml="";
|
||||
DbOpenHelper dboh = new DbOpenHelper(_context);
|
||||
Cursor cursor = null;
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select * from frmlocustdel where uid=?", new String[] { String.valueOf(uid) });
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
|
||||
cursor = rdb.rawQuery("select * from frmlocustdel where uid=?", new String[] { String.valueOf(uid) });
|
||||
if(cursor.moveToFirst())
|
||||
{
|
||||
do{
|
||||
@ -296,7 +305,7 @@ public class MySynchronizationOld
|
||||
xml+=" <"+cursor.getColumnName(i)+"><![CDATA["+val+"]]></"+cursor.getColumnName(i)+">\n";
|
||||
}
|
||||
String geom="";
|
||||
Cursor cursor2 = dboh.getReadableDatabase().rawQuery("select lat,lon from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||
Cursor cursor2 = rdb.rawQuery("select lat,lon from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||
if(cursor2.moveToFirst()) {
|
||||
String first="["+cursor2.getDouble(1)+","+cursor2.getDouble(0)+"]";
|
||||
do {
|
||||
@ -312,7 +321,7 @@ public class MySynchronizationOld
|
||||
rid_sendFrmLocust = myThread.addRequest(MySynchronizationOld.URL+"/get/", xml, null,null);
|
||||
|
||||
//Отправляю данные координат отдельно (без подтверждения доставки, потом нужно добавить поле send boolean и отправлять отдельно от frmlocustdel)
|
||||
/* Cursor cursor3 = dboh.getReadableDatabase().rawQuery("select uid,del,seq,frmlocustdel_uid,pos,lon,lat from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||
/* Cursor cursor3 = rdb.rawQuery("select uid,del,seq,frmlocustdel_uid,pos,lon,lat from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
TCTableTools2.getTCTableFromCursor("frmlocustdel_locations", 0, cursor3, outStream);
|
||||
myThread.addRequest(MySynchronizationOld.URL+"/asdc/tctable/", null, null, outStream.toByteArray());*/
|
||||
@ -328,7 +337,7 @@ public class MySynchronizationOld
|
||||
tbl.addField(new TCField("lat",TCField.BD_FLOAT8));
|
||||
tbl.getHeader(outStream);
|
||||
//Переписываю значения из базы данных в outStream
|
||||
Cursor cursor3 = dboh.getReadableDatabase().rawQuery("select uid,del,seq,frmlocustdel_uid,pos,lon,lat from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||
Cursor cursor3 = rdb.rawQuery("select uid,del,seq,frmlocustdel_uid,pos,lon,lat from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||
if(cursor3.moveToFirst()) {
|
||||
do {
|
||||
tbl.fields.get(0).setValue(cursor3.getString(0));
|
||||
@ -349,6 +358,9 @@ public class MySynchronizationOld
|
||||
}while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
@ -364,7 +376,10 @@ public class MySynchronizationOld
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(_context);
|
||||
Cursor cursor = null;
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select * from frmlocusthealth where uid=?", new String[] { String.valueOf(uid) });
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
cursor = rdb.rawQuery("select * from frmlocusthealth where uid=?", new String[] { String.valueOf(uid) });
|
||||
if(cursor.moveToFirst())
|
||||
{
|
||||
do{
|
||||
@ -402,6 +417,9 @@ public class MySynchronizationOld
|
||||
}while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
@ -410,13 +428,18 @@ public class MySynchronizationOld
|
||||
{
|
||||
String seq="";
|
||||
DbOpenHelper dboh = new DbOpenHelper(_context);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery("select max(seq) as seq from " + tableName + ";", null);
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select max(seq) as seq from " + tableName + ";", null);
|
||||
if (cursor.moveToFirst()) {
|
||||
seq = cursor.getString(cursor.getColumnIndex("seq"));
|
||||
}
|
||||
if (seq == null) seq = "0";
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
if(days!=null && !days.isEmpty() && country_id!=null && !country_id.isEmpty()){
|
||||
return myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=1&r=0&n="+tableName+"&s=" + seq + "&l=1000&days="+days+"&country_id="+country_id+"&android_id="+android_id,"", null,null);
|
||||
@ -441,7 +464,10 @@ public class MySynchronizationOld
|
||||
|
||||
//Последовательно отправляю изменёные пользователям записи (send=0 и они заполнены)
|
||||
DbOpenHelper dboh = new DbOpenHelper(_context);
|
||||
Cursor cursor = dboh.getReadableDatabase().rawQuery("select uid from frmlocust where send=0 and filled=1 and device_id=?", new String[]{ android_id });
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select uid from frmlocust where send=0 and filled=1 and device_id=?", new String[]{ android_id });
|
||||
if(cursor.moveToFirst())
|
||||
{
|
||||
do{
|
||||
@ -449,11 +475,17 @@ public class MySynchronizationOld
|
||||
}while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//Последовательно отправляю изменёные пользователям записи (send=0 и они заполнены)
|
||||
dboh = new DbOpenHelper(_context);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select uid from frmlocustdel where send=0 and filled=1 and device_id=?", new String[]{ android_id });
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select uid from frmlocustdel where send=0 and filled=1 and device_id=?", new String[]{ android_id });
|
||||
if(cursor.moveToFirst())
|
||||
{
|
||||
do{
|
||||
@ -461,6 +493,9 @@ public class MySynchronizationOld
|
||||
}while (cursor.moveToNext());
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//Запрос в очередь на получение списка стран, направлений, итд.
|
||||
@ -505,7 +540,10 @@ public class MySynchronizationOld
|
||||
|
||||
//Загружаю формы саранчовых обработок за последние X дней для страны Y
|
||||
dboh = new DbOpenHelper(_context);
|
||||
cursor = dboh.getReadableDatabase().rawQuery("select t.country_id from terminals t where t.del=0 and t.serial='"+ android_id +"';", null);
|
||||
rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select t.country_id from terminals t where t.del=0 and t.serial='"+ android_id +"';", null);
|
||||
if(cursor.moveToFirst())
|
||||
{
|
||||
String country_id = cursor.getString(0);
|
||||
@ -514,6 +552,9 @@ public class MySynchronizationOld
|
||||
rid_frmlocustdel_locations = makeRequest("frmlocustdel_locations",String.valueOf(MySynchronizationOld.SyncDays),country_id);
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
}
|
||||
|
||||
@ -610,22 +651,26 @@ public class MySynchronizationOld
|
||||
|
||||
Cursor cursor;
|
||||
DbOpenHelper dboh = new DbOpenHelper(_context);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
SQLiteDatabase rdb = null;
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
wdb = dboh.getWritableDatabase();
|
||||
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("send", 1); //Отмечаем как отправленное
|
||||
//cv.put("changed", 0); //Отмечаем как не измененное
|
||||
|
||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
try {
|
||||
db.update("frmlocust", cv, "uid = ?", new String[]{String.valueOf(uid)});
|
||||
db.setTransactionSuccessful();
|
||||
wdb.update("frmlocust", cv, "uid = ?", new String[]{String.valueOf(uid)});
|
||||
wdb.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
wdb.endTransaction();
|
||||
}
|
||||
|
||||
//Ищем имя файла по id и удаляем фотографии
|
||||
cursor = db.rawQuery("select image_name1, image_name2, image_name3 from frmlocust where uid=?;", new String[]{String.valueOf(uid)});
|
||||
cursor = rdb.rawQuery("select image_name1, image_name2, image_name3 from frmlocust where uid=?;", new String[]{String.valueOf(uid)});
|
||||
if (cursor.moveToFirst()) {
|
||||
String path;
|
||||
File pFile;
|
||||
@ -648,7 +693,11 @@ public class MySynchronizationOld
|
||||
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name3"))));
|
||||
}
|
||||
}
|
||||
db.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
} else if (fn.equals("5")) //Сохранили данные о саранче на сервере ставим признак отправленности
|
||||
{
|
||||
@ -657,22 +706,26 @@ public class MySynchronizationOld
|
||||
|
||||
Cursor cursor;
|
||||
DbOpenHelper dboh = new DbOpenHelper(_context);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
SQLiteDatabase rdb = null;
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
wdb = dboh.getWritableDatabase();
|
||||
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("send", 1); //Отмечаем как отправленное
|
||||
//cv.put("changed", 0); //Отмечаем как не измененное
|
||||
|
||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||
try {
|
||||
db.update("frmlocustdel", cv, "uid = ?", new String[]{String.valueOf(uid)});
|
||||
db.setTransactionSuccessful();
|
||||
wdb.update("frmlocustdel", cv, "uid = ?", new String[]{String.valueOf(uid)});
|
||||
wdb.setTransactionSuccessful();
|
||||
} finally {
|
||||
db.endTransaction();
|
||||
wdb.endTransaction();
|
||||
}
|
||||
|
||||
//Ищем имя файла по id и удаляем фотографии
|
||||
cursor = db.rawQuery("select image_name1, image_name2, image_name3 from frmlocustdel where uid=?;", new String[]{String.valueOf(uid)});
|
||||
cursor = rdb.rawQuery("select image_name1, image_name2, image_name3 from frmlocustdel where uid=?;", new String[]{String.valueOf(uid)});
|
||||
if (cursor.moveToFirst()) {
|
||||
String path;
|
||||
File pFile;
|
||||
@ -695,7 +748,10 @@ public class MySynchronizationOld
|
||||
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name3"))));
|
||||
}
|
||||
}
|
||||
db.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
|
||||
} else if (fn.equals("6")) //Фото отправлено
|
||||
{
|
||||
|
||||
@ -119,8 +119,10 @@ public class ScanActivity extends Activity {
|
||||
tvOrganization = (TextView) findViewById(R.id.tvOrganization);
|
||||
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery("select " +
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
Cursor cursor = rdb.rawQuery("select " +
|
||||
" cr.name as country_name," +
|
||||
" cp.name as company_name," +
|
||||
" t.name " +
|
||||
@ -136,6 +138,9 @@ public class ScanActivity extends Activity {
|
||||
tvName.setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||
}
|
||||
cursor.close();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
|
||||
@ -241,8 +246,12 @@ public class ScanActivity extends Activity {
|
||||
String sql="select * from terminals where id="+json.getString("id");
|
||||
boolean exists=false;
|
||||
DbOpenHelper dboh = new DbOpenHelper(this);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
Cursor cursor = db.rawQuery(sql, null);
|
||||
SQLiteDatabase rdb = null;
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
wdb = dboh.getWritableDatabase();
|
||||
Cursor cursor = rdb.rawQuery(sql, null);
|
||||
if(cursor.moveToFirst())
|
||||
{
|
||||
exists=true;
|
||||
@ -250,7 +259,6 @@ public class ScanActivity extends Activity {
|
||||
cursor.close();
|
||||
if(exists){
|
||||
sql="update terminals set country_id=?,company_id=?,name=?,serial=? where id=?";
|
||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
||||
SQLiteStatement stmt = wdb.compileStatement(sql);
|
||||
stmt.bindLong(1, json.getLong("country_id"));
|
||||
stmt.bindLong(2, json.getLong("company_id"));
|
||||
@ -260,7 +268,6 @@ public class ScanActivity extends Activity {
|
||||
stmt.executeUpdateDelete();
|
||||
}else{
|
||||
sql="insert into terminals(id,country_id,company_id,name,serial)values(?,?,?,?,?);";
|
||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
||||
SQLiteStatement stmt = wdb.compileStatement(sql);
|
||||
stmt.bindLong(1, json.getLong("id"));
|
||||
stmt.bindLong(2, json.getLong("country_id"));
|
||||
@ -269,6 +276,10 @@ public class ScanActivity extends Activity {
|
||||
stmt.bindString(5, Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID));
|
||||
stmt.executeInsert();
|
||||
}
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
}else {
|
||||
|
||||
@ -8,6 +8,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Color;
|
||||
@ -378,8 +379,14 @@ public class SetupActivity extends Activity {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
//Delete all data
|
||||
DbOpenHelper dboh = new DbOpenHelper(SetupActivity.this);
|
||||
dboh.dropAllTables(dboh.getReadableDatabase());
|
||||
dboh.onCreate(dboh.getReadableDatabase());
|
||||
SQLiteDatabase wdb = null;
|
||||
try {
|
||||
wdb = dboh.getWritableDatabase();
|
||||
dboh.dropAllTables(wdb);
|
||||
dboh.onCreate(wdb);
|
||||
}finally{
|
||||
if(wdb!=null){ wdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
//Restarting APP
|
||||
|
||||
@ -22,8 +22,12 @@ public class SplashScreen extends Activity {
|
||||
|
||||
//Создаём базу
|
||||
DbOpenHelper dboh=new DbOpenHelper(this);
|
||||
SQLiteDatabase db = dboh.getReadableDatabase();
|
||||
db.close();
|
||||
SQLiteDatabase rdb = null;
|
||||
try {
|
||||
rdb = dboh.getReadableDatabase();
|
||||
}finally{
|
||||
if(rdb!=null){ rdb.close(); }
|
||||
}
|
||||
dboh.close();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user