Skip to content

Commit 5b6e336

Browse files
committed
Close unused streams for make share file function.
1 parent 66ea674 commit 5b6e336

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/com/androidquery/AbstractAQuery.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,13 +2338,19 @@ public File makeSharedFile(String url, String filename){
23382338
file = new File(temp, filename);
23392339
file.createNewFile();
23402340

2341-
FileChannel ic = new FileInputStream(cached).getChannel();
2342-
FileChannel oc = new FileOutputStream(file).getChannel();
2341+
FileInputStream fis = new FileInputStream(cached);
2342+
FileOutputStream fos = new FileOutputStream(file);
2343+
2344+
FileChannel ic = fis.getChannel();
2345+
FileChannel oc = fos.getChannel();
2346+
23432347
try{
23442348
ic.transferTo(0, ic.size(), oc);
23452349
}finally{
2346-
if(ic != null) ic.close();
2347-
if(oc != null) oc.close();
2350+
AQUtility.close(fis);
2351+
AQUtility.close(fos);
2352+
AQUtility.close(ic);
2353+
AQUtility.close(oc);
23482354
}
23492355

23502356
}
@@ -2445,6 +2451,12 @@ public T longClick(){
24452451
//weak hash map that holds the dialogs so they will never memory leaked
24462452
private static WeakHashMap<Dialog, Void> dialogs = new WeakHashMap<Dialog, Void>();
24472453

2454+
/**
2455+
* Show a dialog. Method dismiss() or dismissAll() should be called later.
2456+
*
2457+
* @return self
2458+
*
2459+
*/
24482460
public T show(Dialog dialog){
24492461

24502462
try{
@@ -2458,6 +2470,12 @@ public T show(Dialog dialog){
24582470
return self();
24592471
}
24602472

2473+
/**
2474+
* Dismiss a dialog previously shown with show().
2475+
*
2476+
* @return self
2477+
*
2478+
*/
24612479
public T dismiss(Dialog dialog){
24622480

24632481
try{

0 commit comments

Comments
 (0)