Merge pull request #180 from misaochan/cursor-close

Fix NPE from cursor close
This commit is contained in:
Nicolas Raoul 2016-07-12 15:26:53 +09:00 committed by GitHub
commit 07e8245fdb

View file

@ -13,6 +13,7 @@ import android.os.IBinder;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import java.io.IOException; import java.io.IOException;
@ -119,7 +120,9 @@ public class UploadController {
contribution.setDataLength(length); contribution.setDataLength(length);
} }
} catch(IOException e) { } catch(IOException e) {
throw new RuntimeException(e); Log.e("UploadController", "IO Exception: ", e);
} catch(NullPointerException e) {
Log.e("UploadController", "Null Pointer Exception: ", e);
} }
String mimeType = (String)contribution.getTag("mimeType"); String mimeType = (String)contribution.getTag("mimeType");
@ -142,10 +145,10 @@ public class UploadController {
dateCreated = new Date(); dateCreated = new Date();
} }
contribution.setDateCreated(dateCreated); contribution.setDateCreated(dateCreated);
cursor.close();
} else { } else {
contribution.setDateCreated(new Date()); contribution.setDateCreated(new Date());
} }
cursor.close();
} }
return contribution; return contribution;