java - Saving multiple images from URLs -
i'm trying save multiple images bought through in-app billing.
new thread(new runnable() { @override public void run() { string path = getfilesdir().getabsolutepath(); file imagefile = new file(path, "image.png"); fileoutputstream fos = null; //i'm sorry mess you're witness if(!imagefile.getname().equals("image.png")) { try { imagefile.createnewfile(); fileoutputstream ostream = new fileoutputstream(imagefile); bitmap.compress(bitmap.compressformat.png, 100, ostream); ostream.close(); log.d(tag, "image saved" + fos.tostring()); } catch (exception e) { } } else if(imagefile.getname().equals("image.png")) { try { imagefile = new file(path, "image2.png"); imagefile.createnewfile(); fileoutputstream ostream = new fileoutputstream(imagefile); bitmap.compress(bitmap.compressformat.png, 100, ostream); ostream.close(); log.d(tag, "image2 saved" + fos.tostring()); } catch (exception e) { } } else if(imagefile.getname().equals("image2.png")) { try { imagefile = new file(path, "imag3.png"); imagefile.createnewfile(); fileoutputstream ostream = new fileoutputstream(imagefile); bitmap.compress(bitmap.compressformat.png, 100, ostream); ostream.close(); log.d(tag, "image2 saved" + fos.tostring()); } catch (exception e) { } } } }).start(); } @override public void onbitmapfailed(drawable errordrawable) {} @override public void onprepareload(drawable placeholderdrawable) {} }; so have saves 1 image, can't save more 1. i'm looking store max of 20 in long term , 5 in short term.
this why buy button. if 1 of buttons clicked download image, image file name download internal storage image2.png.
else if (purchase.getsku().equals(item_sku_1)) { //sets buy button false; loadbutton(buybutton); picasso.with(purchaseactivity.this) .load(itemskuimageurl) .into(target); } else if (purchase.getsku().equals(item_sku_2)) { loadbutton(buybutton2); drawable d = getbitmapfromurl(itemskuimageurl); //string encoded = imagetobytearray(bm); picasso.with(purchaseactivity.this) .load(itemskuimageurl) .into(target);
Comments
Post a Comment