private void uploadFiles() { boolean needWork = true; while (needWork) { boolean uploading = isUploading; boolean connected = internetHelper.isConnected(); boolean wifiOnlyState = daoHelper.getWifiOnlyState(); boolean wifiConnected = internetHelper.isWifiConnected(); boolean canUploadWifi = internetHelper.canUploadWifi(); boolean canUploadCellular = internetHelper.canUploadCellular(wifiOnlyState); boolean canUpload = internetHelper.canUpload(wifiOnlyState); Log.w( LOG_TAG, "onUpload files" + " isUploading = " + uploading + " conneted = " + connected + " wifionly = " + wifiOnlyState + " wifi connected = " + wifiConnected + " canUpload = " + canUpload + " canUploadWifi = " + canUploadWifi + " canUploadCellular = " + canUploadCellular); if (!uploading) { uploadCycleStarted(); checkFilesForDelete(); if (canUpload) { boolean uploadStarted = startUploadFile(); while (isUploading) { doThreadSleepAndDelay(); } if (!uploadStarted) { needWork = false; } } else { needWork = false; uploadCycleFinished(); } } else { needWork = false; } Thread.yield(); } }
private void addInFailed(String filename) { Context applicationContext = getApplicationContext(); InternetHelper internetHelper = InternetHelper.getInstance(applicationContext); DAOHelper instance = DAOHelper.getInstance(applicationContext); boolean wifiOnly = instance.getWifiOnlyState(); if (internetHelper.canUpload(wifiOnly)) { synchronized (failedUploadsList) { if (!failedUploadsList.contains(filename)) { failedUploadsList.add(filename); } } } }