Начал делать дни синхронизации
This commit is contained in:
@ -73,6 +73,7 @@ public class MySynchronizationOld
|
||||
{
|
||||
public static String URL="https://ccalm.org";
|
||||
//public static String URL="http://192.168.200.100:8080";
|
||||
public static int SyncDays=30;
|
||||
|
||||
private Context _context; //От какого контекста показывать алерты
|
||||
//private boolean _showAlert; //Показывать ли окно подождите пожалуйста (его нельзя создавать если в сервисе)
|
||||
@ -138,6 +139,7 @@ public class MySynchronizationOld
|
||||
String URL = MySynchronizationOld.URL;
|
||||
SharedPreferences prefs = _context.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
||||
URL = prefs.getString("URL", "");
|
||||
MySynchronizationOld.SyncDays = prefs.getInt("SynDays", MySynchronizationOld.SyncDays);
|
||||
if(URLUtil.isValidUrl(URL))
|
||||
MySynchronizationOld.URL = URL;
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ public class SetupActivity extends Activity {
|
||||
public Button btnQR = null;
|
||||
public Button btnDeleteAllData = null;
|
||||
public EditText edtURL = null;
|
||||
public EditText edtSyncDays = null;
|
||||
public CheckBox cbIdentifyCountryRegion = null;
|
||||
public CheckBox cbShowAdvancedSettings = null;
|
||||
|
||||
@ -101,7 +102,10 @@ public class SetupActivity extends Activity {
|
||||
|
||||
//Загрузка сохранёного языка
|
||||
Tools.loadLocale(this);
|
||||
|
||||
|
||||
//Прячу всё что должно быть спрятано
|
||||
((LinearLayout)findViewById(R.id.llShowAdvancedSettings)).setVisibility(View.GONE);
|
||||
|
||||
tvSynchronization = (TextView)findViewById(R.id.tvSynchronization);
|
||||
|
||||
//Кнопочка синхронизировать
|
||||
@ -338,6 +342,28 @@ public class SetupActivity extends Activity {
|
||||
}
|
||||
});
|
||||
|
||||
edtSyncDays = (EditText) findViewById(R.id.edtSyncDays);
|
||||
edtSyncDays.setText(MySynchronizationOld.SyncDays);
|
||||
|
||||
edtSyncDays.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
try {
|
||||
MySynchronizationOld.SyncDays=Integer.parseInt(edtSyncDays.toString());
|
||||
SharedPreferences prefs = SetupActivity.this.getSharedPreferences("CommonPrefs", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = prefs.edit();
|
||||
editor.putInt("SyncDays", MySynchronizationOld.SyncDays);
|
||||
editor.apply(); // or editor.commit(); if you want to save synchronously
|
||||
} catch (NumberFormatException e) {
|
||||
Toast.makeText(SetupActivity.this, "Invalid integer", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Button delete all data
|
||||
OnClickListener oclDeleteAllData = new OnClickListener()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user