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