|
|
@ -7,6 +7,7 @@ import java.io.InputStream; |
|
|
|
|
|
|
|
|
|
|
|
import org.floens.chan.R; |
|
|
|
import org.floens.chan.R; |
|
|
|
import org.floens.chan.manager.ReplyManager; |
|
|
|
import org.floens.chan.manager.ReplyManager; |
|
|
|
|
|
|
|
import org.floens.chan.utils.IOUtils; |
|
|
|
|
|
|
|
|
|
|
|
import android.app.Activity; |
|
|
|
import android.app.Activity; |
|
|
|
import android.content.ActivityNotFoundException; |
|
|
|
import android.content.ActivityNotFoundException; |
|
|
@ -49,23 +50,16 @@ public class ImagePickActivity extends Activity { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
InputStream is = getContentResolver().openInputStream(uri); |
|
|
|
|
|
|
|
final File cacheFile = new File(getCacheDir() + File.separator + "pickedFileCache"); |
|
|
|
final File cacheFile = new File(getCacheDir() + File.separator + "pickedFileCache"); |
|
|
|
|
|
|
|
|
|
|
|
if (cacheFile.exists()) { |
|
|
|
if (cacheFile.exists()) { |
|
|
|
cacheFile.delete(); |
|
|
|
cacheFile.delete(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
FileOutputStream fis = new FileOutputStream(cacheFile); |
|
|
|
InputStream is = getContentResolver().openInputStream(uri); |
|
|
|
|
|
|
|
FileOutputStream fos = new FileOutputStream(cacheFile); |
|
|
|
byte[] buffer = new byte[1024]; |
|
|
|
|
|
|
|
int length = 0; |
|
|
|
|
|
|
|
while((length = is.read(buffer)) != -1) { |
|
|
|
|
|
|
|
fis.write(buffer, 0, length); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
is.close(); |
|
|
|
IOUtils.copy(is, fos); |
|
|
|
fis.close(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|