Отправка широты и долготы отдельно для синхронизации
This commit is contained in:
@ -5,15 +5,17 @@ import android.os.Parcelable;
|
|||||||
|
|
||||||
|
|
||||||
public class LatLon implements android.os.Parcelable{
|
public class LatLon implements android.os.Parcelable{
|
||||||
|
String uid;
|
||||||
public double lat;
|
public double lat;
|
||||||
public double lon;
|
public double lon;
|
||||||
|
|
||||||
public static final Parcelable.Creator<LatLon> CREATOR = new Parcelable.Creator<LatLon>() {
|
public static final Parcelable.Creator<LatLon> CREATOR = new Parcelable.Creator<LatLon>() {
|
||||||
@Override
|
@Override
|
||||||
public LatLon createFromParcel(Parcel source) {
|
public LatLon createFromParcel(Parcel source) {
|
||||||
|
String uid = source.readString();
|
||||||
double lat = source.readDouble();
|
double lat = source.readDouble();
|
||||||
double lon = source.readDouble();
|
double lon = source.readDouble();
|
||||||
return new LatLon(lat, lon);
|
return new LatLon(uid, lat, lon);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -22,7 +24,8 @@ public class LatLon implements android.os.Parcelable{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LatLon(double lat, double lon){
|
LatLon(String uid, double lat, double lon){
|
||||||
|
this.uid=uid;
|
||||||
this.lat=lat;
|
this.lat=lat;
|
||||||
this.lon=lon;
|
this.lon=lon;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.text.DecimalFormatSymbols;
|
import java.text.DecimalFormatSymbols;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import tools.LatLonListener;
|
import tools.LatLonListener;
|
||||||
|
|
||||||
@ -125,7 +126,7 @@ public class LatLonAdapter extends ArrayAdapter<LatLon> {
|
|||||||
latlon.lat=adapter.latlonListener.getLat();
|
latlon.lat=adapter.latlonListener.getLat();
|
||||||
latlon.lon=adapter.latlonListener.getLon();
|
latlon.lon=adapter.latlonListener.getLon();
|
||||||
if(adapter.latlonList.get(adapter.latlonList.size()-1).lat!=0 && adapter.latlonList.get(adapter.latlonList.size()-1).lon!=0){
|
if(adapter.latlonList.get(adapter.latlonList.size()-1).lat!=0 && adapter.latlonList.get(adapter.latlonList.size()-1).lon!=0){
|
||||||
adapter.latlonList.add(new LatLon(0, 0));
|
adapter.latlonList.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
if(adapter.clc!=null){
|
if(adapter.clc!=null){
|
||||||
adapter.clc.onClick(null);
|
adapter.clc.onClick(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,7 @@ import java.text.DecimalFormatSymbols;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
import dbfields.AutoCompleteTextViewDB;
|
import dbfields.AutoCompleteTextViewDB;
|
||||||
@ -403,7 +404,7 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
|||||||
|
|
||||||
ArrayList<LatLon> latlon = new ArrayList<LatLon>();
|
ArrayList<LatLon> latlon = new ArrayList<LatLon>();
|
||||||
if(latlon.size()==0){
|
if(latlon.size()==0){
|
||||||
latlon.add(new LatLon(0, 0));
|
latlon.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
}
|
}
|
||||||
latlonList = findViewById(R.id.latlonList);
|
latlonList = findViewById(R.id.latlonList);
|
||||||
LatLonAdapter adapter = new LatLonAdapter(this, R.layout.list_lat_lon, latlon, this, latlonList,false);
|
LatLonAdapter adapter = new LatLonAdapter(this, R.layout.list_lat_lon, latlon, this, latlonList,false);
|
||||||
@ -1374,10 +1375,10 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
|||||||
list.clear();
|
list.clear();
|
||||||
for(int i=0;i<points.size();i++){
|
for(int i=0;i<points.size();i++){
|
||||||
if(points.get(i)!=null && points.get(i).lon!=0 && points.get(i).lat!=0) {
|
if(points.get(i)!=null && points.get(i).lon!=0 && points.get(i).lat!=0) {
|
||||||
list.add(new LatLon(points.get(i).lat, points.get(i).lon));
|
list.add(new LatLon(points.get(i).uid,points.get(i).lat, points.get(i).lon));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.add(new LatLon(0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
Tools.setListViewHeightBasedOnItems(latlonList);
|
Tools.setListViewHeightBasedOnItems(latlonList);
|
||||||
break;
|
break;
|
||||||
@ -1808,17 +1809,17 @@ 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 lat,lon from frmlocust_locations where frmlocust_uid='" + uid + "' order by pos", null);
|
Cursor cursor = dboh.getReadableDatabase().rawQuery("select uid,lat,lon from frmlocust_locations where del=false and frmlocust_uid='" + uid + "' order by pos", null);
|
||||||
if (cursor.moveToFirst())
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
list.add(new LatLon(cursor.getDouble(0), cursor.getDouble(1)));
|
list.add(new LatLon(cursor.getString(0), cursor.getDouble(1), cursor.getDouble(2)));
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
dboh.close();
|
dboh.close();
|
||||||
list.add(new LatLon(0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2469,11 +2470,12 @@ public class LocustActivity extends FragmentActivity implements LocationListener
|
|||||||
{
|
{
|
||||||
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
||||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
||||||
SQLiteStatement stmt = wdb.compileStatement("insert into frmlocust_locations(frmlocust_uid,pos,lat,lon)values(?,?,?,?)");
|
SQLiteStatement stmt = wdb.compileStatement("insert into frmlocust_locations(uid,frmlocust_uid,pos,lat,lon)values(?,?,?,?,?)");
|
||||||
stmt.bindString(1, uid);
|
stmt.bindString(1, UUID.randomUUID().toString());
|
||||||
stmt.bindLong(2, i);
|
stmt.bindString(2, uid);
|
||||||
stmt.bindDouble(3, list.get(i).lat);
|
stmt.bindLong(3, i);
|
||||||
stmt.bindDouble(4, list.get(i).lon);
|
stmt.bindDouble(4, list.get(i).lat);
|
||||||
|
stmt.bindDouble(5, list.get(i).lon);
|
||||||
stmt.executeInsert();
|
stmt.executeInsert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
import dbfields.AutoCompleteTextViewDB;
|
import dbfields.AutoCompleteTextViewDB;
|
||||||
@ -447,7 +448,7 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
|||||||
guiTable.add(edtLonCenter, "lon_center");
|
guiTable.add(edtLonCenter, "lon_center");
|
||||||
|
|
||||||
ArrayList<LatLon> latlon = new ArrayList<LatLon>();
|
ArrayList<LatLon> latlon = new ArrayList<LatLon>();
|
||||||
latlon.add(new LatLon(0, 0));
|
latlon.add(new LatLon(UUID.randomUUID().toString(), 0, 0));
|
||||||
latlonList = findViewById(R.id.latlonList);
|
latlonList = findViewById(R.id.latlonList);
|
||||||
LatLonAdapter adapter = new LatLonAdapter(this, R.layout.list_lat_lon, latlon, this, latlonList, false);
|
LatLonAdapter adapter = new LatLonAdapter(this, R.layout.list_lat_lon, latlon, this, latlonList, false);
|
||||||
latlonList.setAdapter(adapter);
|
latlonList.setAdapter(adapter);
|
||||||
@ -1763,10 +1764,10 @@ public class LocustDelActivity extends FragmentActivity implements LocationListe
|
|||||||
list.clear();
|
list.clear();
|
||||||
for(int i=0;i<points.size();i++){
|
for(int i=0;i<points.size();i++){
|
||||||
if(points.get(i)!=null && points.get(i).lon!=0 && points.get(i).lat!=0) {
|
if(points.get(i)!=null && points.get(i).lon!=0 && points.get(i).lat!=0) {
|
||||||
list.add(new LatLon(points.get(i).lat, points.get(i).lon));
|
list.add(new LatLon(points.get(i).uid, points.get(i).lat, points.get(i).lon));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.add(new LatLon(0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
Tools.setListViewHeightBasedOnItems(latlonList);
|
Tools.setListViewHeightBasedOnItems(latlonList);
|
||||||
break;
|
break;
|
||||||
@ -1828,20 +1829,39 @@ 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("delete from frmlocustdel_locations where frmlocustdel_uid=\'" + uid+"\'");
|
dboh.getReadableDatabase().execSQL("update frmlocustdel_locations set del=true where frmlocustdel_uid=\'" + uid+"\'");
|
||||||
ArrayList<LatLon> list = ((LatLonAdapter)latlonList.getAdapter()).latlonList;
|
ArrayList<LatLon> list = ((LatLonAdapter)latlonList.getAdapter()).latlonList;
|
||||||
for(int i=0;i<list.size();i++)
|
for(int i=0;i<list.size();i++)
|
||||||
{
|
{
|
||||||
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
if(list.get(i)!=null && list.get(i).lon!=0 && list.get(i).lat!=0){
|
||||||
|
boolean exists=false;
|
||||||
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
SQLiteDatabase wdb = dboh.getWritableDatabase();
|
||||||
SQLiteStatement stmt = wdb.compileStatement("insert into frmlocustdel_locations(frmlocustdel_uid,pos,lat,lon)values(?,?,?,?)");
|
SQLiteStatement stmt = wdb.compileStatement("select 1 from frmlocustdel_locations where uid=?");
|
||||||
|
stmt.bindString(1, list.get(i).uid);
|
||||||
|
try {
|
||||||
|
long result = stmt.simpleQueryForLong();
|
||||||
|
exists = result == 1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
if(exists){
|
||||||
|
stmt = wdb.compileStatement("update frmlocustdel_locations set del=false,frmlocustdel_uid=?,pos=?,lat=?,lon=? where uid=?");
|
||||||
stmt.bindString(1, uid);
|
stmt.bindString(1, uid);
|
||||||
stmt.bindLong(2, i);
|
stmt.bindLong(2, i);
|
||||||
stmt.bindDouble(3, list.get(i).lat);
|
stmt.bindDouble(3, list.get(i).lat);
|
||||||
stmt.bindDouble(4, list.get(i).lon);
|
stmt.bindDouble(4, list.get(i).lon);
|
||||||
|
stmt.bindString(5, list.get(i).uid);
|
||||||
|
stmt.executeUpdateDelete();
|
||||||
|
}else{
|
||||||
|
stmt = wdb.compileStatement("insert into frmlocustdel_locations(frmlocustdel_uid,pos,lat,lon,uid)values(?,?,?,?,?)");
|
||||||
|
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();
|
stmt.executeInsert();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1908,17 +1928,17 @@ 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 lat,lon from frmlocustdel_locations where frmlocustdel_uid='" + uid + "' order by pos", null);
|
Cursor cursor = dboh.getReadableDatabase().rawQuery("select uid,lat,lon from frmlocustdel_locations where del=false and frmlocustdel_uid='" + uid + "' order by pos", null);
|
||||||
if (cursor.moveToFirst())
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
list.add(new LatLon(cursor.getDouble(0), cursor.getDouble(1)));
|
list.add(new LatLon(cursor.getString(0), cursor.getDouble(1), cursor.getDouble(2)));
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
dboh.close();
|
dboh.close();
|
||||||
list.add(new LatLon(0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,7 @@ import java.io.InputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
import dbfields.AutoCompleteTextViewDB;
|
import dbfields.AutoCompleteTextViewDB;
|
||||||
@ -433,7 +434,7 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
|||||||
guiTableDel.add(edtLonCenter, "lon_center");
|
guiTableDel.add(edtLonCenter, "lon_center");
|
||||||
|
|
||||||
ArrayList<LatLon> latlon = new ArrayList<LatLon>();
|
ArrayList<LatLon> latlon = new ArrayList<LatLon>();
|
||||||
latlon.add(new LatLon(0, 0));
|
latlon.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
latlonList = findViewById(R.id.latlonList);
|
latlonList = findViewById(R.id.latlonList);
|
||||||
LatLonAdapter adapter = new LatLonAdapter(this, R.layout.list_lat_lon, latlon, this, latlonList, true);
|
LatLonAdapter adapter = new LatLonAdapter(this, R.layout.list_lat_lon, latlon, this, latlonList, true);
|
||||||
latlonList.setAdapter(adapter);
|
latlonList.setAdapter(adapter);
|
||||||
@ -3208,10 +3209,10 @@ public class LocustHealthActivity extends FragmentActivity implements LocationLi
|
|||||||
list.clear();
|
list.clear();
|
||||||
for(int i=0;i<points.size();i++){
|
for(int i=0;i<points.size();i++){
|
||||||
if(points.get(i)!=null && points.get(i).lon!=0 && points.get(i).lat!=0) {
|
if(points.get(i)!=null && points.get(i).lon!=0 && points.get(i).lat!=0) {
|
||||||
list.add(new LatLon(points.get(i).lat, points.get(i).lon));
|
list.add(new LatLon(points.get(i).uid,points.get(i).lat, points.get(i).lon));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.add(new LatLon(0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
Tools.setListViewHeightBasedOnItems(latlonList);
|
Tools.setListViewHeightBasedOnItems(latlonList);
|
||||||
break;
|
break;
|
||||||
@ -3483,17 +3484,17 @@ 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 lat,lon from frmlocustdel_locations where frmlocustdel_uid='" + uid + "' order by pos", null);
|
Cursor cursor = dboh.getReadableDatabase().rawQuery("select uid,lat,lon from frmlocustdel_locations where frmlocustdel_uid='" + uid + "' order by pos", null);
|
||||||
if (cursor.moveToFirst())
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
list.add(new LatLon(cursor.getDouble(0), cursor.getDouble(1)));
|
list.add(new LatLon(cursor.getString(0), cursor.getDouble(1), cursor.getDouble(2)));
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
dboh.close();
|
dboh.close();
|
||||||
list.add(new LatLon(0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3517,17 +3518,17 @@ 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 lat,lon from frmlocusthealth_locations where frmlocusthealth_uid='" + uid + "' order by pos", null);
|
Cursor cursor = dboh.getReadableDatabase().rawQuery("select uid,lat,lon from frmlocusthealth_locations where frmlocusthealth_uid='" + uid + "' order by pos", null);
|
||||||
if (cursor.moveToFirst())
|
if (cursor.moveToFirst())
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
list.add(new LatLon(cursor.getDouble(0), cursor.getDouble(1)));
|
list.add(new LatLon(cursor.getString(0),cursor.getDouble(1), cursor.getDouble(2)));
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
cursor.close();
|
cursor.close();
|
||||||
dboh.close();
|
dboh.close();
|
||||||
list.add(new LatLon(0, 0));
|
list.add(new LatLon(UUID.randomUUID().toString(),0, 0));
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import com.google.maps.android.ui.IconGenerator;
|
|||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import dbfields.selectDB;
|
import dbfields.selectDB;
|
||||||
import tctable.Point;
|
import tctable.Point;
|
||||||
@ -259,7 +260,7 @@ public class MapsActivity extends FragmentActivity implements OnMapReadyCallback
|
|||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
ArrayList<LatLon> list=new ArrayList<LatLon>();
|
ArrayList<LatLon> list=new ArrayList<LatLon>();
|
||||||
for(int j=0;j<MapsActivity.this.polygon.getPoints().size()-1;j++){
|
for(int j=0;j<MapsActivity.this.polygon.getPoints().size()-1;j++){
|
||||||
list.add(new LatLon(MapsActivity.this.polygon.getPoints().get(j).latitude,MapsActivity.this.polygon.getPoints().get(j).longitude));
|
list.add(new LatLon(UUID.randomUUID().toString(),MapsActivity.this.polygon.getPoints().get(j).latitude,MapsActivity.this.polygon.getPoints().get(j).longitude));
|
||||||
}
|
}
|
||||||
intent.putParcelableArrayListExtra("LatLon", list);
|
intent.putParcelableArrayListExtra("LatLon", list);
|
||||||
MapsActivity.this.setResult(Activity.RESULT_OK,intent);
|
MapsActivity.this.setResult(Activity.RESULT_OK,intent);
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import android.provider.Settings;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
|
|
||||||
|
|
||||||
/*import org.apache.http.HttpResponse;
|
/*import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpVersion;
|
import org.apache.http.HttpVersion;
|
||||||
import org.apache.http.client.ClientProtocolException;
|
import org.apache.http.client.ClientProtocolException;
|
||||||
@ -35,6 +36,7 @@ import org.json.JSONObject;
|
|||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -55,6 +57,7 @@ import java.net.URL;
|
|||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -65,7 +68,10 @@ import javax.net.ssl.SSLSocketFactory;
|
|||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
|
import tctable.TCField;
|
||||||
import tctable.TCTable;
|
import tctable.TCTable;
|
||||||
|
import tctable.TCTableTools;
|
||||||
|
import tools.TCTableTools2;
|
||||||
|
|
||||||
//import org.apache.http.entity.MultipartEntity;
|
//import org.apache.http.entity.MultipartEntity;
|
||||||
|
|
||||||
@ -196,15 +202,15 @@ public class MySynchronizationOld
|
|||||||
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);
|
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);
|
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);
|
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\">";
|
||||||
@ -235,7 +241,7 @@ public class MySynchronizationOld
|
|||||||
cursor2.close();
|
cursor2.close();
|
||||||
xml+="</metadata>";
|
xml+="</metadata>";
|
||||||
|
|
||||||
rid_sendFrmLocust = myThread.addRequest(MySynchronizationOld.URL+"/get/", xml, null);
|
rid_sendFrmLocust = myThread.addRequest(MySynchronizationOld.URL+"/get/", xml, null,null);
|
||||||
|
|
||||||
}while (cursor.moveToNext());
|
}while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
@ -263,15 +269,15 @@ public class MySynchronizationOld
|
|||||||
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);
|
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);
|
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);
|
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\"?>";
|
||||||
@ -302,7 +308,43 @@ public class MySynchronizationOld
|
|||||||
cursor2.close();
|
cursor2.close();
|
||||||
xml+="</metadata>";
|
xml+="</metadata>";
|
||||||
|
|
||||||
rid_sendFrmLocustDel = myThread.addRequest(MySynchronizationOld.URL+"/get/", xml, null);
|
rid_sendFrmLocust = myThread.addRequest(MySynchronizationOld.URL+"/get/", xml, null,null);
|
||||||
|
|
||||||
|
//Отправляю данные координат отдельно (без подтверждения доставки, потом нужно добавить поле send boolean и отправлять отдельно от frmlocustdel)
|
||||||
|
Cursor cursor3 = dboh.getReadableDatabase().rawQuery("select uid,del,seq,frmlocustdel_uid,pos,lon,lat from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||||
|
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||||
|
TCTableTools2.getTCTableFromCursor("frmlocustdel_locations", 0, cursor3, outStream);
|
||||||
|
myThread.addRequest(MySynchronizationOld.URL+"/asdc/tctable/", null, null, outStream.toByteArray());
|
||||||
|
|
||||||
|
|
||||||
|
/* ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||||
|
TCTable tbl = new TCTable("frmlocustdel_locations", 0);
|
||||||
|
tbl.addField(new TCField("uid",TCField.BD_UTF8_1));
|
||||||
|
tbl.addField(new TCField("del",TCField.BD_UINT1));
|
||||||
|
tbl.addField(new TCField("seq",TCField.BD_UINT4));
|
||||||
|
tbl.addField(new TCField("frmlocustdel_uid",TCField.BD_UTF8_1));
|
||||||
|
tbl.addField(new TCField("pos",TCField.BD_UINT4));
|
||||||
|
tbl.addField(new TCField("lon",TCField.BD_FLOAT8));
|
||||||
|
tbl.addField(new TCField("lat",TCField.BD_FLOAT8));
|
||||||
|
tbl.getHeader(outStream);
|
||||||
|
//Переписываю значения из базы данных в outStream
|
||||||
|
Cursor cursor3 = dboh.getReadableDatabase().rawQuery("select uid,del,seq,frmlocustdel_uid,pos,lon,lat from frmlocustdel_locations where frmlocustdel_uid=? order by pos", new String[] { String.valueOf(uid) });
|
||||||
|
if(cursor3.moveToFirst()) {
|
||||||
|
do {
|
||||||
|
tbl.fields.get(0).setValue(cursor3.getString(0));
|
||||||
|
tbl.fields.get(1).setValue(cursor3.getString(1));
|
||||||
|
tbl.fields.get(2).setValue(cursor3.getString(2));
|
||||||
|
tbl.fields.get(3).setValue(cursor3.getString(3));
|
||||||
|
tbl.fields.get(4).setValue(cursor3.getString(4));
|
||||||
|
tbl.fields.get(5).setValue(cursor3.getString(5));
|
||||||
|
tbl.fields.get(6).setValue(cursor3.getString(6));
|
||||||
|
tbl.getCol(outStream);
|
||||||
|
}while (cursor3.moveToNext());
|
||||||
|
}
|
||||||
|
cursor3.close();
|
||||||
|
//Отправляю пакет данных на сервер для вставки либо обновления
|
||||||
|
myThread.addRequest(MySynchronizationOld.URL+"/asdc/tctable/", null, null, outStream.toByteArray());
|
||||||
|
*/
|
||||||
|
|
||||||
}while (cursor.moveToNext());
|
}while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
@ -330,19 +372,19 @@ public class MySynchronizationOld
|
|||||||
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);
|
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);
|
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);
|
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_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);
|
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_name5"));
|
||||||
if(fname!=null && !fname.equals(""))
|
if(fname!=null && !fname.equals(""))
|
||||||
myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=6", null, Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Locust/" + fname);
|
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++)
|
||||||
@ -355,7 +397,7 @@ public class MySynchronizationOld
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rid_sendFrmLocustHealth = myThread.addRequest(MySynchronizationOld.URL+"/asdc/FrmLocustHealth/", jsonObject.toString(), null);
|
rid_sendFrmLocustHealth = myThread.addRequest(MySynchronizationOld.URL+"/asdc/FrmLocustHealth/", jsonObject.toString(), null,null);
|
||||||
|
|
||||||
}while (cursor.moveToNext());
|
}while (cursor.moveToNext());
|
||||||
}
|
}
|
||||||
@ -377,9 +419,9 @@ public class MySynchronizationOld
|
|||||||
cursor.close();
|
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);
|
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);
|
||||||
}else{
|
}else{
|
||||||
return myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=1&r=0&n="+tableName+"&s=" + seq + "&l=1000","", null);
|
return myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=1&r=0&n="+tableName+"&s=" + seq + "&l=1000","", null,null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -688,6 +730,7 @@ class MyThread extends Thread
|
|||||||
String url = ""; //URL куда отправлять данные
|
String url = ""; //URL куда отправлять данные
|
||||||
String str = ""; //Отправляемая строка
|
String str = ""; //Отправляемая строка
|
||||||
String file = ""; //Отправляемый файл
|
String file = ""; //Отправляемый файл
|
||||||
|
byte[] data = null; //Отправляемые данные
|
||||||
Boolean s = false; //Integer s = 0; // false - не отправлялось true - в процессе отправки (если ошибка то ставиться статус не отправлено иначе удаляется из списка заданий)
|
Boolean s = false; //Integer s = 0; // false - не отправлялось true - в процессе отправки (если ошибка то ставиться статус не отправлено иначе удаляется из списка заданий)
|
||||||
int id = 0; //Инкриментальный идентификатор запроса
|
int id = 0; //Инкриментальный идентификатор запроса
|
||||||
int wait = 10; //Милисекунд ждать перед отправкой текущего задания
|
int wait = 10; //Милисекунд ждать перед отправкой текущего задания
|
||||||
@ -752,17 +795,17 @@ class MyThread extends Thread
|
|||||||
|
|
||||||
// Добавление в задание на отправку до того как не получен ответ от предедущего запроса следующий не отсылается те. последовательно это делает (обработка результатов не в потоке загрузки а в основном потоке)
|
// Добавление в задание на отправку до того как не получен ответ от предедущего запроса следующий не отсылается те. последовательно это делает (обработка результатов не в потоке загрузки а в основном потоке)
|
||||||
//return id запроса
|
//return id запроса
|
||||||
public int addRequest(String url, String str, String file)
|
public int addRequest(String url, String str, String file,byte[] data)
|
||||||
{
|
{
|
||||||
mId++; //Инкрементируем идентификатор запроса
|
mId++; //Инкрементируем идентификатор запроса
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mSemaphore.acquire();
|
mSemaphore.acquire();
|
||||||
|
|
||||||
Tsk t = new Tsk();
|
Tsk t = new Tsk();
|
||||||
t.url = url;
|
t.url = url;
|
||||||
t.str = str;
|
t.str = str;
|
||||||
t.file = file;
|
t.file = file;
|
||||||
|
t.data = data;
|
||||||
t.s = false;
|
t.s = false;
|
||||||
t.id = mId;
|
t.id = mId;
|
||||||
mTList.add(t);
|
mTList.add(t);
|
||||||
@ -825,7 +868,9 @@ class MyThread extends Thread
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
sleep(tsk.wait); //Если в задании задано сколько подождать перед запуском
|
sleep(tsk.wait); //Если в задании задано сколько подождать перед запуском
|
||||||
} catch (InterruptedException e) { }
|
} catch (InterruptedException e) {
|
||||||
|
Log.i("igor", "InterruptedException");
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -840,8 +885,7 @@ class MyThread extends Thread
|
|||||||
|
|
||||||
if(tsk.file!=null) { //Отправляем файл на сервер
|
if(tsk.file!=null) { //Отправляем файл на сервер
|
||||||
File file = new File(tsk.file);
|
File file = new File(tsk.file);
|
||||||
if(file.exists())
|
if (file.exists()) {
|
||||||
{
|
|
||||||
String boundary = UUID.randomUUID().toString();
|
String boundary = UUID.randomUUID().toString();
|
||||||
String crlf = "\r\n";
|
String crlf = "\r\n";
|
||||||
conn.setRequestProperty("Connection", "Keep-Alive");
|
conn.setRequestProperty("Connection", "Keep-Alive");
|
||||||
@ -854,7 +898,7 @@ class MyThread extends Thread
|
|||||||
dos.writeBytes("Content-Disposition: form-data; name=\"file\";filename=\"" + tctable.Tools.afterLast(tsk.file, "/") + "\"" + crlf);
|
dos.writeBytes("Content-Disposition: form-data; name=\"file\";filename=\"" + tctable.Tools.afterLast(tsk.file, "/") + "\"" + crlf);
|
||||||
dos.writeBytes(crlf);
|
dos.writeBytes(crlf);
|
||||||
// Read file
|
// Read file
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024]; //The phone's resources are not unlimited, so we send a little at a time
|
||||||
FileInputStream fileInputStream = new FileInputStream(file);
|
FileInputStream fileInputStream = new FileInputStream(file);
|
||||||
int bytesRead = fileInputStream.read(buffer);
|
int bytesRead = fileInputStream.read(buffer);
|
||||||
try {
|
try {
|
||||||
@ -876,6 +920,23 @@ class MyThread extends Thread
|
|||||||
dos.flush();
|
dos.flush();
|
||||||
dos.close();
|
dos.close();
|
||||||
}
|
}
|
||||||
|
}else if(tsk.data!=null) { //Отправляем двоичные данные на сервер
|
||||||
|
String boundary = UUID.randomUUID().toString();
|
||||||
|
String crlf = "\r\n";
|
||||||
|
conn.setRequestProperty("Connection", "Keep-Alive");
|
||||||
|
conn.setRequestProperty("Cache-Control", "no-cache");
|
||||||
|
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
|
||||||
|
//Now we send the data itself, framed by a border.
|
||||||
|
DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
|
||||||
|
dos.writeBytes("--" + boundary + crlf);
|
||||||
|
dos.writeBytes("Content-Type: application/octet-stream" + crlf);
|
||||||
|
dos.writeBytes("Content-Disposition: form-data; name=\"file\";filename=\"bin_data.bin\"" + crlf);
|
||||||
|
dos.writeBytes(crlf);
|
||||||
|
dos.write(tsk.data, 0, tsk.data.length);
|
||||||
|
dos.writeBytes(crlf);
|
||||||
|
dos.writeBytes("--" + boundary + "--" + crlf);
|
||||||
|
dos.flush();
|
||||||
|
dos.close();
|
||||||
}else{
|
}else{
|
||||||
conn.setRequestProperty("Accept-Charset", "UTF-8");
|
conn.setRequestProperty("Accept-Charset", "UTF-8");
|
||||||
conn.setRequestProperty("Content-Type", "application/xml; charset=utf-8");
|
conn.setRequestProperty("Content-Type", "application/xml; charset=utf-8");
|
||||||
|
|||||||
52
app/src/main/java/tools/TCTableTools2.java
Normal file
52
app/src/main/java/tools/TCTableTools2.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package tools;
|
||||||
|
|
||||||
|
import android.database.Cursor;
|
||||||
|
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import tctable.TCField;
|
||||||
|
import tctable.TCTable;
|
||||||
|
|
||||||
|
public class TCTableTools2 {
|
||||||
|
|
||||||
|
public static int convertType(int type)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
if (type == Cursor.FIELD_TYPE_NULL) { //Такого типа у меня нет
|
||||||
|
result=TCField.BD_NULL;
|
||||||
|
} else if (type == Cursor.FIELD_TYPE_BLOB) {
|
||||||
|
result=TCField.BD_BLOB_4;
|
||||||
|
} else if (type == Cursor.FIELD_TYPE_FLOAT) { //Похоже что это почти в SQLITE но перед вставкой преобразуется в нужный тип
|
||||||
|
result=TCField.BD_SFLOAT8;
|
||||||
|
} else if (type == Cursor.FIELD_TYPE_INTEGER) {
|
||||||
|
result=TCField.BD_SINT8;
|
||||||
|
} else if (type == Cursor.FIELD_TYPE_STRING) {
|
||||||
|
result=TCField.BD_UTF8_4;
|
||||||
|
}
|
||||||
|
else result=TCField.BD_UTF8_4;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Записать таблицу в OutputStream из курсора андроида
|
||||||
|
public static boolean getTCTableFromCursor(String name, int id, Cursor cursor, OutputStream os) {
|
||||||
|
TCTable tbl = new TCTable(name, id);
|
||||||
|
String[] columnNames = cursor.getColumnNames();
|
||||||
|
boolean first=true;
|
||||||
|
while (cursor.moveToNext()) {
|
||||||
|
if(first){
|
||||||
|
for (int i = 0; i < columnNames.length; i++) {
|
||||||
|
TCField field = new TCField(columnNames[i], TCTableTools2.convertType(cursor.getType(i)));
|
||||||
|
tbl.addField(field);
|
||||||
|
}
|
||||||
|
tbl.getHeader(os);
|
||||||
|
first=false;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < columnNames.length; i++) {
|
||||||
|
tbl.fields.get(i).setValue(cursor.getString(i));
|
||||||
|
}
|
||||||
|
tbl.getCol(os);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -5,5 +5,6 @@
|
|||||||
<domain includeSubdomains="true">ccalm.org</domain>
|
<domain includeSubdomains="true">ccalm.org</domain>
|
||||||
<domain includeSubdomains="true">test.ccalm.org</domain>
|
<domain includeSubdomains="true">test.ccalm.org</domain>
|
||||||
<domain includeSubdomains="true">192.168.200.100</domain>
|
<domain includeSubdomains="true">192.168.200.100</domain>
|
||||||
|
<domain includeSubdomains="true">10.0.2.2</domain>
|
||||||
</domain-config>
|
</domain-config>
|
||||||
</network-security-config>
|
</network-security-config>
|
||||||
Reference in New Issue
Block a user