cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [2/2] cordova-plugin-file git commit: Fixed NullPointer Exception in Android 5 and above due to invalid column name on cursor
Date Mon, 09 Nov 2015 23:18:48 GMT
Fixed NullPointer Exception in Android 5 and above due to invalid column name on cursor


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/53835beb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/53835beb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/53835beb

Branch: refs/heads/master
Commit: 53835beb93cca3e549b6750c727a6fbdc8c61309
Parents: 2c0d885
Author: aroberson <adam.roberson@ventyx.abb.com>
Authored: Thu Jun 18 13:52:01 2015 -0500
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Mon Nov 9 15:18:19 2015 -0800

----------------------------------------------------------------------
 src/android/ContentFilesystem.java | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/53835beb/src/android/ContentFilesystem.java
----------------------------------------------------------------------
diff --git a/src/android/ContentFilesystem.java b/src/android/ContentFilesystem.java
index eab0b03..f43414a 100644
--- a/src/android/ContentFilesystem.java
+++ b/src/android/ContentFilesystem.java
@@ -127,7 +127,9 @@ public class ContentFilesystem extends Filesystem {
         try {
         	if (cursor != null && cursor.moveToFirst()) {
         		size = resourceSizeForCursor(cursor);
-        		lastModified = lastModifiedDateForCursor(cursor);
+                Long modified = lastModifiedDateForCursor(cursor);
+                if (modified != null)
+                    lastModified = modified.longValue();
         	} else {
                 // Some content providers don't support cursors at all!
                 CordovaResourceApi.OpenForReadResult offr = resourceApi.openForRead(nativeUri);
@@ -185,12 +187,15 @@ public class ContentFilesystem extends Filesystem {
 	}
 	
 	protected Long lastModifiedDateForCursor(Cursor cursor) {
-        final String[] LOCAL_FILE_PROJECTION = { MediaStore.MediaColumns.DATE_MODIFIED };
-        int columnIndex = cursor.getColumnIndex(LOCAL_FILE_PROJECTION[0]);
+        int columnIndex = cursor.getColumnIndex(MediaStore.MediaColumns.DATE_MODIFIED);
+        if (columnIndex == -1) {
+            columnIndex = cursor.getColumnIndex(DocumentsContract.Document.COLUMN_LAST_MODIFIED);
+        }
         if (columnIndex != -1) {
             String dateStr = cursor.getString(columnIndex);
             if (dateStr != null) {
-            	return Long.parseLong(dateStr);
+            if (dateStr != null) {
+                return Long.parseLong(dateStr);
             }
         }
         return null;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message