Close ParcelFileDescriptor after improting blacklist
This commit is contained in:
parent
787ca3c94a
commit
29f7d7b5b5
|
@ -249,19 +249,27 @@ public class BlacklistActivity extends AppCompatActivity {
|
||||||
|
|
||||||
ParcelFileDescriptor pfd = null;
|
ParcelFileDescriptor pfd = null;
|
||||||
try {
|
try {
|
||||||
pfd = getContentResolver().openFileDescriptor(data.getData(), "r");
|
try {
|
||||||
} catch (FileNotFoundException e) {
|
pfd = getContentResolver().openFileDescriptor(data.getData(), "r");
|
||||||
error = true;
|
} catch (FileNotFoundException e) {
|
||||||
LOG.warn("onActivityResult() get file for import result", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pfd != null) {
|
|
||||||
if (new BlacklistImporterExporter().importBlacklist(
|
|
||||||
YacbHolder.getBlacklistDao(), YacbHolder.getBlacklistService(),
|
|
||||||
pfd.getFileDescriptor())) {
|
|
||||||
Toast.makeText(this, R.string.done, Toast.LENGTH_SHORT).show();
|
|
||||||
} else {
|
|
||||||
error = true;
|
error = true;
|
||||||
|
LOG.warn("onActivityResult() get file for import result", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pfd != null) {
|
||||||
|
if (new BlacklistImporterExporter().importBlacklist(
|
||||||
|
YacbHolder.getBlacklistDao(), YacbHolder.getBlacklistService(),
|
||||||
|
pfd.getFileDescriptor())) {
|
||||||
|
Toast.makeText(this, R.string.done, Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
error = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (pfd != null) {
|
||||||
|
try {
|
||||||
|
pfd.close();
|
||||||
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue