mirror of
https://github.com/nerzhul/ownCloud-SMS-App.git
synced 2025-06-20 14:26:15 +00:00
Use foreach loops to improve a little bit performance.
This also permit to fix a bug on periodic sync fetches
This commit is contained in:
parent
facdd5032f
commit
ac239f1f71
@ -97,14 +97,12 @@ public class GeneralSettingsActivity extends NrzSettingsActivity {
|
|||||||
long syncFreq = Long.parseLong(value);
|
long syncFreq = Long.parseLong(value);
|
||||||
|
|
||||||
// Get ownCloud SMS account list
|
// Get ownCloud SMS account list
|
||||||
for (int i = 0; i < myAccountList.length; i++) {
|
for (Account acct: myAccountList) {
|
||||||
// And get all authorities for this account
|
// And get all authorities for this account
|
||||||
List<PeriodicSync> syncList = ContentResolver.getPeriodicSyncs(myAccountList[i], GeneralSettingsActivity._accountAuthority);
|
List<PeriodicSync> syncList = ContentResolver.getPeriodicSyncs(acct, GeneralSettingsActivity._accountAuthority);
|
||||||
|
|
||||||
boolean foundSameSyncCycle = false;
|
boolean foundSameSyncCycle = false;
|
||||||
for (int j = 0; j < syncList.size(); j++) {
|
for (PeriodicSync ps: syncList) {
|
||||||
PeriodicSync ps = syncList.get(i);
|
|
||||||
|
|
||||||
if ((ps.period == syncFreq) && (ps.extras.getInt("synctype") == 1)) {
|
if ((ps.period == syncFreq) && (ps.extras.getInt("synctype") == 1)) {
|
||||||
foundSameSyncCycle = true;
|
foundSameSyncCycle = true;
|
||||||
}
|
}
|
||||||
@ -114,11 +112,9 @@ public class GeneralSettingsActivity extends NrzSettingsActivity {
|
|||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putInt("synctype", 1);
|
b.putInt("synctype", 1);
|
||||||
|
|
||||||
ContentResolver.removePeriodicSync(myAccountList[i],
|
ContentResolver.removePeriodicSync(acct, GeneralSettingsActivity._accountAuthority, b);
|
||||||
GeneralSettingsActivity._accountAuthority, b);
|
|
||||||
if (syncFreq > 0) {
|
if (syncFreq > 0) {
|
||||||
ContentResolver.addPeriodicSync(myAccountList[i],
|
ContentResolver.addPeriodicSync(acct, GeneralSettingsActivity._accountAuthority, b, syncFreq * 60);
|
||||||
GeneralSettingsActivity._accountAuthority, b, syncFreq * 60);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user