Merge branch 'master' into dependency-injection

This commit is contained in:
Paul Hawke 2017-11-24 22:12:43 -06:00
commit 02b5b9b680
148 changed files with 1169 additions and 364 deletions

View file

@ -123,8 +123,9 @@ public class FileUtils {
} catch (IllegalArgumentException e) {
Timber.d(e);
} finally {
if (cursor != null)
if (cursor != null) {
cursor.close();
}
}
return null;
}

View file

@ -224,7 +224,7 @@ public class GPSExtractor {
return decimalCoords;
}
private double convertToDegree(String stringDMS){
private double convertToDegree(String stringDMS) {
double result;
String[] DMS = stringDMS.split(",", 3);

View file

@ -69,7 +69,7 @@ public class MwVolleyApi {
* @param coords Coordinates to build query with
* @return URL for API query
*/
private String buildUrl (String coords){
private String buildUrl(String coords) {
Uri.Builder builder = Uri.parse(MWURL).buildUpon();

View file

@ -65,7 +65,7 @@ public class UploadController {
}
public void cleanup() {
if(isUploadServiceConnected) {
if (isUploadServiceConnected) {
context.unbindService(uploadServiceConnection);
}
}
@ -87,11 +87,11 @@ public class UploadController {
public void startUpload(final Contribution contribution, final ContributionUploadProgress onComplete) {
//Set creator, desc, and license
if(TextUtils.isEmpty(contribution.getCreator())) {
if (TextUtils.isEmpty(contribution.getCreator())) {
contribution.setCreator(sessionManager.getCurrentAccount().name);
}
if(contribution.getDescription() == null) {
if (contribution.getDescription() == null) {
contribution.setDescription("");
}
@ -109,11 +109,11 @@ public class UploadController {
long length;
ContentResolver contentResolver = context.getContentResolver();
try {
if(contribution.getDataLength() <= 0) {
if (contribution.getDataLength() <= 0) {
length = contentResolver
.openAssetFileDescriptor(contribution.getLocalUri(), "r")
.getLength();
if(length == -1) {
if (length == -1) {
// Let us find out the long way!
length = countBytes(contentResolver
.openInputStream(contribution.getLocalUri()));

View file

@ -185,7 +185,7 @@ public class UploadService extends HandlerService<Contribution> {
@SuppressLint("StringFormatInvalid")
private void uploadContribution(Contribution contribution) {
InputStream file = null;
InputStream file;
String notificationTag = contribution.getLocalUri().toString();
@ -196,6 +196,14 @@ public class UploadService extends HandlerService<Contribution> {
Timber.d("File not found");
Toast fileNotFound = Toast.makeText(this, R.string.upload_failed, Toast.LENGTH_LONG);
fileNotFound.show();
return;
}
//As the file is null there's no point in continuing the upload process
//mwapi.upload accepts a NonNull input stream
if(file == null) {
Timber.d("File not found");
return;
}
Timber.d("Before execution!");