Делаю подгрузку старых анкет
This commit is contained in:
@ -10,6 +10,7 @@ import android.os.Bundle;
|
|||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
|
|
||||||
@ -139,7 +140,7 @@ public class MySynchronizationOld
|
|||||||
String URL = MySynchronizationOld.URL;
|
String URL = MySynchronizationOld.URL;
|
||||||
SharedPreferences prefs = _context.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
SharedPreferences prefs = _context.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
||||||
URL = prefs.getString("URL", "");
|
URL = prefs.getString("URL", "");
|
||||||
MySynchronizationOld.SyncDays = prefs.getInt("SynDays", MySynchronizationOld.SyncDays);
|
MySynchronizationOld.SyncDays = prefs.getInt("SyncDays", MySynchronizationOld.SyncDays);
|
||||||
if(URLUtil.isValidUrl(URL))
|
if(URLUtil.isValidUrl(URL))
|
||||||
MySynchronizationOld.URL = URL;
|
MySynchronizationOld.URL = URL;
|
||||||
}
|
}
|
||||||
@ -302,8 +303,8 @@ public class MySynchronizationOld
|
|||||||
dboh.close();
|
dboh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Для обновления справочников
|
//Для обновления справочников и загрузки старых анкет уничножения саранчи
|
||||||
int makeRequest(String tableName)
|
int makeRequest(String tableName,String days,String country_id)
|
||||||
{
|
{
|
||||||
String seq="";
|
String seq="";
|
||||||
DbOpenHelper dboh = new DbOpenHelper(_context);
|
DbOpenHelper dboh = new DbOpenHelper(_context);
|
||||||
@ -315,9 +316,14 @@ public class MySynchronizationOld
|
|||||||
if (seq == null) seq = "0";
|
if (seq == null) seq = "0";
|
||||||
cursor.close();
|
cursor.close();
|
||||||
dboh.close();
|
dboh.close();
|
||||||
|
if(days!=null && !days.isEmpty() && country_id!=null && !country_id.isEmpty()){
|
||||||
|
return myThread.addRequest(MySynchronizationOld.URL+"/get/?fn=1&r=0&n="+tableName+"&s=" + seq + "&l=1000&days="+days+"&country_id="+country_id,"", null);
|
||||||
|
}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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Синхронизовать данные с сервером (добавляет задания в поток)
|
* Синхронизовать данные с сервером (добавляет задания в поток)
|
||||||
@ -356,43 +362,55 @@ public class MySynchronizationOld
|
|||||||
dboh.close();
|
dboh.close();
|
||||||
|
|
||||||
//Запрос в очередь на получение списка стран, направлений, итд.
|
//Запрос в очередь на получение списка стран, направлений, итд.
|
||||||
rid_LocustsTypes = makeRequest("locuststypes");
|
rid_LocustsTypes = makeRequest("locuststypes",null,null);
|
||||||
rid_sprayers = makeRequest("sprayers");
|
rid_sprayers = makeRequest("sprayers",null,null);
|
||||||
rid_sprayers_types = makeRequest("sprayers_types");
|
rid_sprayers_types = makeRequest("sprayers_types",null,null);
|
||||||
rid_Fledgling = makeRequest("fledgling");
|
rid_Fledgling = makeRequest("fledgling",null,null);
|
||||||
rid_list_density = makeRequest("list_density");
|
rid_list_density = makeRequest("list_density",null,null);
|
||||||
rid_list_phase = makeRequest("list_phase");
|
rid_list_phase = makeRequest("list_phase",null,null);
|
||||||
rid_list_directions = makeRequest("list_directions"); //Стороны света (направления)
|
rid_list_directions = makeRequest("list_directions",null,null); //Стороны света (направления)
|
||||||
rid_list_damage = makeRequest("list_damage"); //Справочник степень повреждения растительного покрова
|
rid_list_damage = makeRequest("list_damage",null,null); //Справочник степень повреждения растительного покрова
|
||||||
rid_list_mortality = makeRequest("list_mortality"); //Справочник степень повреждения растительного покрова
|
rid_list_mortality = makeRequest("list_mortality",null,null); //Справочник степень повреждения растительного покрова
|
||||||
rid_list_greenery = makeRequest("list_greenery");
|
rid_list_greenery = makeRequest("list_greenery",null,null);
|
||||||
rid_list_biotope = makeRequest("list_biotope");
|
rid_list_biotope = makeRequest("list_biotope",null,null);
|
||||||
rid_list_cover = makeRequest("list_cover");
|
rid_list_cover = makeRequest("list_cover",null,null);
|
||||||
rid_list_age = makeRequest("list_age");
|
rid_list_age = makeRequest("list_age",null,null);
|
||||||
rid_list_actions = makeRequest("list_actions");
|
rid_list_actions = makeRequest("list_actions",null,null);
|
||||||
rid_list_paintings = makeRequest("list_paintings");
|
rid_list_paintings = makeRequest("list_paintings",null,null);
|
||||||
rid_list_behaviors = makeRequest("list_behaviors");
|
rid_list_behaviors = makeRequest("list_behaviors",null,null);
|
||||||
rid_list_breeding = makeRequest("list_breeding");
|
rid_list_breeding = makeRequest("list_breeding",null,null);
|
||||||
rid_list_capacities = makeRequest("list_capacities");
|
rid_list_capacities = makeRequest("list_capacities",null,null);
|
||||||
rid_list_markings = makeRequest("list_markings");
|
rid_list_markings = makeRequest("list_markings",null,null);
|
||||||
rid_list_containers = makeRequest("list_containers");
|
rid_list_containers = makeRequest("list_containers",null,null);
|
||||||
rid_list_vegetation = makeRequest("list_vegetation");
|
rid_list_vegetation = makeRequest("list_vegetation",null,null);
|
||||||
rid_list_formulation = makeRequest("list_formulation");
|
rid_list_formulation = makeRequest("list_formulation",null,null);
|
||||||
rid_list_height = makeRequest("list_height");
|
rid_list_height = makeRequest("list_height",null,null);
|
||||||
rid_list_enemies = makeRequest("list_enemies");
|
rid_list_enemies = makeRequest("list_enemies",null,null);
|
||||||
rid_list_purpose = makeRequest("list_purpose");
|
rid_list_purpose = makeRequest("list_purpose",null,null);
|
||||||
rid_list_impact = makeRequest("list_impact");
|
rid_list_impact = makeRequest("list_impact",null,null);
|
||||||
rid_list_diluted = makeRequest("list_diluted");
|
rid_list_diluted = makeRequest("list_diluted",null,null);
|
||||||
rid_terminals = makeRequest("terminals");
|
rid_terminals = makeRequest("terminals",null,null);
|
||||||
rid_companies = makeRequest("companies");
|
rid_companies = makeRequest("companies",null,null);
|
||||||
|
|
||||||
rid_countries = makeRequest("countries"); //Если есть хоть 1 запись то считается что справояники хоть 1 раз загрузились
|
rid_countries = makeRequest("countries",null,null); //Если есть хоть 1 запись то считается что справочники хоть 1 раз загрузились
|
||||||
rid_CountriesRegions = makeRequest("countriesregions");
|
rid_CountriesRegions = makeRequest("countriesregions",null,null);
|
||||||
|
|
||||||
rid__languages = makeRequest("_languages");
|
rid__languages = makeRequest("_languages",null,null);
|
||||||
rid__translations = makeRequest("_translations");
|
rid__translations = makeRequest("_translations",null,null);
|
||||||
|
|
||||||
|
rid_Borns = makeRequest("borns",null,null); //Справочник отрождение "Начало", "Массовое".
|
||||||
|
|
||||||
|
//Загружаю формы саранчовых обработок за последние X дней для страны Y
|
||||||
|
dboh = new DbOpenHelper(_context);
|
||||||
|
cursor = dboh.getReadableDatabase().rawQuery("select t.country_id from terminals t where t.del=0 and t.serial='"+ Settings.Secure.getString(_context.getContentResolver(), Settings.Secure.ANDROID_ID)+"';", null);
|
||||||
|
if(cursor.moveToFirst())
|
||||||
|
{
|
||||||
|
String country_id = cursor.getString(0);
|
||||||
|
rid_frmlocustdel = makeRequest("frmlocustdel",String.valueOf(MySynchronizationOld.SyncDays),country_id);
|
||||||
|
}
|
||||||
|
cursor.close();
|
||||||
|
dboh.close();
|
||||||
|
|
||||||
rid_Borns = makeRequest("borns"); //Справочник отрождение "Начало", "Массовое".
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Пришел ответ от HTTP сервера
|
//Пришел ответ от HTTP сервера
|
||||||
|
|||||||
@ -343,7 +343,7 @@ public class SetupActivity extends Activity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
edtSyncDays = (EditText) findViewById(R.id.edtSyncDays);
|
edtSyncDays = (EditText) findViewById(R.id.edtSyncDays);
|
||||||
edtSyncDays.setText(MySynchronizationOld.SyncDays);
|
edtSyncDays.setText(String.valueOf(MySynchronizationOld.SyncDays));
|
||||||
|
|
||||||
edtSyncDays.addTextChangedListener(new TextWatcher() {
|
edtSyncDays.addTextChangedListener(new TextWatcher() {
|
||||||
@Override
|
@Override
|
||||||
@ -353,7 +353,7 @@ public class SetupActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void afterTextChanged(Editable editable) {
|
public void afterTextChanged(Editable editable) {
|
||||||
try {
|
try {
|
||||||
MySynchronizationOld.SyncDays=Integer.parseInt(edtSyncDays.toString());
|
MySynchronizationOld.SyncDays=Integer.parseInt(edtSyncDays.getText().toString());
|
||||||
SharedPreferences prefs = SetupActivity.this.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
SharedPreferences prefs = SetupActivity.this.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putInt("SyncDays", MySynchronizationOld.SyncDays);
|
editor.putInt("SyncDays", MySynchronizationOld.SyncDays);
|
||||||
|
|||||||
@ -232,6 +232,16 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/URL_path_to_the_server"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
@ -248,6 +258,16 @@
|
|||||||
android:inputType="textUri" />
|
android:inputType="textUri" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/Days_of_synchronization"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|||||||
Reference in New Issue
Block a user