Закрытие базы, освобождение ресурсов.
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,67 +1624,72 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
db = this.getWritableDatabase();
|
SQLiteDatabase wdb = null;
|
||||||
//Переписываем значения существующих полей и выполняем запросы
|
try {
|
||||||
while(tbl.ReadNextRecord())
|
wdb = this.getWritableDatabase();
|
||||||
{
|
//Переписываем значения существующих полей и выполняем запросы
|
||||||
if(tbl.name.equals("frmlocustdel")){
|
while(tbl.ReadNextRecord())
|
||||||
Log.i("igor","tbl.name="+tbl.name);
|
|
||||||
}
|
|
||||||
String sql="select 1 from "+tbl.name+" where id = ?";
|
|
||||||
String[] par = new String[] { tbl.getRowByName("id").getStrVal() };
|
|
||||||
|
|
||||||
boolean exists=false;
|
|
||||||
SQLiteDatabase rdb=null;
|
|
||||||
try {
|
|
||||||
rdb = getReadableDatabase();
|
|
||||||
cursor = rdb.rawQuery(sql, par);
|
|
||||||
exists=cursor.moveToFirst();
|
|
||||||
cursor.close();
|
|
||||||
}finally{
|
|
||||||
if(rdb != null) { rdb.close(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentValues cv = new ContentValues();
|
|
||||||
for(int i=0;i<tbl.fields.size();i++)
|
|
||||||
{
|
{
|
||||||
//if(b && tbl.fields.get(i).name.equals("id")) continue; //Если существует не записываем
|
if(tbl.name.equals("frmlocustdel")){
|
||||||
Log.i("igor","fld="+tbl.fields.get(i).name+" val="+tbl.fields.get(i).getStrVal()+" type="+tbl.fields.get(i).type); //Для дебага
|
Log.i("igor","tbl.name="+tbl.name);
|
||||||
|
}
|
||||||
|
String sql="select 1 from "+tbl.name+" where id = ?";
|
||||||
|
String[] par = new String[] { tbl.getRowByName("id").getStrVal() };
|
||||||
|
|
||||||
if(fb[i]) //Присваиваем только поля существующие в локальной базе
|
boolean exists=false;
|
||||||
|
SQLiteDatabase rdb=null;
|
||||||
|
try {
|
||||||
|
rdb = getReadableDatabase();
|
||||||
|
cursor = rdb.rawQuery(sql, par);
|
||||||
|
exists=cursor.moveToFirst();
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb != null) { rdb.close(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentValues cv = new ContentValues();
|
||||||
|
for(int i=0;i<tbl.fields.size();i++)
|
||||||
{
|
{
|
||||||
if(tbl.fields.get(i).value==null)
|
//if(b && tbl.fields.get(i).name.equals("id")) continue; //Если существует не записываем
|
||||||
cv.putNull(tbl.fields.get(i).name);
|
Log.i("igor","fld="+tbl.fields.get(i).name+" val="+tbl.fields.get(i).getStrVal()+" type="+tbl.fields.get(i).type); //Для дебага
|
||||||
else
|
|
||||||
cv.put(tbl.fields.get(i).name, tbl.fields.get(i).getStrVal());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!exists)
|
if(fb[i]) //Присваиваем только поля существующие в локальной базе
|
||||||
{
|
{
|
||||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
if(tbl.fields.get(i).value==null)
|
||||||
try {
|
cv.putNull(tbl.fields.get(i).name);
|
||||||
db.insert(tbl.name, null, cv);
|
else
|
||||||
db.setTransactionSuccessful();
|
cv.put(tbl.fields.get(i).name, tbl.fields.get(i).getStrVal());
|
||||||
}catch(SQLException ex){
|
}
|
||||||
ex.printStackTrace();
|
|
||||||
}finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
}
|
||||||
}else
|
|
||||||
{
|
if(!exists)
|
||||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
{
|
||||||
try {
|
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||||
db.update(tbl.name, cv, "id = ?", new String[] { tbl.getRowByName("id").getStrVal() });
|
try {
|
||||||
db.setTransactionSuccessful();
|
wdb.insert(tbl.name, null, cv);
|
||||||
}catch(SQLException ex){
|
wdb.setTransactionSuccessful();
|
||||||
ex.printStackTrace();
|
}catch(SQLException ex){
|
||||||
} finally {
|
ex.printStackTrace();
|
||||||
db.endTransaction();
|
}finally {
|
||||||
|
wdb.endTransaction();
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||||
|
try {
|
||||||
|
wdb.update(tbl.name, cv, "id = ?", new String[] { tbl.getRowByName("id").getStrVal() });
|
||||||
|
wdb.setTransactionSuccessful();
|
||||||
|
}catch(SQLException ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
wdb.endTransaction();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}finally{
|
||||||
|
if(wdb!=null){ wdb.close(); }
|
||||||
}
|
}
|
||||||
db.close();
|
|
||||||
|
|
||||||
//Для дебага
|
//Для дебага
|
||||||
SQLiteDatabase rdb=null;
|
SQLiteDatabase rdb=null;
|
||||||
@ -1720,32 +1728,37 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SQLiteDatabase db = this.getWritableDatabase();
|
|
||||||
//Переписываем значения существующих полей и выполняем запросы
|
SQLiteDatabase wdb = null;
|
||||||
try {
|
try {
|
||||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
wdb = this.getWritableDatabase();
|
||||||
while(tbl.ReadNextRecord())
|
//Переписываем значения существующих полей и выполняем запросы
|
||||||
{
|
try {
|
||||||
ContentValues cv = new ContentValues();
|
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||||
for(int i=0;i<tbl.fields.size();i++)
|
while(tbl.ReadNextRecord())
|
||||||
{
|
{
|
||||||
if(fb[i]) //Присваиваем только поля существующие локально
|
ContentValues cv = new ContentValues();
|
||||||
|
for(int i=0;i<tbl.fields.size();i++)
|
||||||
{
|
{
|
||||||
if(tbl.fields.get(i).value==null)
|
if(fb[i]) //Присваиваем только поля существующие локально
|
||||||
cv.putNull(tbl.fields.get(i).name);
|
{
|
||||||
else
|
if(tbl.fields.get(i).value==null)
|
||||||
cv.put(tbl.fields.get(i).name, tbl.fields.get(i).getStrVal());
|
cv.putNull(tbl.fields.get(i).name);
|
||||||
|
else
|
||||||
|
cv.put(tbl.fields.get(i).name, tbl.fields.get(i).getStrVal());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
wdb.insert(tbl.name, null, cv);
|
||||||
}
|
}
|
||||||
db.insert(tbl.name, null, cv);
|
wdb.setTransactionSuccessful();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
wdb.endTransaction();
|
||||||
}
|
}
|
||||||
db.setTransactionSuccessful();
|
}finally{
|
||||||
} catch (Exception e) {
|
if(wdb!=null){ wdb.close(); }
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
}
|
||||||
db.close();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1768,46 +1781,52 @@ public class DbOpenHelper extends SQLiteOpenHelper
|
|||||||
|
|
||||||
if(!b) //Новый
|
if(!b) //Новый
|
||||||
{
|
{
|
||||||
SQLiteDatabase db = this.getWritableDatabase();
|
SQLiteDatabase wdb = null;
|
||||||
ContentValues cv = new ContentValues();
|
|
||||||
cv.put("id", id);
|
|
||||||
cv.put("del", del);
|
|
||||||
cv.put("seq", seq);
|
|
||||||
cv.put("name", name);
|
|
||||||
cv.put("surname", surname);
|
|
||||||
cv.put("patronymic", patronymic);
|
|
||||||
cv.put("login", login);
|
|
||||||
cv.put("password", password);
|
|
||||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
|
||||||
try {
|
try {
|
||||||
db.insert("_user", null, cv);
|
wdb = this.getWritableDatabase();
|
||||||
db.setTransactionSuccessful();
|
ContentValues cv = new ContentValues();
|
||||||
} finally {
|
cv.put("id", id);
|
||||||
db.endTransaction();
|
cv.put("del", del);
|
||||||
|
cv.put("seq", seq);
|
||||||
|
cv.put("name", name);
|
||||||
|
cv.put("surname", surname);
|
||||||
|
cv.put("patronymic", patronymic);
|
||||||
|
cv.put("login", login);
|
||||||
|
cv.put("password", password);
|
||||||
|
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||||
|
try {
|
||||||
|
wdb.insert("_user", null, cv);
|
||||||
|
wdb.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
wdb.endTransaction();
|
||||||
|
}
|
||||||
|
}finally{
|
||||||
|
if(wdb!=null){ wdb.close(); }
|
||||||
}
|
}
|
||||||
db.close();
|
|
||||||
}else //Обновить
|
}else //Обновить
|
||||||
{
|
{
|
||||||
SQLiteDatabase db = this.getWritableDatabase();
|
SQLiteDatabase wdb = null;
|
||||||
ContentValues cv = new ContentValues();
|
|
||||||
//cv.put("id", id);
|
|
||||||
cv.put("del", del);
|
|
||||||
cv.put("seq", seq);
|
|
||||||
cv.put("name", name);
|
|
||||||
cv.put("surname", surname);
|
|
||||||
cv.put("patronymic", patronymic);
|
|
||||||
cv.put("login", login);
|
|
||||||
cv.put("password", password);
|
|
||||||
|
|
||||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
|
||||||
try {
|
try {
|
||||||
db.update("_user", cv, "id = ?", new String[] { String.valueOf(id) });
|
wdb = this.getWritableDatabase();
|
||||||
db.setTransactionSuccessful();
|
ContentValues cv = new ContentValues();
|
||||||
} finally {
|
//cv.put("id", id);
|
||||||
db.endTransaction();
|
cv.put("del", del);
|
||||||
|
cv.put("seq", seq);
|
||||||
|
cv.put("name", name);
|
||||||
|
cv.put("surname", surname);
|
||||||
|
cv.put("patronymic", patronymic);
|
||||||
|
cv.put("login", login);
|
||||||
|
cv.put("password", password);
|
||||||
|
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||||
|
try {
|
||||||
|
wdb.update("_user", cv, "id = ?", new String[] { String.valueOf(id) });
|
||||||
|
wdb.setTransactionSuccessful();
|
||||||
|
} finally {
|
||||||
|
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);
|
||||||
if (cursor.moveToFirst()) {
|
SQLiteDatabase rdb = null;
|
||||||
do {
|
try {
|
||||||
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
rdb = dboh.getReadableDatabase();
|
||||||
} while (cursor.moveToNext());
|
Cursor cursor = rdb.rawQuery(sql, null);
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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);
|
||||||
if (cursor.moveToFirst()) {
|
rdb = null;
|
||||||
do {
|
try {
|
||||||
((selectDB)spiBioGreenery).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
rdb = dboh.getReadableDatabase();
|
||||||
} while (cursor.moveToNext());
|
cursor = rdb.rawQuery(sql, null);
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiBioGreenery).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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 {
|
||||||
if (cursor.moveToFirst()) {
|
rdb = dboh.getReadableDatabase();
|
||||||
do {
|
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);
|
||||||
((selectDB)spiBioGreeneryCover).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
if (cursor.moveToFirst()) {
|
||||||
} while (cursor.moveToNext());
|
do {
|
||||||
|
((selectDB)spiBioGreeneryCover).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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 {
|
||||||
if (cursor.moveToFirst()) {
|
rdb = dboh.getReadableDatabase();
|
||||||
do {
|
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);
|
||||||
((selectDB)spiLocustType).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
if (cursor.moveToFirst()) {
|
||||||
} while (cursor.moveToNext());
|
do {
|
||||||
|
((selectDB)spiLocustType).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiEggsEnemies).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiEggsEnemies).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiLarvaBorn).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiLarvaBorn).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiLarvaAge).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiLarvaAge).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiLarvaPainting).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiLarvaPainting).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiLarvaBehavior).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiLarvaBehavior).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiKuliguliAction).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiKuliguliAction).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiKuliguliAge).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiKuliguliAge).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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 {
|
||||||
if (cursor.moveToFirst()) {
|
rdb = dboh.getReadableDatabase();
|
||||||
do {
|
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);
|
||||||
((selectDB)spiImagoWing).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
if (cursor.moveToFirst()) {
|
||||||
} while (cursor.moveToNext());
|
do {
|
||||||
|
((selectDB)spiImagoWing).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiImagoPhase).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiImagoPhase).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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 {
|
||||||
if (cursor.moveToFirst()) {
|
rdb = dboh.getReadableDatabase();
|
||||||
do {
|
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);
|
||||||
((selectDB)spiImagoAction).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
if (cursor.moveToFirst()) {
|
||||||
} while (cursor.moveToNext());
|
do {
|
||||||
|
((selectDB)spiImagoAction).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiSwarmDensity).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiSwarmDensity).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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 {
|
||||||
if (cursor.moveToFirst()) {
|
rdb = dboh.getReadableDatabase();
|
||||||
do {
|
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);
|
||||||
((selectDB)spiSwarmFlying).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
if (cursor.moveToFirst()) {
|
||||||
} while (cursor.moveToNext());
|
do {
|
||||||
|
((selectDB)spiSwarmFlying).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
do {
|
rdb = dboh.getReadableDatabase();
|
||||||
((selectDB)spiSwarmHeight).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
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);
|
||||||
} while (cursor.moveToNext());
|
if (cursor.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
((selectDB)spiSwarmHeight).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// public CheckBox cbBoxDescription = null;
|
// public CheckBox cbBoxDescription = null;
|
||||||
@ -1820,15 +1916,21 @@ 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;
|
||||||
if (cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
do
|
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())
|
||||||
{
|
{
|
||||||
list.add(new LatLon(cursor.getString(0), cursor.getDouble(1), cursor.getDouble(2)));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
list.add(new LatLon(cursor.getString(0), cursor.getDouble(1), cursor.getDouble(2)));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
}
|
}
|
||||||
@ -2475,20 +2577,31 @@ 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;
|
||||||
ArrayList<LatLon> list = ((LatLonAdapter)latlonList.getAdapter()).latlonList;
|
try {
|
||||||
for(int i=0;i<list.size();i++)
|
rdb = dboh.getReadableDatabase();
|
||||||
{
|
rdb.execSQL("delete from frmlocust_locations where frmlocust_uid=\'" + uid+"\'");
|
||||||
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
ArrayList<LatLon> list = ((LatLonAdapter)latlonList.getAdapter()).latlonList;
|
||||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
for(int i=0;i<list.size();i++)
|
||||||
SQLiteStatement stmt = wdb.compileStatement("insert into frmlocust_locations(uid,frmlocust_uid,pos,lat,lon)values(?,?,?,?,?)");
|
{
|
||||||
stmt.bindString(1, UUID.randomUUID().toString());
|
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
||||||
stmt.bindString(2, uid);
|
SQLiteDatabase wdb = null;
|
||||||
stmt.bindLong(3, i);
|
try {
|
||||||
stmt.bindDouble(4, list.get(i).lat);
|
wdb = dboh.getWritableDatabase();
|
||||||
stmt.bindDouble(5, list.get(i).lon);
|
SQLiteStatement stmt = wdb.compileStatement("insert into frmlocust_locations(uid,frmlocust_uid,pos,lat,lon)values(?,?,?,?,?)");
|
||||||
stmt.executeInsert();
|
stmt.bindString(1, UUID.randomUUID().toString());
|
||||||
|
stmt.bindString(2, uid);
|
||||||
|
stmt.bindLong(3, i);
|
||||||
|
stmt.bindDouble(4, list.get(i).lat);
|
||||||
|
stmt.bindDouble(5, list.get(i).lon);
|
||||||
|
stmt.executeInsert();
|
||||||
|
}finally{
|
||||||
|
if(wdb!=null){ wdb.close(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
@ -2542,17 +2655,21 @@ 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 {
|
||||||
if(!cursor.moveToFirst())
|
rdb = dboh.getReadableDatabase();
|
||||||
{
|
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||||
Toast toast = Toast.makeText(getApplicationContext(),
|
if(!cursor.moveToFirst())
|
||||||
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
{
|
||||||
toast.show();
|
Toast toast = Toast.makeText(getApplicationContext(),
|
||||||
|
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -297,15 +297,21 @@ 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;
|
||||||
if (cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
do
|
cursor = rdb.rawQuery("select id, name from countries where del=0 order by name", null);
|
||||||
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
((selectDB)spiCountry).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiCountry).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// Чтоб при изменении страны обновлялся список регионов
|
// Чтоб при изменении страны обновлялся список регионов
|
||||||
@ -320,17 +326,22 @@ 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 {
|
||||||
if (cursor.moveToFirst())
|
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);
|
||||||
do
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")),
|
do
|
||||||
cursor.getString(cursor.getColumnIndex("id")));
|
{
|
||||||
} while (cursor.moveToNext());
|
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")),
|
||||||
|
cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -386,19 +397,22 @@ 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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiVegType).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiVegType).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
edtVegHeight = (EditText) findViewById(R.id.edtVegHeight); // Высота (м)
|
edtVegHeight = (EditText) findViewById(R.id.edtVegHeight); // Высота (м)
|
||||||
@ -408,19 +422,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_cover d where d.del=0 order by d.sort, d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiVegCover).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiVegCover).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
edtVegCrop = (EditText) findViewById(R.id.edtVegCrop); // Перечисление культур
|
edtVegCrop = (EditText) findViewById(R.id.edtVegCrop); // Перечисление культур
|
||||||
@ -431,19 +449,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_damage d where d.del=0 order by d.sort, d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiVegDamage).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiVegDamage).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
edtVegDamageArea = (EditText) findViewById(R.id.edtVegDamageArea); // Площядь повреждения
|
edtVegDamageArea = (EditText) findViewById(R.id.edtVegDamageArea); // Площядь повреждения
|
||||||
@ -461,19 +483,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_formulation d where d.del=0 order by d.sort, d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiInsFormulation).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiInsFormulation).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
edtInsDose = (EditText) findViewById(R.id.edtInsDose); // норма расхода(л/га)
|
edtInsDose = (EditText) findViewById(R.id.edtInsDose); // норма расхода(л/га)
|
||||||
@ -482,19 +508,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_diluted d where d.del=0 order by d.sort, d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiInsDiluted).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiInsDiluted).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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,79 +561,93 @@ 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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiWindDirectionStart).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiWindDirectionStart).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiWindDirectionEnd).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiWindDirectionEnd).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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();
|
||||||
"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(
|
||||||
+ 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",
|
"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='"
|
||||||
null);
|
+ 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",
|
||||||
if (cursor.moveToFirst())
|
null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprayDirectionStart).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprayDirectionStart).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name, degree from list_directions d where d.del=0 and d.degree>=0 order by d.degree",
|
"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='"
|
||||||
null);
|
+ Tools.getLang() + "' LIMIT 1),d.name) name, degree from list_directions d where d.del=0 and d.degree>=0 order by d.degree",
|
||||||
if (cursor.moveToFirst())
|
null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprayDirectionEnd).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprayDirectionEnd).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// locuststypes
|
// locuststypes
|
||||||
@ -611,38 +655,45 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from LocustsTypes lt where lt.del=0 order by lt.sort,lt.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ Tools.getLang() + "' LIMIT 1),lt.name) name from LocustsTypes lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiLocSpecies).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiLocSpecies).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiLocHoppers).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiLocHoppers).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -682,19 +733,22 @@ 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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiMainPurpose).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiMainPurpose).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
|
|
||||||
@ -702,98 +756,117 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_phase d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_phase d where d.del=0 order by d.sort,d.name", null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiLocustPhaseId).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiLocustPhaseId).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprPlatform).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprPlatform).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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();
|
||||||
"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(
|
||||||
+ 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",
|
"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='"
|
||||||
null);
|
+ 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",
|
||||||
if (cursor.moveToFirst())
|
null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprPlatformA).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprPlatformA).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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();
|
||||||
"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(
|
||||||
+ 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",
|
"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='"
|
||||||
null);
|
+ 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",
|
||||||
if (cursor.moveToFirst())
|
null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprPlatformG).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprPlatformG).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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();
|
||||||
"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(
|
||||||
+ 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",
|
"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='"
|
||||||
null);
|
+ 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",
|
||||||
if (cursor.moveToFirst())
|
null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprPlatformH).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprPlatformH).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -836,19 +909,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_markings d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprMarking).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprMarking).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
cbEffectiveness = (CheckBox) findViewById(R.id.cbEffectiveness);
|
cbEffectiveness = (CheckBox) findViewById(R.id.cbEffectiveness);
|
||||||
@ -892,19 +969,22 @@ 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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiTypeImpact).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiTypeImpact).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
edtEffMortality = (EditText) findViewById(R.id.edtEffMortality); // смертность саранчи(%)
|
edtEffMortality = (EditText) findViewById(R.id.edtEffMortality); // смертность саранчи(%)
|
||||||
@ -918,19 +998,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_mortality d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiEffMethod).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiEffMethod).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
OnCheckedChangeListener cclsl = new OnCheckedChangeListener()
|
OnCheckedChangeListener cclsl = new OnCheckedChangeListener()
|
||||||
@ -1105,33 +1189,37 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_containers d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
//spiSafEmptyСontainers.addField(this, cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
|
{
|
||||||
|
//spiSafEmptyСontainers.addField(this, cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==1)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==1)
|
||||||
((CheckBox) findViewById(R.id.cbTripleRinsed)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbTripleRinsed)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==2)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==2)
|
||||||
((CheckBox) findViewById(R.id.cbPunctured)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbPunctured)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==3)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==3)
|
||||||
((CheckBox) findViewById(R.id.cbTakenBackToBase)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbTakenBackToBase)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==4)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==4)
|
||||||
((CheckBox) findViewById(R.id.cbLeftInField)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbLeftInField)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==5)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==5)
|
||||||
((CheckBox) findViewById(R.id.cbBuried)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbBuried)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==6)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==6)
|
||||||
((CheckBox) findViewById(R.id.cbBurned)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbBurned)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
|
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
ccl = new OnCheckedChangeListener()
|
ccl = new OnCheckedChangeListener()
|
||||||
@ -1747,38 +1835,49 @@ 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;
|
||||||
ArrayList<LatLon> list = ((LatLonAdapter)latlonList.getAdapter()).latlonList;
|
try {
|
||||||
for(int i=0;i<list.size();i++)
|
rdb = dboh.getReadableDatabase();
|
||||||
{
|
rdb.execSQL("update frmlocustdel_locations set del=true where frmlocustdel_uid=\'" + uid+"\'");
|
||||||
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
ArrayList<LatLon> list = ((LatLonAdapter)latlonList.getAdapter()).latlonList;
|
||||||
boolean exists=false;
|
for(int i=0;i<list.size();i++)
|
||||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
{
|
||||||
SQLiteStatement stmt = wdb.compileStatement("select 1 from frmlocustdel_locations where uid=?");
|
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
||||||
stmt.bindString(1, list.get(i).uid);
|
boolean exists=false;
|
||||||
try {
|
SQLiteDatabase wdb = null;
|
||||||
long result = stmt.simpleQueryForLong();
|
try {
|
||||||
exists = result == 1;
|
wdb = dboh.getWritableDatabase();
|
||||||
} catch (Exception e) {
|
SQLiteStatement stmt = wdb.compileStatement("select 1 from frmlocustdel_locations where uid=?");
|
||||||
}
|
stmt.bindString(1, list.get(i).uid);
|
||||||
if(exists){
|
try {
|
||||||
stmt = wdb.compileStatement("update frmlocustdel_locations set del=false,frmlocustdel_uid=?,pos=?,lat=?,lon=? where uid=?");
|
long result = stmt.simpleQueryForLong();
|
||||||
stmt.bindString(1, uid);
|
exists = result == 1;
|
||||||
stmt.bindLong(2, i);
|
} catch (Exception e) {
|
||||||
stmt.bindDouble(3, list.get(i).lat);
|
}
|
||||||
stmt.bindDouble(4, list.get(i).lon);
|
if(exists){
|
||||||
stmt.bindString(5, list.get(i).uid);
|
stmt = wdb.compileStatement("update frmlocustdel_locations set del=false,frmlocustdel_uid=?,pos=?,lat=?,lon=? where uid=?");
|
||||||
stmt.executeUpdateDelete();
|
stmt.bindString(1, uid);
|
||||||
}else{
|
stmt.bindLong(2, i);
|
||||||
stmt = wdb.compileStatement("insert into frmlocustdel_locations(frmlocustdel_uid,pos,lat,lon,uid)values(?,?,?,?,?)");
|
stmt.bindDouble(3, list.get(i).lat);
|
||||||
stmt.bindString(1, uid);
|
stmt.bindDouble(4, list.get(i).lon);
|
||||||
stmt.bindLong(2, i);
|
stmt.bindString(5, list.get(i).uid);
|
||||||
stmt.bindDouble(3, list.get(i).lat);
|
stmt.executeUpdateDelete();
|
||||||
stmt.bindDouble(4, list.get(i).lon);
|
}else{
|
||||||
stmt.bindString(5, list.get(i).uid);
|
stmt = wdb.compileStatement("insert into frmlocustdel_locations(frmlocustdel_uid,pos,lat,lon,uid)values(?,?,?,?,?)");
|
||||||
stmt.executeInsert();
|
stmt.bindString(1, uid);
|
||||||
|
stmt.bindLong(2, i);
|
||||||
|
stmt.bindDouble(3, list.get(i).lat);
|
||||||
|
stmt.bindDouble(4, list.get(i).lon);
|
||||||
|
stmt.bindString(5, list.get(i).uid);
|
||||||
|
stmt.executeInsert();
|
||||||
|
}
|
||||||
|
}finally{
|
||||||
|
if(wdb!=null){ wdb.close(); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
@ -1846,15 +1945,21 @@ 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;
|
||||||
if (cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
do
|
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())
|
||||||
{
|
{
|
||||||
list.add(new LatLon(cursor.getString(0), cursor.getDouble(1), cursor.getDouble(2)));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
list.add(new LatLon(cursor.getString(0), cursor.getDouble(1), cursor.getDouble(2)));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
}
|
}
|
||||||
@ -2367,17 +2472,21 @@ 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 {
|
||||||
if(!cursor.moveToFirst())
|
rdb = dboh.getReadableDatabase();
|
||||||
{
|
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||||
Toast toast = Toast.makeText(getApplicationContext(),
|
if(!cursor.moveToFirst())
|
||||||
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
{
|
||||||
toast.show();
|
Toast toast = Toast.makeText(getApplicationContext(),
|
||||||
|
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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,82 +606,88 @@ public class LocustDelListActivity extends AppCompatActivity
|
|||||||
llList.removeAllViews();
|
llList.removeAllViews();
|
||||||
|
|
||||||
DbOpenHelper dboh = new DbOpenHelper(LocustDelListActivity.this);
|
DbOpenHelper dboh = new DbOpenHelper(LocustDelListActivity.this);
|
||||||
Cursor cursor = null;
|
SQLiteDatabase rdb = null;
|
||||||
switch (spiList.getSelectedItemPosition())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
case 0:
|
Cursor cursor = null;
|
||||||
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); //Не отправленные
|
switch (spiList.getSelectedItemPosition())
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
cursor = dboh.getReadableDatabase().rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and send=0 and filled=1 and device_id='"+android_id+"'", null); //Не отправленные
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
cursor = dboh.getReadableDatabase().rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and send=1 and device_id='"+android_id+"'", null); //Отправленные
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
cursor = dboh.getReadableDatabase().rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and device_id='"+android_id+"'", null); //Все
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tools.logCursor(cursor);
|
|
||||||
OnClickListener oclBtn = new OnClickListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(View v)
|
|
||||||
{
|
{
|
||||||
MyButton b = (MyButton) v;
|
case 0:
|
||||||
|
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); //Не отправленные
|
||||||
Intent intent = new Intent(LocustDelListActivity.this, LocustDelActivity.class);
|
break;
|
||||||
intent.putExtra("uid", b.uid1);
|
case 1:
|
||||||
startActivity(intent);
|
cursor = rdb.rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and send=0 and filled=1 and device_id='"+android_id+"'", null); //Не отправленные
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
cursor = rdb.rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and send=1 and device_id='"+android_id+"'", null); //Отправленные
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cursor = rdb.rawQuery("select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocustdel where del=0 and device_id='"+android_id+"'", null); //Все
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if (cursor.moveToFirst())
|
// Tools.logCursor(cursor);
|
||||||
{
|
OnClickListener oclBtn = new OnClickListener()
|
||||||
do
|
|
||||||
{
|
{
|
||||||
btn = new MyButton(this);
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
MyButton b = (MyButton) v;
|
||||||
|
|
||||||
btn.setOnClickListener(oclBtn);
|
Intent intent = new Intent(LocustDelListActivity.this, LocustDelActivity.class);
|
||||||
|
intent.putExtra("uid", b.uid1);
|
||||||
btn.uid1 = cursor.getString(cursor.getColumnIndex("uid"));
|
startActivity(intent);
|
||||||
|
|
||||||
// Преобразует с учётом временой зоны (пример long dv = 946684800L * 1000L; //2000 ный по гринвичу дало 6 утра)
|
|
||||||
String vv = "";
|
|
||||||
String val = cursor.getString(cursor.getColumnIndex("date"));
|
|
||||||
try {
|
|
||||||
long dv = Long.parseLong(val) * (long) 1000;// its need to be in milisecond
|
|
||||||
Date df = new java.util.Date(dv);
|
|
||||||
vv = new SimpleDateFormat("dd.MM.yyyy").format(df);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
}
|
||||||
if(vv.isEmpty()) {
|
};
|
||||||
|
|
||||||
|
if (cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
btn = new MyButton(this);
|
||||||
|
|
||||||
|
btn.setOnClickListener(oclBtn);
|
||||||
|
|
||||||
|
btn.uid1 = cursor.getString(cursor.getColumnIndex("uid"));
|
||||||
|
|
||||||
|
// Преобразует с учётом временой зоны (пример long dv = 946684800L * 1000L; //2000 ный по гринвичу дало 6 утра)
|
||||||
|
String vv = "";
|
||||||
|
String val = cursor.getString(cursor.getColumnIndex("date"));
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
long dv = Long.parseLong(val) * (long) 1000;// its need to be in milisecond
|
||||||
Date df = format.parse(val);
|
Date df = new java.util.Date(dv);
|
||||||
vv = new SimpleDateFormat("dd.MM.yyyy").format(df);
|
vv = new SimpleDateFormat("dd.MM.yyyy").format(df);
|
||||||
} catch (ParseException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
if(vv.isEmpty()) {
|
||||||
|
try {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Date df = format.parse(val);
|
||||||
|
vv = new SimpleDateFormat("dd.MM.yyyy").format(df);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
btn.setText(cursor.getString(cursor.getColumnIndex("terrain")) + " (" + vv + ")");
|
btn.setText(cursor.getString(cursor.getColumnIndex("terrain")) + " (" + vv + ")");
|
||||||
|
|
||||||
// Устанавливаю высоту в пикселях через высоту макета
|
// Устанавливаю высоту в пикселях через высоту макета
|
||||||
int heightInDp = 40;
|
int heightInDp = 40;
|
||||||
float scale = getResources().getDisplayMetrics().density;
|
float scale = getResources().getDisplayMetrics().density;
|
||||||
int heightInPx = (int) (heightInDp * scale + 0.5f); //Перевожу в dp
|
int heightInPx = (int) (heightInDp * scale + 0.5f); //Перевожу в dp
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||||
LayoutParams.MATCH_PARENT,
|
LayoutParams.MATCH_PARENT,
|
||||||
heightInPx
|
heightInPx
|
||||||
);
|
);
|
||||||
params.bottomMargin = 4;
|
params.bottomMargin = 4;
|
||||||
|
|
||||||
llList.addView(btn,params);
|
llList.addView(btn,params);
|
||||||
|
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -687,15 +700,20 @@ 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 {
|
||||||
if(!cursor.moveToFirst())
|
rdb = dboh.getReadableDatabase();
|
||||||
{
|
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||||
Toast toast = Toast.makeText(getApplicationContext(),
|
if(!cursor.moveToFirst())
|
||||||
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
{
|
||||||
toast.show();
|
Toast toast = Toast.makeText(getApplicationContext(),
|
||||||
|
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -374,15 +374,21 @@ 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;
|
||||||
if (cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
do
|
cursor = rdb.rawQuery("select id, uid, name from countries where del=0 order by name", null);
|
||||||
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
((selectDB)spiCountry).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiCountry).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
spiCountry.setOnTouchListener(new View.OnTouchListener() {
|
spiCountry.setOnTouchListener(new View.OnTouchListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -396,16 +402,22 @@ 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;
|
||||||
if (cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
do
|
cursor = rdb.rawQuery("select id, name from countriesregions where del=0 order by name", null);
|
||||||
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")),
|
do
|
||||||
cursor.getString(cursor.getColumnIndex("id")));
|
{
|
||||||
} while (cursor.moveToNext());
|
((selectDB)spiRegion).addField(cursor.getString(cursor.getColumnIndex("name")),
|
||||||
|
cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
spiRegion.setOnTouchListener(new View.OnTouchListener() {
|
spiRegion.setOnTouchListener(new View.OnTouchListener() {
|
||||||
@ -479,19 +491,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_vegetation d where d.del=0 order by d.sort, d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiVegType).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiVegType).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
//высота растительности
|
//высота растительности
|
||||||
@ -503,19 +519,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_cover d where d.del=0 order by d.sort, d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiVegCover).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiVegCover).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
//Наименование сельхоз культуры
|
//Наименование сельхоз культуры
|
||||||
@ -550,19 +570,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_formulation d where d.del=0 order by d.sort, d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiInsFormulation).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiInsFormulation).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// норма расхода(л/га)
|
// норма расхода(л/га)
|
||||||
@ -574,19 +598,22 @@ 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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiInsDiluted).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiInsDiluted).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// Если применимо: Коэффициент разбавления рабочего раствора (л или кг коммерческого препарата/л воды или дизельного топлива)
|
// Если применимо: Коэффициент разбавления рабочего раствора (л или кг коммерческого препарата/л воды или дизельного топлива)
|
||||||
@ -602,19 +629,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_containers_states d where d.del=0 order by d.sort, d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiInsContainerState).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiInsContainerState).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
//**********Погодные условия**********
|
//**********Погодные условия**********
|
||||||
@ -644,20 +675,23 @@ 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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiWindDirectionStart).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiWindDirectionStart).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// направление ветра кон.
|
// направление ветра кон.
|
||||||
@ -665,19 +699,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name, degree from list_directions d where d.del=0 order by d.degree", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ Tools.getLang() + "' LIMIT 1),d.name) name, degree from list_directions d where d.del=0 order by d.degree", null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiWindDirectionEnd).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiWindDirectionEnd).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// направление опрыскивания нач.
|
// направление опрыскивания нач.
|
||||||
@ -685,20 +723,24 @@ 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();
|
||||||
"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(
|
||||||
+ 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",
|
"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='"
|
||||||
null);
|
+ 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",
|
||||||
if (cursor.moveToFirst())
|
null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprayDirectionStart).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprayDirectionStart).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// направление опрыскивания кон.
|
// направление опрыскивания кон.
|
||||||
@ -706,20 +748,24 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name, degree from list_directions d where d.del=0 and d.degree>=0 order by d.degree",
|
"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='"
|
||||||
null);
|
+ Tools.getLang() + "' LIMIT 1),d.name) name, degree from list_directions d where d.del=0 and d.degree>=0 order by d.degree",
|
||||||
if (cursor.moveToFirst())
|
null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprayDirectionEnd).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprayDirectionEnd).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
//**********Информация о саранчовых**********
|
//**********Информация о саранчовых**********
|
||||||
@ -728,38 +774,46 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from LocustsTypes lt where lt.del=0 order by lt.sort,lt.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ Tools.getLang() + "' LIMIT 1),lt.name) name from LocustsTypes lt where lt.del=0 order by lt.sort,lt.name", null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiLocSpecies).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiLocSpecies).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from list_age lt where lt.del=0 order by lt.sort,lt.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiLocHoppers).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiLocHoppers).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
// плотность на м2
|
// плотность на м2
|
||||||
edtLocDensity = (EditText) findViewById(R.id.edtLocDensity);
|
edtLocDensity = (EditText) findViewById(R.id.edtLocDensity);
|
||||||
@ -770,19 +824,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),lt.name) name from list_purpose lt where lt.del=0 order by lt.sort,lt.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiMainPurpose).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiMainPurpose).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
//**********Сведения по опрыскиванию**********
|
//**********Сведения по опрыскиванию**********
|
||||||
@ -791,19 +849,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from sprayers_types d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprPlatform).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprPlatform).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// «Авиа» - выпадающий список:«Самолет», «Вертолет», «Дельтаплан».
|
// «Авиа» - выпадающий список:«Самолет», «Вертолет», «Дельтаплан».
|
||||||
@ -811,20 +873,24 @@ 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();
|
||||||
"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(
|
||||||
+ 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",
|
"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='"
|
||||||
null);
|
+ 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",
|
||||||
if (cursor.moveToFirst())
|
null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprPlatformA).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprPlatformA).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// «Наземное» - выпадающий список:«Трактор», «Машина», «Аэроз.генераторG».
|
// «Наземное» - выпадающий список:«Трактор», «Машина», «Аэроз.генераторG».
|
||||||
@ -832,20 +898,23 @@ 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())
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprPlatformG).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprPlatformG).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// «Ручное» - выпадающий список:«Ранцевый», «Моторный», «Батарейный».
|
// «Ручное» - выпадающий список:«Ранцевый», «Моторный», «Батарейный».
|
||||||
@ -853,20 +922,24 @@ 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();
|
||||||
"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(
|
||||||
+ 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",
|
"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='"
|
||||||
null);
|
+ 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",
|
||||||
if (cursor.moveToFirst())
|
null);
|
||||||
{
|
if (cursor.moveToFirst())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprPlatformH).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprPlatformH).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// Марка опрыскивателя
|
// Марка опрыскивателя
|
||||||
@ -918,19 +991,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_markings d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiSprMarking).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiSprMarking).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// обработанная площадь(га)
|
// обработанная площадь(га)
|
||||||
@ -1016,19 +1093,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_impact d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiEffTypeImpact).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiEffTypeImpact).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
// Наблюдаемая эфективность обработок (%)
|
// Наблюдаемая эфективность обработок (%)
|
||||||
@ -1044,19 +1125,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_mortality d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiEffMethod).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiEffMethod).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
//H Проведен ли контроль эффективности (бригада мониторинга)?
|
//H Проведен ли контроль эффективности (бригада мониторинга)?
|
||||||
@ -1078,19 +1163,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_impact d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiEffTypeImpact2).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiEffTypeImpact2).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
//H Наблюдаемая эффективность обработки (%)
|
//H Наблюдаемая эффективность обработки (%)
|
||||||
@ -1104,19 +1193,23 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_mortality d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
((selectDB)spiEffMethod2).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
((selectDB)spiEffMethod2).addField(cursor.getString(cursor.getColumnIndex("name")), cursor.getString(cursor.getColumnIndex("id")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
|
|
||||||
@ -1220,30 +1313,34 @@ 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();
|
||||||
"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(
|
||||||
+ Tools.getLang() + "' LIMIT 1),d.name) name from list_containers d where d.del=0 order by d.sort,d.name", null);
|
"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='"
|
||||||
if (cursor.moveToFirst())
|
+ 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())
|
||||||
do
|
|
||||||
{
|
{
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==1)
|
do
|
||||||
((CheckBox) findViewById(R.id.cbTripleRinsed)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
{
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==2)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==1)
|
||||||
((CheckBox) findViewById(R.id.cbPunctured)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbTripleRinsed)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==3)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==2)
|
||||||
((CheckBox) findViewById(R.id.cbTakenBackToBase)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbPunctured)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==4)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==3)
|
||||||
((CheckBox) findViewById(R.id.cbLeftInField)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbTakenBackToBase)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==5)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==4)
|
||||||
((CheckBox) findViewById(R.id.cbBuried)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbLeftInField)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
if(cursor.getLong(cursor.getColumnIndex("id"))==6)
|
if(cursor.getLong(cursor.getColumnIndex("id"))==5)
|
||||||
((CheckBox) findViewById(R.id.cbBurned)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
((CheckBox) findViewById(R.id.cbBuried)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
} while (cursor.moveToNext());
|
if(cursor.getLong(cursor.getColumnIndex("id"))==6)
|
||||||
|
((CheckBox) findViewById(R.id.cbBurned)).setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
SQLiteStatement stmt = wdb.compileStatement("insert into frmlocusthealth_locations(frmlocusthealth_uid,pos,lat,lon)values(?,?,?,?)");
|
try {
|
||||||
stmt.bindString(1, uid);
|
wdb = dboh.getWritableDatabase();
|
||||||
stmt.bindLong(2, i);
|
SQLiteStatement stmt = wdb.compileStatement("insert into frmlocusthealth_locations(frmlocusthealth_uid,pos,lat,lon)values(?,?,?,?)");
|
||||||
stmt.bindDouble(3, list.get(i).lat);
|
stmt.bindString(1, uid);
|
||||||
stmt.bindDouble(4, list.get(i).lon);
|
stmt.bindLong(2, i);
|
||||||
stmt.executeInsert();
|
stmt.bindDouble(3, list.get(i).lat);
|
||||||
|
stmt.bindDouble(4, list.get(i).lon);
|
||||||
|
stmt.executeInsert();
|
||||||
|
}finally{
|
||||||
|
if(wdb!=null){ wdb.close(); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dboh.close();
|
dboh.close();
|
||||||
@ -3403,15 +3511,21 @@ 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;
|
||||||
if (cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getWritableDatabase();
|
||||||
do
|
Cursor cursor = rdb.rawQuery("select uid,lat,lon from frmlocustdel_locations where frmlocustdel_uid='" + uid + "' order by pos", null);
|
||||||
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
list.add(new LatLon(cursor.getString(0), cursor.getDouble(1), cursor.getDouble(2)));
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
list.add(new LatLon(cursor.getString(0), cursor.getDouble(1), cursor.getDouble(2)));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
}
|
}
|
||||||
@ -3970,15 +4084,20 @@ 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 {
|
||||||
if(!cursor.moveToFirst())
|
rdb = dboh.getWritableDatabase();
|
||||||
{
|
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Secure.getString(getContentResolver(), Secure.ANDROID_ID)+"';", null);
|
||||||
Toast toast = Toast.makeText(getApplicationContext(),
|
if(!cursor.moveToFirst())
|
||||||
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
{
|
||||||
toast.show();
|
Toast toast = Toast.makeText(getApplicationContext(),
|
||||||
|
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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,31 @@ 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
|
||||||
|
ld.uid as frmlocustdel_uid,
|
||||||
|
lh.uid as frmlocusthealth_uid,
|
||||||
|
coalesce(ld.district,'') || ' ' || coalesce(ld.terrain,'') terrain,
|
||||||
|
lh.date,
|
||||||
|
EXISTS(select true from frmlocusthealth where frmlocustdel_uid=ld.uid) as health
|
||||||
|
from
|
||||||
|
frmlocusthealth lh
|
||||||
|
left join frmlocustdel ld on lh.frmlocustdel_uid=ld.uid
|
||||||
|
where
|
||||||
|
lh.del=0
|
||||||
|
and lh.filled!=1
|
||||||
|
""", null); //Не отправленные
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
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,
|
||||||
@ -613,130 +638,117 @@ public class LocustHealthListActivity extends AppCompatActivity
|
|||||||
left join frmlocustdel ld on lh.frmlocustdel_uid=ld.uid
|
left join frmlocustdel ld on lh.frmlocustdel_uid=ld.uid
|
||||||
where
|
where
|
||||||
lh.del=0
|
lh.del=0
|
||||||
and lh.filled!=1
|
and lh.send=0
|
||||||
|
and lh.filled=1
|
||||||
""", null); //Не отправленные
|
""", null); //Не отправленные
|
||||||
break;
|
break;
|
||||||
case 1:
|
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,
|
||||||
coalesce(ld.district,'') || ' ' || coalesce(ld.terrain,'') terrain,
|
coalesce(ld.district,'') || ' ' || coalesce(ld.terrain,'') terrain,
|
||||||
lh.date,
|
lh.date,
|
||||||
EXISTS(select true from frmlocusthealth where frmlocustdel_uid=ld.uid) as health
|
EXISTS(select true from frmlocusthealth where frmlocustdel_uid=ld.uid) as health
|
||||||
from
|
from
|
||||||
frmlocusthealth lh
|
frmlocusthealth lh
|
||||||
left join frmlocustdel ld on lh.frmlocustdel_uid=ld.uid
|
left join frmlocustdel ld on lh.frmlocustdel_uid=ld.uid
|
||||||
where
|
where
|
||||||
lh.del=0
|
lh.del=0
|
||||||
and lh.send=0
|
and lh.send=1
|
||||||
and lh.filled=1
|
""", null); //Отправленные
|
||||||
""", null); //Не отправленные
|
break;
|
||||||
break;
|
default:
|
||||||
case 2:
|
cursor = rdb.rawQuery("""
|
||||||
cursor = dboh.getReadableDatabase().rawQuery("""
|
select
|
||||||
select
|
ld.uid as frmlocustdel_uid,
|
||||||
ld.uid as frmlocustdel_uid,
|
lh.uid as frmlocusthealth_uid,
|
||||||
lh.uid as frmlocusthealth_uid,
|
coalesce(ld.district,'') || ' ' || coalesce(ld.terrain,'') terrain,
|
||||||
coalesce(ld.district,'') || ' ' || coalesce(ld.terrain,'') terrain,
|
coalesce(lh.date,ld.date) as date,
|
||||||
lh.date,
|
EXISTS(select true from frmlocusthealth where frmlocustdel_uid=ld.uid) as health
|
||||||
EXISTS(select true from frmlocusthealth where frmlocustdel_uid=ld.uid) as health
|
from
|
||||||
from
|
frmlocustdel ld
|
||||||
frmlocusthealth lh
|
left join frmlocusthealth lh on lh.frmlocustdel_uid=ld.uid
|
||||||
left join frmlocustdel ld on lh.frmlocustdel_uid=ld.uid
|
where ld.del=0 and ld.filled=true
|
||||||
where
|
""", null); //Все
|
||||||
lh.del=0
|
break;
|
||||||
and lh.send=1
|
|
||||||
""", null); //Отправленные
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
cursor = dboh.getReadableDatabase().rawQuery("""
|
|
||||||
select
|
|
||||||
ld.uid as frmlocustdel_uid,
|
|
||||||
lh.uid as frmlocusthealth_uid,
|
|
||||||
coalesce(ld.district,'') || ' ' || coalesce(ld.terrain,'') terrain,
|
|
||||||
coalesce(lh.date,ld.date) as date,
|
|
||||||
EXISTS(select true from frmlocusthealth where frmlocustdel_uid=ld.uid) as health
|
|
||||||
from
|
|
||||||
frmlocustdel ld
|
|
||||||
left join frmlocusthealth lh on lh.frmlocustdel_uid=ld.uid
|
|
||||||
where ld.del=0 and ld.filled=true
|
|
||||||
""", null); //Все
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tools.logCursor(cursor);
|
|
||||||
OnClickListener oclBtn = new OnClickListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(View v)
|
|
||||||
{
|
|
||||||
MyButton b = (MyButton) v;
|
|
||||||
|
|
||||||
Intent intent = new Intent(LocustHealthListActivity.this, LocustHealthActivity.class);
|
|
||||||
intent.putExtra("frmlocustdel_uid", b.uid1);
|
|
||||||
intent.putExtra("frmlocusthealth_uid", b.uid2);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if (cursor.moveToFirst())
|
// Tools.logCursor(cursor);
|
||||||
{
|
OnClickListener oclBtn = new OnClickListener()
|
||||||
do
|
|
||||||
{
|
{
|
||||||
btn = null;
|
@Override
|
||||||
if(cursor.getInt(cursor.getColumnIndex("health"))==0){
|
public void onClick(View v)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //Задаю стиль для кнопки для которой нет анкеты здоровья
|
{
|
||||||
int buttonPinkStyle = R.style.ButtonPinkTheme;
|
MyButton b = (MyButton) v;
|
||||||
ContextThemeWrapper newContext = new ContextThemeWrapper(this, R.style.ButtonPinkTheme);
|
|
||||||
btn = new MyButton(newContext, null, 0, buttonPinkStyle);
|
Intent intent = new Intent(LocustHealthListActivity.this, LocustHealthActivity.class);
|
||||||
|
intent.putExtra("frmlocustdel_uid", b.uid1);
|
||||||
|
intent.putExtra("frmlocusthealth_uid", b.uid2);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
btn = null;
|
||||||
|
if(cursor.getInt(cursor.getColumnIndex("health"))==0){
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { //Задаю стиль для кнопки для которой нет анкеты здоровья
|
||||||
|
int buttonPinkStyle = R.style.ButtonPinkTheme;
|
||||||
|
ContextThemeWrapper newContext = new ContextThemeWrapper(this, R.style.ButtonPinkTheme);
|
||||||
|
btn = new MyButton(newContext, null, 0, buttonPinkStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(btn==null) {
|
||||||
|
btn = new MyButton(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(btn==null) {
|
|
||||||
btn = new MyButton(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
btn.setOnClickListener(oclBtn);
|
btn.setOnClickListener(oclBtn);
|
||||||
|
|
||||||
btn.uid1 = cursor.getString(cursor.getColumnIndex("frmlocustdel_uid"));
|
btn.uid1 = cursor.getString(cursor.getColumnIndex("frmlocustdel_uid"));
|
||||||
btn.uid2 = cursor.getString(cursor.getColumnIndex("frmlocusthealth_uid"));
|
btn.uid2 = cursor.getString(cursor.getColumnIndex("frmlocusthealth_uid"));
|
||||||
|
|
||||||
// Преобразует с учётом временой зоны (пример long dv = 946684800L * 1000L; //2000 ный по гринвичу дало 6 утра)
|
// Преобразует с учётом временой зоны (пример long dv = 946684800L * 1000L; //2000 ный по гринвичу дало 6 утра)
|
||||||
String vv = "";
|
String vv = "";
|
||||||
String val = cursor.getString(cursor.getColumnIndex("date"));
|
String val = cursor.getString(cursor.getColumnIndex("date"));
|
||||||
try {
|
|
||||||
long dv = Long.parseLong(val) * (long) 1000;// its need to be in milisecond
|
|
||||||
Date df = new Date(dv);
|
|
||||||
vv = new SimpleDateFormat("dd.MM.yyyy").format(df);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
}
|
|
||||||
if(vv.isEmpty()) {
|
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
long dv = Long.parseLong(val) * (long) 1000;// its need to be in milisecond
|
||||||
Date df = format.parse(val);
|
Date df = new Date(dv);
|
||||||
vv = new SimpleDateFormat("dd.MM.yyyy").format(df);
|
vv = new SimpleDateFormat("dd.MM.yyyy").format(df);
|
||||||
} catch (ParseException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
if(vv.isEmpty()) {
|
||||||
|
try {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
Date df = format.parse(val);
|
||||||
|
vv = new SimpleDateFormat("dd.MM.yyyy").format(df);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
btn.setText(cursor.getString(cursor.getColumnIndex("terrain")) + " (" + vv + ")");
|
btn.setText(cursor.getString(cursor.getColumnIndex("terrain")) + " (" + vv + ")");
|
||||||
|
|
||||||
// Устанавливаю высоту в пикселях через высоту макета
|
// Устанавливаю высоту в пикселях через высоту макета
|
||||||
int heightInDp = 40;
|
int heightInDp = 40;
|
||||||
float scale = getResources().getDisplayMetrics().density;
|
float scale = getResources().getDisplayMetrics().density;
|
||||||
int heightInPx = (int) (heightInDp * scale + 0.5f); //Перевожу в dp
|
int heightInPx = (int) (heightInDp * scale + 0.5f); //Перевожу в dp
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||||
LayoutParams.MATCH_PARENT,
|
LayoutParams.MATCH_PARENT,
|
||||||
heightInPx
|
heightInPx
|
||||||
);
|
);
|
||||||
params.bottomMargin = 4;
|
params.bottomMargin = 4;
|
||||||
|
|
||||||
llList.addView(btn,params);
|
llList.addView(btn,params);
|
||||||
|
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,15 +761,20 @@ 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 {
|
||||||
if(!cursor.moveToFirst())
|
rdb = dboh.getReadableDatabase();
|
||||||
{
|
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||||
Toast toast = Toast.makeText(getApplicationContext(),
|
if(!cursor.moveToFirst())
|
||||||
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
{
|
||||||
toast.show();
|
Toast toast = Toast.makeText(getApplicationContext(),
|
||||||
|
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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,75 +579,80 @@ public class LocustListActivity extends AppCompatActivity
|
|||||||
llList.removeAllViews();
|
llList.removeAllViews();
|
||||||
|
|
||||||
DbOpenHelper dboh = new DbOpenHelper(LocustListActivity.this);
|
DbOpenHelper dboh = new DbOpenHelper(LocustListActivity.this);
|
||||||
|
SQLiteDatabase rdb = null;
|
||||||
String sql;
|
try {
|
||||||
Cursor cursor = null;
|
rdb = dboh.getReadableDatabase();
|
||||||
switch (spiList.getSelectedItemPosition())
|
String sql;
|
||||||
{
|
Cursor cursor = null;
|
||||||
case 0:
|
switch (spiList.getSelectedItemPosition())
|
||||||
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0 and filled!=1";
|
|
||||||
cursor = dboh.getReadableDatabase().rawQuery(sql, null); //Не заполненые
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0 and send=0 and filled=1";
|
|
||||||
cursor = dboh.getReadableDatabase().rawQuery(sql, null); //Не отправленные
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0 and send=1";
|
|
||||||
cursor = dboh.getReadableDatabase().rawQuery(sql, null); //Отправленные
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0";
|
|
||||||
cursor = dboh.getReadableDatabase().rawQuery(sql, null); //Все
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Tools.logCursor(cursor);
|
|
||||||
OnClickListener oclBtn = new OnClickListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onClick(View v)
|
|
||||||
{
|
{
|
||||||
MyButton b = (MyButton) v;
|
case 0:
|
||||||
|
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0 and filled!=1";
|
||||||
Intent intent = new Intent(LocustListActivity.this, LocustActivity.class);
|
cursor = rdb.rawQuery(sql, null); //Не заполненые
|
||||||
intent.putExtra("uid", b.uid1);
|
break;
|
||||||
startActivity(intent);
|
case 1:
|
||||||
|
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0 and send=0 and filled=1";
|
||||||
|
cursor = rdb.rawQuery(sql, null); //Не отправленные
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0 and send=1";
|
||||||
|
cursor = rdb.rawQuery(sql, null); //Отправленные
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sql = "select uid, coalesce(district,'') || ' ' || coalesce(terrain,'') terrain, date from frmlocust where del=0";
|
||||||
|
cursor = rdb.rawQuery(sql, null); //Все
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
if (cursor.moveToFirst())
|
// Tools.logCursor(cursor);
|
||||||
{
|
OnClickListener oclBtn = new OnClickListener()
|
||||||
do
|
|
||||||
{
|
{
|
||||||
btn = new MyButton(this);
|
@Override
|
||||||
|
public void onClick(View v)
|
||||||
|
{
|
||||||
|
MyButton b = (MyButton) v;
|
||||||
|
|
||||||
btn.setOnClickListener(oclBtn);
|
Intent intent = new Intent(LocustListActivity.this, LocustActivity.class);
|
||||||
|
intent.putExtra("uid", b.uid1);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
btn.uid1 = cursor.getString(cursor.getColumnIndex("uid"));
|
if (cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
btn = new MyButton(this);
|
||||||
|
|
||||||
long dv = cursor.getLong(cursor.getColumnIndex("date")) * (long) 1000; // its need to be in milisecond
|
btn.setOnClickListener(oclBtn);
|
||||||
Date df = new java.util.Date(dv);
|
|
||||||
String vv = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(df);
|
|
||||||
|
|
||||||
btn.setText(cursor.getString(cursor.getColumnIndex("terrain")) + " (" + vv + ")");
|
btn.uid1 = cursor.getString(cursor.getColumnIndex("uid"));
|
||||||
|
|
||||||
// Устанавливаю высоту в пикселях через высоту макета
|
long dv = cursor.getLong(cursor.getColumnIndex("date")) * (long) 1000; // its need to be in milisecond
|
||||||
int heightInDp = 40;
|
Date df = new java.util.Date(dv);
|
||||||
float scale = getResources().getDisplayMetrics().density;
|
String vv = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(df);
|
||||||
int heightInPx = (int) (heightInDp * scale + 0.5f); //Перевожу в dp
|
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
|
||||||
LayoutParams.MATCH_PARENT,
|
|
||||||
heightInPx
|
|
||||||
);
|
|
||||||
params.bottomMargin = 4;
|
|
||||||
|
|
||||||
llList.addView(btn,params);
|
btn.setText(cursor.getString(cursor.getColumnIndex("terrain")) + " (" + vv + ")");
|
||||||
|
|
||||||
} while (cursor.moveToNext());
|
// Устанавливаю высоту в пикселях через высоту макета
|
||||||
|
int heightInDp = 40;
|
||||||
|
float scale = getResources().getDisplayMetrics().density;
|
||||||
|
int heightInPx = (int) (heightInDp * scale + 0.5f); //Перевожу в dp
|
||||||
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||||
|
LayoutParams.MATCH_PARENT,
|
||||||
|
heightInPx
|
||||||
|
);
|
||||||
|
params.bottomMargin = 4;
|
||||||
|
|
||||||
|
llList.addView(btn,params);
|
||||||
|
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -652,15 +663,20 @@ 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 {
|
||||||
if(!cursor.moveToFirst())
|
rdb = dboh.getReadableDatabase();
|
||||||
{
|
Cursor cursor = rdb.rawQuery("select * from terminals where del=0 and serial='"+ Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||||
Toast toast = Toast.makeText(getApplicationContext(),
|
if(!cursor.moveToFirst())
|
||||||
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
{
|
||||||
toast.show();
|
Toast toast = Toast.makeText(getApplicationContext(),
|
||||||
|
getResources().getString(R.string.Please_authorize_the_tablet), Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,68 +85,69 @@ 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");
|
||||||
|
directory.mkdirs();
|
||||||
|
File[] files = directory.listFiles();
|
||||||
|
if(files!=null) {
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
String fileName = files[i].getName();
|
||||||
|
if (fileName.charAt(0) == '_')
|
||||||
|
fileName = fileName.substring(1); //Чтобы не реагировало на "_"
|
||||||
|
|
||||||
File directory = new File(Environment.getExternalStorageDirectory() + File.separator + "Pictures" + File.separator + "Locust");
|
boolean exest = false;
|
||||||
directory.mkdirs();
|
String sql;
|
||||||
File[] files = directory.listFiles();
|
|
||||||
if(files!=null) {
|
|
||||||
for (int i = 0; i < files.length; i++) {
|
|
||||||
String fileName = files[i].getName();
|
|
||||||
if (fileName.charAt(0) == '_')
|
|
||||||
fileName = fileName.substring(1); //Чтобы не реагировало на "_"
|
|
||||||
|
|
||||||
boolean exest = false;
|
Cursor cursor;
|
||||||
String sql;
|
sql = "select 1 from frmlocust where image_name1='" + fileName + "' or image_name2='" + fileName + "' or image_name3='" + fileName + "';";
|
||||||
|
cursor = rdb.rawQuery(sql, null);
|
||||||
|
if (cursor.moveToFirst())
|
||||||
|
exest = exest | true;
|
||||||
|
cursor.close();
|
||||||
|
|
||||||
Cursor cursor;
|
sql = "select 1 from frmlocustdel 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 = rdb.rawQuery(sql, null);
|
||||||
cursor = db.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 + "';";
|
if (!exest) //Если в базе нет удаляем
|
||||||
cursor = db.rawQuery(sql, null);
|
{
|
||||||
if (cursor.moveToFirst())
|
files[i].delete();
|
||||||
exest = exest | true;
|
|
||||||
cursor.close();
|
|
||||||
|
|
||||||
if (!exest) //Если в базе нет удаляем
|
|
||||||
{
|
|
||||||
files[i].delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Проверяю есть ли в безе записи и вставляю только если их нет
|
|
||||||
/* теперь в базу не переписываю так как всё храниться в файлах
|
|
||||||
boolean exest = false;
|
|
||||||
String sql = "select 1 from CountriesRegionsPoints limit 1;";
|
|
||||||
Cursor cursor = db.rawQuery(sql, null);
|
|
||||||
if (cursor.moveToFirst())
|
|
||||||
exest = true;
|
|
||||||
cursor.close();
|
|
||||||
if(!exest) {
|
|
||||||
//Переписываю координаты из файла в базу данных
|
|
||||||
try {
|
|
||||||
InputStream isRaw = null;
|
|
||||||
isRaw = getResources().openRawResource(R.raw.points);
|
|
||||||
if (isRaw != null) {
|
|
||||||
TCTable tbl = new TCTable("", 0);
|
|
||||||
if (tbl.OpenTableH(isRaw)) {
|
|
||||||
dboh.insertTable(tbl);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
db.close();
|
//Проверяю есть ли в безе записи и вставляю только если их нет
|
||||||
|
/* теперь в базу не переписываю так как всё храниться в файлах
|
||||||
|
boolean exest = false;
|
||||||
|
String sql = "select 1 from CountriesRegionsPoints limit 1;";
|
||||||
|
Cursor cursor = db.rawQuery(sql, null);
|
||||||
|
if (cursor.moveToFirst())
|
||||||
|
exest = true;
|
||||||
|
cursor.close();
|
||||||
|
if(!exest) {
|
||||||
|
//Переписываю координаты из файла в базу данных
|
||||||
|
try {
|
||||||
|
InputStream isRaw = null;
|
||||||
|
isRaw = getResources().openRawResource(R.raw.points);
|
||||||
|
if (isRaw != null) {
|
||||||
|
TCTable tbl = new TCTable("", 0);
|
||||||
|
if (tbl.OpenTableH(isRaw)) {
|
||||||
|
dboh.insertTable(tbl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
|
}
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
tvCountTasks = (TextView) findViewById(R.id.tvCountTasks);
|
tvCountTasks = (TextView) findViewById(R.id.tvCountTasks);
|
||||||
@ -201,15 +202,21 @@ 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;
|
||||||
if (cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
do
|
cursor = rdb.rawQuery("select c.id from borns c limit 1;", null);
|
||||||
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
exists=true;
|
do
|
||||||
} while (cursor.moveToNext());
|
{
|
||||||
|
exists=true;
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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,56 +131,61 @@ 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;
|
||||||
if (cursor.moveToFirst()) {
|
try {
|
||||||
String uid="";
|
rdb = dboh.getReadableDatabase();
|
||||||
PolygonOptions pOptions2 = new PolygonOptions();
|
Cursor cursor = rdb.rawQuery("select frmlocust_uid,lat,lon from frmlocust_locations where frmlocust_uid!='"+uid+"' order by frmlocust_uid,pos;", null);
|
||||||
do {
|
if (cursor.moveToFirst()) {
|
||||||
if(!uid.equals(cursor.getString(0)) && pOptions2.getPoints().size()>1) {
|
String uid="";
|
||||||
|
PolygonOptions pOptions2 = new PolygonOptions();
|
||||||
|
do {
|
||||||
|
if(!uid.equals(cursor.getString(0)) && pOptions2.getPoints().size()>1) {
|
||||||
|
Polygon polygon = mMap.addPolygon(pOptions2);
|
||||||
|
polygons.add(polygon);
|
||||||
|
polygon.setFillColor(0x7F0000FF);
|
||||||
|
}
|
||||||
|
if(!uid.equals(cursor.getString(0))) {
|
||||||
|
pOptions2 = new PolygonOptions();
|
||||||
|
uid=cursor.getString(0);
|
||||||
|
}
|
||||||
|
pOptions2.add(new LatLng(cursor.getDouble(1), cursor.getDouble(2)));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
if(pOptions2.getPoints().size()>1){
|
||||||
Polygon polygon = mMap.addPolygon(pOptions2);
|
Polygon polygon = mMap.addPolygon(pOptions2);
|
||||||
polygons.add(polygon);
|
polygons.add(polygon);
|
||||||
polygon.setFillColor(0x7F0000FF);
|
polygon.setFillColor(0x7F0000FF);
|
||||||
}
|
}
|
||||||
if(!uid.equals(cursor.getString(0))) {
|
|
||||||
pOptions2 = new PolygonOptions();
|
|
||||||
uid=cursor.getString(0);
|
|
||||||
}
|
|
||||||
pOptions2.add(new LatLng(cursor.getDouble(1), cursor.getDouble(2)));
|
|
||||||
} while (cursor.moveToNext());
|
|
||||||
if(pOptions2.getPoints().size()>1){
|
|
||||||
Polygon polygon = mMap.addPolygon(pOptions2);
|
|
||||||
polygons.add(polygon);
|
|
||||||
polygon.setFillColor(0x7F0000FF);
|
|
||||||
}
|
}
|
||||||
}
|
cursor.close();
|
||||||
cursor.close();
|
//Геозоны противосаначовой обработки
|
||||||
//Геозоны противосаначовой обработки
|
cursor = rdb.rawQuery("select frmlocustdel_uid,lat,lon from frmlocustdel_locations where frmlocustdel_uid!='"+uid+"' order by frmlocustdel_uid,pos;", null);
|
||||||
cursor = dboh.getReadableDatabase().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();
|
do {
|
||||||
do {
|
if(!uid.equals(cursor.getString(0)) && pOptions2.getPoints().size()>1) {
|
||||||
if(!uid.equals(cursor.getString(0)) && pOptions2.getPoints().size()>1) {
|
Polygon polygon = mMap.addPolygon(pOptions2);
|
||||||
|
polygons.add(polygon);
|
||||||
|
polygon.setFillColor(0x7FFF0000);
|
||||||
|
}
|
||||||
|
if(!uid.equals(cursor.getString(0))) {
|
||||||
|
pOptions2 = new PolygonOptions();
|
||||||
|
uid=cursor.getString(0);
|
||||||
|
}
|
||||||
|
pOptions2.add(new LatLng(cursor.getDouble(1), cursor.getDouble(2)));
|
||||||
|
} while (cursor.moveToNext());
|
||||||
|
if(pOptions2.getPoints().size()>1){
|
||||||
Polygon polygon = mMap.addPolygon(pOptions2);
|
Polygon polygon = mMap.addPolygon(pOptions2);
|
||||||
polygons.add(polygon);
|
polygons.add(polygon);
|
||||||
polygon.setFillColor(0x7FFF0000);
|
polygon.setFillColor(0x7FFF0000);
|
||||||
}
|
}
|
||||||
if(!uid.equals(cursor.getString(0))) {
|
|
||||||
pOptions2 = new PolygonOptions();
|
|
||||||
uid=cursor.getString(0);
|
|
||||||
}
|
|
||||||
pOptions2.add(new LatLng(cursor.getDouble(1), cursor.getDouble(2)));
|
|
||||||
} while (cursor.moveToNext());
|
|
||||||
if(pOptions2.getPoints().size()>1){
|
|
||||||
Polygon polygon = mMap.addPolygon(pOptions2);
|
|
||||||
polygons.add(polygon);
|
|
||||||
polygon.setFillColor(0x7FFF0000);
|
|
||||||
}
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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,59 +194,65 @@ 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())
|
||||||
{
|
{
|
||||||
do{
|
do{
|
||||||
//Если задано имя файла то добавляем его в очередь на отправку на сервер
|
//Если задано имя файла то добавляем его в очередь на отправку на сервер
|
||||||
String fname;
|
String fname;
|
||||||
fname=cursor.getString(cursor.getColumnIndex("image_name1"));
|
fname=cursor.getString(cursor.getColumnIndex("image_name1"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
|
|
||||||
fname = cursor.getString(cursor.getColumnIndex("image_name2"));
|
fname = cursor.getString(cursor.getColumnIndex("image_name2"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
|
|
||||||
fname = cursor.getString(cursor.getColumnIndex("image_name3"));
|
fname = cursor.getString(cursor.getColumnIndex("image_name3"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
|
|
||||||
xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||||
xml+="<metadata fn=\"4\">";
|
xml+="<metadata fn=\"4\">";
|
||||||
for(int i=0;i<cursor.getColumnCount();i++)
|
for(int i=0;i<cursor.getColumnCount();i++)
|
||||||
{
|
{
|
||||||
String val="";
|
String val="";
|
||||||
if(!cursor.isNull(i)) {
|
if(!cursor.isNull(i)) {
|
||||||
if (cursor.getType(i) == 2) { //Because cutting double
|
if (cursor.getType(i) == 2) { //Because cutting double
|
||||||
val = "" + cursor.getDouble(i);
|
val = "" + cursor.getDouble(i);
|
||||||
} else {
|
} else {
|
||||||
val = cursor.getString(i);
|
val = cursor.getString(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
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 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 {
|
||||||
geom+="["+cursor2.getDouble(1)+","+cursor2.getDouble(0)+"],";
|
geom+="["+cursor2.getDouble(1)+","+cursor2.getDouble(0)+"],";
|
||||||
}while (cursor2.moveToNext());
|
}while (cursor2.moveToNext());
|
||||||
geom += first;
|
geom += first;
|
||||||
geom="{\"type\":\"Polygon\",\"coordinates\":[["+geom+"]]}";
|
geom="{\"type\":\"Polygon\",\"coordinates\":[["+geom+"]]}";
|
||||||
}
|
}
|
||||||
xml+=" <geom><![CDATA["+geom+"]]></geom>";
|
xml+=" <geom><![CDATA["+geom+"]]></geom>";
|
||||||
cursor2.close();
|
cursor2.close();
|
||||||
xml+="</metadata>";
|
xml+="</metadata>";
|
||||||
|
|
||||||
rid_sendFrmLocust = myThread.addRequest(MySynchronizationOld.URL+"/get/", xml, null,null);
|
rid_sendFrmLocust = myThread.addRequest(MySynchronizationOld.URL+"/get/", xml, null,null);
|
||||||
|
|
||||||
}while (cursor.moveToNext());
|
}while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,94 +267,100 @@ 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();
|
||||||
|
|
||||||
if(cursor.moveToFirst())
|
cursor = rdb.rawQuery("select * from frmlocustdel where uid=?", new String[] { String.valueOf(uid) });
|
||||||
{
|
if(cursor.moveToFirst())
|
||||||
do{
|
{
|
||||||
//Если задано имя файла то добавляем его в очередь на отправку на сервер
|
do{
|
||||||
String fname;
|
//Если задано имя файла то добавляем его в очередь на отправку на сервер
|
||||||
fname=cursor.getString(cursor.getColumnIndex("image_name1"));
|
String fname;
|
||||||
if(fname!=null && !fname.equals(""))
|
fname=cursor.getString(cursor.getColumnIndex("image_name1"));
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
if(fname!=null && !fname.equals(""))
|
||||||
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
|
|
||||||
fname = cursor.getString(cursor.getColumnIndex("image_name2"));
|
fname = cursor.getString(cursor.getColumnIndex("image_name2"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
|
|
||||||
fname = cursor.getString(cursor.getColumnIndex("image_name3"));
|
fname = cursor.getString(cursor.getColumnIndex("image_name3"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
|
|
||||||
|
|
||||||
xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||||
xml+="<metadata fn=\"5\">";
|
xml+="<metadata fn=\"5\">";
|
||||||
for(int i=0;i<cursor.getColumnCount();i++)
|
for(int i=0;i<cursor.getColumnCount();i++)
|
||||||
{
|
{
|
||||||
String val="";
|
String val="";
|
||||||
if(!cursor.isNull(i)) {
|
if(!cursor.isNull(i)) {
|
||||||
if (cursor.getType(i) == 2) { //Because cutting double
|
if (cursor.getType(i) == 2) { //Because cutting double
|
||||||
val = "" + cursor.getDouble(i);
|
val = "" + cursor.getDouble(i);
|
||||||
} else {
|
} else {
|
||||||
val = cursor.getString(i);
|
val = cursor.getString(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
xml+=" <"+cursor.getColumnName(i)+"><![CDATA["+val+"]]></"+cursor.getColumnName(i)+">\n";
|
||||||
}
|
}
|
||||||
xml+=" <"+cursor.getColumnName(i)+"><![CDATA["+val+"]]></"+cursor.getColumnName(i)+">\n";
|
String geom="";
|
||||||
}
|
Cursor cursor2 = rdb.rawQuery("select lat,lon from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||||
String geom="";
|
if(cursor2.moveToFirst()) {
|
||||||
Cursor cursor2 = dboh.getReadableDatabase().rawQuery("select lat,lon from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
String first="["+cursor2.getDouble(1)+","+cursor2.getDouble(0)+"]";
|
||||||
if(cursor2.moveToFirst()) {
|
do {
|
||||||
String first="["+cursor2.getDouble(1)+","+cursor2.getDouble(0)+"]";
|
geom+="["+cursor2.getDouble(1)+","+cursor2.getDouble(0)+"],";
|
||||||
do {
|
}while (cursor2.moveToNext());
|
||||||
geom+="["+cursor2.getDouble(1)+","+cursor2.getDouble(0)+"],";
|
geom += first;
|
||||||
}while (cursor2.moveToNext());
|
geom="{\"type\":\"Polygon\",\"coordinates\":[["+geom+"]]}";
|
||||||
geom += first;
|
}
|
||||||
geom="{\"type\":\"Polygon\",\"coordinates\":[["+geom+"]]}";
|
xml+=" <geom><![CDATA["+geom+"]]></geom>";
|
||||||
}
|
cursor2.close();
|
||||||
xml+=" <geom><![CDATA["+geom+"]]></geom>";
|
xml+="</metadata>";
|
||||||
cursor2.close();
|
|
||||||
xml+="</metadata>";
|
|
||||||
|
|
||||||
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());*/
|
||||||
|
|
||||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||||
TCTable tbl = new TCTable("frmlocustdel_locations", 0);
|
TCTable tbl = new TCTable("frmlocustdel_locations", 0);
|
||||||
tbl.addField(new TCField("uid",TCField.BD_UTF8_1));
|
tbl.addField(new TCField("uid",TCField.BD_UTF8_1));
|
||||||
tbl.addField(new TCField("del",TCField.BD_UINT1));
|
tbl.addField(new TCField("del",TCField.BD_UINT1));
|
||||||
tbl.addField(new TCField("seq",TCField.BD_UINT4));
|
tbl.addField(new TCField("seq",TCField.BD_UINT4));
|
||||||
tbl.addField(new TCField("frmlocustdel_uid",TCField.BD_UTF8_1));
|
tbl.addField(new TCField("frmlocustdel_uid",TCField.BD_UTF8_1));
|
||||||
tbl.addField(new TCField("pos",TCField.BD_UINT4));
|
tbl.addField(new TCField("pos",TCField.BD_UINT4));
|
||||||
tbl.addField(new TCField("lon",TCField.BD_FLOAT8));
|
tbl.addField(new TCField("lon",TCField.BD_FLOAT8));
|
||||||
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));
|
||||||
tbl.fields.get(1).setValue(cursor3.getString(1));
|
tbl.fields.get(1).setValue(cursor3.getString(1));
|
||||||
tbl.fields.get(2).setValue(cursor3.getString(2));
|
tbl.fields.get(2).setValue(cursor3.getString(2));
|
||||||
tbl.fields.get(3).setValue(cursor3.getString(3));
|
tbl.fields.get(3).setValue(cursor3.getString(3));
|
||||||
tbl.fields.get(4).setValue(cursor3.getString(4));
|
tbl.fields.get(4).setValue(cursor3.getString(4));
|
||||||
tbl.fields.get(5).setDoubleVal(cursor3.getDouble(5));
|
tbl.fields.get(5).setDoubleVal(cursor3.getDouble(5));
|
||||||
tbl.fields.get(6).setDoubleVal(cursor3.getDouble(6));
|
tbl.fields.get(6).setDoubleVal(cursor3.getDouble(6));
|
||||||
tbl.getCol(outStream);
|
tbl.getCol(outStream);
|
||||||
}while (cursor3.moveToNext());
|
}while (cursor3.moveToNext());
|
||||||
}
|
}
|
||||||
cursor3.close();
|
cursor3.close();
|
||||||
//Отправляю пакет данных на сервер для вставки либо обновления
|
//Отправляю пакет данных на сервер для вставки либо обновления
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/asdc/tctable/", null, null, outStream.toByteArray());
|
myThread.addRequest(MySynchronizationOld.URL+"/asdc/tctable/", null, null, outStream.toByteArray());
|
||||||
|
|
||||||
|
|
||||||
}while (cursor.moveToNext());
|
}while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,44 +376,50 @@ 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;
|
||||||
if(cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
do{
|
cursor = rdb.rawQuery("select * from frmlocusthealth where uid=?", new String[] { String.valueOf(uid) });
|
||||||
//Если задано имя файла то добавляем его в очередь на отправку на сервер
|
if(cursor.moveToFirst())
|
||||||
String fname;
|
{
|
||||||
fname=cursor.getString(cursor.getColumnIndex("image_name1"));
|
do{
|
||||||
if(fname!=null && !fname.equals(""))
|
//Если задано имя файла то добавляем его в очередь на отправку на сервер
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
String fname;
|
||||||
fname = cursor.getString(cursor.getColumnIndex("image_name2"));
|
fname=cursor.getString(cursor.getColumnIndex("image_name1"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
fname = cursor.getString(cursor.getColumnIndex("image_name3"));
|
fname = cursor.getString(cursor.getColumnIndex("image_name2"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
fname = cursor.getString(cursor.getColumnIndex("image_name4"));
|
fname = cursor.getString(cursor.getColumnIndex("image_name3"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
fname = cursor.getString(cursor.getColumnIndex("image_name5"));
|
fname = cursor.getString(cursor.getColumnIndex("image_name4"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
|
fname = cursor.getString(cursor.getColumnIndex("image_name5"));
|
||||||
|
if(fname!=null && !fname.equals(""))
|
||||||
|
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname,null);
|
||||||
|
|
||||||
|
|
||||||
for(int i=0;i<cursor.getColumnCount();i++)
|
for(int i=0;i<cursor.getColumnCount();i++)
|
||||||
{
|
{
|
||||||
String columnName = cursor.getColumnName(i);
|
String columnName = cursor.getColumnName(i);
|
||||||
String value = cursor.getString(i);
|
String value = cursor.getString(i);
|
||||||
try {
|
try {
|
||||||
jsonObject.put(columnName, value);
|
jsonObject.put(columnName, value);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
rid_sendFrmLocustHealth = myThread.addRequest(MySynchronizationOld.URL+"/asdc/FrmLocustHealth/", jsonObject.toString(), null,null);
|
||||||
rid_sendFrmLocustHealth = myThread.addRequest(MySynchronizationOld.URL+"/asdc/FrmLocustHealth/", jsonObject.toString(), null,null);
|
|
||||||
|
|
||||||
}while (cursor.moveToNext());
|
}while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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 {
|
||||||
if (cursor.moveToFirst()) {
|
rdb = dboh.getReadableDatabase();
|
||||||
seq = cursor.getString(cursor.getColumnIndex("seq"));
|
Cursor cursor = rdb.rawQuery("select max(seq) as seq from " + tableName + ";", null);
|
||||||
|
if (cursor.moveToFirst()) {
|
||||||
|
seq = cursor.getString(cursor.getColumnIndex("seq"));
|
||||||
|
}
|
||||||
|
if (seq == null) seq = "0";
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
if (seq == null) seq = "0";
|
|
||||||
cursor.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,26 +464,38 @@ 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;
|
||||||
if(cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
do{
|
Cursor cursor = rdb.rawQuery("select uid from frmlocust where send=0 and filled=1 and device_id=?", new String[]{ android_id });
|
||||||
sendFrmLocust(cursor.getString(cursor.getColumnIndex("uid")));
|
if(cursor.moveToFirst())
|
||||||
}while (cursor.moveToNext());
|
{
|
||||||
|
do{
|
||||||
|
sendFrmLocust(cursor.getString(cursor.getColumnIndex("uid")));
|
||||||
|
}while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.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;
|
||||||
if(cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
do{
|
Cursor cursor = rdb.rawQuery("select uid from frmlocustdel where send=0 and filled=1 and device_id=?", new String[]{ android_id });
|
||||||
sendFrmLocustDel(cursor.getString(cursor.getColumnIndex("uid")));
|
if(cursor.moveToFirst())
|
||||||
}while (cursor.moveToNext());
|
{
|
||||||
|
do{
|
||||||
|
sendFrmLocustDel(cursor.getString(cursor.getColumnIndex("uid")));
|
||||||
|
}while (cursor.moveToNext());
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
//Запрос в очередь на получение списка стран, направлений, итд.
|
//Запрос в очередь на получение списка стран, направлений, итд.
|
||||||
@ -505,15 +540,21 @@ 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;
|
||||||
if(cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
String country_id = cursor.getString(0);
|
Cursor cursor = rdb.rawQuery("select t.country_id from terminals t where t.del=0 and t.serial='"+ android_id +"';", null);
|
||||||
rid_frmlocustdel = makeRequest("frmlocustdel",String.valueOf(MySynchronizationOld.SyncDays),country_id);
|
if(cursor.moveToFirst())
|
||||||
//Загружаю координаты для формы frmlocustdel
|
{
|
||||||
rid_frmlocustdel_locations = makeRequest("frmlocustdel_locations",String.valueOf(MySynchronizationOld.SyncDays),country_id);
|
String country_id = cursor.getString(0);
|
||||||
|
rid_frmlocustdel = makeRequest("frmlocustdel",String.valueOf(MySynchronizationOld.SyncDays),country_id);
|
||||||
|
//Загружаю координаты для формы frmlocustdel
|
||||||
|
rid_frmlocustdel_locations = makeRequest("frmlocustdel_locations",String.valueOf(MySynchronizationOld.SyncDays),country_id);
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
}
|
}
|
||||||
cursor.close();
|
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,45 +651,53 @@ 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;
|
||||||
ContentValues cv = new ContentValues();
|
|
||||||
cv.put("send", 1); //Отмечаем как отправленное
|
|
||||||
//cv.put("changed", 0); //Отмечаем как не измененное
|
|
||||||
|
|
||||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
|
||||||
try {
|
try {
|
||||||
db.update("frmlocust", cv, "uid = ?", new String[]{String.valueOf(uid)});
|
rdb = dboh.getReadableDatabase();
|
||||||
db.setTransactionSuccessful();
|
wdb = dboh.getWritableDatabase();
|
||||||
} finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Ищем имя файла по id и удаляем фотографии
|
ContentValues cv = new ContentValues();
|
||||||
cursor = db.rawQuery("select image_name1, image_name2, image_name3 from frmlocust where uid=?;", new String[]{String.valueOf(uid)});
|
cv.put("send", 1); //Отмечаем как отправленное
|
||||||
if (cursor.moveToFirst()) {
|
//cv.put("changed", 0); //Отмечаем как не измененное
|
||||||
String path;
|
|
||||||
File pFile;
|
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||||
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name1"));
|
try {
|
||||||
pFile = new File(path);
|
wdb.update("frmlocust", cv, "uid = ?", new String[]{String.valueOf(uid)});
|
||||||
if (pFile.exists()) //Переименовываю файл чтобы зановоне отправить при редактировании
|
wdb.setTransactionSuccessful();
|
||||||
{
|
} finally {
|
||||||
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name1"))));
|
wdb.endTransaction();
|
||||||
}
|
}
|
||||||
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name2"));
|
|
||||||
pFile = new File(path);
|
//Ищем имя файла по id и удаляем фотографии
|
||||||
if (pFile.exists()) //Переименовываю файл чтобы зановоне отправить при редактировании
|
cursor = rdb.rawQuery("select image_name1, image_name2, image_name3 from frmlocust where uid=?;", new String[]{String.valueOf(uid)});
|
||||||
{
|
if (cursor.moveToFirst()) {
|
||||||
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name2"))));
|
String path;
|
||||||
}
|
File pFile;
|
||||||
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name3"));
|
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name1"));
|
||||||
pFile = new File(path);
|
pFile = new File(path);
|
||||||
if (pFile.exists()) //Переименовываю файл чтобы зановоне отправить при редактировании
|
if (pFile.exists()) //Переименовываю файл чтобы зановоне отправить при редактировании
|
||||||
{
|
{
|
||||||
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_name1"))));
|
||||||
|
}
|
||||||
|
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name2"));
|
||||||
|
pFile = new File(path);
|
||||||
|
if (pFile.exists()) //Переименовываю файл чтобы зановоне отправить при редактировании
|
||||||
|
{
|
||||||
|
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name2"))));
|
||||||
|
}
|
||||||
|
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name3"));
|
||||||
|
pFile = new File(path);
|
||||||
|
if (pFile.exists()) //Переименовываю файл чтобы зановоне отправить при редактировании
|
||||||
|
{
|
||||||
|
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name3"))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
|
if(wdb!=null){ wdb.close(); }
|
||||||
}
|
}
|
||||||
db.close();
|
dboh.close();
|
||||||
|
|
||||||
} else if (fn.equals("5")) //Сохранили данные о саранче на сервере ставим признак отправленности
|
} else if (fn.equals("5")) //Сохранили данные о саранче на сервере ставим признак отправленности
|
||||||
{
|
{
|
||||||
@ -657,45 +706,52 @@ 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;
|
||||||
ContentValues cv = new ContentValues();
|
|
||||||
cv.put("send", 1); //Отмечаем как отправленное
|
|
||||||
//cv.put("changed", 0); //Отмечаем как не измененное
|
|
||||||
|
|
||||||
db.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
|
||||||
try {
|
try {
|
||||||
db.update("frmlocustdel", cv, "uid = ?", new String[]{String.valueOf(uid)});
|
rdb = dboh.getReadableDatabase();
|
||||||
db.setTransactionSuccessful();
|
wdb = dboh.getWritableDatabase();
|
||||||
} finally {
|
|
||||||
db.endTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Ищем имя файла по id и удаляем фотографии
|
ContentValues cv = new ContentValues();
|
||||||
cursor = db.rawQuery("select image_name1, image_name2, image_name3 from frmlocustdel where uid=?;", new String[]{String.valueOf(uid)});
|
cv.put("send", 1); //Отмечаем как отправленное
|
||||||
if (cursor.moveToFirst()) {
|
//cv.put("changed", 0); //Отмечаем как не измененное
|
||||||
String path;
|
|
||||||
File pFile;
|
wdb.beginTransaction(); //Вроде как защита от многопоточности (для сервиса)
|
||||||
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name1"));
|
try {
|
||||||
pFile = new File(path);
|
wdb.update("frmlocustdel", cv, "uid = ?", new String[]{String.valueOf(uid)});
|
||||||
if (pFile.exists()) //Переименовываю файл чтобы заново не отправить при редактировании
|
wdb.setTransactionSuccessful();
|
||||||
{
|
} finally {
|
||||||
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name1"))));
|
wdb.endTransaction();
|
||||||
}
|
}
|
||||||
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name2"));
|
|
||||||
pFile = new File(path);
|
//Ищем имя файла по id и удаляем фотографии
|
||||||
if (pFile.exists()) //Переименовываю файл чтобы заново не отправить при редактировании
|
cursor = rdb.rawQuery("select image_name1, image_name2, image_name3 from frmlocustdel where uid=?;", new String[]{String.valueOf(uid)});
|
||||||
{
|
if (cursor.moveToFirst()) {
|
||||||
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name2"))));
|
String path;
|
||||||
}
|
File pFile;
|
||||||
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name3"));
|
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name1"));
|
||||||
pFile = new File(path);
|
pFile = new File(path);
|
||||||
if (pFile.exists()) //Переименовываю файл чтобы заново не отправить при редактировании
|
if (pFile.exists()) //Переименовываю файл чтобы заново не отправить при редактировании
|
||||||
{
|
{
|
||||||
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_name1"))));
|
||||||
|
}
|
||||||
|
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name2"));
|
||||||
|
pFile = new File(path);
|
||||||
|
if (pFile.exists()) //Переименовываю файл чтобы заново не отправить при редактировании
|
||||||
|
{
|
||||||
|
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name2"))));
|
||||||
|
}
|
||||||
|
path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + cursor.getString(cursor.getColumnIndex("image_name3"));
|
||||||
|
pFile = new File(path);
|
||||||
|
if (pFile.exists()) //Переименовываю файл чтобы заново не отправить при редактировании
|
||||||
|
{
|
||||||
|
pFile.renameTo(new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/_" + cursor.getString(cursor.getColumnIndex("image_name3"))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
|
if(wdb!=null){ wdb.close(); }
|
||||||
}
|
}
|
||||||
db.close();
|
|
||||||
|
|
||||||
} else if (fn.equals("6")) //Фото отправлено
|
} else if (fn.equals("6")) //Фото отправлено
|
||||||
{
|
{
|
||||||
|
|||||||
@ -119,23 +119,28 @@ 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 {
|
||||||
" cr.name as country_name," +
|
rdb = dboh.getReadableDatabase();
|
||||||
" cp.name as company_name," +
|
Cursor cursor = rdb.rawQuery("select " +
|
||||||
" t.name " +
|
" cr.name as country_name," +
|
||||||
"from " +
|
" cp.name as company_name," +
|
||||||
" terminals t " +
|
" t.name " +
|
||||||
" left join countries cr on cr.id=t.country_id " +
|
"from " +
|
||||||
" left join companies cp on cp.id=t.company_id " +
|
" terminals t " +
|
||||||
"where t.del=0 and t.serial='"+Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
" left join countries cr on cr.id=t.country_id " +
|
||||||
if(cursor.moveToFirst())
|
" left join companies cp on cp.id=t.company_id " +
|
||||||
{
|
"where t.del=0 and t.serial='"+Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||||
tvCountry.setText(cursor.getString(cursor.getColumnIndex("country_name")));
|
if(cursor.moveToFirst())
|
||||||
tvOrganization.setText(cursor.getString(cursor.getColumnIndex("company_name")));
|
{
|
||||||
tvName.setText(cursor.getString(cursor.getColumnIndex("name")));
|
tvCountry.setText(cursor.getString(cursor.getColumnIndex("country_name")));
|
||||||
}
|
tvOrganization.setText(cursor.getString(cursor.getColumnIndex("company_name")));
|
||||||
cursor.close();
|
tvName.setText(cursor.getString(cursor.getColumnIndex("name")));
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
|
}
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
|
|
||||||
@ -241,33 +246,39 @@ 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;
|
||||||
if(cursor.moveToFirst())
|
try {
|
||||||
{
|
rdb = dboh.getReadableDatabase();
|
||||||
exists=true;
|
wdb = dboh.getWritableDatabase();
|
||||||
}
|
Cursor cursor = rdb.rawQuery(sql, null);
|
||||||
cursor.close();
|
if(cursor.moveToFirst())
|
||||||
if(exists){
|
{
|
||||||
sql="update terminals set country_id=?,company_id=?,name=?,serial=? where id=?";
|
exists=true;
|
||||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
}
|
||||||
SQLiteStatement stmt = wdb.compileStatement(sql);
|
cursor.close();
|
||||||
stmt.bindLong(1, json.getLong("country_id"));
|
if(exists){
|
||||||
stmt.bindLong(2, json.getLong("company_id"));
|
sql="update terminals set country_id=?,company_id=?,name=?,serial=? where id=?";
|
||||||
stmt.bindString(3, json.getString("name"));
|
SQLiteStatement stmt = wdb.compileStatement(sql);
|
||||||
stmt.bindString(4, Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID));
|
stmt.bindLong(1, json.getLong("country_id"));
|
||||||
stmt.bindLong(5, json.getLong("id"));
|
stmt.bindLong(2, json.getLong("company_id"));
|
||||||
stmt.executeUpdateDelete();
|
stmt.bindString(3, json.getString("name"));
|
||||||
}else{
|
stmt.bindString(4, Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID));
|
||||||
sql="insert into terminals(id,country_id,company_id,name,serial)values(?,?,?,?,?);";
|
stmt.bindLong(5, json.getLong("id"));
|
||||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
stmt.executeUpdateDelete();
|
||||||
SQLiteStatement stmt = wdb.compileStatement(sql);
|
}else{
|
||||||
stmt.bindLong(1, json.getLong("id"));
|
sql="insert into terminals(id,country_id,company_id,name,serial)values(?,?,?,?,?);";
|
||||||
stmt.bindLong(2, json.getLong("country_id"));
|
SQLiteStatement stmt = wdb.compileStatement(sql);
|
||||||
stmt.bindLong(3, json.getLong("company_id"));
|
stmt.bindLong(1, json.getLong("id"));
|
||||||
stmt.bindString(4, json.getString("name"));
|
stmt.bindLong(2, json.getLong("country_id"));
|
||||||
stmt.bindString(5, Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID));
|
stmt.bindLong(3, json.getLong("company_id"));
|
||||||
stmt.executeInsert();
|
stmt.bindString(4, json.getString("name"));
|
||||||
|
stmt.bindString(5, Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID));
|
||||||
|
stmt.executeInsert();
|
||||||
|
}
|
||||||
|
}finally{
|
||||||
|
if(rdb!=null){ rdb.close(); }
|
||||||
|
if(wdb!=null){ wdb.close(); }
|
||||||
}
|
}
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
|
|||||||
@ -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