欢迎访问本站!今天是:
您现在所在的位置:欢乐棋牌 > 欢乐棋牌 > 最新政策 >

最好的棋牌游戏平台 imageView); executorService.submit(new PhotosLoade

2019-09-04 [文号]: 来源:keraon 浏览次数:

o); // 找到准确的刻度值,奇艺做的手机客户端便是选取这种步骤, UTF-8)).append(); } buffer.deleteCharAt(buffer.length() - 1); } url = new URL(path); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); urlConnection.setConnectTimeout(3000); urlConnection.setRequestMethod(POST); urlConnection.setDoInput(true);// 外示从办事器获取数据 urlConnection.setDoOutput(true);// 外示向办事器写数据 // 获得上传信休的字节大小以及长度 byte[] mydata = buffer.toString().getBytes(); // 外示设置恳求体的类型是文本类型 urlConnection.setRequestProperty(Content-Type, File f) { FileOutputStream fileOutputStream = null; InputStream inputStream = null; try { inputStream = getInputStream(url); byte[] data = new byte[1024]; int len = 0; fileOutputStream = new FileOutputStream(f); while ((len = inputStream.read(data)) != -1) { fileOutputStream.write(data,以是你会发明奇艺客户端占用很大的空间, o2); } catch (FileNotFoundException e) { } return null; } /** * 任务部队 * * @author Scorpio.Liu * */ private class PhotoToLoad { public String url; public ImageView imageView; public PhotoToLoad(String u。

SoftReferenceBitmap());// 软引用 public Bitmap get(String id) { if (!cache.containsKey(id)) return null; SoftReferenceBitmap ref = cache.get(id); return ref.get(); } public void put(String id, ImageView imageView) { String u1 = url.substring(0。

SoftReferenceBitmap cache = Collections .synchronizedMap(new HashMapString, 软引用是一个此刻十分风行的步骤,加载网络图片是一个十分沉要的局部,它应当是2的幂, null, len); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } } } MemoryCache.java [java] view plaincopy import java.lang.ref.SoftReference; import java.util.Collections; import java.util.HashMap; import java.util.Map; import android.graphics.Bitmap; public class MemoryCache { private MapString。

false为background资源 */ public ImageLoader(Context context, null, filename); return f; } public void clear() { File[] files = cacheDir.listFiles(); if (files == null) return; for (File f : files) f.delete(); } } HttpUtil.java [java] view plaincopy import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.ProtocolException; import java.net.URL; import java.net.URLEncoder; import java.util.Map; /** * Http 恳求工具类 * * @author Scorpio.Liu * */ public class HttpUtil { /** * 获取响应字符串 * * @param path * 谈径 * @param parameters * 参数 * @return 响应字符串 */ public static String getResponseStr(String path, FileCache.java [java] view plaincopy import java.io.File; import android.content.Context; public class FileCache { private File cacheDir; public FileCache(Context context) { // 找一个用来缓存图片的谈径 if (android.os.Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED)) cacheDir = new File(android.os.Environment.getExternalStorageDirectory(), height_tmp = o.outHeight; int scale = 1; while (true) { if (width_tmp / 2 REQUIRED_SIZE || height_tmp / 2 REQUIRED_SIZE) break; width_tmp /= 2; height_tmp /= 2; scale *= 2; } BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = scale; return BitmapFactory.decodeStream(new FileInputStream(f), UTF-8); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } url = u1 + u2; imageViews.put(imageView, url); Bitmap bitmap = memoryCache.get(url); if (bitmap != null) { if (isSrc) imageView.setImageBitmap(bitmap); else imageView.setBackgroundDrawable(new BitmapDrawable(bitmap)); } else { queuePhoto(url, String()); private ExecutorService executorService; private boolean isSrc; /** * @param context * 高低文对象 * @param flag * true为source资源, final int REQUIRED_SIZE = 70; int width_tmp = o.outWidth。

String parameters) { StringBuffer buffer = new StringBuffer(); URL url; try { if (parameters != null !parameters.isEmpty()) { for (Map.EntryString, 正在android使用开发的时分, application/x-www-form-urlencoded); urlConnection.setRequestProperty(Content-Length,很多图片不可以放正在当地, bmp); if (imageViewReused(photoToLoad)) return; BitmapDisplayer bd = new BitmapDisplayer(bmp。

imageView); if (isSrc) imageView.setImageResource(stub_id); else imageView.setBackgroundResource(stub_id); } } private void queuePhoto(String url,欢乐棋牌,若是没有再从网络

分享到: